diff --git a/.dockerignore b/.dockerignore index eb47a50..c6b8817 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,7 @@ .gitattributes .dockerignore Dockerfile +test/ +bin/ +!bin/run.py +!bin/run.sh \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0eb59a5..c3e611f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,24 +6,36 @@ on: branches: - main paths-ignore: - - '.gitignore' - - 'LICENSE' - - '**.md' + - ".gitignore" + - "LICENSE" + - "**.md" push: paths-ignore: - - '.gitignore' - - 'LICENSE' - - '**.md' - + - ".gitignore" + - "LICENSE" + - "**.md" jobs: test: name: Test Representer runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e + - name: Checkout code + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1 + with: + install: true + + - name: Build Docker image and store in cache + uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 + with: + context: . + push: false + load: true + tags: exercism/python-representer + cache-from: type=gha + cache-to: type=gha,mode=max - - name: Build Docker Image - run: docker build -f Dockerfile -t python-representer . - - - name: Run Tests - run: docker run --entrypoint "pytest" python-representer + - name: Run Tests in Docker + run: bin/run-tests-in-docker.sh diff --git a/Dockerfile b/Dockerfile index b8cbd4c..03674fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,9 @@ -FROM python:3.11.2-slim as base - -FROM base as builder - -RUN mkdir /install - -WORKDIR /install +FROM python:3.11.5-alpine3.18 COPY requirements.txt /requirements.txt COPY dev-requirements.txt /dev-requirements.txt -RUN pip install --prefix=/install --no-warn-script-location -r /requirements.txt -r /dev-requirements.txt - -FROM base - -COPY --from=builder /install /usr/local - - -RUN apt-get update \ - && apt-get install curl -y \ - && apt-get remove curl -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* +RUN pip install -r /requirements.txt -r /dev-requirements.txt COPY . /opt/representer diff --git a/bin/run-in-docker.sh b/bin/run-in-docker.sh index f2538e5..5b42c58 100755 --- a/bin/run-in-docker.sh +++ b/bin/run-in-docker.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -e # Synopsis: @@ -32,8 +32,13 @@ docker build --rm --no-cache -t python-representer . output_dir="$3" mkdir -p "$output_dir" +# run image passing the arguments # run image passing the arguments docker run \ + --rm \ + --network none \ + --read-only \ --mount type=bind,src=$PWD/$2,dst=/solution \ --mount type=bind,src=$PWD/$output_dir,dst=/output \ - python-representer $1 /solution/ /output/ + --mount type=tmpfs,destination=/tmp \ + exercism/python-representer $1 /solution/ /output/ diff --git a/bin/run-tests-in-docker.sh b/bin/run-tests-in-docker.sh new file mode 100755 index 0000000..a25c491 --- /dev/null +++ b/bin/run-tests-in-docker.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +# Synopsis: +# Test the test runner Docker image by running it against a predefined set of +# solutions with an expected output. +# The test runner Docker image is built automatically. + +# Output: +# Outputs the diff of the expected test results against the actual test results +# generated by the test runner Docker image. + +# Example: +# ./bin/run-tests-in-docker.sh + +# Stop executing when a command returns a non-zero return code +set -e + +# Build the Docker image +docker build --rm -t exercism/python-representer . + +# Run the Docker image using the settings mimicking the production environment +docker run \ + --rm \ + --network none \ + --read-only \ + --mount type=bind,src="${PWD}/test",dst=/opt/representer/test \ + --mount type=tmpfs,dst=/tmp \ + --workdir /opt/representer \ + --entrypoint pytest \ + exercism/python-representer -v --disable-warnings diff --git a/bin/run.sh b/bin/run.sh index 1f4675b..ad46f2e 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -1,4 +1,5 @@ -#! /bin/sh +#! /usr/bin/env sh + root="$( dirname "$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )" )" export PYTHONPATH="$root:$PYTHONPATH" -python bin/run.py "$@" +/usr/bin/env python3 bin/run.py "$@" \ No newline at end of file diff --git a/representer/__init__.py b/representer/__init__.py index fb5f3ae..5a8fa7d 100644 --- a/representer/__init__.py +++ b/representer/__init__.py @@ -1,6 +1,7 @@ """ Representer for Python. """ + import json from typing import Dict @@ -17,6 +18,7 @@ class Representer: def __init__(self, source: str) -> None: self._tree = utils.parse(source) self._normalizer = Normalizer() + self.metadata = {"version" : 2} def normalize(self) -> None: """ @@ -30,6 +32,12 @@ def dump_tree(self) -> str: """ return utils.dump_tree(self._tree) + def dump_ast(self) -> str: + """ + Dump the current stat of the tree without indents. + """ + return utils.dump_ast(self._tree) + def dump_code(self, reformat=True) -> str: """ Dump the current tree as generate code. @@ -52,6 +60,12 @@ def dump_map(self) -> str: """ return utils.to_json(self.mapping) + def dump_metadata(self) -> Dict[str, int]: + """ + Dump the representer metadata. + """ + return utils.to_json(self.metadata) + def represent(slug: utils.Slug, input: utils.Directory, output: utils.Directory) -> None: """ @@ -80,21 +94,26 @@ def represent(slug: utils.Slug, input: utils.Directory, output: utils.Directory) out_dst = output.joinpath("representation.out") txt_dst = output.joinpath("representation.txt") map_dst = output.joinpath("mapping.json") + metadata_dst = output.joinpath("representation.json") # parse the tree from the file contents representation = Representer(src.read_text()) # save dump of the initial tree for debug - out = ["# BEGIN TREE BEFORE", representation.dump_tree(), ""] + out = ['## BEGIN TREE BEFORE ##', representation.dump_tree(), '## END TREE BEFORE ##', ''] # normalize the tree representation.normalize() + # save dump of normalized code for debug (from un-parsing the normalized AST). + out[0:0] = ['## BEGIN NORMALIZED CODE ##', representation.dump_code(), "## END NORMALIZED CODE ##", ''] + # save dump of the normalized tree for debug - out.extend(["# BEGIN TREE AFTER", representation.dump_tree()]) + out.extend(['## BEGIN NORMALIZED TREE ##', representation.dump_tree(), '## END NORMALIZED TREE ##']) # dump the representation files out_dst.write_text("\n".join(out)) - txt_dst.write_text(representation.dump_code()) + txt_dst.write_text(representation.dump_ast()) map_dst.write_text(representation.dump_map()) + metadata_dst.write_text(representation.dump_metadata()) diff --git a/representer/normalizer.py b/representer/normalizer.py index 7cfab32..9938975 100644 --- a/representer/normalizer.py +++ b/representer/normalizer.py @@ -10,14 +10,18 @@ Assign, AsyncFunctionDef, Attribute, + Call, ClassDef, + Compare, Constant, DictComp, + Eq, ExceptHandler, Expr, FunctionDef, GeneratorExp, Global, + If, ListComp, Load, Module, @@ -25,7 +29,9 @@ NodeTransformer, Nonlocal, SetComp, + Str, Store, + Yield, alias, arg, get_docstring, @@ -140,6 +146,7 @@ def visit_AsyncFunctionDef(self, node: AsyncFunctionDef) -> AsyncFunctionDef: def visit_arg(self, node: arg) -> arg: """ Arguments in definition signatures. + Drops type annotations. """ node.arg = self.add_placeholder(node.arg) if node.annotation: @@ -190,17 +197,6 @@ def visit_Nonlocal(self, node: Nonlocal) -> Nonlocal: self.generic_visit(node) return node - def visit_Expr(self, node: Expr) -> Optional[Expr]: - """ - Expressions not assigned to an identifier. - """ - if isinstance(node.value, Constant): - # eliminate registered docstrings - if utils.md5sum(node.value.value) in self._docstring_cache: - return None - self.generic_visit(node) - return node - @overload def _visit_identifier(self, node: Name) -> Name: ... @@ -231,6 +227,7 @@ def visit_Attribute(self, node: Attribute) -> Attribute: """ return self._visit_identifier(node) + @overload def _visit_comprehension(self, node: ListComp) -> ListComp: ... @@ -280,5 +277,52 @@ def visit_DictComp(self, node: DictComp) -> DictComp: """ return self._visit_comprehension(node) + @overload + def _visit_If(self, node: If) -> If: + ... + + def visit_If(self, node: If) -> None: + """Remove if __name__ == '__main__' nodes. + + Looks for ast.If that includes __name__ == __main__ checks + and removes the block. + """ + if isinstance(node.test, Compare): + if not (isinstance(node.test.left, Name) and node.test.left.id == '__name__'): + self.generic_visit(node) + return node + else: + if node.test.comparators[0].value == '__main__': + return None + + self.generic_visit(node) + return node + + def visit_Expr(self, node: Expr) -> Optional[Expr]: + """Expressions not assigned to an identifier. + + Removes print statements and docstrings from + the representation. + """ + + # Remove print() statements from representation. + if (isinstance(node.value, Call) and + isinstance(node.value.func, Name)): + if node.value.func.id == 'print': + return None + + # Pass through generator code. + if isinstance(node.value, Yield): + return node + + + # Eliminate previously registered docstrings + if not isinstance(node.value, Call): + if utils.md5sum(node.value.value) in self._docstring_cache: + return None + + self.generic_visit(node) + return node + __all__ = ["Normalizer"] diff --git a/representer/utils.py b/representer/utils.py index 0618c92..699d5ff 100644 --- a/representer/utils.py +++ b/representer/utils.py @@ -1,6 +1,8 @@ """ -Representer for Python. +Representer Utilities for Python track. """ + + import ast import errno import json @@ -11,12 +13,10 @@ from pathlib import Path from typing import NewType -import astor import black Slug = NewType("Slug", str) - SLUG_RE = re.compile(r"^[a-z]+(-[a-z]+)*$") @@ -41,6 +41,7 @@ def directory(string: str) -> Directory: err = errno.ENOENT msg = os.strerror(err) raise FileNotFoundError(err, f"{msg}: {string!r}") + if not os.access(path, os.R_OK | os.W_OK): err = errno.EACCES msg = os.strerror(err) @@ -80,19 +81,27 @@ def to_json(data: dict) -> str: def parse(source: str) -> ast.AST: """ Wrapper around ast.parse. + Preserves type annotations. """ - return ast.parse(source) + return ast.parse(source, type_comments=False, feature_version=(3,11)) def dump_tree(tree: ast.AST) -> str: """ Dump a formatted string of the AST. """ - return astor.dump_tree(tree, indentation=" ", maxline=88) + return ast.dump(tree, annotate_fields=False, include_attributes=True, indent=2) + + +def dump_ast(tree: ast.AST) -> str: + """ + dump an un-formatted string of the AST. + """ + return ast.dump(tree, annotate_fields=False, include_attributes=True) def to_source(tree: ast.AST) -> str: """ Dump the AST to generated source doe. """ - return astor.to_source(tree) + return ast.unparse(tree) diff --git a/requirements.txt b/requirements.txt index 1b0b106..210d365 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -astor==0.8.0 black<=22.3.0 diff --git a/test/concept-black-jack/.meta/config.json b/test/concept-black-jack/.meta/config.json new file mode 100644 index 0000000..3993787 --- /dev/null +++ b/test/concept-black-jack/.meta/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "Ticktakto", + "Yabby1997", + "limm-jk", + "OMEGA-Y", + "wnstj2007", + "pranasziaukas", + "bethanyG" + ], + "contributors": [ + "PaulT89" + ], + "files": { + "solution": [ + "black_jack.py" + ] + }, + "icon": "poker", + "blurb": "Learn about comparisons by implementing some Black Jack judging rules." +} diff --git a/test/concept-black-jack/black_jack.py b/test/concept-black-jack/black_jack.py new file mode 100644 index 0000000..27c7a5d --- /dev/null +++ b/test/concept-black-jack/black_jack.py @@ -0,0 +1,107 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card. See below for values. + + 1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10 + 2. 'A' (ace card) = 1 + 3. '2' - '10' = numerical value. + """ + + if card in ('JQK'): + value = 10 + + elif card == 'A': + value = 1 + + else: + value = int(card) + + return value + + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt in hand. See below for values. + :return: str or tuple - resulting Tuple contains both cards if they are of equal value. + + 1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10 + 2. 'A' (ace card) = 1 + 3. '2' - '10' = numerical value. + """ + + card_one_value = value_of_card(card_one) + card_two_value = value_of_card(card_two) + + if card_one_value == card_two_value: + result = card_one, card_two + + elif card_one_value > card_two_value: + result = card_one + + else: + result = card_two + + return result + + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card dealt. See below for values. + :return: int - either 1 or 11 value of the upcoming ace card. + + 1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10 + 2. 'A' (ace card) = 11 (if already in hand) + 3. '2' - '10' = numerical value. + """ + + card_one_value = 11 if card_one == 'A' else value_of_card(card_one) + card_two_value = 11 if card_two == 'A' else value_of_card(card_two) + + ace_value = 1 if 11 + (card_one_value + card_two_value) > 21 else 11 + + return ace_value + + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - card dealt. See below for values. + :return: bool - is the hand is a blackjack (two cards worth 21). + + 1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10 + 2. 'A' (ace card) = 11 (if already in hand) + 3. '2' - '10' = numerical value. + """ + + return (card_one == 'A' or card_two == 'A') and (value_of_card(card_one) == 10 or value_of_card(card_two) == 10) + + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards dealt. + :return: bool - can the hand be split into two pairs? (i.e. cards are of the same value). + """ + + return value_of_card(card_one) == value_of_card(card_two) + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - can the hand can be doubled down? (i.e. totals 9, 10 or 11 points). + """ + + return 8 < value_of_card(card_one) + value_of_card(card_two) < 12 diff --git a/test/concept-black-jack/mapping.json b/test/concept-black-jack/mapping.json new file mode 100644 index 0000000..ae55ecf --- /dev/null +++ b/test/concept-black-jack/mapping.json @@ -0,0 +1,16 @@ +{ + "placeholder_0": "value_of_card", + "placeholder_1": "card", + "placeholder_2": "value", + "placeholder_3": "higher_card", + "placeholder_4": "card_one", + "placeholder_5": "card_two", + "placeholder_6": "card_one_value", + "placeholder_7": "card_two_value", + "placeholder_8": "result", + "placeholder_9": "value_of_ace", + "placeholder_10": "ace_value", + "placeholder_11": "is_blackjack", + "placeholder_12": "can_split_pairs", + "placeholder_13": "can_double_down" +} \ No newline at end of file diff --git a/test/concept-black-jack/representation.json b/test/concept-black-jack/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-black-jack/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-black-jack/representation.out b/test/concept-black-jack/representation.out new file mode 100644 index 0000000..769c363 --- /dev/null +++ b/test/concept-black-jack/representation.out @@ -0,0 +1,2111 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + if placeholder_1 in "JQK": + placeholder_2 = 10 + elif placeholder_1 == "A": + placeholder_2 = 1 + else: + placeholder_2 = int(placeholder_1) + return placeholder_2 + + +def placeholder_3(placeholder_4, placeholder_5): + placeholder_6 = placeholder_0(placeholder_4) + placeholder_7 = placeholder_0(placeholder_5) + if placeholder_6 == placeholder_7: + placeholder_8 = (placeholder_4, placeholder_5) + elif placeholder_6 > placeholder_7: + placeholder_8 = placeholder_4 + else: + placeholder_8 = placeholder_5 + return placeholder_8 + + +def placeholder_9(placeholder_4, placeholder_5): + placeholder_6 = 11 if placeholder_4 == "A" else placeholder_0(placeholder_4) + placeholder_7 = 11 if placeholder_5 == "A" else placeholder_0(placeholder_5) + placeholder_10 = 1 if 11 + (placeholder_6 + placeholder_7) > 21 else 11 + return placeholder_10 + + +def placeholder_11(placeholder_4, placeholder_5): + return (placeholder_4 == "A" or placeholder_5 == "A") and ( + placeholder_0(placeholder_4) == 10 or placeholder_0(placeholder_5) == 10 + ) + + +def placeholder_12(placeholder_4, placeholder_5): + return placeholder_0(placeholder_4) == placeholder_0(placeholder_5) + + +def placeholder_13(placeholder_4, placeholder_5): + return 8 < placeholder_0(placeholder_4) + placeholder_0(placeholder_5) < 12 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to help play and score a game of blackjack.\n\nHow to play blackjack: https://bicyclecards.com/how-to-play/blackjack/\n"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck\n', + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=3), + FunctionDef( + 'value_of_card', + arguments( + [], + [ + arg( + 'card', + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Determine the scoring value of a card.\n\n :param card: str - given card.\n :return: int - value of a given card. See below for values.\n\n 1. \'J\', \'Q\', or \'K\' (otherwise known as "face cards") = 10\n 2. \'A\' (ace card) = 1\n 3. \'2\' - \'10\' = numerical value.\n ', + lineno=9, + col_offset=4, + end_lineno=17, + end_col_offset=7), + lineno=9, + col_offset=4, + end_lineno=17, + end_col_offset=7), + If( + Compare( + Name( + 'card', + Load(), + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=11), + [ + In()], + [ + Constant( + 'JQK', + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=21)], + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=22), + [ + Assign( + [ + Name( + 'value', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=13)], + Constant( + 10, + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=18), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=18)], + [ + If( + Compare( + Name( + 'card', + Load(), + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 'A', + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=20)], + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=20), + [ + Assign( + [ + Name( + 'value', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=13)], + Constant( + 1, + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=17), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=17)], + [ + Assign( + [ + Name( + 'value', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=13)], + Call( + Name( + 'int', + Load(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=19), + [ + Name( + 'card', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=24)], + [], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=25), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=25)], + lineno=22, + col_offset=4, + end_lineno=26, + end_col_offset=25)], + lineno=19, + col_offset=4, + end_lineno=26, + end_col_offset=25), + Return( + Name( + 'value', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=16), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=16)], + [], + lineno=8, + col_offset=0, + end_lineno=28, + end_col_offset=16), + FunctionDef( + 'higher_card', + arguments( + [], + [ + arg( + 'card_one', + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=24), + arg( + 'card_two', + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Determine which card has a higher value in the hand.\n\n :param card_one, card_two: str - cards dealt in hand. See below for values.\n :return: str or tuple - resulting Tuple contains both cards if they are of equal value.\n\n 1. \'J\', \'Q\', or \'K\' (otherwise known as "face cards") = 10\n 2. \'A\' (ace card) = 1\n 3. \'2\' - \'10\' = numerical value.\n ', + lineno=32, + col_offset=4, + end_lineno=40, + end_col_offset=7), + lineno=32, + col_offset=4, + end_lineno=40, + end_col_offset=7), + Assign( + [ + Name( + 'card_one_value', + Store(), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=18)], + Call( + Name( + 'value_of_card', + Load(), + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=34), + [ + Name( + 'card_one', + Load(), + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=43)], + [], + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=44), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=44), + Assign( + [ + Name( + 'card_two_value', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=18)], + Call( + Name( + 'value_of_card', + Load(), + lineno=43, + col_offset=21, + end_lineno=43, + end_col_offset=34), + [ + Name( + 'card_two', + Load(), + lineno=43, + col_offset=35, + end_lineno=43, + end_col_offset=43)], + [], + lineno=43, + col_offset=21, + end_lineno=43, + end_col_offset=44), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=44), + If( + Compare( + Name( + 'card_one_value', + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=21), + [ + Eq()], + [ + Name( + 'card_two_value', + Load(), + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=39)], + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=39), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=14)], + Tuple( + [ + Name( + 'card_one', + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=25), + Name( + 'card_two', + Load(), + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=35)], + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=35), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=35)], + [ + If( + Compare( + Name( + 'card_one_value', + Load(), + lineno=48, + col_offset=9, + end_lineno=48, + end_col_offset=23), + [ + Gt()], + [ + Name( + 'card_two_value', + Load(), + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=40)], + lineno=48, + col_offset=9, + end_lineno=48, + end_col_offset=40), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=14)], + Name( + 'card_one', + Load(), + lineno=49, + col_offset=17, + end_lineno=49, + end_col_offset=25), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=25)], + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=14)], + Name( + 'card_two', + Load(), + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=25), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=25)], + lineno=48, + col_offset=4, + end_lineno=52, + end_col_offset=25)], + lineno=45, + col_offset=4, + end_lineno=52, + end_col_offset=25), + Return( + Name( + 'result', + Load(), + lineno=54, + col_offset=11, + end_lineno=54, + end_col_offset=17), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=17)], + [], + lineno=31, + col_offset=0, + end_lineno=54, + end_col_offset=17), + FunctionDef( + 'value_of_ace', + arguments( + [], + [ + arg( + 'card_one', + lineno=57, + col_offset=17, + end_lineno=57, + end_col_offset=25), + arg( + 'card_two', + lineno=57, + col_offset=27, + end_lineno=57, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Calculate the most advantageous value for the ace card.\n\n :param card_one, card_two: str - card dealt. See below for values.\n :return: int - either 1 or 11 value of the upcoming ace card.\n\n 1. \'J\', \'Q\', or \'K\' (otherwise known as "face cards") = 10\n 2. \'A\' (ace card) = 11 (if already in hand)\n 3. \'2\' - \'10\' = numerical value.\n ', + lineno=58, + col_offset=4, + end_lineno=66, + end_col_offset=7), + lineno=58, + col_offset=4, + end_lineno=66, + end_col_offset=7), + Assign( + [ + Name( + 'card_one_value', + Store(), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=18)], + IfExp( + Compare( + Name( + 'card_one', + Load(), + lineno=68, + col_offset=27, + end_lineno=68, + end_col_offset=35), + [ + Eq()], + [ + Constant( + 'A', + lineno=68, + col_offset=39, + end_lineno=68, + end_col_offset=42)], + lineno=68, + col_offset=27, + end_lineno=68, + end_col_offset=42), + Constant( + 11, + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=23), + Call( + Name( + 'value_of_card', + Load(), + lineno=68, + col_offset=48, + end_lineno=68, + end_col_offset=61), + [ + Name( + 'card_one', + Load(), + lineno=68, + col_offset=62, + end_lineno=68, + end_col_offset=70)], + [], + lineno=68, + col_offset=48, + end_lineno=68, + end_col_offset=71), + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=71), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=71), + Assign( + [ + Name( + 'card_two_value', + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=18)], + IfExp( + Compare( + Name( + 'card_two', + Load(), + lineno=69, + col_offset=27, + end_lineno=69, + end_col_offset=35), + [ + Eq()], + [ + Constant( + 'A', + lineno=69, + col_offset=39, + end_lineno=69, + end_col_offset=42)], + lineno=69, + col_offset=27, + end_lineno=69, + end_col_offset=42), + Constant( + 11, + lineno=69, + col_offset=21, + end_lineno=69, + end_col_offset=23), + Call( + Name( + 'value_of_card', + Load(), + lineno=69, + col_offset=48, + end_lineno=69, + end_col_offset=61), + [ + Name( + 'card_two', + Load(), + lineno=69, + col_offset=62, + end_lineno=69, + end_col_offset=70)], + [], + lineno=69, + col_offset=48, + end_lineno=69, + end_col_offset=71), + lineno=69, + col_offset=21, + end_lineno=69, + end_col_offset=71), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=71), + Assign( + [ + Name( + 'ace_value', + Store(), + lineno=71, + col_offset=4, + end_lineno=71, + end_col_offset=13)], + IfExp( + Compare( + BinOp( + Constant( + 11, + lineno=71, + col_offset=21, + end_lineno=71, + end_col_offset=23), + Add(), + BinOp( + Name( + 'card_one_value', + Load(), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=41), + Add(), + Name( + 'card_two_value', + Load(), + lineno=71, + col_offset=44, + end_lineno=71, + end_col_offset=58), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=58), + lineno=71, + col_offset=21, + end_lineno=71, + end_col_offset=59), + [ + Gt()], + [ + Constant( + 21, + lineno=71, + col_offset=62, + end_lineno=71, + end_col_offset=64)], + lineno=71, + col_offset=21, + end_lineno=71, + end_col_offset=64), + Constant( + 1, + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=17), + Constant( + 11, + lineno=71, + col_offset=70, + end_lineno=71, + end_col_offset=72), + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=72), + lineno=71, + col_offset=4, + end_lineno=71, + end_col_offset=72), + Return( + Name( + 'ace_value', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=20), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=20)], + [], + lineno=57, + col_offset=0, + end_lineno=73, + end_col_offset=20), + FunctionDef( + 'is_blackjack', + arguments( + [], + [ + arg( + 'card_one', + lineno=76, + col_offset=17, + end_lineno=76, + end_col_offset=25), + arg( + 'card_two', + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Determine if the hand is a \'natural\' or \'blackjack\'.\n\n :param card_one, card_two: str - card dealt. See below for values.\n :return: bool - is the hand is a blackjack (two cards worth 21).\n\n 1. \'J\', \'Q\', or \'K\' (otherwise known as "face cards") = 10\n 2. \'A\' (ace card) = 11 (if already in hand)\n 3. \'2\' - \'10\' = numerical value.\n ', + lineno=77, + col_offset=4, + end_lineno=85, + end_col_offset=7), + lineno=77, + col_offset=4, + end_lineno=85, + end_col_offset=7), + Return( + BoolOp( + And(), + [ + BoolOp( + Or(), + [ + Compare( + Name( + 'card_one', + Load(), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 'A', + lineno=87, + col_offset=24, + end_lineno=87, + end_col_offset=27)], + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=27), + Compare( + Name( + 'card_two', + Load(), + lineno=87, + col_offset=31, + end_lineno=87, + end_col_offset=39), + [ + Eq()], + [ + Constant( + 'A', + lineno=87, + col_offset=43, + end_lineno=87, + end_col_offset=46)], + lineno=87, + col_offset=31, + end_lineno=87, + end_col_offset=46)], + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=46), + BoolOp( + Or(), + [ + Compare( + Call( + Name( + 'value_of_card', + Load(), + lineno=87, + col_offset=53, + end_lineno=87, + end_col_offset=66), + [ + Name( + 'card_one', + Load(), + lineno=87, + col_offset=67, + end_lineno=87, + end_col_offset=75)], + [], + lineno=87, + col_offset=53, + end_lineno=87, + end_col_offset=76), + [ + Eq()], + [ + Constant( + 10, + lineno=87, + col_offset=80, + end_lineno=87, + end_col_offset=82)], + lineno=87, + col_offset=53, + end_lineno=87, + end_col_offset=82), + Compare( + Call( + Name( + 'value_of_card', + Load(), + lineno=87, + col_offset=86, + end_lineno=87, + end_col_offset=99), + [ + Name( + 'card_two', + Load(), + lineno=87, + col_offset=100, + end_lineno=87, + end_col_offset=108)], + [], + lineno=87, + col_offset=86, + end_lineno=87, + end_col_offset=109), + [ + Eq()], + [ + Constant( + 10, + lineno=87, + col_offset=113, + end_lineno=87, + end_col_offset=115)], + lineno=87, + col_offset=86, + end_lineno=87, + end_col_offset=115)], + lineno=87, + col_offset=53, + end_lineno=87, + end_col_offset=115)], + lineno=87, + col_offset=11, + end_lineno=87, + end_col_offset=116), + lineno=87, + col_offset=4, + end_lineno=87, + end_col_offset=116)], + [], + lineno=76, + col_offset=0, + end_lineno=87, + end_col_offset=116), + FunctionDef( + 'can_split_pairs', + arguments( + [], + [ + arg( + 'card_one', + lineno=90, + col_offset=20, + end_lineno=90, + end_col_offset=28), + arg( + 'card_two', + lineno=90, + col_offset=30, + end_lineno=90, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Determine if a player can split their hand into two hands.\n\n :param card_one, card_two: str - cards dealt.\n :return: bool - can the hand be split into two pairs? (i.e. cards are of the same value).\n ', + lineno=91, + col_offset=4, + end_lineno=95, + end_col_offset=7), + lineno=91, + col_offset=4, + end_lineno=95, + end_col_offset=7), + Return( + Compare( + Call( + Name( + 'value_of_card', + Load(), + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=24), + [ + Name( + 'card_one', + Load(), + lineno=97, + col_offset=25, + end_lineno=97, + end_col_offset=33)], + [], + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=34), + [ + Eq()], + [ + Call( + Name( + 'value_of_card', + Load(), + lineno=97, + col_offset=38, + end_lineno=97, + end_col_offset=51), + [ + Name( + 'card_two', + Load(), + lineno=97, + col_offset=52, + end_lineno=97, + end_col_offset=60)], + [], + lineno=97, + col_offset=38, + end_lineno=97, + end_col_offset=61)], + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=61), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=61)], + [], + lineno=90, + col_offset=0, + end_lineno=97, + end_col_offset=61), + FunctionDef( + 'can_double_down', + arguments( + [], + [ + arg( + 'card_one', + lineno=100, + col_offset=20, + end_lineno=100, + end_col_offset=28), + arg( + 'card_two', + lineno=100, + col_offset=30, + end_lineno=100, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Determine if a blackjack player can place a double down bet.\n\n :param card_one, card_two: str - first and second cards in hand.\n :return: bool - can the hand can be doubled down? (i.e. totals 9, 10 or 11 points).\n ', + lineno=101, + col_offset=4, + end_lineno=105, + end_col_offset=7), + lineno=101, + col_offset=4, + end_lineno=105, + end_col_offset=7), + Return( + Compare( + Constant( + 8, + lineno=107, + col_offset=11, + end_lineno=107, + end_col_offset=12), + [ + Lt(), + Lt()], + [ + BinOp( + Call( + Name( + 'value_of_card', + Load(), + lineno=107, + col_offset=15, + end_lineno=107, + end_col_offset=28), + [ + Name( + 'card_one', + Load(), + lineno=107, + col_offset=29, + end_lineno=107, + end_col_offset=37)], + [], + lineno=107, + col_offset=15, + end_lineno=107, + end_col_offset=38), + Add(), + Call( + Name( + 'value_of_card', + Load(), + lineno=107, + col_offset=41, + end_lineno=107, + end_col_offset=54), + [ + Name( + 'card_two', + Load(), + lineno=107, + col_offset=55, + end_lineno=107, + end_col_offset=63)], + [], + lineno=107, + col_offset=41, + end_lineno=107, + end_col_offset=64), + lineno=107, + col_offset=15, + end_lineno=107, + end_col_offset=64), + Constant( + 12, + lineno=107, + col_offset=67, + end_lineno=107, + end_col_offset=69)], + lineno=107, + col_offset=11, + end_lineno=107, + end_col_offset=69), + lineno=107, + col_offset=4, + end_lineno=107, + end_col_offset=69)], + [], + lineno=100, + col_offset=0, + end_lineno=107, + end_col_offset=69)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=11), + [ + In()], + [ + Constant( + 'JQK', + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=21)], + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=22), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=13)], + Constant( + 10, + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=18), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=18)], + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 'A', + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=20)], + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=20), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=13)], + Constant( + 1, + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=17), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=17)], + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=13)], + Call( + Name( + 'int', + Load(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=19), + [ + Name( + 'placeholder_1', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=24)], + [], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=25), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=25)], + lineno=22, + col_offset=4, + end_lineno=26, + end_col_offset=25)], + lineno=19, + col_offset=4, + end_lineno=26, + end_col_offset=25), + Return( + Name( + 'placeholder_2', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=16), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=16)], + [], + lineno=8, + col_offset=0, + end_lineno=28, + end_col_offset=16), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=24), + arg( + 'placeholder_5', + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=18)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=34), + [ + Name( + 'placeholder_4', + Load(), + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=43)], + [], + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=44), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=18)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=43, + col_offset=21, + end_lineno=43, + end_col_offset=34), + [ + Name( + 'placeholder_5', + Load(), + lineno=43, + col_offset=35, + end_lineno=43, + end_col_offset=43)], + [], + lineno=43, + col_offset=21, + end_lineno=43, + end_col_offset=44), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=44), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=21), + [ + Eq()], + [ + Name( + 'placeholder_7', + Load(), + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=39)], + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=39), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=14)], + Tuple( + [ + Name( + 'placeholder_4', + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=25), + Name( + 'placeholder_5', + Load(), + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=35)], + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=35), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=35)], + [ + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=48, + col_offset=9, + end_lineno=48, + end_col_offset=23), + [ + Gt()], + [ + Name( + 'placeholder_7', + Load(), + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=40)], + lineno=48, + col_offset=9, + end_lineno=48, + end_col_offset=40), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=14)], + Name( + 'placeholder_4', + Load(), + lineno=49, + col_offset=17, + end_lineno=49, + end_col_offset=25), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=25)], + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=14)], + Name( + 'placeholder_5', + Load(), + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=25), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=25)], + lineno=48, + col_offset=4, + end_lineno=52, + end_col_offset=25)], + lineno=45, + col_offset=4, + end_lineno=52, + end_col_offset=25), + Return( + Name( + 'placeholder_8', + Load(), + lineno=54, + col_offset=11, + end_lineno=54, + end_col_offset=17), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=17)], + [], + lineno=31, + col_offset=0, + end_lineno=54, + end_col_offset=17), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=57, + col_offset=17, + end_lineno=57, + end_col_offset=25), + arg( + 'placeholder_5', + lineno=57, + col_offset=27, + end_lineno=57, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=18)], + IfExp( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=68, + col_offset=27, + end_lineno=68, + end_col_offset=35), + [ + Eq()], + [ + Constant( + 'A', + lineno=68, + col_offset=39, + end_lineno=68, + end_col_offset=42)], + lineno=68, + col_offset=27, + end_lineno=68, + end_col_offset=42), + Constant( + 11, + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=23), + Call( + Name( + 'placeholder_0', + Load(), + lineno=68, + col_offset=48, + end_lineno=68, + end_col_offset=61), + [ + Name( + 'placeholder_4', + Load(), + lineno=68, + col_offset=62, + end_lineno=68, + end_col_offset=70)], + [], + lineno=68, + col_offset=48, + end_lineno=68, + end_col_offset=71), + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=71), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=71), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=18)], + IfExp( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=69, + col_offset=27, + end_lineno=69, + end_col_offset=35), + [ + Eq()], + [ + Constant( + 'A', + lineno=69, + col_offset=39, + end_lineno=69, + end_col_offset=42)], + lineno=69, + col_offset=27, + end_lineno=69, + end_col_offset=42), + Constant( + 11, + lineno=69, + col_offset=21, + end_lineno=69, + end_col_offset=23), + Call( + Name( + 'placeholder_0', + Load(), + lineno=69, + col_offset=48, + end_lineno=69, + end_col_offset=61), + [ + Name( + 'placeholder_5', + Load(), + lineno=69, + col_offset=62, + end_lineno=69, + end_col_offset=70)], + [], + lineno=69, + col_offset=48, + end_lineno=69, + end_col_offset=71), + lineno=69, + col_offset=21, + end_lineno=69, + end_col_offset=71), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=71), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=71, + col_offset=4, + end_lineno=71, + end_col_offset=13)], + IfExp( + Compare( + BinOp( + Constant( + 11, + lineno=71, + col_offset=21, + end_lineno=71, + end_col_offset=23), + Add(), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=41), + Add(), + Name( + 'placeholder_7', + Load(), + lineno=71, + col_offset=44, + end_lineno=71, + end_col_offset=58), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=58), + lineno=71, + col_offset=21, + end_lineno=71, + end_col_offset=59), + [ + Gt()], + [ + Constant( + 21, + lineno=71, + col_offset=62, + end_lineno=71, + end_col_offset=64)], + lineno=71, + col_offset=21, + end_lineno=71, + end_col_offset=64), + Constant( + 1, + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=17), + Constant( + 11, + lineno=71, + col_offset=70, + end_lineno=71, + end_col_offset=72), + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=72), + lineno=71, + col_offset=4, + end_lineno=71, + end_col_offset=72), + Return( + Name( + 'placeholder_10', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=20), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=20)], + [], + lineno=57, + col_offset=0, + end_lineno=73, + end_col_offset=20), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=76, + col_offset=17, + end_lineno=76, + end_col_offset=25), + arg( + 'placeholder_5', + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_4', + Load(), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 'A', + lineno=87, + col_offset=24, + end_lineno=87, + end_col_offset=27)], + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=27), + Compare( + Name( + 'placeholder_5', + Load(), + lineno=87, + col_offset=31, + end_lineno=87, + end_col_offset=39), + [ + Eq()], + [ + Constant( + 'A', + lineno=87, + col_offset=43, + end_lineno=87, + end_col_offset=46)], + lineno=87, + col_offset=31, + end_lineno=87, + end_col_offset=46)], + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=46), + BoolOp( + Or(), + [ + Compare( + Call( + Name( + 'placeholder_0', + Load(), + lineno=87, + col_offset=53, + end_lineno=87, + end_col_offset=66), + [ + Name( + 'placeholder_4', + Load(), + lineno=87, + col_offset=67, + end_lineno=87, + end_col_offset=75)], + [], + lineno=87, + col_offset=53, + end_lineno=87, + end_col_offset=76), + [ + Eq()], + [ + Constant( + 10, + lineno=87, + col_offset=80, + end_lineno=87, + end_col_offset=82)], + lineno=87, + col_offset=53, + end_lineno=87, + end_col_offset=82), + Compare( + Call( + Name( + 'placeholder_0', + Load(), + lineno=87, + col_offset=86, + end_lineno=87, + end_col_offset=99), + [ + Name( + 'placeholder_5', + Load(), + lineno=87, + col_offset=100, + end_lineno=87, + end_col_offset=108)], + [], + lineno=87, + col_offset=86, + end_lineno=87, + end_col_offset=109), + [ + Eq()], + [ + Constant( + 10, + lineno=87, + col_offset=113, + end_lineno=87, + end_col_offset=115)], + lineno=87, + col_offset=86, + end_lineno=87, + end_col_offset=115)], + lineno=87, + col_offset=53, + end_lineno=87, + end_col_offset=115)], + lineno=87, + col_offset=11, + end_lineno=87, + end_col_offset=116), + lineno=87, + col_offset=4, + end_lineno=87, + end_col_offset=116)], + [], + lineno=76, + col_offset=0, + end_lineno=87, + end_col_offset=116), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=90, + col_offset=20, + end_lineno=90, + end_col_offset=28), + arg( + 'placeholder_5', + lineno=90, + col_offset=30, + end_lineno=90, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'placeholder_0', + Load(), + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=24), + [ + Name( + 'placeholder_4', + Load(), + lineno=97, + col_offset=25, + end_lineno=97, + end_col_offset=33)], + [], + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=34), + [ + Eq()], + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=97, + col_offset=38, + end_lineno=97, + end_col_offset=51), + [ + Name( + 'placeholder_5', + Load(), + lineno=97, + col_offset=52, + end_lineno=97, + end_col_offset=60)], + [], + lineno=97, + col_offset=38, + end_lineno=97, + end_col_offset=61)], + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=61), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=61)], + [], + lineno=90, + col_offset=0, + end_lineno=97, + end_col_offset=61), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=100, + col_offset=20, + end_lineno=100, + end_col_offset=28), + arg( + 'placeholder_5', + lineno=100, + col_offset=30, + end_lineno=100, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Constant( + 8, + lineno=107, + col_offset=11, + end_lineno=107, + end_col_offset=12), + [ + Lt(), + Lt()], + [ + BinOp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=107, + col_offset=15, + end_lineno=107, + end_col_offset=28), + [ + Name( + 'placeholder_4', + Load(), + lineno=107, + col_offset=29, + end_lineno=107, + end_col_offset=37)], + [], + lineno=107, + col_offset=15, + end_lineno=107, + end_col_offset=38), + Add(), + Call( + Name( + 'placeholder_0', + Load(), + lineno=107, + col_offset=41, + end_lineno=107, + end_col_offset=54), + [ + Name( + 'placeholder_5', + Load(), + lineno=107, + col_offset=55, + end_lineno=107, + end_col_offset=63)], + [], + lineno=107, + col_offset=41, + end_lineno=107, + end_col_offset=64), + lineno=107, + col_offset=15, + end_lineno=107, + end_col_offset=64), + Constant( + 12, + lineno=107, + col_offset=67, + end_lineno=107, + end_col_offset=69)], + lineno=107, + col_offset=11, + end_lineno=107, + end_col_offset=69), + lineno=107, + col_offset=4, + end_lineno=107, + end_col_offset=69)], + [], + lineno=100, + col_offset=0, + end_lineno=107, + end_col_offset=69)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-black-jack/representation.txt b/test/concept-black-jack/representation.txt new file mode 100644 index 0000000..7a89e82 --- /dev/null +++ b/test/concept-black-jack/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=8, col_offset=18, end_lineno=8, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_1', Load(), lineno=19, col_offset=7, end_lineno=19, end_col_offset=11), [In()], [Constant('JQK', lineno=19, col_offset=16, end_lineno=19, end_col_offset=21)], lineno=19, col_offset=7, end_lineno=19, end_col_offset=22), [Assign([Name('placeholder_2', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=13)], Constant(10, lineno=20, col_offset=16, end_lineno=20, end_col_offset=18), lineno=20, col_offset=8, end_lineno=20, end_col_offset=18)], [If(Compare(Name('placeholder_1', Load(), lineno=22, col_offset=9, end_lineno=22, end_col_offset=13), [Eq()], [Constant('A', lineno=22, col_offset=17, end_lineno=22, end_col_offset=20)], lineno=22, col_offset=9, end_lineno=22, end_col_offset=20), [Assign([Name('placeholder_2', Store(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=13)], Constant(1, lineno=23, col_offset=16, end_lineno=23, end_col_offset=17), lineno=23, col_offset=8, end_lineno=23, end_col_offset=17)], [Assign([Name('placeholder_2', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=13)], Call(Name('int', Load(), lineno=26, col_offset=16, end_lineno=26, end_col_offset=19), [Name('placeholder_1', Load(), lineno=26, col_offset=20, end_lineno=26, end_col_offset=24)], [], lineno=26, col_offset=16, end_lineno=26, end_col_offset=25), lineno=26, col_offset=8, end_lineno=26, end_col_offset=25)], lineno=22, col_offset=4, end_lineno=26, end_col_offset=25)], lineno=19, col_offset=4, end_lineno=26, end_col_offset=25), Return(Name('placeholder_2', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=16), lineno=28, col_offset=4, end_lineno=28, end_col_offset=16)], [], lineno=8, col_offset=0, end_lineno=28, end_col_offset=16), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=31, col_offset=16, end_lineno=31, end_col_offset=24), arg('placeholder_5', lineno=31, col_offset=26, end_lineno=31, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=42, col_offset=4, end_lineno=42, end_col_offset=18)], Call(Name('placeholder_0', Load(), lineno=42, col_offset=21, end_lineno=42, end_col_offset=34), [Name('placeholder_4', Load(), lineno=42, col_offset=35, end_lineno=42, end_col_offset=43)], [], lineno=42, col_offset=21, end_lineno=42, end_col_offset=44), lineno=42, col_offset=4, end_lineno=42, end_col_offset=44), Assign([Name('placeholder_7', Store(), lineno=43, col_offset=4, end_lineno=43, end_col_offset=18)], Call(Name('placeholder_0', Load(), lineno=43, col_offset=21, end_lineno=43, end_col_offset=34), [Name('placeholder_5', Load(), lineno=43, col_offset=35, end_lineno=43, end_col_offset=43)], [], lineno=43, col_offset=21, end_lineno=43, end_col_offset=44), lineno=43, col_offset=4, end_lineno=43, end_col_offset=44), If(Compare(Name('placeholder_6', Load(), lineno=45, col_offset=7, end_lineno=45, end_col_offset=21), [Eq()], [Name('placeholder_7', Load(), lineno=45, col_offset=25, end_lineno=45, end_col_offset=39)], lineno=45, col_offset=7, end_lineno=45, end_col_offset=39), [Assign([Name('placeholder_8', Store(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=14)], Tuple([Name('placeholder_4', Load(), lineno=46, col_offset=17, end_lineno=46, end_col_offset=25), Name('placeholder_5', Load(), lineno=46, col_offset=27, end_lineno=46, end_col_offset=35)], Load(), lineno=46, col_offset=17, end_lineno=46, end_col_offset=35), lineno=46, col_offset=8, end_lineno=46, end_col_offset=35)], [If(Compare(Name('placeholder_6', Load(), lineno=48, col_offset=9, end_lineno=48, end_col_offset=23), [Gt()], [Name('placeholder_7', Load(), lineno=48, col_offset=26, end_lineno=48, end_col_offset=40)], lineno=48, col_offset=9, end_lineno=48, end_col_offset=40), [Assign([Name('placeholder_8', Store(), lineno=49, col_offset=8, end_lineno=49, end_col_offset=14)], Name('placeholder_4', Load(), lineno=49, col_offset=17, end_lineno=49, end_col_offset=25), lineno=49, col_offset=8, end_lineno=49, end_col_offset=25)], [Assign([Name('placeholder_8', Store(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=14)], Name('placeholder_5', Load(), lineno=52, col_offset=17, end_lineno=52, end_col_offset=25), lineno=52, col_offset=8, end_lineno=52, end_col_offset=25)], lineno=48, col_offset=4, end_lineno=52, end_col_offset=25)], lineno=45, col_offset=4, end_lineno=52, end_col_offset=25), Return(Name('placeholder_8', Load(), lineno=54, col_offset=11, end_lineno=54, end_col_offset=17), lineno=54, col_offset=4, end_lineno=54, end_col_offset=17)], [], lineno=31, col_offset=0, end_lineno=54, end_col_offset=17), FunctionDef('placeholder_9', arguments([], [arg('placeholder_4', lineno=57, col_offset=17, end_lineno=57, end_col_offset=25), arg('placeholder_5', lineno=57, col_offset=27, end_lineno=57, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=68, col_offset=4, end_lineno=68, end_col_offset=18)], IfExp(Compare(Name('placeholder_4', Load(), lineno=68, col_offset=27, end_lineno=68, end_col_offset=35), [Eq()], [Constant('A', lineno=68, col_offset=39, end_lineno=68, end_col_offset=42)], lineno=68, col_offset=27, end_lineno=68, end_col_offset=42), Constant(11, lineno=68, col_offset=21, end_lineno=68, end_col_offset=23), Call(Name('placeholder_0', Load(), lineno=68, col_offset=48, end_lineno=68, end_col_offset=61), [Name('placeholder_4', Load(), lineno=68, col_offset=62, end_lineno=68, end_col_offset=70)], [], lineno=68, col_offset=48, end_lineno=68, end_col_offset=71), lineno=68, col_offset=21, end_lineno=68, end_col_offset=71), lineno=68, col_offset=4, end_lineno=68, end_col_offset=71), Assign([Name('placeholder_7', Store(), lineno=69, col_offset=4, end_lineno=69, end_col_offset=18)], IfExp(Compare(Name('placeholder_5', Load(), lineno=69, col_offset=27, end_lineno=69, end_col_offset=35), [Eq()], [Constant('A', lineno=69, col_offset=39, end_lineno=69, end_col_offset=42)], lineno=69, col_offset=27, end_lineno=69, end_col_offset=42), Constant(11, lineno=69, col_offset=21, end_lineno=69, end_col_offset=23), Call(Name('placeholder_0', Load(), lineno=69, col_offset=48, end_lineno=69, end_col_offset=61), [Name('placeholder_5', Load(), lineno=69, col_offset=62, end_lineno=69, end_col_offset=70)], [], lineno=69, col_offset=48, end_lineno=69, end_col_offset=71), lineno=69, col_offset=21, end_lineno=69, end_col_offset=71), lineno=69, col_offset=4, end_lineno=69, end_col_offset=71), Assign([Name('placeholder_10', Store(), lineno=71, col_offset=4, end_lineno=71, end_col_offset=13)], IfExp(Compare(BinOp(Constant(11, lineno=71, col_offset=21, end_lineno=71, end_col_offset=23), Add(), BinOp(Name('placeholder_6', Load(), lineno=71, col_offset=27, end_lineno=71, end_col_offset=41), Add(), Name('placeholder_7', Load(), lineno=71, col_offset=44, end_lineno=71, end_col_offset=58), lineno=71, col_offset=27, end_lineno=71, end_col_offset=58), lineno=71, col_offset=21, end_lineno=71, end_col_offset=59), [Gt()], [Constant(21, lineno=71, col_offset=62, end_lineno=71, end_col_offset=64)], lineno=71, col_offset=21, end_lineno=71, end_col_offset=64), Constant(1, lineno=71, col_offset=16, end_lineno=71, end_col_offset=17), Constant(11, lineno=71, col_offset=70, end_lineno=71, end_col_offset=72), lineno=71, col_offset=16, end_lineno=71, end_col_offset=72), lineno=71, col_offset=4, end_lineno=71, end_col_offset=72), Return(Name('placeholder_10', Load(), lineno=73, col_offset=11, end_lineno=73, end_col_offset=20), lineno=73, col_offset=4, end_lineno=73, end_col_offset=20)], [], lineno=57, col_offset=0, end_lineno=73, end_col_offset=20), FunctionDef('placeholder_11', arguments([], [arg('placeholder_4', lineno=76, col_offset=17, end_lineno=76, end_col_offset=25), arg('placeholder_5', lineno=76, col_offset=27, end_lineno=76, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [BoolOp(Or(), [Compare(Name('placeholder_4', Load(), lineno=87, col_offset=12, end_lineno=87, end_col_offset=20), [Eq()], [Constant('A', lineno=87, col_offset=24, end_lineno=87, end_col_offset=27)], lineno=87, col_offset=12, end_lineno=87, end_col_offset=27), Compare(Name('placeholder_5', Load(), lineno=87, col_offset=31, end_lineno=87, end_col_offset=39), [Eq()], [Constant('A', lineno=87, col_offset=43, end_lineno=87, end_col_offset=46)], lineno=87, col_offset=31, end_lineno=87, end_col_offset=46)], lineno=87, col_offset=12, end_lineno=87, end_col_offset=46), BoolOp(Or(), [Compare(Call(Name('placeholder_0', Load(), lineno=87, col_offset=53, end_lineno=87, end_col_offset=66), [Name('placeholder_4', Load(), lineno=87, col_offset=67, end_lineno=87, end_col_offset=75)], [], lineno=87, col_offset=53, end_lineno=87, end_col_offset=76), [Eq()], [Constant(10, lineno=87, col_offset=80, end_lineno=87, end_col_offset=82)], lineno=87, col_offset=53, end_lineno=87, end_col_offset=82), Compare(Call(Name('placeholder_0', Load(), lineno=87, col_offset=86, end_lineno=87, end_col_offset=99), [Name('placeholder_5', Load(), lineno=87, col_offset=100, end_lineno=87, end_col_offset=108)], [], lineno=87, col_offset=86, end_lineno=87, end_col_offset=109), [Eq()], [Constant(10, lineno=87, col_offset=113, end_lineno=87, end_col_offset=115)], lineno=87, col_offset=86, end_lineno=87, end_col_offset=115)], lineno=87, col_offset=53, end_lineno=87, end_col_offset=115)], lineno=87, col_offset=11, end_lineno=87, end_col_offset=116), lineno=87, col_offset=4, end_lineno=87, end_col_offset=116)], [], lineno=76, col_offset=0, end_lineno=87, end_col_offset=116), FunctionDef('placeholder_12', arguments([], [arg('placeholder_4', lineno=90, col_offset=20, end_lineno=90, end_col_offset=28), arg('placeholder_5', lineno=90, col_offset=30, end_lineno=90, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Call(Name('placeholder_0', Load(), lineno=97, col_offset=11, end_lineno=97, end_col_offset=24), [Name('placeholder_4', Load(), lineno=97, col_offset=25, end_lineno=97, end_col_offset=33)], [], lineno=97, col_offset=11, end_lineno=97, end_col_offset=34), [Eq()], [Call(Name('placeholder_0', Load(), lineno=97, col_offset=38, end_lineno=97, end_col_offset=51), [Name('placeholder_5', Load(), lineno=97, col_offset=52, end_lineno=97, end_col_offset=60)], [], lineno=97, col_offset=38, end_lineno=97, end_col_offset=61)], lineno=97, col_offset=11, end_lineno=97, end_col_offset=61), lineno=97, col_offset=4, end_lineno=97, end_col_offset=61)], [], lineno=90, col_offset=0, end_lineno=97, end_col_offset=61), FunctionDef('placeholder_13', arguments([], [arg('placeholder_4', lineno=100, col_offset=20, end_lineno=100, end_col_offset=28), arg('placeholder_5', lineno=100, col_offset=30, end_lineno=100, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Constant(8, lineno=107, col_offset=11, end_lineno=107, end_col_offset=12), [Lt(), Lt()], [BinOp(Call(Name('placeholder_0', Load(), lineno=107, col_offset=15, end_lineno=107, end_col_offset=28), [Name('placeholder_4', Load(), lineno=107, col_offset=29, end_lineno=107, end_col_offset=37)], [], lineno=107, col_offset=15, end_lineno=107, end_col_offset=38), Add(), Call(Name('placeholder_0', Load(), lineno=107, col_offset=41, end_lineno=107, end_col_offset=54), [Name('placeholder_5', Load(), lineno=107, col_offset=55, end_lineno=107, end_col_offset=63)], [], lineno=107, col_offset=41, end_lineno=107, end_col_offset=64), lineno=107, col_offset=15, end_lineno=107, end_col_offset=64), Constant(12, lineno=107, col_offset=67, end_lineno=107, end_col_offset=69)], lineno=107, col_offset=11, end_lineno=107, end_col_offset=69), lineno=107, col_offset=4, end_lineno=107, end_col_offset=69)], [], lineno=100, col_offset=0, end_lineno=107, end_col_offset=69)], []) \ No newline at end of file diff --git a/test/concept-card-games/.meta/config.json b/test/concept-card-games/.meta/config.json new file mode 100644 index 0000000..98a9c48 --- /dev/null +++ b/test/concept-card-games/.meta/config.json @@ -0,0 +1,18 @@ +{ + "authors": [ + "itamargal", + "isaacg", + "bethanyg" + ], + "contributors": [ + "valentin-p", + "pranasziaukas" + ], + "files": { + "solution": [ + "lists.py" + ] + }, + "icon": "poker", + "blurb": "Learn about lists by tracking hands in card games." +} diff --git a/test/concept-card-games/lists.py b/test/concept-card-games/lists.py new file mode 100644 index 0000000..840aea6 --- /dev/null +++ b/test/concept-card-games/lists.py @@ -0,0 +1,88 @@ +"""Functions for tracking poker hands and assorted card tasks. + +Python list documentation: https://docs.python.org/3/tutorial/datastructures.html +""" + + +def get_rounds(number): + """Create a list containing the current and next two round numbers. + + :param number: int - current round number. + :return: list - current round and the two that follow. + """ + + return [number, number + 1, number + 2] + + +def concatenate_rounds(rounds_1, rounds_2): + """Concatenate two lists of round numbers. + + :param rounds_1: list - first rounds played. + :param rounds_2: list - second set of rounds played. + :return: list - all rounds played. + """ + + return rounds_1 + rounds_2 + + +def list_contains_round(rounds, number): + """Check if the list of rounds contains the specified number. + + :param rounds: list - rounds played. + :param number: int - round number. + :return: bool - was the round played? + """ + + return number in rounds + + +def card_average(hand): + """Calculate and returns the average card value from the list. + + :param hand: list - cards in hand. + :return: float - average value of the cards in the hand. + """ + + return sum(hand) / len(hand) + + +def approx_average_is_average(hand): + """Return if an average is using (first + last index values ) OR ('middle' card) == calculated average. + + :param hand: list - cards in hand. + :return: bool - does one of the approximate averages equal the `true average`? + """ + + real_average = card_average(hand) + + if card_average([hand[0], hand[-1]]) == real_average: + is_same = True + elif hand[len(hand) // 2] == real_average: + is_same = True + else: + is_same = False + + return is_same + + +def average_even_is_average_odd(hand): + """Return if the (average of even indexed card values) == (average of odd indexed card values). + + :param hand: list - cards in hand. + :return: bool - are even and odd averages equal? + """ + + return card_average(hand[::2]) == card_average(hand[1::2]) + + +def maybe_double_last(hand): + """Multiply a Jack card value in the last index position by 2. + + :param hand: list - cards in hand. + :return: list - hand with Jacks (if present) value doubled. + """ + + if hand[-1] == 11: + hand[-1] *= 2 + + return hand diff --git a/test/concept-card-games/mapping.json b/test/concept-card-games/mapping.json new file mode 100644 index 0000000..14d030c --- /dev/null +++ b/test/concept-card-games/mapping.json @@ -0,0 +1,16 @@ +{ + "placeholder_0": "get_rounds", + "placeholder_1": "number", + "placeholder_2": "concatenate_rounds", + "placeholder_3": "rounds_1", + "placeholder_4": "rounds_2", + "placeholder_5": "list_contains_round", + "placeholder_6": "rounds", + "placeholder_7": "card_average", + "placeholder_8": "hand", + "placeholder_9": "approx_average_is_average", + "placeholder_10": "real_average", + "placeholder_11": "is_same", + "placeholder_12": "average_even_is_average_odd", + "placeholder_13": "maybe_double_last" +} \ No newline at end of file diff --git a/test/concept-card-games/representation.json b/test/concept-card-games/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-card-games/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-card-games/representation.out b/test/concept-card-games/representation.out new file mode 100644 index 0000000..9917d95 --- /dev/null +++ b/test/concept-card-games/representation.out @@ -0,0 +1,1662 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return [placeholder_1, placeholder_1 + 1, placeholder_1 + 2] + + +def placeholder_2(placeholder_3, placeholder_4): + return placeholder_3 + placeholder_4 + + +def placeholder_5(placeholder_6, placeholder_1): + return placeholder_1 in placeholder_6 + + +def placeholder_7(placeholder_8): + return sum(placeholder_8) / len(placeholder_8) + + +def placeholder_9(placeholder_8): + placeholder_10 = placeholder_7(placeholder_8) + if placeholder_7([placeholder_8[0], placeholder_8[-1]]) == placeholder_10: + placeholder_11 = True + elif placeholder_8[len(placeholder_8) // 2] == placeholder_10: + placeholder_11 = True + else: + placeholder_11 = False + return placeholder_11 + + +def placeholder_12(placeholder_8): + return placeholder_7(placeholder_8[::2]) == placeholder_7(placeholder_8[1::2]) + + +def placeholder_13(placeholder_8): + if placeholder_8[-1] == 11: + placeholder_8[-1] *= 2 + return placeholder_8 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions for tracking poker hands and assorted card tasks.\n\nPython list documentation: https://docs.python.org/3/tutorial/datastructures.html\n', + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + FunctionDef( + 'get_rounds', + arguments( + [], + [ + arg( + 'number', + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Create a list containing the current and next two round numbers.\n\n :param number: int - current round number.\n :return: list - current round and the two that follow.\n ', + lineno=8, + col_offset=4, + end_lineno=12, + end_col_offset=7), + lineno=8, + col_offset=4, + end_lineno=12, + end_col_offset=7), + Return( + List( + [ + Name( + 'number', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=18), + BinOp( + Name( + 'number', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=26), + Add(), + Constant( + 1, + lineno=14, + col_offset=29, + end_lineno=14, + end_col_offset=30), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=30), + BinOp( + Name( + 'number', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=38), + Add(), + Constant( + 2, + lineno=14, + col_offset=41, + end_lineno=14, + end_col_offset=42), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=42)], + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=43), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=43)], + [], + lineno=7, + col_offset=0, + end_lineno=14, + end_col_offset=43), + FunctionDef( + 'concatenate_rounds', + arguments( + [], + [ + arg( + 'rounds_1', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=31), + arg( + 'rounds_2', + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Concatenate two lists of round numbers.\n\n :param rounds_1: list - first rounds played.\n :param rounds_2: list - second set of rounds played.\n :return: list - all rounds played.\n ', + lineno=18, + col_offset=4, + end_lineno=23, + end_col_offset=7), + lineno=18, + col_offset=4, + end_lineno=23, + end_col_offset=7), + Return( + BinOp( + Name( + 'rounds_1', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=19), + Add(), + Name( + 'rounds_2', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=30)], + [], + lineno=17, + col_offset=0, + end_lineno=25, + end_col_offset=30), + FunctionDef( + 'list_contains_round', + arguments( + [], + [ + arg( + 'rounds', + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=30), + arg( + 'number', + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Check if the list of rounds contains the specified number.\n\n :param rounds: list - rounds played.\n :param number: int - round number.\n :return: bool - was the round played?\n ', + lineno=29, + col_offset=4, + end_lineno=34, + end_col_offset=7), + lineno=29, + col_offset=4, + end_lineno=34, + end_col_offset=7), + Return( + Compare( + Name( + 'number', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=17), + [ + In()], + [ + Name( + 'rounds', + Load(), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=27)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=27), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=27)], + [], + lineno=28, + col_offset=0, + end_lineno=36, + end_col_offset=27), + FunctionDef( + 'card_average', + arguments( + [], + [ + arg( + 'hand', + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Calculate and returns the average card value from the list.\n\n :param hand: list - cards in hand.\n :return: float - average value of the cards in the hand.\n ', + lineno=40, + col_offset=4, + end_lineno=44, + end_col_offset=7), + lineno=40, + col_offset=4, + end_lineno=44, + end_col_offset=7), + Return( + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=14), + [ + Name( + 'hand', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19)], + [], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=20), + Div(), + Call( + Name( + 'len', + Load(), + lineno=46, + col_offset=23, + end_lineno=46, + end_col_offset=26), + [ + Name( + 'hand', + Load(), + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=31)], + [], + lineno=46, + col_offset=23, + end_lineno=46, + end_col_offset=32), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=32), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=32)], + [], + lineno=39, + col_offset=0, + end_lineno=46, + end_col_offset=32), + FunctionDef( + 'approx_average_is_average', + arguments( + [], + [ + arg( + 'hand', + lineno=49, + col_offset=30, + end_lineno=49, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Return if an average is using (first + last index values ) OR ('middle' card) == calculated average.\n\n :param hand: list - cards in hand.\n :return: bool - does one of the approximate averages equal the `true average`?\n ", + lineno=50, + col_offset=4, + end_lineno=54, + end_col_offset=7), + lineno=50, + col_offset=4, + end_lineno=54, + end_col_offset=7), + Assign( + [ + Name( + 'real_average', + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=16)], + Call( + Name( + 'card_average', + Load(), + lineno=56, + col_offset=19, + end_lineno=56, + end_col_offset=31), + [ + Name( + 'hand', + Load(), + lineno=56, + col_offset=32, + end_lineno=56, + end_col_offset=36)], + [], + lineno=56, + col_offset=19, + end_lineno=56, + end_col_offset=37), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=37), + If( + Compare( + Call( + Name( + 'card_average', + Load(), + lineno=58, + col_offset=7, + end_lineno=58, + end_col_offset=19), + [ + List( + [ + Subscript( + Name( + 'hand', + Load(), + lineno=58, + col_offset=21, + end_lineno=58, + end_col_offset=25), + Constant( + 0, + lineno=58, + col_offset=26, + end_lineno=58, + end_col_offset=27), + Load(), + lineno=58, + col_offset=21, + end_lineno=58, + end_col_offset=28), + Subscript( + Name( + 'hand', + Load(), + lineno=58, + col_offset=30, + end_lineno=58, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 1, + lineno=58, + col_offset=36, + end_lineno=58, + end_col_offset=37), + lineno=58, + col_offset=35, + end_lineno=58, + end_col_offset=37), + Load(), + lineno=58, + col_offset=30, + end_lineno=58, + end_col_offset=38)], + Load(), + lineno=58, + col_offset=20, + end_lineno=58, + end_col_offset=39)], + [], + lineno=58, + col_offset=7, + end_lineno=58, + end_col_offset=40), + [ + Eq()], + [ + Name( + 'real_average', + Load(), + lineno=58, + col_offset=44, + end_lineno=58, + end_col_offset=56)], + lineno=58, + col_offset=7, + end_lineno=58, + end_col_offset=56), + [ + Assign( + [ + Name( + 'is_same', + Store(), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=15)], + Constant( + True, + lineno=59, + col_offset=18, + end_lineno=59, + end_col_offset=22), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=22)], + [ + If( + Compare( + Subscript( + Name( + 'hand', + Load(), + lineno=60, + col_offset=9, + end_lineno=60, + end_col_offset=13), + BinOp( + Call( + Name( + 'len', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=17), + [ + Name( + 'hand', + Load(), + lineno=60, + col_offset=18, + end_lineno=60, + end_col_offset=22)], + [], + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=23), + FloorDiv(), + Constant( + 2, + lineno=60, + col_offset=27, + end_lineno=60, + end_col_offset=28), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=28), + Load(), + lineno=60, + col_offset=9, + end_lineno=60, + end_col_offset=29), + [ + Eq()], + [ + Name( + 'real_average', + Load(), + lineno=60, + col_offset=33, + end_lineno=60, + end_col_offset=45)], + lineno=60, + col_offset=9, + end_lineno=60, + end_col_offset=45), + [ + Assign( + [ + Name( + 'is_same', + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=15)], + Constant( + True, + lineno=61, + col_offset=18, + end_lineno=61, + end_col_offset=22), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=22)], + [ + Assign( + [ + Name( + 'is_same', + Store(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=15)], + Constant( + False, + lineno=63, + col_offset=18, + end_lineno=63, + end_col_offset=23), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=23)], + lineno=60, + col_offset=4, + end_lineno=63, + end_col_offset=23)], + lineno=58, + col_offset=4, + end_lineno=63, + end_col_offset=23), + Return( + Name( + 'is_same', + Load(), + lineno=65, + col_offset=11, + end_lineno=65, + end_col_offset=18), + lineno=65, + col_offset=4, + end_lineno=65, + end_col_offset=18)], + [], + lineno=49, + col_offset=0, + end_lineno=65, + end_col_offset=18), + FunctionDef( + 'average_even_is_average_odd', + arguments( + [], + [ + arg( + 'hand', + lineno=68, + col_offset=32, + end_lineno=68, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return if the (average of even indexed card values) == (average of odd indexed card values).\n\n :param hand: list - cards in hand.\n :return: bool - are even and odd averages equal?\n ', + lineno=69, + col_offset=4, + end_lineno=73, + end_col_offset=7), + lineno=69, + col_offset=4, + end_lineno=73, + end_col_offset=7), + Return( + Compare( + Call( + Name( + 'card_average', + Load(), + lineno=75, + col_offset=11, + end_lineno=75, + end_col_offset=23), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=28), + Slice( + step=Constant( + 2, + lineno=75, + col_offset=31, + end_lineno=75, + end_col_offset=32), + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=32), + Load(), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=33)], + [], + lineno=75, + col_offset=11, + end_lineno=75, + end_col_offset=34), + [ + Eq()], + [ + Call( + Name( + 'card_average', + Load(), + lineno=75, + col_offset=38, + end_lineno=75, + end_col_offset=50), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=75, + col_offset=51, + end_lineno=75, + end_col_offset=55), + Slice( + Constant( + 1, + lineno=75, + col_offset=56, + end_lineno=75, + end_col_offset=57), + step=Constant( + 2, + lineno=75, + col_offset=59, + end_lineno=75, + end_col_offset=60), + lineno=75, + col_offset=56, + end_lineno=75, + end_col_offset=60), + Load(), + lineno=75, + col_offset=51, + end_lineno=75, + end_col_offset=61)], + [], + lineno=75, + col_offset=38, + end_lineno=75, + end_col_offset=62)], + lineno=75, + col_offset=11, + end_lineno=75, + end_col_offset=62), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=62)], + [], + lineno=68, + col_offset=0, + end_lineno=75, + end_col_offset=62), + FunctionDef( + 'maybe_double_last', + arguments( + [], + [ + arg( + 'hand', + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Multiply a Jack card value in the last index position by 2.\n\n :param hand: list - cards in hand.\n :return: list - hand with Jacks (if present) value doubled.\n ', + lineno=79, + col_offset=4, + end_lineno=83, + end_col_offset=7), + lineno=79, + col_offset=4, + end_lineno=83, + end_col_offset=7), + If( + Compare( + Subscript( + Name( + 'hand', + Load(), + lineno=85, + col_offset=7, + end_lineno=85, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=85, + col_offset=13, + end_lineno=85, + end_col_offset=14), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=14), + Load(), + lineno=85, + col_offset=7, + end_lineno=85, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 11, + lineno=85, + col_offset=19, + end_lineno=85, + end_col_offset=21)], + lineno=85, + col_offset=7, + end_lineno=85, + end_col_offset=21), + [ + AugAssign( + Subscript( + Name( + 'hand', + Load(), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=12), + UnaryOp( + USub(), + Constant( + 1, + lineno=86, + col_offset=14, + end_lineno=86, + end_col_offset=15), + lineno=86, + col_offset=13, + end_lineno=86, + end_col_offset=15), + Store(), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=16), + Mult(), + Constant( + 2, + lineno=86, + col_offset=20, + end_lineno=86, + end_col_offset=21), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=21)], + [], + lineno=85, + col_offset=4, + end_lineno=86, + end_col_offset=21), + Return( + Name( + 'hand', + Load(), + lineno=88, + col_offset=11, + end_lineno=88, + end_col_offset=15), + lineno=88, + col_offset=4, + end_lineno=88, + end_col_offset=15)], + [], + lineno=78, + col_offset=0, + end_lineno=88, + end_col_offset=15)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + List( + [ + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=18), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=26), + Add(), + Constant( + 1, + lineno=14, + col_offset=29, + end_lineno=14, + end_col_offset=30), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=30), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=38), + Add(), + Constant( + 2, + lineno=14, + col_offset=41, + end_lineno=14, + end_col_offset=42), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=42)], + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=43), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=43)], + [], + lineno=7, + col_offset=0, + end_lineno=14, + end_col_offset=43), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=31), + arg( + 'placeholder_4', + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=19), + Add(), + Name( + 'placeholder_4', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=30)], + [], + lineno=17, + col_offset=0, + end_lineno=25, + end_col_offset=30), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=30), + arg( + 'placeholder_1', + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=17), + [ + In()], + [ + Name( + 'placeholder_6', + Load(), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=27)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=27), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=27)], + [], + lineno=28, + col_offset=0, + end_lineno=36, + end_col_offset=27), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=14), + [ + Name( + 'placeholder_8', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19)], + [], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=20), + Div(), + Call( + Name( + 'len', + Load(), + lineno=46, + col_offset=23, + end_lineno=46, + end_col_offset=26), + [ + Name( + 'placeholder_8', + Load(), + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=31)], + [], + lineno=46, + col_offset=23, + end_lineno=46, + end_col_offset=32), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=32), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=32)], + [], + lineno=39, + col_offset=0, + end_lineno=46, + end_col_offset=32), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=49, + col_offset=30, + end_lineno=49, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=16)], + Call( + Name( + 'placeholder_7', + Load(), + lineno=56, + col_offset=19, + end_lineno=56, + end_col_offset=31), + [ + Name( + 'placeholder_8', + Load(), + lineno=56, + col_offset=32, + end_lineno=56, + end_col_offset=36)], + [], + lineno=56, + col_offset=19, + end_lineno=56, + end_col_offset=37), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=37), + If( + Compare( + Call( + Name( + 'placeholder_7', + Load(), + lineno=58, + col_offset=7, + end_lineno=58, + end_col_offset=19), + [ + List( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=58, + col_offset=21, + end_lineno=58, + end_col_offset=25), + Constant( + 0, + lineno=58, + col_offset=26, + end_lineno=58, + end_col_offset=27), + Load(), + lineno=58, + col_offset=21, + end_lineno=58, + end_col_offset=28), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=58, + col_offset=30, + end_lineno=58, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 1, + lineno=58, + col_offset=36, + end_lineno=58, + end_col_offset=37), + lineno=58, + col_offset=35, + end_lineno=58, + end_col_offset=37), + Load(), + lineno=58, + col_offset=30, + end_lineno=58, + end_col_offset=38)], + Load(), + lineno=58, + col_offset=20, + end_lineno=58, + end_col_offset=39)], + [], + lineno=58, + col_offset=7, + end_lineno=58, + end_col_offset=40), + [ + Eq()], + [ + Name( + 'placeholder_10', + Load(), + lineno=58, + col_offset=44, + end_lineno=58, + end_col_offset=56)], + lineno=58, + col_offset=7, + end_lineno=58, + end_col_offset=56), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=15)], + Constant( + True, + lineno=59, + col_offset=18, + end_lineno=59, + end_col_offset=22), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=22)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=60, + col_offset=9, + end_lineno=60, + end_col_offset=13), + BinOp( + Call( + Name( + 'len', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=17), + [ + Name( + 'placeholder_8', + Load(), + lineno=60, + col_offset=18, + end_lineno=60, + end_col_offset=22)], + [], + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=23), + FloorDiv(), + Constant( + 2, + lineno=60, + col_offset=27, + end_lineno=60, + end_col_offset=28), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=28), + Load(), + lineno=60, + col_offset=9, + end_lineno=60, + end_col_offset=29), + [ + Eq()], + [ + Name( + 'placeholder_10', + Load(), + lineno=60, + col_offset=33, + end_lineno=60, + end_col_offset=45)], + lineno=60, + col_offset=9, + end_lineno=60, + end_col_offset=45), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=15)], + Constant( + True, + lineno=61, + col_offset=18, + end_lineno=61, + end_col_offset=22), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=22)], + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=15)], + Constant( + False, + lineno=63, + col_offset=18, + end_lineno=63, + end_col_offset=23), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=23)], + lineno=60, + col_offset=4, + end_lineno=63, + end_col_offset=23)], + lineno=58, + col_offset=4, + end_lineno=63, + end_col_offset=23), + Return( + Name( + 'placeholder_11', + Load(), + lineno=65, + col_offset=11, + end_lineno=65, + end_col_offset=18), + lineno=65, + col_offset=4, + end_lineno=65, + end_col_offset=18)], + [], + lineno=49, + col_offset=0, + end_lineno=65, + end_col_offset=18), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=68, + col_offset=32, + end_lineno=68, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'placeholder_7', + Load(), + lineno=75, + col_offset=11, + end_lineno=75, + end_col_offset=23), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=28), + Slice( + step=Constant( + 2, + lineno=75, + col_offset=31, + end_lineno=75, + end_col_offset=32), + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=32), + Load(), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=33)], + [], + lineno=75, + col_offset=11, + end_lineno=75, + end_col_offset=34), + [ + Eq()], + [ + Call( + Name( + 'placeholder_7', + Load(), + lineno=75, + col_offset=38, + end_lineno=75, + end_col_offset=50), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=75, + col_offset=51, + end_lineno=75, + end_col_offset=55), + Slice( + Constant( + 1, + lineno=75, + col_offset=56, + end_lineno=75, + end_col_offset=57), + step=Constant( + 2, + lineno=75, + col_offset=59, + end_lineno=75, + end_col_offset=60), + lineno=75, + col_offset=56, + end_lineno=75, + end_col_offset=60), + Load(), + lineno=75, + col_offset=51, + end_lineno=75, + end_col_offset=61)], + [], + lineno=75, + col_offset=38, + end_lineno=75, + end_col_offset=62)], + lineno=75, + col_offset=11, + end_lineno=75, + end_col_offset=62), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=62)], + [], + lineno=68, + col_offset=0, + end_lineno=75, + end_col_offset=62), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=85, + col_offset=7, + end_lineno=85, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=85, + col_offset=13, + end_lineno=85, + end_col_offset=14), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=14), + Load(), + lineno=85, + col_offset=7, + end_lineno=85, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 11, + lineno=85, + col_offset=19, + end_lineno=85, + end_col_offset=21)], + lineno=85, + col_offset=7, + end_lineno=85, + end_col_offset=21), + [ + AugAssign( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=12), + UnaryOp( + USub(), + Constant( + 1, + lineno=86, + col_offset=14, + end_lineno=86, + end_col_offset=15), + lineno=86, + col_offset=13, + end_lineno=86, + end_col_offset=15), + Store(), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=16), + Mult(), + Constant( + 2, + lineno=86, + col_offset=20, + end_lineno=86, + end_col_offset=21), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=21)], + [], + lineno=85, + col_offset=4, + end_lineno=86, + end_col_offset=21), + Return( + Name( + 'placeholder_8', + Load(), + lineno=88, + col_offset=11, + end_lineno=88, + end_col_offset=15), + lineno=88, + col_offset=4, + end_lineno=88, + end_col_offset=15)], + [], + lineno=78, + col_offset=0, + end_lineno=88, + end_col_offset=15)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-card-games/representation.txt b/test/concept-card-games/representation.txt new file mode 100644 index 0000000..aee7e86 --- /dev/null +++ b/test/concept-card-games/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=7, col_offset=15, end_lineno=7, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(List([Name('placeholder_1', Load(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=18), BinOp(Name('placeholder_1', Load(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=26), Add(), Constant(1, lineno=14, col_offset=29, end_lineno=14, end_col_offset=30), lineno=14, col_offset=20, end_lineno=14, end_col_offset=30), BinOp(Name('placeholder_1', Load(), lineno=14, col_offset=32, end_lineno=14, end_col_offset=38), Add(), Constant(2, lineno=14, col_offset=41, end_lineno=14, end_col_offset=42), lineno=14, col_offset=32, end_lineno=14, end_col_offset=42)], Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=43), lineno=14, col_offset=4, end_lineno=14, end_col_offset=43)], [], lineno=7, col_offset=0, end_lineno=14, end_col_offset=43), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=17, col_offset=23, end_lineno=17, end_col_offset=31), arg('placeholder_4', lineno=17, col_offset=33, end_lineno=17, end_col_offset=41)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_3', Load(), lineno=25, col_offset=11, end_lineno=25, end_col_offset=19), Add(), Name('placeholder_4', Load(), lineno=25, col_offset=22, end_lineno=25, end_col_offset=30), lineno=25, col_offset=11, end_lineno=25, end_col_offset=30), lineno=25, col_offset=4, end_lineno=25, end_col_offset=30)], [], lineno=17, col_offset=0, end_lineno=25, end_col_offset=30), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=28, col_offset=24, end_lineno=28, end_col_offset=30), arg('placeholder_1', lineno=28, col_offset=32, end_lineno=28, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Name('placeholder_1', Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=17), [In()], [Name('placeholder_6', Load(), lineno=36, col_offset=21, end_lineno=36, end_col_offset=27)], lineno=36, col_offset=11, end_lineno=36, end_col_offset=27), lineno=36, col_offset=4, end_lineno=36, end_col_offset=27)], [], lineno=28, col_offset=0, end_lineno=36, end_col_offset=27), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=39, col_offset=17, end_lineno=39, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Call(Name('sum', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=14), [Name('placeholder_8', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=19)], [], lineno=46, col_offset=11, end_lineno=46, end_col_offset=20), Div(), Call(Name('len', Load(), lineno=46, col_offset=23, end_lineno=46, end_col_offset=26), [Name('placeholder_8', Load(), lineno=46, col_offset=27, end_lineno=46, end_col_offset=31)], [], lineno=46, col_offset=23, end_lineno=46, end_col_offset=32), lineno=46, col_offset=11, end_lineno=46, end_col_offset=32), lineno=46, col_offset=4, end_lineno=46, end_col_offset=32)], [], lineno=39, col_offset=0, end_lineno=46, end_col_offset=32), FunctionDef('placeholder_9', arguments([], [arg('placeholder_8', lineno=49, col_offset=30, end_lineno=49, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_10', Store(), lineno=56, col_offset=4, end_lineno=56, end_col_offset=16)], Call(Name('placeholder_7', Load(), lineno=56, col_offset=19, end_lineno=56, end_col_offset=31), [Name('placeholder_8', Load(), lineno=56, col_offset=32, end_lineno=56, end_col_offset=36)], [], lineno=56, col_offset=19, end_lineno=56, end_col_offset=37), lineno=56, col_offset=4, end_lineno=56, end_col_offset=37), If(Compare(Call(Name('placeholder_7', Load(), lineno=58, col_offset=7, end_lineno=58, end_col_offset=19), [List([Subscript(Name('placeholder_8', Load(), lineno=58, col_offset=21, end_lineno=58, end_col_offset=25), Constant(0, lineno=58, col_offset=26, end_lineno=58, end_col_offset=27), Load(), lineno=58, col_offset=21, end_lineno=58, end_col_offset=28), Subscript(Name('placeholder_8', Load(), lineno=58, col_offset=30, end_lineno=58, end_col_offset=34), UnaryOp(USub(), Constant(1, lineno=58, col_offset=36, end_lineno=58, end_col_offset=37), lineno=58, col_offset=35, end_lineno=58, end_col_offset=37), Load(), lineno=58, col_offset=30, end_lineno=58, end_col_offset=38)], Load(), lineno=58, col_offset=20, end_lineno=58, end_col_offset=39)], [], lineno=58, col_offset=7, end_lineno=58, end_col_offset=40), [Eq()], [Name('placeholder_10', Load(), lineno=58, col_offset=44, end_lineno=58, end_col_offset=56)], lineno=58, col_offset=7, end_lineno=58, end_col_offset=56), [Assign([Name('placeholder_11', Store(), lineno=59, col_offset=8, end_lineno=59, end_col_offset=15)], Constant(True, lineno=59, col_offset=18, end_lineno=59, end_col_offset=22), lineno=59, col_offset=8, end_lineno=59, end_col_offset=22)], [If(Compare(Subscript(Name('placeholder_8', Load(), lineno=60, col_offset=9, end_lineno=60, end_col_offset=13), BinOp(Call(Name('len', Load(), lineno=60, col_offset=14, end_lineno=60, end_col_offset=17), [Name('placeholder_8', Load(), lineno=60, col_offset=18, end_lineno=60, end_col_offset=22)], [], lineno=60, col_offset=14, end_lineno=60, end_col_offset=23), FloorDiv(), Constant(2, lineno=60, col_offset=27, end_lineno=60, end_col_offset=28), lineno=60, col_offset=14, end_lineno=60, end_col_offset=28), Load(), lineno=60, col_offset=9, end_lineno=60, end_col_offset=29), [Eq()], [Name('placeholder_10', Load(), lineno=60, col_offset=33, end_lineno=60, end_col_offset=45)], lineno=60, col_offset=9, end_lineno=60, end_col_offset=45), [Assign([Name('placeholder_11', Store(), lineno=61, col_offset=8, end_lineno=61, end_col_offset=15)], Constant(True, lineno=61, col_offset=18, end_lineno=61, end_col_offset=22), lineno=61, col_offset=8, end_lineno=61, end_col_offset=22)], [Assign([Name('placeholder_11', Store(), lineno=63, col_offset=8, end_lineno=63, end_col_offset=15)], Constant(False, lineno=63, col_offset=18, end_lineno=63, end_col_offset=23), lineno=63, col_offset=8, end_lineno=63, end_col_offset=23)], lineno=60, col_offset=4, end_lineno=63, end_col_offset=23)], lineno=58, col_offset=4, end_lineno=63, end_col_offset=23), Return(Name('placeholder_11', Load(), lineno=65, col_offset=11, end_lineno=65, end_col_offset=18), lineno=65, col_offset=4, end_lineno=65, end_col_offset=18)], [], lineno=49, col_offset=0, end_lineno=65, end_col_offset=18), FunctionDef('placeholder_12', arguments([], [arg('placeholder_8', lineno=68, col_offset=32, end_lineno=68, end_col_offset=36)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Call(Name('placeholder_7', Load(), lineno=75, col_offset=11, end_lineno=75, end_col_offset=23), [Subscript(Name('placeholder_8', Load(), lineno=75, col_offset=24, end_lineno=75, end_col_offset=28), Slice(step=Constant(2, lineno=75, col_offset=31, end_lineno=75, end_col_offset=32), lineno=75, col_offset=29, end_lineno=75, end_col_offset=32), Load(), lineno=75, col_offset=24, end_lineno=75, end_col_offset=33)], [], lineno=75, col_offset=11, end_lineno=75, end_col_offset=34), [Eq()], [Call(Name('placeholder_7', Load(), lineno=75, col_offset=38, end_lineno=75, end_col_offset=50), [Subscript(Name('placeholder_8', Load(), lineno=75, col_offset=51, end_lineno=75, end_col_offset=55), Slice(Constant(1, lineno=75, col_offset=56, end_lineno=75, end_col_offset=57), step=Constant(2, lineno=75, col_offset=59, end_lineno=75, end_col_offset=60), lineno=75, col_offset=56, end_lineno=75, end_col_offset=60), Load(), lineno=75, col_offset=51, end_lineno=75, end_col_offset=61)], [], lineno=75, col_offset=38, end_lineno=75, end_col_offset=62)], lineno=75, col_offset=11, end_lineno=75, end_col_offset=62), lineno=75, col_offset=4, end_lineno=75, end_col_offset=62)], [], lineno=68, col_offset=0, end_lineno=75, end_col_offset=62), FunctionDef('placeholder_13', arguments([], [arg('placeholder_8', lineno=78, col_offset=22, end_lineno=78, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Subscript(Name('placeholder_8', Load(), lineno=85, col_offset=7, end_lineno=85, end_col_offset=11), UnaryOp(USub(), Constant(1, lineno=85, col_offset=13, end_lineno=85, end_col_offset=14), lineno=85, col_offset=12, end_lineno=85, end_col_offset=14), Load(), lineno=85, col_offset=7, end_lineno=85, end_col_offset=15), [Eq()], [Constant(11, lineno=85, col_offset=19, end_lineno=85, end_col_offset=21)], lineno=85, col_offset=7, end_lineno=85, end_col_offset=21), [AugAssign(Subscript(Name('placeholder_8', Load(), lineno=86, col_offset=8, end_lineno=86, end_col_offset=12), UnaryOp(USub(), Constant(1, lineno=86, col_offset=14, end_lineno=86, end_col_offset=15), lineno=86, col_offset=13, end_lineno=86, end_col_offset=15), Store(), lineno=86, col_offset=8, end_lineno=86, end_col_offset=16), Mult(), Constant(2, lineno=86, col_offset=20, end_lineno=86, end_col_offset=21), lineno=86, col_offset=8, end_lineno=86, end_col_offset=21)], [], lineno=85, col_offset=4, end_lineno=86, end_col_offset=21), Return(Name('placeholder_8', Load(), lineno=88, col_offset=11, end_lineno=88, end_col_offset=15), lineno=88, col_offset=4, end_lineno=88, end_col_offset=15)], [], lineno=78, col_offset=0, end_lineno=88, end_col_offset=15)], []) \ No newline at end of file diff --git a/test/concept-cater-waiter/.meta/config.json b/test/concept-cater-waiter/.meta/config.json new file mode 100644 index 0000000..1c518ef --- /dev/null +++ b/test/concept-cater-waiter/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "bethanyg" + ], + "contributors": [ + "zepam" + ], + "files": { + "solution": [ + "sets.py" + ], + "editor": [ + "sets_test_data.py", + "sets_categories_data.py" + ] + }, + "icon": "meetup", + "blurb": "Learn about sets by managing the menus and ingredients for your catering company's event." +} diff --git a/test/concept-cater-waiter/mapping.json b/test/concept-cater-waiter/mapping.json new file mode 100644 index 0000000..43b45ac --- /dev/null +++ b/test/concept-cater-waiter/mapping.json @@ -0,0 +1,22 @@ +{ + "placeholder_0": "clean_ingredients", + "placeholder_1": "dish_name", + "placeholder_2": "dish_ingredients", + "placeholder_3": "check_drinks", + "placeholder_4": "drink_name", + "placeholder_5": "drink_ingredients", + "placeholder_6": "categorize_dish", + "placeholder_7": "categories", + "placeholder_8": "category", + "placeholder_9": "tag_special_ingredients", + "placeholder_10": "dish", + "placeholder_11": "compile_ingredients", + "placeholder_12": "dishes", + "placeholder_13": "combined_ingredients", + "placeholder_14": "ingredients", + "placeholder_15": "separate_appetizers", + "placeholder_16": "appetizers", + "placeholder_17": "singleton_ingredients", + "placeholder_18": "intersection", + "placeholder_19": "all_ingredients" +} \ No newline at end of file diff --git a/test/concept-cater-waiter/representation.json b/test/concept-cater-waiter/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-cater-waiter/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-cater-waiter/representation.out b/test/concept-cater-waiter/representation.out new file mode 100644 index 0000000..2b1e9c8 --- /dev/null +++ b/test/concept-cater-waiter/representation.out @@ -0,0 +1,2070 @@ +## BEGIN NORMALIZED CODE ## +from sets_categories_data import ( + VEGAN, + VEGETARIAN, + KETO, + PALEO, + OMNIVORE, + ALCOHOLS, + SPECIAL_INGREDIENTS, +) + + +def placeholder_0(placeholder_1, placeholder_2): + return (placeholder_1, set(placeholder_2)) + + +def placeholder_3(placeholder_4, placeholder_5): + if not ALCOHOLS.isdisjoint(placeholder_5): + return placeholder_4 + " Cocktail" + return placeholder_4 + " Mocktail" + + +def placeholder_6(placeholder_1, placeholder_2): + placeholder_7 = ( + (VEGAN, "VEGAN"), + (VEGETARIAN, "VEGETARIAN"), + (KETO, "KETO"), + (PALEO, "PALEO"), + (OMNIVORE, "OMNIVORE"), + ) + for placeholder_8 in placeholder_7: + if set(placeholder_2) <= placeholder_8[0]: + return placeholder_1 + ": " + placeholder_8[1] + return None + + +def placeholder_9(placeholder_10): + return (placeholder_10[0], SPECIAL_INGREDIENTS & set(placeholder_10[1])) + + +def placeholder_11(placeholder_12): + placeholder_13 = set() + for placeholder_14 in placeholder_12: + placeholder_13 = placeholder_13.union(placeholder_14) + return placeholder_13 + + +def placeholder_15(placeholder_12, placeholder_16): + return list(set(placeholder_12) - set(placeholder_16)) + + +def placeholder_17(placeholder_12, placeholder_18): + placeholder_19 = set() + for placeholder_14 in placeholder_12: + placeholder_19 = placeholder_19 ^ placeholder_14 + return placeholder_19 - placeholder_18 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions for compiling dishes and ingredients for a catering company.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=76), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=76), + ImportFrom( + 'sets_categories_data', + [ + alias( + 'VEGAN', + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=39), + alias( + 'VEGETARIAN', + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=44), + alias( + 'KETO', + lineno=6, + col_offset=34, + end_lineno=6, + end_col_offset=38), + alias( + 'PALEO', + lineno=7, + col_offset=34, + end_lineno=7, + end_col_offset=39), + alias( + 'OMNIVORE', + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=42), + alias( + 'ALCOHOLS', + lineno=9, + col_offset=34, + end_lineno=9, + end_col_offset=42), + alias( + 'SPECIAL_INGREDIENTS', + lineno=10, + col_offset=34, + end_lineno=10, + end_col_offset=53)], + 0, + lineno=4, + col_offset=0, + end_lineno=10, + end_col_offset=54), + FunctionDef( + 'clean_ingredients', + arguments( + [], + [ + arg( + 'dish_name', + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=31), + arg( + 'dish_ingredients', + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=49)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Remove duplicates from `dish_ingredients`.\n\n :param dish_name: str - containing the dish name.\n :param dish_ingredients: list - dish ingredients.\n :return: tuple - containing (dish_name, ingredient set).\n\n This function should return a `tuple` with the name of the dish as the first item,\n followed by the de-duped `set` of ingredients as the second item.\n ', + lineno=14, + col_offset=4, + end_lineno=22, + end_col_offset=7), + lineno=14, + col_offset=4, + end_lineno=22, + end_col_offset=7), + Return( + Tuple( + [ + Name( + 'dish_name', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=20), + Call( + Name( + 'set', + Load(), + lineno=24, + col_offset=22, + end_lineno=24, + end_col_offset=25), + [ + Name( + 'dish_ingredients', + Load(), + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=42)], + [], + lineno=24, + col_offset=22, + end_lineno=24, + end_col_offset=43)], + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=43), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=43)], + [], + lineno=13, + col_offset=0, + end_lineno=24, + end_col_offset=43), + FunctionDef( + 'check_drinks', + arguments( + [], + [ + arg( + 'drink_name', + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=27), + arg( + 'drink_ingredients', + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Append "Cocktail" (alcohol) or "Mocktail" (no alcohol) to `drink_name`, based on `drink_ingredients`.\n\n :param drink_name: str - name of the drink.\n :param drink_ingredients: list - ingredients in the drink.\n :return: str - drink_name appended with "Mocktail" or "Cocktail".\n\n The function should return the name of the drink followed by "Mocktail" (non-alcoholic) and drink\n name followed by "Cocktail" (includes alcohol).\n ', + lineno=28, + col_offset=4, + end_lineno=36, + end_col_offset=7), + lineno=28, + col_offset=4, + end_lineno=36, + end_col_offset=7), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'ALCOHOLS', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=19), + 'isdisjoint', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=30), + [ + Name( + 'drink_ingredients', + Load(), + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=48)], + [], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=49), + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=49), + [ + Return( + BinOp( + Name( + 'drink_name', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=25), + Add(), + Constant( + ' Cocktail', + lineno=39, + col_offset=28, + end_lineno=39, + end_col_offset=39), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=39), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=39)], + [], + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=39), + Return( + BinOp( + Name( + 'drink_name', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=21), + Add(), + Constant( + ' Mocktail', + lineno=41, + col_offset=24, + end_lineno=41, + end_col_offset=35), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=35), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=35)], + [], + lineno=27, + col_offset=0, + end_lineno=41, + end_col_offset=35), + FunctionDef( + 'categorize_dish', + arguments( + [], + [ + arg( + 'dish_name', + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=29), + arg( + 'dish_ingredients', + lineno=44, + col_offset=31, + end_lineno=44, + end_col_offset=47)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Categorize `dish_name` based on `dish_ingredients`.\n\n :param dish_name: str - dish to be categorized.\n :param dish_ingredients: list - ingredients for the dish.\n :return: str - the dish name appended with ": ".\n\n This function should return a string with the `dish name: ` (which meal category the dish belongs to).\n `` can be any one of (VEGAN, VEGETARIAN, PALEO, KETO, or OMNIVORE).\n All dishes will "fit" into one of the categories imported from `sets_categories_data.py`\n\n ', + lineno=45, + col_offset=4, + end_lineno=55, + end_col_offset=7), + lineno=45, + col_offset=4, + end_lineno=55, + end_col_offset=7), + Assign( + [ + Name( + 'categories', + Store(), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=14)], + Tuple( + [ + Tuple( + [ + Name( + 'VEGAN', + Load(), + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=24), + Constant( + 'VEGAN', + lineno=57, + col_offset=26, + end_lineno=57, + end_col_offset=33)], + Load(), + lineno=57, + col_offset=18, + end_lineno=57, + end_col_offset=34), + Tuple( + [ + Name( + 'VEGETARIAN', + Load(), + lineno=58, + col_offset=19, + end_lineno=58, + end_col_offset=29), + Constant( + 'VEGETARIAN', + lineno=58, + col_offset=31, + end_lineno=58, + end_col_offset=43)], + Load(), + lineno=58, + col_offset=18, + end_lineno=58, + end_col_offset=44), + Tuple( + [ + Name( + 'KETO', + Load(), + lineno=59, + col_offset=19, + end_lineno=59, + end_col_offset=23), + Constant( + 'KETO', + lineno=59, + col_offset=25, + end_lineno=59, + end_col_offset=31)], + Load(), + lineno=59, + col_offset=18, + end_lineno=59, + end_col_offset=32), + Tuple( + [ + Name( + 'PALEO', + Load(), + lineno=60, + col_offset=19, + end_lineno=60, + end_col_offset=24), + Constant( + 'PALEO', + lineno=60, + col_offset=26, + end_lineno=60, + end_col_offset=33)], + Load(), + lineno=60, + col_offset=18, + end_lineno=60, + end_col_offset=34), + Tuple( + [ + Name( + 'OMNIVORE', + Load(), + lineno=61, + col_offset=19, + end_lineno=61, + end_col_offset=27), + Constant( + 'OMNIVORE', + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=39)], + Load(), + lineno=61, + col_offset=18, + end_lineno=61, + end_col_offset=40)], + Load(), + lineno=57, + col_offset=17, + end_lineno=61, + end_col_offset=41), + lineno=57, + col_offset=4, + end_lineno=61, + end_col_offset=41), + For( + Name( + 'category', + Store(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=16), + Name( + 'categories', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=30), + [ + If( + Compare( + Call( + Name( + 'set', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=14), + [ + Name( + 'dish_ingredients', + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=31)], + [], + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=32), + [ + LtE()], + [ + Subscript( + Name( + 'category', + Load(), + lineno=64, + col_offset=36, + end_lineno=64, + end_col_offset=44), + Constant( + 0, + lineno=64, + col_offset=45, + end_lineno=64, + end_col_offset=46), + Load(), + lineno=64, + col_offset=36, + end_lineno=64, + end_col_offset=47)], + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=47), + [ + Return( + BinOp( + BinOp( + Name( + 'dish_name', + Load(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=28), + Add(), + Constant( + ': ', + lineno=65, + col_offset=31, + end_lineno=65, + end_col_offset=35), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=35), + Add(), + Subscript( + Name( + 'category', + Load(), + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=46), + Constant( + 1, + lineno=65, + col_offset=47, + end_lineno=65, + end_col_offset=48), + Load(), + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=49), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=49), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=49)], + [], + lineno=64, + col_offset=8, + end_lineno=65, + end_col_offset=49)], + [], + lineno=63, + col_offset=4, + end_lineno=65, + end_col_offset=49), + Return( + Constant( + None, + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=15), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=15)], + [], + lineno=44, + col_offset=0, + end_lineno=66, + end_col_offset=15), + FunctionDef( + 'tag_special_ingredients', + arguments( + [], + [ + arg( + 'dish', + lineno=69, + col_offset=28, + end_lineno=69, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Compare `dish` ingredients to `SPECIAL_INGREDIENTS`.\n\n :param dish: tuple - of (dish name, list of dish ingredients).\n :return: tuple - containing (dish name, dish special ingredients).\n\n Return the dish name followed by the `set` of ingredients that require a special note on the dish description.\n For the purposes of this exercise, all allergens or special ingredients that need to be tracked are in the\n SPECIAL_INGREDIENTS constant imported from `sets_categories_data.py`.\n ', + lineno=70, + col_offset=4, + end_lineno=78, + end_col_offset=7), + lineno=70, + col_offset=4, + end_lineno=78, + end_col_offset=7), + Return( + Tuple( + [ + Subscript( + Name( + 'dish', + Load(), + lineno=80, + col_offset=11, + end_lineno=80, + end_col_offset=15), + Constant( + 0, + lineno=80, + col_offset=16, + end_lineno=80, + end_col_offset=17), + Load(), + lineno=80, + col_offset=11, + end_lineno=80, + end_col_offset=18), + BinOp( + Name( + 'SPECIAL_INGREDIENTS', + Load(), + lineno=80, + col_offset=21, + end_lineno=80, + end_col_offset=40), + BitAnd(), + Call( + Name( + 'set', + Load(), + lineno=80, + col_offset=43, + end_lineno=80, + end_col_offset=46), + [ + Subscript( + Name( + 'dish', + Load(), + lineno=80, + col_offset=47, + end_lineno=80, + end_col_offset=51), + Constant( + 1, + lineno=80, + col_offset=52, + end_lineno=80, + end_col_offset=53), + Load(), + lineno=80, + col_offset=47, + end_lineno=80, + end_col_offset=54)], + [], + lineno=80, + col_offset=43, + end_lineno=80, + end_col_offset=55), + lineno=80, + col_offset=21, + end_lineno=80, + end_col_offset=55)], + Load(), + lineno=80, + col_offset=11, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=4, + end_lineno=80, + end_col_offset=56)], + [], + lineno=69, + col_offset=0, + end_lineno=80, + end_col_offset=56), + FunctionDef( + 'compile_ingredients', + arguments( + [], + [ + arg( + 'dishes', + lineno=83, + col_offset=24, + end_lineno=83, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Create a master list of ingredients.\n\n :param dishes: list - of dish ingredient sets.\n :return: set - of ingredients compiled from `dishes`.\n\n This function should return a `set` of all ingredients from all listed dishes.\n ', + lineno=84, + col_offset=4, + end_lineno=90, + end_col_offset=7), + lineno=84, + col_offset=4, + end_lineno=90, + end_col_offset=7), + Assign( + [ + Name( + 'combined_ingredients', + Store(), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=24)], + Call( + Name( + 'set', + Load(), + lineno=92, + col_offset=27, + end_lineno=92, + end_col_offset=30), + [], + [], + lineno=92, + col_offset=27, + end_lineno=92, + end_col_offset=32), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=32), + For( + Name( + 'ingredients', + Store(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=19), + Name( + 'dishes', + Load(), + lineno=94, + col_offset=23, + end_lineno=94, + end_col_offset=29), + [ + Assign( + [ + Name( + 'combined_ingredients', + Store(), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=28)], + Call( + Attribute( + Name( + 'combined_ingredients', + Load(), + lineno=95, + col_offset=31, + end_lineno=95, + end_col_offset=51), + 'union', + Load(), + lineno=95, + col_offset=31, + end_lineno=95, + end_col_offset=57), + [ + Name( + 'ingredients', + Load(), + lineno=95, + col_offset=58, + end_lineno=95, + end_col_offset=69)], + [], + lineno=95, + col_offset=31, + end_lineno=95, + end_col_offset=70), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=70)], + [], + lineno=94, + col_offset=4, + end_lineno=95, + end_col_offset=70), + Return( + Name( + 'combined_ingredients', + Load(), + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=31), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=31)], + [], + lineno=83, + col_offset=0, + end_lineno=97, + end_col_offset=31), + FunctionDef( + 'separate_appetizers', + arguments( + [], + [ + arg( + 'dishes', + lineno=100, + col_offset=24, + end_lineno=100, + end_col_offset=30), + arg( + 'appetizers', + lineno=100, + col_offset=32, + end_lineno=100, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Determine which `dishes` are designated `appetizers` and remove them.\n\n :param dishes: list - of dish names.\n :param appetizers: list - of appetizer names.\n :return: list - of dish names that do not appear on appetizer list.\n\n The function should return the list of dish names with appetizer names removed.\n Either list could contain duplicates and may require de-duping.\n ', + lineno=101, + col_offset=4, + end_lineno=109, + end_col_offset=7), + lineno=101, + col_offset=4, + end_lineno=109, + end_col_offset=7), + Return( + Call( + Name( + 'list', + Load(), + lineno=111, + col_offset=11, + end_lineno=111, + end_col_offset=15), + [ + BinOp( + Call( + Name( + 'set', + Load(), + lineno=111, + col_offset=16, + end_lineno=111, + end_col_offset=19), + [ + Name( + 'dishes', + Load(), + lineno=111, + col_offset=20, + end_lineno=111, + end_col_offset=26)], + [], + lineno=111, + col_offset=16, + end_lineno=111, + end_col_offset=27), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=111, + col_offset=30, + end_lineno=111, + end_col_offset=33), + [ + Name( + 'appetizers', + Load(), + lineno=111, + col_offset=34, + end_lineno=111, + end_col_offset=44)], + [], + lineno=111, + col_offset=30, + end_lineno=111, + end_col_offset=45), + lineno=111, + col_offset=16, + end_lineno=111, + end_col_offset=45)], + [], + lineno=111, + col_offset=11, + end_lineno=111, + end_col_offset=46), + lineno=111, + col_offset=4, + end_lineno=111, + end_col_offset=46)], + [], + lineno=100, + col_offset=0, + end_lineno=111, + end_col_offset=46), + FunctionDef( + 'singleton_ingredients', + arguments( + [], + [ + arg( + 'dishes', + lineno=114, + col_offset=26, + end_lineno=114, + end_col_offset=32), + arg( + 'intersection', + lineno=114, + col_offset=34, + end_lineno=114, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Determine which `dishes` have a singleton ingredient (an ingredient that only appears once across dishes).\n\n :param dishes: list - of ingredient sets.\n :param intersection: constant - can be one of `_INTERSECTION` constants imported from `sets_categories_data.py`.\n :return: set - containing singleton ingredients.\n\n Each dish is represented by a `set` of its ingredients.\n\n Each `_INTERSECTION` is an `intersection` of all dishes in the category. `` can be any one of:\n (VEGAN, VEGETARIAN, PALEO, KETO, or OMNIVORE).\n\n The function should return a `set` of ingredients that only appear in a single dish.\n ', + lineno=115, + col_offset=4, + end_lineno=127, + end_col_offset=7), + lineno=115, + col_offset=4, + end_lineno=127, + end_col_offset=7), + Assign( + [ + Name( + 'all_ingredients', + Store(), + lineno=129, + col_offset=4, + end_lineno=129, + end_col_offset=19)], + Call( + Name( + 'set', + Load(), + lineno=129, + col_offset=22, + end_lineno=129, + end_col_offset=25), + [], + [], + lineno=129, + col_offset=22, + end_lineno=129, + end_col_offset=27), + lineno=129, + col_offset=4, + end_lineno=129, + end_col_offset=27), + For( + Name( + 'ingredients', + Store(), + lineno=131, + col_offset=8, + end_lineno=131, + end_col_offset=19), + Name( + 'dishes', + Load(), + lineno=131, + col_offset=23, + end_lineno=131, + end_col_offset=29), + [ + Assign( + [ + Name( + 'all_ingredients', + Store(), + lineno=132, + col_offset=8, + end_lineno=132, + end_col_offset=23)], + BinOp( + Name( + 'all_ingredients', + Load(), + lineno=132, + col_offset=26, + end_lineno=132, + end_col_offset=41), + BitXor(), + Name( + 'ingredients', + Load(), + lineno=132, + col_offset=44, + end_lineno=132, + end_col_offset=55), + lineno=132, + col_offset=26, + end_lineno=132, + end_col_offset=55), + lineno=132, + col_offset=8, + end_lineno=132, + end_col_offset=55)], + [], + lineno=131, + col_offset=4, + end_lineno=132, + end_col_offset=55), + Return( + BinOp( + Name( + 'all_ingredients', + Load(), + lineno=134, + col_offset=11, + end_lineno=134, + end_col_offset=26), + Sub(), + Name( + 'intersection', + Load(), + lineno=134, + col_offset=29, + end_lineno=134, + end_col_offset=41), + lineno=134, + col_offset=11, + end_lineno=134, + end_col_offset=41), + lineno=134, + col_offset=4, + end_lineno=134, + end_col_offset=41)], + [], + lineno=114, + col_offset=0, + end_lineno=134, + end_col_offset=41)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'sets_categories_data', + [ + alias( + 'VEGAN', + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=39), + alias( + 'VEGETARIAN', + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=44), + alias( + 'KETO', + lineno=6, + col_offset=34, + end_lineno=6, + end_col_offset=38), + alias( + 'PALEO', + lineno=7, + col_offset=34, + end_lineno=7, + end_col_offset=39), + alias( + 'OMNIVORE', + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=42), + alias( + 'ALCOHOLS', + lineno=9, + col_offset=34, + end_lineno=9, + end_col_offset=42), + alias( + 'SPECIAL_INGREDIENTS', + lineno=10, + col_offset=34, + end_lineno=10, + end_col_offset=53)], + 0, + lineno=4, + col_offset=0, + end_lineno=10, + end_col_offset=54), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=31), + arg( + 'placeholder_2', + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=49)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Tuple( + [ + Name( + 'placeholder_1', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=20), + Call( + Name( + 'set', + Load(), + lineno=24, + col_offset=22, + end_lineno=24, + end_col_offset=25), + [ + Name( + 'placeholder_2', + Load(), + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=42)], + [], + lineno=24, + col_offset=22, + end_lineno=24, + end_col_offset=43)], + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=43), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=43)], + [], + lineno=13, + col_offset=0, + end_lineno=24, + end_col_offset=43), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=27), + arg( + 'placeholder_5', + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'ALCOHOLS', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=19), + 'isdisjoint', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=30), + [ + Name( + 'placeholder_5', + Load(), + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=48)], + [], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=49), + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=49), + [ + Return( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=25), + Add(), + Constant( + ' Cocktail', + lineno=39, + col_offset=28, + end_lineno=39, + end_col_offset=39), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=39), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=39)], + [], + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=39), + Return( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=21), + Add(), + Constant( + ' Mocktail', + lineno=41, + col_offset=24, + end_lineno=41, + end_col_offset=35), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=35), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=35)], + [], + lineno=27, + col_offset=0, + end_lineno=41, + end_col_offset=35), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=29), + arg( + 'placeholder_2', + lineno=44, + col_offset=31, + end_lineno=44, + end_col_offset=47)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=14)], + Tuple( + [ + Tuple( + [ + Name( + 'VEGAN', + Load(), + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=24), + Constant( + 'VEGAN', + lineno=57, + col_offset=26, + end_lineno=57, + end_col_offset=33)], + Load(), + lineno=57, + col_offset=18, + end_lineno=57, + end_col_offset=34), + Tuple( + [ + Name( + 'VEGETARIAN', + Load(), + lineno=58, + col_offset=19, + end_lineno=58, + end_col_offset=29), + Constant( + 'VEGETARIAN', + lineno=58, + col_offset=31, + end_lineno=58, + end_col_offset=43)], + Load(), + lineno=58, + col_offset=18, + end_lineno=58, + end_col_offset=44), + Tuple( + [ + Name( + 'KETO', + Load(), + lineno=59, + col_offset=19, + end_lineno=59, + end_col_offset=23), + Constant( + 'KETO', + lineno=59, + col_offset=25, + end_lineno=59, + end_col_offset=31)], + Load(), + lineno=59, + col_offset=18, + end_lineno=59, + end_col_offset=32), + Tuple( + [ + Name( + 'PALEO', + Load(), + lineno=60, + col_offset=19, + end_lineno=60, + end_col_offset=24), + Constant( + 'PALEO', + lineno=60, + col_offset=26, + end_lineno=60, + end_col_offset=33)], + Load(), + lineno=60, + col_offset=18, + end_lineno=60, + end_col_offset=34), + Tuple( + [ + Name( + 'OMNIVORE', + Load(), + lineno=61, + col_offset=19, + end_lineno=61, + end_col_offset=27), + Constant( + 'OMNIVORE', + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=39)], + Load(), + lineno=61, + col_offset=18, + end_lineno=61, + end_col_offset=40)], + Load(), + lineno=57, + col_offset=17, + end_lineno=61, + end_col_offset=41), + lineno=57, + col_offset=4, + end_lineno=61, + end_col_offset=41), + For( + Name( + 'placeholder_8', + Store(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=16), + Name( + 'placeholder_7', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=30), + [ + If( + Compare( + Call( + Name( + 'set', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=14), + [ + Name( + 'placeholder_2', + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=31)], + [], + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=32), + [ + LtE()], + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=64, + col_offset=36, + end_lineno=64, + end_col_offset=44), + Constant( + 0, + lineno=64, + col_offset=45, + end_lineno=64, + end_col_offset=46), + Load(), + lineno=64, + col_offset=36, + end_lineno=64, + end_col_offset=47)], + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=47), + [ + Return( + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=28), + Add(), + Constant( + ': ', + lineno=65, + col_offset=31, + end_lineno=65, + end_col_offset=35), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=35), + Add(), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=46), + Constant( + 1, + lineno=65, + col_offset=47, + end_lineno=65, + end_col_offset=48), + Load(), + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=49), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=49), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=49)], + [], + lineno=64, + col_offset=8, + end_lineno=65, + end_col_offset=49)], + [], + lineno=63, + col_offset=4, + end_lineno=65, + end_col_offset=49), + Return( + Constant( + None, + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=15), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=15)], + [], + lineno=44, + col_offset=0, + end_lineno=66, + end_col_offset=15), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=69, + col_offset=28, + end_lineno=69, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Tuple( + [ + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=80, + col_offset=11, + end_lineno=80, + end_col_offset=15), + Constant( + 0, + lineno=80, + col_offset=16, + end_lineno=80, + end_col_offset=17), + Load(), + lineno=80, + col_offset=11, + end_lineno=80, + end_col_offset=18), + BinOp( + Name( + 'SPECIAL_INGREDIENTS', + Load(), + lineno=80, + col_offset=21, + end_lineno=80, + end_col_offset=40), + BitAnd(), + Call( + Name( + 'set', + Load(), + lineno=80, + col_offset=43, + end_lineno=80, + end_col_offset=46), + [ + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=80, + col_offset=47, + end_lineno=80, + end_col_offset=51), + Constant( + 1, + lineno=80, + col_offset=52, + end_lineno=80, + end_col_offset=53), + Load(), + lineno=80, + col_offset=47, + end_lineno=80, + end_col_offset=54)], + [], + lineno=80, + col_offset=43, + end_lineno=80, + end_col_offset=55), + lineno=80, + col_offset=21, + end_lineno=80, + end_col_offset=55)], + Load(), + lineno=80, + col_offset=11, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=4, + end_lineno=80, + end_col_offset=56)], + [], + lineno=69, + col_offset=0, + end_lineno=80, + end_col_offset=56), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_12', + lineno=83, + col_offset=24, + end_lineno=83, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=24)], + Call( + Name( + 'set', + Load(), + lineno=92, + col_offset=27, + end_lineno=92, + end_col_offset=30), + [], + [], + lineno=92, + col_offset=27, + end_lineno=92, + end_col_offset=32), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=32), + For( + Name( + 'placeholder_14', + Store(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=19), + Name( + 'placeholder_12', + Load(), + lineno=94, + col_offset=23, + end_lineno=94, + end_col_offset=29), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=28)], + Call( + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=95, + col_offset=31, + end_lineno=95, + end_col_offset=51), + 'union', + Load(), + lineno=95, + col_offset=31, + end_lineno=95, + end_col_offset=57), + [ + Name( + 'placeholder_14', + Load(), + lineno=95, + col_offset=58, + end_lineno=95, + end_col_offset=69)], + [], + lineno=95, + col_offset=31, + end_lineno=95, + end_col_offset=70), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=70)], + [], + lineno=94, + col_offset=4, + end_lineno=95, + end_col_offset=70), + Return( + Name( + 'placeholder_13', + Load(), + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=31), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=31)], + [], + lineno=83, + col_offset=0, + end_lineno=97, + end_col_offset=31), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'placeholder_12', + lineno=100, + col_offset=24, + end_lineno=100, + end_col_offset=30), + arg( + 'placeholder_16', + lineno=100, + col_offset=32, + end_lineno=100, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'list', + Load(), + lineno=111, + col_offset=11, + end_lineno=111, + end_col_offset=15), + [ + BinOp( + Call( + Name( + 'set', + Load(), + lineno=111, + col_offset=16, + end_lineno=111, + end_col_offset=19), + [ + Name( + 'placeholder_12', + Load(), + lineno=111, + col_offset=20, + end_lineno=111, + end_col_offset=26)], + [], + lineno=111, + col_offset=16, + end_lineno=111, + end_col_offset=27), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=111, + col_offset=30, + end_lineno=111, + end_col_offset=33), + [ + Name( + 'placeholder_16', + Load(), + lineno=111, + col_offset=34, + end_lineno=111, + end_col_offset=44)], + [], + lineno=111, + col_offset=30, + end_lineno=111, + end_col_offset=45), + lineno=111, + col_offset=16, + end_lineno=111, + end_col_offset=45)], + [], + lineno=111, + col_offset=11, + end_lineno=111, + end_col_offset=46), + lineno=111, + col_offset=4, + end_lineno=111, + end_col_offset=46)], + [], + lineno=100, + col_offset=0, + end_lineno=111, + end_col_offset=46), + FunctionDef( + 'placeholder_17', + arguments( + [], + [ + arg( + 'placeholder_12', + lineno=114, + col_offset=26, + end_lineno=114, + end_col_offset=32), + arg( + 'placeholder_18', + lineno=114, + col_offset=34, + end_lineno=114, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=129, + col_offset=4, + end_lineno=129, + end_col_offset=19)], + Call( + Name( + 'set', + Load(), + lineno=129, + col_offset=22, + end_lineno=129, + end_col_offset=25), + [], + [], + lineno=129, + col_offset=22, + end_lineno=129, + end_col_offset=27), + lineno=129, + col_offset=4, + end_lineno=129, + end_col_offset=27), + For( + Name( + 'placeholder_14', + Store(), + lineno=131, + col_offset=8, + end_lineno=131, + end_col_offset=19), + Name( + 'placeholder_12', + Load(), + lineno=131, + col_offset=23, + end_lineno=131, + end_col_offset=29), + [ + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=132, + col_offset=8, + end_lineno=132, + end_col_offset=23)], + BinOp( + Name( + 'placeholder_19', + Load(), + lineno=132, + col_offset=26, + end_lineno=132, + end_col_offset=41), + BitXor(), + Name( + 'placeholder_14', + Load(), + lineno=132, + col_offset=44, + end_lineno=132, + end_col_offset=55), + lineno=132, + col_offset=26, + end_lineno=132, + end_col_offset=55), + lineno=132, + col_offset=8, + end_lineno=132, + end_col_offset=55)], + [], + lineno=131, + col_offset=4, + end_lineno=132, + end_col_offset=55), + Return( + BinOp( + Name( + 'placeholder_19', + Load(), + lineno=134, + col_offset=11, + end_lineno=134, + end_col_offset=26), + Sub(), + Name( + 'placeholder_18', + Load(), + lineno=134, + col_offset=29, + end_lineno=134, + end_col_offset=41), + lineno=134, + col_offset=11, + end_lineno=134, + end_col_offset=41), + lineno=134, + col_offset=4, + end_lineno=134, + end_col_offset=41)], + [], + lineno=114, + col_offset=0, + end_lineno=134, + end_col_offset=41)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-cater-waiter/representation.txt b/test/concept-cater-waiter/representation.txt new file mode 100644 index 0000000..0fd3ddd --- /dev/null +++ b/test/concept-cater-waiter/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('sets_categories_data', [alias('VEGAN', lineno=4, col_offset=34, end_lineno=4, end_col_offset=39), alias('VEGETARIAN', lineno=5, col_offset=34, end_lineno=5, end_col_offset=44), alias('KETO', lineno=6, col_offset=34, end_lineno=6, end_col_offset=38), alias('PALEO', lineno=7, col_offset=34, end_lineno=7, end_col_offset=39), alias('OMNIVORE', lineno=8, col_offset=34, end_lineno=8, end_col_offset=42), alias('ALCOHOLS', lineno=9, col_offset=34, end_lineno=9, end_col_offset=42), alias('SPECIAL_INGREDIENTS', lineno=10, col_offset=34, end_lineno=10, end_col_offset=53)], 0, lineno=4, col_offset=0, end_lineno=10, end_col_offset=54), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=13, col_offset=22, end_lineno=13, end_col_offset=31), arg('placeholder_2', lineno=13, col_offset=33, end_lineno=13, end_col_offset=49)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Tuple([Name('placeholder_1', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=20), Call(Name('set', Load(), lineno=24, col_offset=22, end_lineno=24, end_col_offset=25), [Name('placeholder_2', Load(), lineno=24, col_offset=26, end_lineno=24, end_col_offset=42)], [], lineno=24, col_offset=22, end_lineno=24, end_col_offset=43)], Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=43), lineno=24, col_offset=4, end_lineno=24, end_col_offset=43)], [], lineno=13, col_offset=0, end_lineno=24, end_col_offset=43), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=27, col_offset=17, end_lineno=27, end_col_offset=27), arg('placeholder_5', lineno=27, col_offset=29, end_lineno=27, end_col_offset=46)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Attribute(Name('ALCOHOLS', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=19), 'isdisjoint', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=30), [Name('placeholder_5', Load(), lineno=38, col_offset=31, end_lineno=38, end_col_offset=48)], [], lineno=38, col_offset=11, end_lineno=38, end_col_offset=49), lineno=38, col_offset=7, end_lineno=38, end_col_offset=49), [Return(BinOp(Name('placeholder_4', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=25), Add(), Constant(' Cocktail', lineno=39, col_offset=28, end_lineno=39, end_col_offset=39), lineno=39, col_offset=15, end_lineno=39, end_col_offset=39), lineno=39, col_offset=8, end_lineno=39, end_col_offset=39)], [], lineno=38, col_offset=4, end_lineno=39, end_col_offset=39), Return(BinOp(Name('placeholder_4', Load(), lineno=41, col_offset=11, end_lineno=41, end_col_offset=21), Add(), Constant(' Mocktail', lineno=41, col_offset=24, end_lineno=41, end_col_offset=35), lineno=41, col_offset=11, end_lineno=41, end_col_offset=35), lineno=41, col_offset=4, end_lineno=41, end_col_offset=35)], [], lineno=27, col_offset=0, end_lineno=41, end_col_offset=35), FunctionDef('placeholder_6', arguments([], [arg('placeholder_1', lineno=44, col_offset=20, end_lineno=44, end_col_offset=29), arg('placeholder_2', lineno=44, col_offset=31, end_lineno=44, end_col_offset=47)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=57, col_offset=4, end_lineno=57, end_col_offset=14)], Tuple([Tuple([Name('VEGAN', Load(), lineno=57, col_offset=19, end_lineno=57, end_col_offset=24), Constant('VEGAN', lineno=57, col_offset=26, end_lineno=57, end_col_offset=33)], Load(), lineno=57, col_offset=18, end_lineno=57, end_col_offset=34), Tuple([Name('VEGETARIAN', Load(), lineno=58, col_offset=19, end_lineno=58, end_col_offset=29), Constant('VEGETARIAN', lineno=58, col_offset=31, end_lineno=58, end_col_offset=43)], Load(), lineno=58, col_offset=18, end_lineno=58, end_col_offset=44), Tuple([Name('KETO', Load(), lineno=59, col_offset=19, end_lineno=59, end_col_offset=23), Constant('KETO', lineno=59, col_offset=25, end_lineno=59, end_col_offset=31)], Load(), lineno=59, col_offset=18, end_lineno=59, end_col_offset=32), Tuple([Name('PALEO', Load(), lineno=60, col_offset=19, end_lineno=60, end_col_offset=24), Constant('PALEO', lineno=60, col_offset=26, end_lineno=60, end_col_offset=33)], Load(), lineno=60, col_offset=18, end_lineno=60, end_col_offset=34), Tuple([Name('OMNIVORE', Load(), lineno=61, col_offset=19, end_lineno=61, end_col_offset=27), Constant('OMNIVORE', lineno=61, col_offset=29, end_lineno=61, end_col_offset=39)], Load(), lineno=61, col_offset=18, end_lineno=61, end_col_offset=40)], Load(), lineno=57, col_offset=17, end_lineno=61, end_col_offset=41), lineno=57, col_offset=4, end_lineno=61, end_col_offset=41), For(Name('placeholder_8', Store(), lineno=63, col_offset=8, end_lineno=63, end_col_offset=16), Name('placeholder_7', Load(), lineno=63, col_offset=20, end_lineno=63, end_col_offset=30), [If(Compare(Call(Name('set', Load(), lineno=64, col_offset=11, end_lineno=64, end_col_offset=14), [Name('placeholder_2', Load(), lineno=64, col_offset=15, end_lineno=64, end_col_offset=31)], [], lineno=64, col_offset=11, end_lineno=64, end_col_offset=32), [LtE()], [Subscript(Name('placeholder_8', Load(), lineno=64, col_offset=36, end_lineno=64, end_col_offset=44), Constant(0, lineno=64, col_offset=45, end_lineno=64, end_col_offset=46), Load(), lineno=64, col_offset=36, end_lineno=64, end_col_offset=47)], lineno=64, col_offset=11, end_lineno=64, end_col_offset=47), [Return(BinOp(BinOp(Name('placeholder_1', Load(), lineno=65, col_offset=19, end_lineno=65, end_col_offset=28), Add(), Constant(': ', lineno=65, col_offset=31, end_lineno=65, end_col_offset=35), lineno=65, col_offset=19, end_lineno=65, end_col_offset=35), Add(), Subscript(Name('placeholder_8', Load(), lineno=65, col_offset=38, end_lineno=65, end_col_offset=46), Constant(1, lineno=65, col_offset=47, end_lineno=65, end_col_offset=48), Load(), lineno=65, col_offset=38, end_lineno=65, end_col_offset=49), lineno=65, col_offset=19, end_lineno=65, end_col_offset=49), lineno=65, col_offset=12, end_lineno=65, end_col_offset=49)], [], lineno=64, col_offset=8, end_lineno=65, end_col_offset=49)], [], lineno=63, col_offset=4, end_lineno=65, end_col_offset=49), Return(Constant(None, lineno=66, col_offset=11, end_lineno=66, end_col_offset=15), lineno=66, col_offset=4, end_lineno=66, end_col_offset=15)], [], lineno=44, col_offset=0, end_lineno=66, end_col_offset=15), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=69, col_offset=28, end_lineno=69, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Tuple([Subscript(Name('placeholder_10', Load(), lineno=80, col_offset=11, end_lineno=80, end_col_offset=15), Constant(0, lineno=80, col_offset=16, end_lineno=80, end_col_offset=17), Load(), lineno=80, col_offset=11, end_lineno=80, end_col_offset=18), BinOp(Name('SPECIAL_INGREDIENTS', Load(), lineno=80, col_offset=21, end_lineno=80, end_col_offset=40), BitAnd(), Call(Name('set', Load(), lineno=80, col_offset=43, end_lineno=80, end_col_offset=46), [Subscript(Name('placeholder_10', Load(), lineno=80, col_offset=47, end_lineno=80, end_col_offset=51), Constant(1, lineno=80, col_offset=52, end_lineno=80, end_col_offset=53), Load(), lineno=80, col_offset=47, end_lineno=80, end_col_offset=54)], [], lineno=80, col_offset=43, end_lineno=80, end_col_offset=55), lineno=80, col_offset=21, end_lineno=80, end_col_offset=55)], Load(), lineno=80, col_offset=11, end_lineno=80, end_col_offset=56), lineno=80, col_offset=4, end_lineno=80, end_col_offset=56)], [], lineno=69, col_offset=0, end_lineno=80, end_col_offset=56), FunctionDef('placeholder_11', arguments([], [arg('placeholder_12', lineno=83, col_offset=24, end_lineno=83, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_13', Store(), lineno=92, col_offset=4, end_lineno=92, end_col_offset=24)], Call(Name('set', Load(), lineno=92, col_offset=27, end_lineno=92, end_col_offset=30), [], [], lineno=92, col_offset=27, end_lineno=92, end_col_offset=32), lineno=92, col_offset=4, end_lineno=92, end_col_offset=32), For(Name('placeholder_14', Store(), lineno=94, col_offset=8, end_lineno=94, end_col_offset=19), Name('placeholder_12', Load(), lineno=94, col_offset=23, end_lineno=94, end_col_offset=29), [Assign([Name('placeholder_13', Store(), lineno=95, col_offset=8, end_lineno=95, end_col_offset=28)], Call(Attribute(Name('placeholder_13', Load(), lineno=95, col_offset=31, end_lineno=95, end_col_offset=51), 'union', Load(), lineno=95, col_offset=31, end_lineno=95, end_col_offset=57), [Name('placeholder_14', Load(), lineno=95, col_offset=58, end_lineno=95, end_col_offset=69)], [], lineno=95, col_offset=31, end_lineno=95, end_col_offset=70), lineno=95, col_offset=8, end_lineno=95, end_col_offset=70)], [], lineno=94, col_offset=4, end_lineno=95, end_col_offset=70), Return(Name('placeholder_13', Load(), lineno=97, col_offset=11, end_lineno=97, end_col_offset=31), lineno=97, col_offset=4, end_lineno=97, end_col_offset=31)], [], lineno=83, col_offset=0, end_lineno=97, end_col_offset=31), FunctionDef('placeholder_15', arguments([], [arg('placeholder_12', lineno=100, col_offset=24, end_lineno=100, end_col_offset=30), arg('placeholder_16', lineno=100, col_offset=32, end_lineno=100, end_col_offset=42)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('list', Load(), lineno=111, col_offset=11, end_lineno=111, end_col_offset=15), [BinOp(Call(Name('set', Load(), lineno=111, col_offset=16, end_lineno=111, end_col_offset=19), [Name('placeholder_12', Load(), lineno=111, col_offset=20, end_lineno=111, end_col_offset=26)], [], lineno=111, col_offset=16, end_lineno=111, end_col_offset=27), Sub(), Call(Name('set', Load(), lineno=111, col_offset=30, end_lineno=111, end_col_offset=33), [Name('placeholder_16', Load(), lineno=111, col_offset=34, end_lineno=111, end_col_offset=44)], [], lineno=111, col_offset=30, end_lineno=111, end_col_offset=45), lineno=111, col_offset=16, end_lineno=111, end_col_offset=45)], [], lineno=111, col_offset=11, end_lineno=111, end_col_offset=46), lineno=111, col_offset=4, end_lineno=111, end_col_offset=46)], [], lineno=100, col_offset=0, end_lineno=111, end_col_offset=46), FunctionDef('placeholder_17', arguments([], [arg('placeholder_12', lineno=114, col_offset=26, end_lineno=114, end_col_offset=32), arg('placeholder_18', lineno=114, col_offset=34, end_lineno=114, end_col_offset=46)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_19', Store(), lineno=129, col_offset=4, end_lineno=129, end_col_offset=19)], Call(Name('set', Load(), lineno=129, col_offset=22, end_lineno=129, end_col_offset=25), [], [], lineno=129, col_offset=22, end_lineno=129, end_col_offset=27), lineno=129, col_offset=4, end_lineno=129, end_col_offset=27), For(Name('placeholder_14', Store(), lineno=131, col_offset=8, end_lineno=131, end_col_offset=19), Name('placeholder_12', Load(), lineno=131, col_offset=23, end_lineno=131, end_col_offset=29), [Assign([Name('placeholder_19', Store(), lineno=132, col_offset=8, end_lineno=132, end_col_offset=23)], BinOp(Name('placeholder_19', Load(), lineno=132, col_offset=26, end_lineno=132, end_col_offset=41), BitXor(), Name('placeholder_14', Load(), lineno=132, col_offset=44, end_lineno=132, end_col_offset=55), lineno=132, col_offset=26, end_lineno=132, end_col_offset=55), lineno=132, col_offset=8, end_lineno=132, end_col_offset=55)], [], lineno=131, col_offset=4, end_lineno=132, end_col_offset=55), Return(BinOp(Name('placeholder_19', Load(), lineno=134, col_offset=11, end_lineno=134, end_col_offset=26), Sub(), Name('placeholder_18', Load(), lineno=134, col_offset=29, end_lineno=134, end_col_offset=41), lineno=134, col_offset=11, end_lineno=134, end_col_offset=41), lineno=134, col_offset=4, end_lineno=134, end_col_offset=41)], [], lineno=114, col_offset=0, end_lineno=134, end_col_offset=41)], []) \ No newline at end of file diff --git a/test/concept-cater-waiter/sets.py b/test/concept-cater-waiter/sets.py new file mode 100644 index 0000000..8f48c52 --- /dev/null +++ b/test/concept-cater-waiter/sets.py @@ -0,0 +1,134 @@ +"""Functions for compiling dishes and ingredients for a catering company.""" + + +from sets_categories_data import (VEGAN, + VEGETARIAN, + KETO, + PALEO, + OMNIVORE, + ALCOHOLS, + SPECIAL_INGREDIENTS) + + +def clean_ingredients(dish_name, dish_ingredients): + """Remove duplicates from `dish_ingredients`. + + :param dish_name: str - containing the dish name. + :param dish_ingredients: list - dish ingredients. + :return: tuple - containing (dish_name, ingredient set). + + This function should return a `tuple` with the name of the dish as the first item, + followed by the de-duped `set` of ingredients as the second item. + """ + + return dish_name, set(dish_ingredients) + + +def check_drinks(drink_name, drink_ingredients): + """Append "Cocktail" (alcohol) or "Mocktail" (no alcohol) to `drink_name`, based on `drink_ingredients`. + + :param drink_name: str - name of the drink. + :param drink_ingredients: list - ingredients in the drink. + :return: str - drink_name appended with "Mocktail" or "Cocktail". + + The function should return the name of the drink followed by "Mocktail" (non-alcoholic) and drink + name followed by "Cocktail" (includes alcohol). + """ + + if not ALCOHOLS.isdisjoint(drink_ingredients): + return drink_name + ' Cocktail' + + return drink_name + ' Mocktail' + + +def categorize_dish(dish_name, dish_ingredients): + """Categorize `dish_name` based on `dish_ingredients`. + + :param dish_name: str - dish to be categorized. + :param dish_ingredients: list - ingredients for the dish. + :return: str - the dish name appended with ": ". + + This function should return a string with the `dish name: ` (which meal category the dish belongs to). + `` can be any one of (VEGAN, VEGETARIAN, PALEO, KETO, or OMNIVORE). + All dishes will "fit" into one of the categories imported from `sets_categories_data.py` + + """ + + categories = ((VEGAN, 'VEGAN'), + (VEGETARIAN, 'VEGETARIAN'), + (KETO, 'KETO'), + (PALEO, 'PALEO'), + (OMNIVORE, 'OMNIVORE')) + + for category in categories: + if set(dish_ingredients) <= category[0]: + return dish_name + ': ' + category[1] + return None + + +def tag_special_ingredients(dish): + """Compare `dish` ingredients to `SPECIAL_INGREDIENTS`. + + :param dish: tuple - of (dish name, list of dish ingredients). + :return: tuple - containing (dish name, dish special ingredients). + + Return the dish name followed by the `set` of ingredients that require a special note on the dish description. + For the purposes of this exercise, all allergens or special ingredients that need to be tracked are in the + SPECIAL_INGREDIENTS constant imported from `sets_categories_data.py`. + """ + + return dish[0], (SPECIAL_INGREDIENTS & set(dish[1])) + + +def compile_ingredients(dishes): + """Create a master list of ingredients. + + :param dishes: list - of dish ingredient sets. + :return: set - of ingredients compiled from `dishes`. + + This function should return a `set` of all ingredients from all listed dishes. + """ + + combined_ingredients = set() + + for ingredients in dishes: + combined_ingredients = combined_ingredients.union(ingredients) + + return combined_ingredients + + +def separate_appetizers(dishes, appetizers): + """Determine which `dishes` are designated `appetizers` and remove them. + + :param dishes: list - of dish names. + :param appetizers: list - of appetizer names. + :return: list - of dish names that do not appear on appetizer list. + + The function should return the list of dish names with appetizer names removed. + Either list could contain duplicates and may require de-duping. + """ + + return list(set(dishes) - set(appetizers)) + + +def singleton_ingredients(dishes, intersection): + """Determine which `dishes` have a singleton ingredient (an ingredient that only appears once across dishes). + + :param dishes: list - of ingredient sets. + :param intersection: constant - can be one of `_INTERSECTION` constants imported from `sets_categories_data.py`. + :return: set - containing singleton ingredients. + + Each dish is represented by a `set` of its ingredients. + + Each `_INTERSECTION` is an `intersection` of all dishes in the category. `` can be any one of: + (VEGAN, VEGETARIAN, PALEO, KETO, or OMNIVORE). + + The function should return a `set` of ingredients that only appear in a single dish. + """ + + all_ingredients = set() + + for ingredients in dishes: + all_ingredients = all_ingredients ^ ingredients + + return all_ingredients - intersection diff --git a/test/concept-cater-waiter/sets_categories_data.py b/test/concept-cater-waiter/sets_categories_data.py new file mode 100644 index 0000000..dc3b1a6 --- /dev/null +++ b/test/concept-cater-waiter/sets_categories_data.py @@ -0,0 +1,212 @@ +# pylint: disable-all +# flake8: noqa, +VEGAN = { + 'chives', 'nutritional yeast', 'tomato', 'orange zest', 'pareve puff pastry', 'cashews', 'tofu', + 'rice vinegar', 'black pepper', 'cardamom powder', 'mustard seeds', 'parev shortcrust pastry', + 'scallions', 'water', 'chinese eggplants', 'lemon juice', 'smoked paprika', 'cloves', 'basmati rice', + 'cayenne pepper', 'green onions', 'sunflower oil', 'mixed herbs', 'garlic paste', 'parsley', + 'fresh red chili', 'flour', 'garlic', 'oregano', 'green beans', 'harissa', 'brandy', 'fresh basil', + 'coriander', 'vinegar', 'thyme', 'coriander seeds', 'clove powder', 'pomegranate seeds', + 'sugar', 'yukon gold potato', 'sesame oil', 'cinnamon powder', 'butternut squash', 'allspice powder', + 'red pepper flakes', 'soy sauce', 'sesame seeds', 'cornstarch', 'mango powder', 'vegetable stock', + 'raisins', 'barley malt', 'olive oil', 'ground almonds', 'white rice', 'garlic powder', 'walnuts', + 'saffron powder', 'red chili powder', 'turmeric powder', 'spring onions', 'yeast', 'khmeli suneli', + 'peanuts', 'bulgur', 'cilantro', 'onion', 'calabash nutmeg', 'black-eyed peas', 'grains of selim', + 'zucchini', 'currants', 'spaghetti', 'figs', 'red bell pepper', 'lemon zest', 'ground turmeric', + 'chili flakes', 'chickpea flour', 'hing', 'slivered almonds', 'vegetable oil', 'serrano chili', + 'salt', 'yellow onions', 'salt', 'coriander powder', 'orange zest', 'garam masala', 'yellow onion', + 'smoked tofu', 'bell pepper', 'apples', 'brown sugar', 'coconut oil', 'orange juice', + 'sorghum stems', 'dried blueberries', 'tomato paste', 'curry leaves', 'vegetarian worcestershire sauce', + 'hot water', 'fresh ginger', 'firm tofu', 'eggplants', 'bell pepper', 'siracha', 'carrot', 'nigella seeds', + 'vegan butter', "za'atar", 'baking soda', 'brown sugar', 'dried cranberries', 'kosher salt', 'mangoes', + 'vegan unsweetened yoghurt', 'black peppercorn', 'vinegar', 'dill', 'barberries', 'honey', 'tomatoes', + 'yellow split peas', 'persian cucumber', 'turmeric', 'lemon', 'cumin', 'oil', 'mushrooms', 'spring onion', + 'pomegranate concentrate', 'cumin seeds', 'balsamic vinegar', 'ripe plantains', 'celeriac', 'breadcrumbs', + 'ginger', 'dried cherries', 'red onion', 'rosemary', 'chopped parsley', 'corn', 'cumin powder', 'pecans', + 'silken tofu', 'pomegranate molasses', 'carrot', 'corn flour', 'mashed potatoes' + } + + +VEGETARIAN = { + 'almonds', 'chives', 'limes', 'puff pastry', 'onion', 'cashews', 'red cabbage', 'red wine vinegar', + 'brussel sprouts', 'fresh corn', 'black pepper', 'lemon juice', 'roasted corn', 'eggs', + 'fresh cilantro leaves', 'shiitake mushrooms', 'sunflower oil', 'sage', 'dijon mustard', + 'blanched almonds', 'dates', 'flour', 'fresh pea tendrils', 'garlic', 'egg', 'green beans', + 'yukon gold potato', 'vermicelli noodles', 'onions', 'avocado', 'dried lasagna noodles', + 'thyme', 'cauliflower', 'basil', 'watercress', 'black beans', 'butternut squash', 'red thai chili', + 'masa', 'red chili', 'red onions', 'jalapeño chili', 'grated nutmeg', 'feta cheese', 'hazelnuts', + 'soy sauce', 'shallots', 'chipotle chili', 'vegetable bullion', 'fresh cherry tomatoes', 'olive oil', + 'milk', 'fresh cherry bocconcini', 'crema', 'marmite', 'walnuts', 'nutmeg', 'ricotta cheese', + 'chestnuts', 'mint leaves', 'lime juice', 'white wine', 'apples', 'pearl barley', 'cotija cheese', + 'zucchini', 'currants', 'leek', 'pomegranate', 'lemon zest', 'avocados', 'parmesan cheese', 'mint', + 'leeks', 'fresh artichoke hearts', 'vegetable oil', 'brazil nuts', 'red chili', 'sharp white cheddar', + 'salt', 'pepitas', 'green lentils', 'beets', 'celery', 'smoked tofu', 'fresh tomatoes', + 'puff pastry sheets', 'palm sugar', 'vegetarian fish sauce', 'oil marinated artichokes', 'hot water', + 'chickpeas', 'firm tofu', 'wombok', 'carrot', 'asparagus', 'bean sprouts', 'kosher salt', + 'pasilla chili', 'tomatillos', 'parmesan rind', 'pasta sheets', 'cream', 'butter', 'croutons', + 'lacinato kale', 'fresh or frozen fava beans', 'fresh pumpkin', 'honey', 'tomatoes', 'olives', + 'capers', 'pine nuts', 'lemon', 'cumin', 'ancho chili', 'fresh peas', 'spring roll wrappers', + 'balsamic vinegar', 'portobello mushrooms', 'breadcrumbs', 'blue cheese', 'red onion', + 'rosemary', 'pecans', 'carrot', 'corn flour', 'toasted peanuts' + } + +PALEO = { + 'cinnamon', 'chiles de árbol', 'chives', 'limes', 'allspice', 'zucchini', 'seranno chili', 'lemon zest', + 'apple cider vinegar', 'avocados', 'cashews', 'mango', 'cilantro leaves', 'pepitas', 'white chicken', + 'chipotles', 'black pepper', 'scallions', 'pumpkin puree', 'water', 'serrano chili', 'lemon juice', + 'smoked paprika', 'homemade apricot honey preserves', 'eggs', 'salt', 'flank steak', 'fresh cilantro leaves', + 'cider vinegar', 'cloves', 'purple sweet potato', 'coconut yogurt', 'green onions', 'tilapia', + 'yellow bell pepper', 'coconut oil', 'whole chicken', 'coconut oil', 'safflower oil', 'roma tomatoes', + 'fresh red chili', 'fresh thai chili', 'shrimp', 'garlic', 'onions', 'lime', 'avocado', 'fresh parsley', + 'cauliflower', 'shredded red cabbage', 'basil', 'baking soda', 'serrano chili', + 'cherry tomatoes', 'kale', 'bacon', 'kosher salt', 'mangoes', 'lacinato kale', 'shallots', 'pineapple', + 'chipotle chili', 'white vinegar', 'honey', 'tomatoes', 'homemade tamarind concentrate', + 'mexican oregano', 'olive oil', 'pine nuts', 'garlic powder', 'coconut flour', 'green bell pepper', + 'dried apricots', 'cumin', 'nutmeg', 'kosher salt', 'onions', 'mustard seed', 'lemons', 'lime zest', + 'ground cumin', 'almond butter', 'chili powder', 'lime juice', 'paleo mayonnaise', 'pork chops', + 'cilantro', 'onion', 'red bell pepper', 'paleo parmesan cheese', 'radishes', 'avocado oil', + 'dijon mustard', 'avocado mayonnaise', 'castelfranco radicchio', 'worcestershire sauce', 'treviso' + } + +KETO = { + 'cinnamon', 'avocado oil', 'chives', 'sriacha', 'almond flour', 'crunchy peanut butter', + 'cucumbers', 'cream cheese', 'red cabbage', 'red wine vinegar', 'brussel sprouts', 'black pepper', + 'cardamom powder', 'mustard seeds', 'scallions', 'kecap manis', 'lemon juice', 'eggs', 'tahini', + 'cloves', 'green onions', 'dijon mustard', 'garlic paste', 'watermelon radishes', 'parmesan', + 'parsley', 'star anise', 'fresh cucumber', 'fresh red chili', 'shrimp', 'garlic', 'oregano', + 'fennel bulb', 'harissa', 'dutch carrot', 'fresh basil', 'avocado', 'clove powder', 'coriander seeds', + 'thyme', 'fresh parsley', 'chicken', 'cauliflower', 'basil', 'watercress', 'cinnamon powder', + 'cherry tomatoes', 'soy sauce', 'sesame seeds', 'micro cilantro', 'mozzarella cheese', 'shallots', + 'mango powder', 'chipotle chili', 'olive oil', 'spinach', 'pink peppercorns', 'coconut flour', + 'salmon steaks', 'dark soy sauce', 'red chili powder', 'turmeric powder', 'spring onions', + 'lime juice', 'ginger garlic paste', 'pork chops', 'peanuts', 'dried fenugreek leaves', 'cilantro', + 'onion', 'salmon fillets', 'toasted buckwheat', 'whole small crimini mushrooms', 'caster sugar', + 'granny smith apples', 'green cabbage', 'apple cider vinegar', 'chili flakes', 'parmesan cheese', + 'hing', 'castelfranco radicchio', 'cilantro leaves', 'fresh greek yogurt', 'roasted chicken', 'ghee', + 'flaxmeal', 'flank steak', 'salt', 'coriander powder', 'boned chicken', 'red chili flakes', + 'garam masala', 'almond meal', 'peanut oil', 'tomato paste', 'oyster sauce', + 'curry leaves', 'fresh ginger', 'cardamom', 'radishes', 'little gem lettuce heads', + 'grilled king fish', 'carrot', 'cinnamon sticks', 'heavy cream', 'asparagus', 'nigella seeds', + 'light soy sauce', 'pork belly', 'green chili', 'mangoes', 'red and green thai chili', 'butter', + 'vinegar', 'dill', 'fish sauce', 'white vinegar', 'tomatoes', 'mirin', + 'avocado mayonnaise', 'turmeric', 'lemon', 'cumin', 'fennel seeds', 'lemon juice', 'salt', + 'roasted peanuts', 'ginger', 'red onion', 'rosemary', 'cumin powder', 'cashew nuts', 'pecans', + 'green chili','whole small crimini mushrooms', 'monk fruit', 'sour cream' + } + +OMNIVORE = { + 'clams', 'prawns', 'white wine vinegar', 'date syrup', 'limes', 'tomato', 'coriander', + 'black chickpeas', 'yellow bell pepper', 'black cardamom', 'baby squid', 'pepitas', + 'red cabbage', 'baby scallops', 'green cardamom', 'black pepper', 'chaat masala', 'water', + 'lemon juice', 'tahini', 'cloves', 'white pepper', 'fennel bulbs', 'tomato puree', + 'maggi cubes', 'couscous', 'yellow mustard', 'parsley', 'sriracha', 'roma tomatoes', + 'shrimp', 'garlic', 'oregano', 'chicken wings', 'yukon gold potato', 'harissa', 'onions', + 'avocado', 'thyme', 'chicken', 'sugar', 'flat-leaf parsley', 'celery seeds', 'cherry tomatoes', + 'mayonnaise', 'scallion chutney', 'red pepper flakes', 'hazelnuts', 'soy sauce', 'sesame seeds', + 'red snapper', 'white onion', 'vegetable bullion', 'marjoram', 'pani puri', 'olive oil', 'rice', + 'serrano chili', 'tamarind concentrate', 'lime juice', 'white wine', 'beef brisket', 'cilantro', + 'onion', 'crushed red pepper flakes', 'chiles de árbol', 'fresh mint', 'zucchini', 'red bell pepper', + 'yoghurt', 'apple cider vinegar', 'parmesan cheese', 'slivered almonds', 'whole-milk yogurt', + 'anchovy fillets', 'fresh ricotta', 'mint', 'chile manzano', 'roasted chicken', 'sea salt', + 'fresh thyme', 'vegetable oil', 'salt', 'mexican crema', 'celery', 'yellow onion', + 'worcestershire sauce', 'fresh tortillas', 'tomato paste', 'oranges', 'chickpeas', + 'scotch bonnet pepper', 'shelled large shrimp', 'mussels', 'summer squash', 'salsa', + 'garlic cloves', 'fish stock', 'bell pepper', 'green bell pepper', 'carrot', 'cinnamon sticks', + 'thin sev', 'brown sugar', 'baby carrot', 'bacon', 'kosher salt', 'bay leaves', 'anaheim chili', + 'oaxaca cheese', 'butter', 'vinegar', 'crab legs', 'white vinegar', 'honey', 'tomatoes', + 'green cabbage', 'toasted bread', 'turmeric', 'lemon', 'cumin', 'black peppercorns', 'poblano chili', + 'arborio risotto rice', 'fresh corn tortillas', 'balsamic vinegar', 'rhubarb', 'ginger', + 'guajillo chile', 'filo pastry', 'leg of lamb', 'red onion', 'chipotle adobo sauce', 'rosemary', + 'chili powder', 'beer', 'carrot' + } + +SPECIAL_INGREDIENTS = {'cream','bacon', 'garlic', 'baby scallops', 'mussels', 'baby squid', 'cashews', 'salmon fillets', + 'filo pastry', 'almonds', 'milk', 'blue cheese', 'clams', 'shrimp', 'tomato puree', 'chocolate', + 'honey', 'anchovy fillets', 'bulgur', 'prawns', 'parmesan cheese', 'fish', 'shelled large shrimp', + 'gluten', 'crab legs', 'feta cheese', 'whole-milk yogurt', 'crema', 'firm tofu', 'fish stock', + 'fresh ricotta', 'tomato paste', 'fresh cherry tomatoes', 'pork chops', 'eggs', 'greek yogurt', + 'hazelnuts', 'pecans', 'brie cheese', 'oaxaca cheese', 'yellow onion', 'whey', 'silken tofu', + 'toasted bread', 'parmesan', 'beef', 'tofu', 'flour', 'tomatoes', 'red onion', 'slivered almonds', + 'strawberries', 'onions', 'pine nuts', 'cherry tomatoes', 'soy sauce', 'oyster sauce', + 'mozzarella cheese', 'roma tomatoes', 'heavy cream', 'paneer', 'pork tenderloin', 'garlic cloves', + 'swiss cheese', 'grilled king fish', 'ground almonds', 'tilapia', 'sprint onion', 'couscous', + 'walnuts', 'semolina', 'yogurt', 'cotija cheese', 'oysters', 'spaghetti', 'cheddar cheese', + 'butter', 'lobster', 'smoked tofu', 'peanuts', 'ground pork', 'fresh cherry bocconcini', + 'pork belly', 'toasted peanuts', 'roasted peanuts' + } + +ALCOHOLS = {"whiskey", "whisky", "white rum", "dark rum", "bourbon", "rye", "scotch", "vodka", + "tequila", "gin", "dry vermouth", "sweet vermouth", "prosecco","aperol", "brandy", "mezcal", + "triple sec", "coffee liqueur", "almond liqueur", "champagne", "orange curacao", "rum" + } + + +VEGAN_INTERSECTIONS = {'brown sugar', 'carrot', 'sugar', 'vegetable stock', 'fresh ginger', 'nutritional yeast', + 'cayenne pepper', 'olive oil', 'lemon', 'ginger', 'red onion', 'pomegranate molasses', + 'onion', 'water', 'chickpea flour', 'orange zest', 'coconut oil', 'smoked paprika', + 'lemon zest', 'sunflower oil', 'orange juice', 'black pepper', 'cinnamon powder', + 'mushrooms', 'cloves', 'salt', 'oil', 'vegan butter', 'turmeric', 'tomato paste', + 'mustard seeds', 'bell pepper', 'rosemary', 'vinegar', 'tomatoes', 'flour', 'soy sauce', + 'lemon juice', 'garlic'} + +VEGETARIAN_INTERSECTIONS = {'carrot', 'milk', 'basil', 'green lentils', 'vegetable bullion', 'red onions', + 'balsamic vinegar', 'lemon', 'olive oil', 'butter', 'honey', 'red chili', + 'red onion', 'breadcrumbs', 'lemon zest', 'pepitas', 'black pepper', 'fresh peas', + 'salt', 'firm tofu', 'ricotta cheese', 'kosher salt', 'watercress', 'cream', + 'parmesan cheese', 'shallots', 'rosemary', 'sage', 'tomatoes', 'walnuts', + 'lemon juice', 'thyme', 'garlic', 'eggs', 'red wine vinegar'} + +PALEO_INTERSECTIONS = {'basil', 'olive oil', 'honey', 'pine nuts', 'baking soda', 'shrimp', 'cherry tomatoes', + 'coconut oil', 'cinnamon', 'lemon zest', 'cumin', 'black pepper', 'lime', 'salt', + 'zucchini', 'kosher salt', 'chipotle chili', 'eggs', 'coconut flour', 'avocado', + 'cauliflower', 'serrano chili', 'safflower oil', 'tomatoes', 'lemon juice', 'onions', + 'garlic'} + +KETO_INTERSECTIONS = {'fresh cucumber', 'red cabbage', 'olive oil', 'ginger', 'butter', 'dill', 'red onion', + 'monk fruit', 'cherry tomatoes', 'spring onions', 'lime juice', 'fish sauce', + 'sesame seeds', 'black pepper', 'salt', 'chives', 'asparagus', 'eggs', + 'avocado mayonnaise', 'rosemary', 'cauliflower', 'flank steak', 'lemon juice', + 'garlic'} + +OMNIVORE_INTERSECTIONS = {'mint', 'carrot', 'fresh mint', 'olive oil', 'lemon', 'ginger', 'butter', 'honey', + 'leg of lamb', 'red onion', 'bay leaves', 'tamarind concentrate', + 'worcestershire sauce', 'onion', 'lime juice', 'water', 'anchovy fillets', 'celery', + 'black pepper', 'cilantro', 'chili powder', 'salt', 'mayonnaise', 'garlic cloves', + 'kosher salt', 'white onion', 'turmeric', 'rosemary', 'vinegar', 'tomatoes', + 'sea salt', 'soy sauce', 'lemon juice', 'onions', 'thyme', 'garlic', 'avocado', + 'fresh corn tortillas', 'tomato paste'} + + +EXAMPLE_INTERSECTION = {'fresh red chili', 'sugar', 'nutritional yeast', 'fresh ginger', 'red chili powder', 'garlic', + 'olive oil', 'mashed potatoes', 'garam masala', 'clove powder', 'cumin powder', 'onion', + 'chickpea flour', 'water', 'turmeric powder', 'hing', 'black pepper', 'cinnamon powder', + 'cilantro', 'salt', 'oil', 'cardamom powder', 'turmeric', 'garlic paste', 'mustard seeds', + 'vinegar', 'mangoes', 'nigella seeds', 'serrano chili', 'flour', 'soy sauce', 'coriander seeds', + 'coriander powder', 'lemon juice', 'mango powder', 'curry leaves'} + +example_dishes = [ + {'salt', 'breadcrumbs', 'water', 'flour', 'celeriac', 'chickpea flour', 'soy sauce', 'parsley', + 'sunflower oil', 'lemon', 'black pepper'}, + + {'cornstarch', 'salt', 'vegetable oil', 'sugar', 'vegetable stock', 'water', 'tofu', 'soy sauce', + 'lemon zest', 'lemon juice', 'black pepper', 'ginger', 'garlic'}, + + {'salt', 'mixed herbs', 'silken tofu', 'smoked tofu', 'nutritional yeast', 'turmeric', 'soy sauce', + 'garlic', 'lemon juice', 'olive oil', 'black pepper', 'spaghetti'}, + + {'salt', 'mushrooms', 'sugar', 'barley malt', 'nutritional yeast', 'fresh basil', 'olive oil', + 'honey', 'yeast', 'red onion', 'bell pepper', 'cashews', 'oregano', 'rosemary', 'garlic powder', + 'tomatoes', 'water', 'flour', 'red pepper flakes', 'garlic'}, + + {'mango powder', 'oil', 'salt', 'cardamom powder', 'fresh red chili', 'sugar', 'fresh ginger', + 'turmeric', 'red chili powder', 'curry leaves', 'garlic paste', 'mustard seeds', 'vinegar', + 'mashed potatoes', 'garam masala', 'mangoes', 'nigella seeds', 'clove powder', 'serrano chili', + 'cumin powder', 'onion', 'water', 'chickpea flour', 'coriander seeds', 'turmeric powder', 'hing', + 'coriander powder', 'cinnamon powder', 'cilantro', 'garlic'}, + + {'mango powder', 'oil', 'salt', 'cardamom powder', 'fresh red chili', 'sugar', 'fresh ginger', + 'turmeric', 'red chili powder', 'curry leaves', 'garlic paste', 'mustard seeds', 'vinegar', + 'mashed potatoes', 'garam masala', 'mangoes', 'nigella seeds', 'clove powder', 'serrano chili', + 'cumin powder', 'onion', 'water', 'chickpea flour', 'coriander seeds', 'turmeric powder', 'hing', + 'coriander powder', 'cinnamon powder', 'cilantro', 'garlic'} + ] diff --git a/test/concept-chaitanas-colossal-coaster/.meta/config.json b/test/concept-chaitanas-colossal-coaster/.meta/config.json new file mode 100644 index 0000000..c2db501 --- /dev/null +++ b/test/concept-chaitanas-colossal-coaster/.meta/config.json @@ -0,0 +1,18 @@ +{ + "authors": [ + "mohanrajanr", + "BethanyG" + ], + "contributors": [ + "BethanyG", + "valentin-p", + "pranasziaukas" + ], + "files": { + "solution": [ + "list_methods.py" + ] + }, + "icon": "spiral-matrix", + "blurb": "Learn useful list methods helping Chaitana manage the lines for her colossal roller coaster." +} diff --git a/test/concept-chaitanas-colossal-coaster/list_methods.py b/test/concept-chaitanas-colossal-coaster/list_methods.py new file mode 100644 index 0000000..24a8394 --- /dev/null +++ b/test/concept-chaitanas-colossal-coaster/list_methods.py @@ -0,0 +1,85 @@ +"""Functions to manage and organize queues at Chaitana's roller coaster.""" + + +def add_me_to_the_queue(express_queue, normal_queue, ticket_type, person_name): + """Add a person to the 'express' or 'normal' queue depending on the ticket number. + + :param express_queue: list - names in the Fast-track queue. + :param normal_queue: list - names in the normal queue. + :param ticket_type: int - type of ticket. 1 = express, 0 = normal. + :param person_name: str - name of person to add to a queue. + :return: list - the (updated) queue the name was added to. + """ + + result = express_queue if ticket_type == 1 else normal_queue + result.append(person_name) + return result + + +def find_my_friend(queue, friend_name): + """Search the queue for a name and return their queue position (index). + + :param queue: list - names in the queue. + :param friend_name: str - name of friend to find. + :return: int - index at which the friends name was found. + """ + + return queue.index(friend_name) + + +def add_me_with_my_friends(queue, index, person_name): + """Insert the late arrival's name at a specific index of the queue. + + :param queue: list - names in the queue. + :param index: int - the index at which to add the new name. + :param person_name: str - the name to add. + :return: list - queue updated with new name. + """ + + queue.insert(index, person_name) + return queue + + +def remove_the_mean_person(queue, person_name): + """Remove the mean person from the queue by the provided name. + + :param queue: list - names in the queue. + :param person_name: str - name of mean person. + :return: list - queue update with the mean persons name removed. + """ + + queue.remove(person_name) + return queue + + +def how_many_namefellows(queue, person_name): + """Count how many times the provided name appears in the queue. + + :param queue: list - names in the queue. + :param person_name: str - name you wish to count or track. + :return: int - the number of times the name appears in the queue. + """ + + return queue.count(person_name) + + +def remove_the_last_person(queue): + """Remove the person in the last index from the queue and return their name. + + :param queue: list - names in the queue. + :return: str - name that has been removed from the end of the queue. + """ + + return queue.pop() + + +def sorted_names(queue): + """Sort the names in the queue in alphabetical order and return the result. + + :param queue: list - names in the queue. + :return: list - copy of the queue in alphabetical order. + """ + + new_queue = queue[:] + new_queue.sort() + return new_queue diff --git a/test/concept-chaitanas-colossal-coaster/mapping.json b/test/concept-chaitanas-colossal-coaster/mapping.json new file mode 100644 index 0000000..8b6ea71 --- /dev/null +++ b/test/concept-chaitanas-colossal-coaster/mapping.json @@ -0,0 +1,18 @@ +{ + "placeholder_0": "add_me_to_the_queue", + "placeholder_1": "express_queue", + "placeholder_2": "normal_queue", + "placeholder_3": "ticket_type", + "placeholder_4": "person_name", + "placeholder_5": "result", + "placeholder_6": "find_my_friend", + "placeholder_7": "queue", + "placeholder_8": "friend_name", + "placeholder_9": "add_me_with_my_friends", + "placeholder_10": "index", + "placeholder_11": "remove_the_mean_person", + "placeholder_12": "how_many_namefellows", + "placeholder_13": "remove_the_last_person", + "placeholder_14": "sorted_names", + "placeholder_15": "new_queue" +} \ No newline at end of file diff --git a/test/concept-chaitanas-colossal-coaster/representation.json b/test/concept-chaitanas-colossal-coaster/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-chaitanas-colossal-coaster/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-chaitanas-colossal-coaster/representation.out b/test/concept-chaitanas-colossal-coaster/representation.out new file mode 100644 index 0000000..0decb7f --- /dev/null +++ b/test/concept-chaitanas-colossal-coaster/representation.out @@ -0,0 +1,1223 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2, placeholder_3, placeholder_4): + placeholder_5 = placeholder_1 if placeholder_3 == 1 else placeholder_2 + placeholder_5.append(placeholder_4) + return placeholder_5 + + +def placeholder_6(placeholder_7, placeholder_8): + return placeholder_7.index(placeholder_8) + + +def placeholder_9(placeholder_7, placeholder_10, placeholder_4): + placeholder_7.insert(placeholder_10, placeholder_4) + return placeholder_7 + + +def placeholder_11(placeholder_7, placeholder_4): + placeholder_7.remove(placeholder_4) + return placeholder_7 + + +def placeholder_12(placeholder_7, placeholder_4): + return placeholder_7.count(placeholder_4) + + +def placeholder_13(placeholder_7): + return placeholder_7.pop() + + +def placeholder_14(placeholder_7): + placeholder_15 = placeholder_7[:] + placeholder_15.sort() + return placeholder_15 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + "Functions to manage and organize queues at Chaitana's roller coaster.", + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=75), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=75), + FunctionDef( + 'add_me_to_the_queue', + arguments( + [], + [ + arg( + 'express_queue', + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=37), + arg( + 'normal_queue', + lineno=4, + col_offset=39, + end_lineno=4, + end_col_offset=51), + arg( + 'ticket_type', + lineno=4, + col_offset=53, + end_lineno=4, + end_col_offset=64), + arg( + 'person_name', + lineno=4, + col_offset=66, + end_lineno=4, + end_col_offset=77)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Add a person to the 'express' or 'normal' queue depending on the ticket number.\n\n :param express_queue: list - names in the Fast-track queue.\n :param normal_queue: list - names in the normal queue.\n :param ticket_type: int - type of ticket. 1 = express, 0 = normal.\n :param person_name: str - name of person to add to a queue.\n :return: list - the (updated) queue the name was added to.\n ", + lineno=5, + col_offset=4, + end_lineno=12, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=12, + end_col_offset=7), + Assign( + [ + Name( + 'result', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=10)], + IfExp( + Compare( + Name( + 'ticket_type', + Load(), + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=41), + [ + Eq()], + [ + Constant( + 1, + lineno=14, + col_offset=45, + end_lineno=14, + end_col_offset=46)], + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=46), + Name( + 'express_queue', + Load(), + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=26), + Name( + 'normal_queue', + Load(), + lineno=14, + col_offset=52, + end_lineno=14, + end_col_offset=64), + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=64), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=64), + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=10), + 'append', + Load(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=17), + [ + Name( + 'person_name', + Load(), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=29)], + [], + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=30), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=30), + Return( + Name( + 'result', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=17)], + [], + lineno=4, + col_offset=0, + end_lineno=16, + end_col_offset=17), + FunctionDef( + 'find_my_friend', + arguments( + [], + [ + arg( + 'queue', + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=24), + arg( + 'friend_name', + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Search the queue for a name and return their queue position (index).\n\n :param queue: list - names in the queue.\n :param friend_name: str - name of friend to find.\n :return: int - index at which the friends name was found.\n ', + lineno=20, + col_offset=4, + end_lineno=25, + end_col_offset=7), + lineno=20, + col_offset=4, + end_lineno=25, + end_col_offset=7), + Return( + Call( + Attribute( + Name( + 'queue', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=16), + 'index', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=22), + [ + Name( + 'friend_name', + Load(), + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=34)], + [], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=35), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=35)], + [], + lineno=19, + col_offset=0, + end_lineno=27, + end_col_offset=35), + FunctionDef( + 'add_me_with_my_friends', + arguments( + [], + [ + arg( + 'queue', + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=32), + arg( + 'index', + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=39), + arg( + 'person_name', + lineno=30, + col_offset=41, + end_lineno=30, + end_col_offset=52)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Insert the late arrival's name at a specific index of the queue.\n\n :param queue: list - names in the queue.\n :param index: int - the index at which to add the new name.\n :param person_name: str - the name to add.\n :return: list - queue updated with new name.\n ", + lineno=31, + col_offset=4, + end_lineno=37, + end_col_offset=7), + lineno=31, + col_offset=4, + end_lineno=37, + end_col_offset=7), + Expr( + Call( + Attribute( + Name( + 'queue', + Load(), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=9), + 'insert', + Load(), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=16), + [ + Name( + 'index', + Load(), + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=22), + Name( + 'person_name', + Load(), + lineno=39, + col_offset=24, + end_lineno=39, + end_col_offset=35)], + [], + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=36), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=36), + Return( + Name( + 'queue', + Load(), + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=16), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=16)], + [], + lineno=30, + col_offset=0, + end_lineno=40, + end_col_offset=16), + FunctionDef( + 'remove_the_mean_person', + arguments( + [], + [ + arg( + 'queue', + lineno=43, + col_offset=27, + end_lineno=43, + end_col_offset=32), + arg( + 'person_name', + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Remove the mean person from the queue by the provided name.\n\n :param queue: list - names in the queue.\n :param person_name: str - name of mean person.\n :return: list - queue update with the mean persons name removed.\n ', + lineno=44, + col_offset=4, + end_lineno=49, + end_col_offset=7), + lineno=44, + col_offset=4, + end_lineno=49, + end_col_offset=7), + Expr( + Call( + Attribute( + Name( + 'queue', + Load(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=9), + 'remove', + Load(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=16), + [ + Name( + 'person_name', + Load(), + lineno=51, + col_offset=17, + end_lineno=51, + end_col_offset=28)], + [], + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=29), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=29), + Return( + Name( + 'queue', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=16), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=16)], + [], + lineno=43, + col_offset=0, + end_lineno=52, + end_col_offset=16), + FunctionDef( + 'how_many_namefellows', + arguments( + [], + [ + arg( + 'queue', + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=30), + arg( + 'person_name', + lineno=55, + col_offset=32, + end_lineno=55, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Count how many times the provided name appears in the queue.\n\n :param queue: list - names in the queue.\n :param person_name: str - name you wish to count or track.\n :return: int - the number of times the name appears in the queue.\n ', + lineno=56, + col_offset=4, + end_lineno=61, + end_col_offset=7), + lineno=56, + col_offset=4, + end_lineno=61, + end_col_offset=7), + Return( + Call( + Attribute( + Name( + 'queue', + Load(), + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=16), + 'count', + Load(), + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=22), + [ + Name( + 'person_name', + Load(), + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=34)], + [], + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=35), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=35)], + [], + lineno=55, + col_offset=0, + end_lineno=63, + end_col_offset=35), + FunctionDef( + 'remove_the_last_person', + arguments( + [], + [ + arg( + 'queue', + lineno=66, + col_offset=27, + end_lineno=66, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Remove the person in the last index from the queue and return their name.\n\n :param queue: list - names in the queue.\n :return: str - name that has been removed from the end of the queue.\n ', + lineno=67, + col_offset=4, + end_lineno=71, + end_col_offset=7), + lineno=67, + col_offset=4, + end_lineno=71, + end_col_offset=7), + Return( + Call( + Attribute( + Name( + 'queue', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=16), + 'pop', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=20), + [], + [], + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=22), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=22)], + [], + lineno=66, + col_offset=0, + end_lineno=73, + end_col_offset=22), + FunctionDef( + 'sorted_names', + arguments( + [], + [ + arg( + 'queue', + lineno=76, + col_offset=17, + end_lineno=76, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Sort the names in the queue in alphabetical order and return the result.\n\n :param queue: list - names in the queue.\n :return: list - copy of the queue in alphabetical order.\n ', + lineno=77, + col_offset=4, + end_lineno=81, + end_col_offset=7), + lineno=77, + col_offset=4, + end_lineno=81, + end_col_offset=7), + Assign( + [ + Name( + 'new_queue', + Store(), + lineno=83, + col_offset=4, + end_lineno=83, + end_col_offset=13)], + Subscript( + Name( + 'queue', + Load(), + lineno=83, + col_offset=16, + end_lineno=83, + end_col_offset=21), + Slice( + lineno=83, + col_offset=22, + end_lineno=83, + end_col_offset=23), + Load(), + lineno=83, + col_offset=16, + end_lineno=83, + end_col_offset=24), + lineno=83, + col_offset=4, + end_lineno=83, + end_col_offset=24), + Expr( + Call( + Attribute( + Name( + 'new_queue', + Load(), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=13), + 'sort', + Load(), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=18), + [], + [], + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=20), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=20), + Return( + Name( + 'new_queue', + Load(), + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=20), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=20)], + [], + lineno=76, + col_offset=0, + end_lineno=85, + end_col_offset=20)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=37), + arg( + 'placeholder_2', + lineno=4, + col_offset=39, + end_lineno=4, + end_col_offset=51), + arg( + 'placeholder_3', + lineno=4, + col_offset=53, + end_lineno=4, + end_col_offset=64), + arg( + 'placeholder_4', + lineno=4, + col_offset=66, + end_lineno=4, + end_col_offset=77)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=10)], + IfExp( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=41), + [ + Eq()], + [ + Constant( + 1, + lineno=14, + col_offset=45, + end_lineno=14, + end_col_offset=46)], + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=46), + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=26), + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=52, + end_lineno=14, + end_col_offset=64), + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=64), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=64), + Expr( + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=10), + 'append', + Load(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=17), + [ + Name( + 'placeholder_4', + Load(), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=29)], + [], + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=30), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=30), + Return( + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=17)], + [], + lineno=4, + col_offset=0, + end_lineno=16, + end_col_offset=17), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=24), + arg( + 'placeholder_8', + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=16), + 'index', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=22), + [ + Name( + 'placeholder_8', + Load(), + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=34)], + [], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=35), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=35)], + [], + lineno=19, + col_offset=0, + end_lineno=27, + end_col_offset=35), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=32), + arg( + 'placeholder_10', + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=39), + arg( + 'placeholder_4', + lineno=30, + col_offset=41, + end_lineno=30, + end_col_offset=52)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=9), + 'insert', + Load(), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=16), + [ + Name( + 'placeholder_10', + Load(), + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=22), + Name( + 'placeholder_4', + Load(), + lineno=39, + col_offset=24, + end_lineno=39, + end_col_offset=35)], + [], + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=36), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=36), + Return( + Name( + 'placeholder_7', + Load(), + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=16), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=16)], + [], + lineno=30, + col_offset=0, + end_lineno=40, + end_col_offset=16), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=43, + col_offset=27, + end_lineno=43, + end_col_offset=32), + arg( + 'placeholder_4', + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=9), + 'remove', + Load(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=16), + [ + Name( + 'placeholder_4', + Load(), + lineno=51, + col_offset=17, + end_lineno=51, + end_col_offset=28)], + [], + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=29), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=29), + Return( + Name( + 'placeholder_7', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=16), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=16)], + [], + lineno=43, + col_offset=0, + end_lineno=52, + end_col_offset=16), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=30), + arg( + 'placeholder_4', + lineno=55, + col_offset=32, + end_lineno=55, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=16), + 'count', + Load(), + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=22), + [ + Name( + 'placeholder_4', + Load(), + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=34)], + [], + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=35), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=35)], + [], + lineno=55, + col_offset=0, + end_lineno=63, + end_col_offset=35), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=66, + col_offset=27, + end_lineno=66, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=16), + 'pop', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=20), + [], + [], + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=22), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=22)], + [], + lineno=66, + col_offset=0, + end_lineno=73, + end_col_offset=22), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=76, + col_offset=17, + end_lineno=76, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=83, + col_offset=4, + end_lineno=83, + end_col_offset=13)], + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=83, + col_offset=16, + end_lineno=83, + end_col_offset=21), + Slice( + lineno=83, + col_offset=22, + end_lineno=83, + end_col_offset=23), + Load(), + lineno=83, + col_offset=16, + end_lineno=83, + end_col_offset=24), + lineno=83, + col_offset=4, + end_lineno=83, + end_col_offset=24), + Expr( + Call( + Attribute( + Name( + 'placeholder_15', + Load(), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=13), + 'sort', + Load(), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=18), + [], + [], + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=20), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=20), + Return( + Name( + 'placeholder_15', + Load(), + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=20), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=20)], + [], + lineno=76, + col_offset=0, + end_lineno=85, + end_col_offset=20)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-chaitanas-colossal-coaster/representation.txt b/test/concept-chaitanas-colossal-coaster/representation.txt new file mode 100644 index 0000000..56eaf00 --- /dev/null +++ b/test/concept-chaitanas-colossal-coaster/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=24, end_lineno=4, end_col_offset=37), arg('placeholder_2', lineno=4, col_offset=39, end_lineno=4, end_col_offset=51), arg('placeholder_3', lineno=4, col_offset=53, end_lineno=4, end_col_offset=64), arg('placeholder_4', lineno=4, col_offset=66, end_lineno=4, end_col_offset=77)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_5', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=10)], IfExp(Compare(Name('placeholder_3', Load(), lineno=14, col_offset=30, end_lineno=14, end_col_offset=41), [Eq()], [Constant(1, lineno=14, col_offset=45, end_lineno=14, end_col_offset=46)], lineno=14, col_offset=30, end_lineno=14, end_col_offset=46), Name('placeholder_1', Load(), lineno=14, col_offset=13, end_lineno=14, end_col_offset=26), Name('placeholder_2', Load(), lineno=14, col_offset=52, end_lineno=14, end_col_offset=64), lineno=14, col_offset=13, end_lineno=14, end_col_offset=64), lineno=14, col_offset=4, end_lineno=14, end_col_offset=64), Expr(Call(Attribute(Name('placeholder_5', Load(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=10), 'append', Load(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=17), [Name('placeholder_4', Load(), lineno=15, col_offset=18, end_lineno=15, end_col_offset=29)], [], lineno=15, col_offset=4, end_lineno=15, end_col_offset=30), lineno=15, col_offset=4, end_lineno=15, end_col_offset=30), Return(Name('placeholder_5', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=17), lineno=16, col_offset=4, end_lineno=16, end_col_offset=17)], [], lineno=4, col_offset=0, end_lineno=16, end_col_offset=17), FunctionDef('placeholder_6', arguments([], [arg('placeholder_7', lineno=19, col_offset=19, end_lineno=19, end_col_offset=24), arg('placeholder_8', lineno=19, col_offset=26, end_lineno=19, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_7', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=16), 'index', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=22), [Name('placeholder_8', Load(), lineno=27, col_offset=23, end_lineno=27, end_col_offset=34)], [], lineno=27, col_offset=11, end_lineno=27, end_col_offset=35), lineno=27, col_offset=4, end_lineno=27, end_col_offset=35)], [], lineno=19, col_offset=0, end_lineno=27, end_col_offset=35), FunctionDef('placeholder_9', arguments([], [arg('placeholder_7', lineno=30, col_offset=27, end_lineno=30, end_col_offset=32), arg('placeholder_10', lineno=30, col_offset=34, end_lineno=30, end_col_offset=39), arg('placeholder_4', lineno=30, col_offset=41, end_lineno=30, end_col_offset=52)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Name('placeholder_7', Load(), lineno=39, col_offset=4, end_lineno=39, end_col_offset=9), 'insert', Load(), lineno=39, col_offset=4, end_lineno=39, end_col_offset=16), [Name('placeholder_10', Load(), lineno=39, col_offset=17, end_lineno=39, end_col_offset=22), Name('placeholder_4', Load(), lineno=39, col_offset=24, end_lineno=39, end_col_offset=35)], [], lineno=39, col_offset=4, end_lineno=39, end_col_offset=36), lineno=39, col_offset=4, end_lineno=39, end_col_offset=36), Return(Name('placeholder_7', Load(), lineno=40, col_offset=11, end_lineno=40, end_col_offset=16), lineno=40, col_offset=4, end_lineno=40, end_col_offset=16)], [], lineno=30, col_offset=0, end_lineno=40, end_col_offset=16), FunctionDef('placeholder_11', arguments([], [arg('placeholder_7', lineno=43, col_offset=27, end_lineno=43, end_col_offset=32), arg('placeholder_4', lineno=43, col_offset=34, end_lineno=43, end_col_offset=45)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Name('placeholder_7', Load(), lineno=51, col_offset=4, end_lineno=51, end_col_offset=9), 'remove', Load(), lineno=51, col_offset=4, end_lineno=51, end_col_offset=16), [Name('placeholder_4', Load(), lineno=51, col_offset=17, end_lineno=51, end_col_offset=28)], [], lineno=51, col_offset=4, end_lineno=51, end_col_offset=29), lineno=51, col_offset=4, end_lineno=51, end_col_offset=29), Return(Name('placeholder_7', Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=16), lineno=52, col_offset=4, end_lineno=52, end_col_offset=16)], [], lineno=43, col_offset=0, end_lineno=52, end_col_offset=16), FunctionDef('placeholder_12', arguments([], [arg('placeholder_7', lineno=55, col_offset=25, end_lineno=55, end_col_offset=30), arg('placeholder_4', lineno=55, col_offset=32, end_lineno=55, end_col_offset=43)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_7', Load(), lineno=63, col_offset=11, end_lineno=63, end_col_offset=16), 'count', Load(), lineno=63, col_offset=11, end_lineno=63, end_col_offset=22), [Name('placeholder_4', Load(), lineno=63, col_offset=23, end_lineno=63, end_col_offset=34)], [], lineno=63, col_offset=11, end_lineno=63, end_col_offset=35), lineno=63, col_offset=4, end_lineno=63, end_col_offset=35)], [], lineno=55, col_offset=0, end_lineno=63, end_col_offset=35), FunctionDef('placeholder_13', arguments([], [arg('placeholder_7', lineno=66, col_offset=27, end_lineno=66, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_7', Load(), lineno=73, col_offset=11, end_lineno=73, end_col_offset=16), 'pop', Load(), lineno=73, col_offset=11, end_lineno=73, end_col_offset=20), [], [], lineno=73, col_offset=11, end_lineno=73, end_col_offset=22), lineno=73, col_offset=4, end_lineno=73, end_col_offset=22)], [], lineno=66, col_offset=0, end_lineno=73, end_col_offset=22), FunctionDef('placeholder_14', arguments([], [arg('placeholder_7', lineno=76, col_offset=17, end_lineno=76, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_15', Store(), lineno=83, col_offset=4, end_lineno=83, end_col_offset=13)], Subscript(Name('placeholder_7', Load(), lineno=83, col_offset=16, end_lineno=83, end_col_offset=21), Slice(lineno=83, col_offset=22, end_lineno=83, end_col_offset=23), Load(), lineno=83, col_offset=16, end_lineno=83, end_col_offset=24), lineno=83, col_offset=4, end_lineno=83, end_col_offset=24), Expr(Call(Attribute(Name('placeholder_15', Load(), lineno=84, col_offset=4, end_lineno=84, end_col_offset=13), 'sort', Load(), lineno=84, col_offset=4, end_lineno=84, end_col_offset=18), [], [], lineno=84, col_offset=4, end_lineno=84, end_col_offset=20), lineno=84, col_offset=4, end_lineno=84, end_col_offset=20), Return(Name('placeholder_15', Load(), lineno=85, col_offset=11, end_lineno=85, end_col_offset=20), lineno=85, col_offset=4, end_lineno=85, end_col_offset=20)], [], lineno=76, col_offset=0, end_lineno=85, end_col_offset=20)], []) \ No newline at end of file diff --git a/test/concept-currency-exchange/.meta/config.json b/test/concept-currency-exchange/.meta/config.json new file mode 100644 index 0000000..e4af464 --- /dev/null +++ b/test/concept-currency-exchange/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "Ticktakto", + "Yabby1997", + "limm-jk", + "OMEGA-Y", + "wnstj2007", + "J08K" + ], + "contributors": [ + "BethanyG", + "kytrinyx", + "pranasziaukas" + ], + "files": { + "solution": [ + "exchange.py" + ] + }, + "icon": "hyperia-forex", + "blurb": "Learn about numbers by solving Chandler's currency exchange conundrums." +} diff --git a/test/concept-currency-exchange/exchange.py b/test/concept-currency-exchange/exchange.py new file mode 100644 index 0000000..e452818 --- /dev/null +++ b/test/concept-currency-exchange/exchange.py @@ -0,0 +1,70 @@ +def exchange_money(budget, exchange_rate): + """ + + :param budget: float - amount of money you are planning to exchange. + :param exchange_rate: float - unit value of the foreign currency. + :return: float - exchanged value of the foreign currency you can receive. + """ + + return budget / exchange_rate + + +def get_change(budget, exchanging_value): + """ + + :param budget: float - amount of money you own. + :param exchanging_value: float - amount of your money you want to exchange now. + :return: float - amount left of your starting currency after exchanging. + """ + + return budget - exchanging_value + + +def get_value_of_bills(denomination, number_of_bills): + """ + + :param denomination: int - the value of a bill. + :param number_of_bills: int - total number of bills. + :return: int - calculated value of the bills. + """ + + return denomination * number_of_bills + + +def get_number_of_bills(amount, denomination): + """ + + :param amount: float - the total starting value. + :param denomination: int - the value of a single bill. + :return: int - number of bills that can be obtained from the amount. + """ + + return int(amount) // denomination + + +def get_leftover_of_bills(amount, denomination): + """ + + :param amount: float - the total starting value. + :param denomination: int - the value of a single bill. + :return: float - the amount that is "leftover", given the current denomination. + """ + + return amount % denomination + + +def exchangeable_value(budget, exchange_rate, spread, denomination): + """ + + :param budget: float - the amount of your money you are planning to exchange. + :param exchange_rate: float - the unit value of the foreign currency. + :param spread: int - percentage that is taken as an exchange fee. + :param denomination: int - the value of a single bill. + :return: int - maximum value you can get. + """ + + exchange_fee = (exchange_rate / 100) * spread + exchange_value = exchange_money(budget, exchange_rate + exchange_fee) + number_of_bills = get_number_of_bills(exchange_value, denomination) + value_of_bills = get_value_of_bills(denomination, number_of_bills) + return value_of_bills diff --git a/test/concept-currency-exchange/mapping.json b/test/concept-currency-exchange/mapping.json new file mode 100644 index 0000000..8e76a56 --- /dev/null +++ b/test/concept-currency-exchange/mapping.json @@ -0,0 +1,18 @@ +{ + "placeholder_0": "exchange_money", + "placeholder_1": "budget", + "placeholder_2": "exchange_rate", + "placeholder_3": "get_change", + "placeholder_4": "exchanging_value", + "placeholder_5": "get_value_of_bills", + "placeholder_6": "denomination", + "placeholder_7": "number_of_bills", + "placeholder_8": "get_number_of_bills", + "placeholder_9": "amount", + "placeholder_10": "get_leftover_of_bills", + "placeholder_11": "exchangeable_value", + "placeholder_12": "spread", + "placeholder_13": "exchange_fee", + "placeholder_14": "exchange_value", + "placeholder_15": "value_of_bills" +} \ No newline at end of file diff --git a/test/concept-currency-exchange/representation.json b/test/concept-currency-exchange/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-currency-exchange/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-currency-exchange/representation.out b/test/concept-currency-exchange/representation.out new file mode 100644 index 0000000..df76b75 --- /dev/null +++ b/test/concept-currency-exchange/representation.out @@ -0,0 +1,1107 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return placeholder_1 / placeholder_2 + + +def placeholder_3(placeholder_1, placeholder_4): + return placeholder_1 - placeholder_4 + + +def placeholder_5(placeholder_6, placeholder_7): + return placeholder_6 * placeholder_7 + + +def placeholder_8(placeholder_9, placeholder_6): + return int(placeholder_9) // placeholder_6 + + +def placeholder_10(placeholder_9, placeholder_6): + return placeholder_9 % placeholder_6 + + +def placeholder_11(placeholder_1, placeholder_2, placeholder_12, placeholder_6): + placeholder_13 = placeholder_2 / 100 * placeholder_12 + placeholder_14 = placeholder_0(placeholder_1, placeholder_2 + placeholder_13) + placeholder_7 = placeholder_8(placeholder_14, placeholder_6) + placeholder_15 = placeholder_5(placeholder_6, placeholder_7) + return placeholder_15 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'exchange_money', + arguments( + [], + [ + arg( + 'budget', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=25), + arg( + 'exchange_rate', + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param budget: float - amount of money you are planning to exchange.\n :param exchange_rate: float - unit value of the foreign currency.\n :return: float - exchanged value of the foreign currency you can receive.\n ', + lineno=2, + col_offset=4, + end_lineno=7, + end_col_offset=7), + lineno=2, + col_offset=4, + end_lineno=7, + end_col_offset=7), + Return( + BinOp( + Name( + 'budget', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=17), + Div(), + Name( + 'exchange_rate', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=33), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=33), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=33)], + [], + lineno=1, + col_offset=0, + end_lineno=9, + end_col_offset=33), + FunctionDef( + 'get_change', + arguments( + [], + [ + arg( + 'budget', + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=21), + arg( + 'exchanging_value', + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param budget: float - amount of money you own.\n :param exchanging_value: float - amount of your money you want to exchange now.\n :return: float - amount left of your starting currency after exchanging.\n ', + lineno=13, + col_offset=4, + end_lineno=18, + end_col_offset=7), + lineno=13, + col_offset=4, + end_lineno=18, + end_col_offset=7), + Return( + BinOp( + Name( + 'budget', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=17), + Sub(), + Name( + 'exchanging_value', + Load(), + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=36), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=36), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=36)], + [], + lineno=12, + col_offset=0, + end_lineno=20, + end_col_offset=36), + FunctionDef( + 'get_value_of_bills', + arguments( + [], + [ + arg( + 'denomination', + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=35), + arg( + 'number_of_bills', + lineno=23, + col_offset=37, + end_lineno=23, + end_col_offset=52)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param denomination: int - the value of a bill.\n :param number_of_bills: int - total number of bills.\n :return: int - calculated value of the bills.\n ', + lineno=24, + col_offset=4, + end_lineno=29, + end_col_offset=7), + lineno=24, + col_offset=4, + end_lineno=29, + end_col_offset=7), + Return( + BinOp( + Name( + 'denomination', + Load(), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=23), + Mult(), + Name( + 'number_of_bills', + Load(), + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=41), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=41), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=41)], + [], + lineno=23, + col_offset=0, + end_lineno=31, + end_col_offset=41), + FunctionDef( + 'get_number_of_bills', + arguments( + [], + [ + arg( + 'amount', + lineno=34, + col_offset=24, + end_lineno=34, + end_col_offset=30), + arg( + 'denomination', + lineno=34, + col_offset=32, + end_lineno=34, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param amount: float - the total starting value.\n :param denomination: int - the value of a single bill.\n :return: int - number of bills that can be obtained from the amount.\n ', + lineno=35, + col_offset=4, + end_lineno=40, + end_col_offset=7), + lineno=35, + col_offset=4, + end_lineno=40, + end_col_offset=7), + Return( + BinOp( + Call( + Name( + 'int', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=14), + [ + Name( + 'amount', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=21)], + [], + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=22), + FloorDiv(), + Name( + 'denomination', + Load(), + lineno=42, + col_offset=26, + end_lineno=42, + end_col_offset=38), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=38), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=38)], + [], + lineno=34, + col_offset=0, + end_lineno=42, + end_col_offset=38), + FunctionDef( + 'get_leftover_of_bills', + arguments( + [], + [ + arg( + 'amount', + lineno=45, + col_offset=26, + end_lineno=45, + end_col_offset=32), + arg( + 'denomination', + lineno=45, + col_offset=34, + end_lineno=45, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param amount: float - the total starting value.\n :param denomination: int - the value of a single bill.\n :return: float - the amount that is "leftover", given the current denomination.\n ', + lineno=46, + col_offset=4, + end_lineno=51, + end_col_offset=7), + lineno=46, + col_offset=4, + end_lineno=51, + end_col_offset=7), + Return( + BinOp( + Name( + 'amount', + Load(), + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=17), + Mod(), + Name( + 'denomination', + Load(), + lineno=53, + col_offset=20, + end_lineno=53, + end_col_offset=32), + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=32), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=32)], + [], + lineno=45, + col_offset=0, + end_lineno=53, + end_col_offset=32), + FunctionDef( + 'exchangeable_value', + arguments( + [], + [ + arg( + 'budget', + lineno=56, + col_offset=23, + end_lineno=56, + end_col_offset=29), + arg( + 'exchange_rate', + lineno=56, + col_offset=31, + end_lineno=56, + end_col_offset=44), + arg( + 'spread', + lineno=56, + col_offset=46, + end_lineno=56, + end_col_offset=52), + arg( + 'denomination', + lineno=56, + col_offset=54, + end_lineno=56, + end_col_offset=66)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param budget: float - the amount of your money you are planning to exchange.\n :param exchange_rate: float - the unit value of the foreign currency.\n :param spread: int - percentage that is taken as an exchange fee.\n :param denomination: int - the value of a single bill.\n :return: int - maximum value you can get.\n ', + lineno=57, + col_offset=4, + end_lineno=64, + end_col_offset=7), + lineno=57, + col_offset=4, + end_lineno=64, + end_col_offset=7), + Assign( + [ + Name( + 'exchange_fee', + Store(), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=16)], + BinOp( + BinOp( + Name( + 'exchange_rate', + Load(), + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=33), + Div(), + Constant( + 100, + lineno=66, + col_offset=36, + end_lineno=66, + end_col_offset=39), + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=39), + Mult(), + Name( + 'spread', + Load(), + lineno=66, + col_offset=43, + end_lineno=66, + end_col_offset=49), + lineno=66, + col_offset=19, + end_lineno=66, + end_col_offset=49), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=49), + Assign( + [ + Name( + 'exchange_value', + Store(), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=18)], + Call( + Name( + 'exchange_money', + Load(), + lineno=67, + col_offset=21, + end_lineno=67, + end_col_offset=35), + [ + Name( + 'budget', + Load(), + lineno=67, + col_offset=36, + end_lineno=67, + end_col_offset=42), + BinOp( + Name( + 'exchange_rate', + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=57), + Add(), + Name( + 'exchange_fee', + Load(), + lineno=67, + col_offset=60, + end_lineno=67, + end_col_offset=72), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=72)], + [], + lineno=67, + col_offset=21, + end_lineno=67, + end_col_offset=73), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=73), + Assign( + [ + Name( + 'number_of_bills', + Store(), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=19)], + Call( + Name( + 'get_number_of_bills', + Load(), + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=41), + [ + Name( + 'exchange_value', + Load(), + lineno=68, + col_offset=42, + end_lineno=68, + end_col_offset=56), + Name( + 'denomination', + Load(), + lineno=68, + col_offset=58, + end_lineno=68, + end_col_offset=70)], + [], + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=71), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=71), + Assign( + [ + Name( + 'value_of_bills', + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=18)], + Call( + Name( + 'get_value_of_bills', + Load(), + lineno=69, + col_offset=21, + end_lineno=69, + end_col_offset=39), + [ + Name( + 'denomination', + Load(), + lineno=69, + col_offset=40, + end_lineno=69, + end_col_offset=52), + Name( + 'number_of_bills', + Load(), + lineno=69, + col_offset=54, + end_lineno=69, + end_col_offset=69)], + [], + lineno=69, + col_offset=21, + end_lineno=69, + end_col_offset=70), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=70), + Return( + Name( + 'value_of_bills', + Load(), + lineno=70, + col_offset=11, + end_lineno=70, + end_col_offset=25), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=25)], + [], + lineno=56, + col_offset=0, + end_lineno=70, + end_col_offset=25)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=25), + arg( + 'placeholder_2', + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=17), + Div(), + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=33), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=33), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=33)], + [], + lineno=1, + col_offset=0, + end_lineno=9, + end_col_offset=33), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=21), + arg( + 'placeholder_4', + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=17), + Sub(), + Name( + 'placeholder_4', + Load(), + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=36), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=36), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=36)], + [], + lineno=12, + col_offset=0, + end_lineno=20, + end_col_offset=36), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=35), + arg( + 'placeholder_7', + lineno=23, + col_offset=37, + end_lineno=23, + end_col_offset=52)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=23), + Mult(), + Name( + 'placeholder_7', + Load(), + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=41), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=41), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=41)], + [], + lineno=23, + col_offset=0, + end_lineno=31, + end_col_offset=41), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'placeholder_9', + lineno=34, + col_offset=24, + end_lineno=34, + end_col_offset=30), + arg( + 'placeholder_6', + lineno=34, + col_offset=32, + end_lineno=34, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Call( + Name( + 'int', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=14), + [ + Name( + 'placeholder_9', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=21)], + [], + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=22), + FloorDiv(), + Name( + 'placeholder_6', + Load(), + lineno=42, + col_offset=26, + end_lineno=42, + end_col_offset=38), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=38), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=38)], + [], + lineno=34, + col_offset=0, + end_lineno=42, + end_col_offset=38), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_9', + lineno=45, + col_offset=26, + end_lineno=45, + end_col_offset=32), + arg( + 'placeholder_6', + lineno=45, + col_offset=34, + end_lineno=45, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=17), + Mod(), + Name( + 'placeholder_6', + Load(), + lineno=53, + col_offset=20, + end_lineno=53, + end_col_offset=32), + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=32), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=32)], + [], + lineno=45, + col_offset=0, + end_lineno=53, + end_col_offset=32), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=56, + col_offset=23, + end_lineno=56, + end_col_offset=29), + arg( + 'placeholder_2', + lineno=56, + col_offset=31, + end_lineno=56, + end_col_offset=44), + arg( + 'placeholder_12', + lineno=56, + col_offset=46, + end_lineno=56, + end_col_offset=52), + arg( + 'placeholder_6', + lineno=56, + col_offset=54, + end_lineno=56, + end_col_offset=66)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=16)], + BinOp( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=33), + Div(), + Constant( + 100, + lineno=66, + col_offset=36, + end_lineno=66, + end_col_offset=39), + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=39), + Mult(), + Name( + 'placeholder_12', + Load(), + lineno=66, + col_offset=43, + end_lineno=66, + end_col_offset=49), + lineno=66, + col_offset=19, + end_lineno=66, + end_col_offset=49), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=49), + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=18)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=67, + col_offset=21, + end_lineno=67, + end_col_offset=35), + [ + Name( + 'placeholder_1', + Load(), + lineno=67, + col_offset=36, + end_lineno=67, + end_col_offset=42), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=57), + Add(), + Name( + 'placeholder_13', + Load(), + lineno=67, + col_offset=60, + end_lineno=67, + end_col_offset=72), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=72)], + [], + lineno=67, + col_offset=21, + end_lineno=67, + end_col_offset=73), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=73), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=19)], + Call( + Name( + 'placeholder_8', + Load(), + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=41), + [ + Name( + 'placeholder_14', + Load(), + lineno=68, + col_offset=42, + end_lineno=68, + end_col_offset=56), + Name( + 'placeholder_6', + Load(), + lineno=68, + col_offset=58, + end_lineno=68, + end_col_offset=70)], + [], + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=71), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=71), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=18)], + Call( + Name( + 'placeholder_5', + Load(), + lineno=69, + col_offset=21, + end_lineno=69, + end_col_offset=39), + [ + Name( + 'placeholder_6', + Load(), + lineno=69, + col_offset=40, + end_lineno=69, + end_col_offset=52), + Name( + 'placeholder_7', + Load(), + lineno=69, + col_offset=54, + end_lineno=69, + end_col_offset=69)], + [], + lineno=69, + col_offset=21, + end_lineno=69, + end_col_offset=70), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=70), + Return( + Name( + 'placeholder_15', + Load(), + lineno=70, + col_offset=11, + end_lineno=70, + end_col_offset=25), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=25)], + [], + lineno=56, + col_offset=0, + end_lineno=70, + end_col_offset=25)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-currency-exchange/representation.txt b/test/concept-currency-exchange/representation.txt new file mode 100644 index 0000000..ebaa8d7 --- /dev/null +++ b/test/concept-currency-exchange/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=19, end_lineno=1, end_col_offset=25), arg('placeholder_2', lineno=1, col_offset=27, end_lineno=1, end_col_offset=40)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_1', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=17), Div(), Name('placeholder_2', Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=33), lineno=9, col_offset=11, end_lineno=9, end_col_offset=33), lineno=9, col_offset=4, end_lineno=9, end_col_offset=33)], [], lineno=1, col_offset=0, end_lineno=9, end_col_offset=33), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=12, col_offset=15, end_lineno=12, end_col_offset=21), arg('placeholder_4', lineno=12, col_offset=23, end_lineno=12, end_col_offset=39)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_1', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=17), Sub(), Name('placeholder_4', Load(), lineno=20, col_offset=20, end_lineno=20, end_col_offset=36), lineno=20, col_offset=11, end_lineno=20, end_col_offset=36), lineno=20, col_offset=4, end_lineno=20, end_col_offset=36)], [], lineno=12, col_offset=0, end_lineno=20, end_col_offset=36), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=23, col_offset=23, end_lineno=23, end_col_offset=35), arg('placeholder_7', lineno=23, col_offset=37, end_lineno=23, end_col_offset=52)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_6', Load(), lineno=31, col_offset=11, end_lineno=31, end_col_offset=23), Mult(), Name('placeholder_7', Load(), lineno=31, col_offset=26, end_lineno=31, end_col_offset=41), lineno=31, col_offset=11, end_lineno=31, end_col_offset=41), lineno=31, col_offset=4, end_lineno=31, end_col_offset=41)], [], lineno=23, col_offset=0, end_lineno=31, end_col_offset=41), FunctionDef('placeholder_8', arguments([], [arg('placeholder_9', lineno=34, col_offset=24, end_lineno=34, end_col_offset=30), arg('placeholder_6', lineno=34, col_offset=32, end_lineno=34, end_col_offset=44)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Call(Name('int', Load(), lineno=42, col_offset=11, end_lineno=42, end_col_offset=14), [Name('placeholder_9', Load(), lineno=42, col_offset=15, end_lineno=42, end_col_offset=21)], [], lineno=42, col_offset=11, end_lineno=42, end_col_offset=22), FloorDiv(), Name('placeholder_6', Load(), lineno=42, col_offset=26, end_lineno=42, end_col_offset=38), lineno=42, col_offset=11, end_lineno=42, end_col_offset=38), lineno=42, col_offset=4, end_lineno=42, end_col_offset=38)], [], lineno=34, col_offset=0, end_lineno=42, end_col_offset=38), FunctionDef('placeholder_10', arguments([], [arg('placeholder_9', lineno=45, col_offset=26, end_lineno=45, end_col_offset=32), arg('placeholder_6', lineno=45, col_offset=34, end_lineno=45, end_col_offset=46)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_9', Load(), lineno=53, col_offset=11, end_lineno=53, end_col_offset=17), Mod(), Name('placeholder_6', Load(), lineno=53, col_offset=20, end_lineno=53, end_col_offset=32), lineno=53, col_offset=11, end_lineno=53, end_col_offset=32), lineno=53, col_offset=4, end_lineno=53, end_col_offset=32)], [], lineno=45, col_offset=0, end_lineno=53, end_col_offset=32), FunctionDef('placeholder_11', arguments([], [arg('placeholder_1', lineno=56, col_offset=23, end_lineno=56, end_col_offset=29), arg('placeholder_2', lineno=56, col_offset=31, end_lineno=56, end_col_offset=44), arg('placeholder_12', lineno=56, col_offset=46, end_lineno=56, end_col_offset=52), arg('placeholder_6', lineno=56, col_offset=54, end_lineno=56, end_col_offset=66)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_13', Store(), lineno=66, col_offset=4, end_lineno=66, end_col_offset=16)], BinOp(BinOp(Name('placeholder_2', Load(), lineno=66, col_offset=20, end_lineno=66, end_col_offset=33), Div(), Constant(100, lineno=66, col_offset=36, end_lineno=66, end_col_offset=39), lineno=66, col_offset=20, end_lineno=66, end_col_offset=39), Mult(), Name('placeholder_12', Load(), lineno=66, col_offset=43, end_lineno=66, end_col_offset=49), lineno=66, col_offset=19, end_lineno=66, end_col_offset=49), lineno=66, col_offset=4, end_lineno=66, end_col_offset=49), Assign([Name('placeholder_14', Store(), lineno=67, col_offset=4, end_lineno=67, end_col_offset=18)], Call(Name('placeholder_0', Load(), lineno=67, col_offset=21, end_lineno=67, end_col_offset=35), [Name('placeholder_1', Load(), lineno=67, col_offset=36, end_lineno=67, end_col_offset=42), BinOp(Name('placeholder_2', Load(), lineno=67, col_offset=44, end_lineno=67, end_col_offset=57), Add(), Name('placeholder_13', Load(), lineno=67, col_offset=60, end_lineno=67, end_col_offset=72), lineno=67, col_offset=44, end_lineno=67, end_col_offset=72)], [], lineno=67, col_offset=21, end_lineno=67, end_col_offset=73), lineno=67, col_offset=4, end_lineno=67, end_col_offset=73), Assign([Name('placeholder_7', Store(), lineno=68, col_offset=4, end_lineno=68, end_col_offset=19)], Call(Name('placeholder_8', Load(), lineno=68, col_offset=22, end_lineno=68, end_col_offset=41), [Name('placeholder_14', Load(), lineno=68, col_offset=42, end_lineno=68, end_col_offset=56), Name('placeholder_6', Load(), lineno=68, col_offset=58, end_lineno=68, end_col_offset=70)], [], lineno=68, col_offset=22, end_lineno=68, end_col_offset=71), lineno=68, col_offset=4, end_lineno=68, end_col_offset=71), Assign([Name('placeholder_15', Store(), lineno=69, col_offset=4, end_lineno=69, end_col_offset=18)], Call(Name('placeholder_5', Load(), lineno=69, col_offset=21, end_lineno=69, end_col_offset=39), [Name('placeholder_6', Load(), lineno=69, col_offset=40, end_lineno=69, end_col_offset=52), Name('placeholder_7', Load(), lineno=69, col_offset=54, end_lineno=69, end_col_offset=69)], [], lineno=69, col_offset=21, end_lineno=69, end_col_offset=70), lineno=69, col_offset=4, end_lineno=69, end_col_offset=70), Return(Name('placeholder_15', Load(), lineno=70, col_offset=11, end_lineno=70, end_col_offset=25), lineno=70, col_offset=4, end_lineno=70, end_col_offset=25)], [], lineno=56, col_offset=0, end_lineno=70, end_col_offset=25)], []) \ No newline at end of file diff --git a/test/concept-electric-bill/.meta/config.json b/test/concept-electric-bill/.meta/config.json new file mode 100644 index 0000000..19c06f2 --- /dev/null +++ b/test/concept-electric-bill/.meta/config.json @@ -0,0 +1,14 @@ +{ + "authors": [ + "meatball133", + "BethanyG" + ], + "contributors": ["MatthijsBlom"], + "files": { + "solution": [ + "electric_bill.py" + ] + }, + "icon": "city-office", + "blurb": "Learn about numbers in Python while saving your employers money on their electric bill." +} diff --git a/test/concept-electric-bill/electric_bill.py b/test/concept-electric-bill/electric_bill.py new file mode 100644 index 0000000..9da3d3d --- /dev/null +++ b/test/concept-electric-bill/electric_bill.py @@ -0,0 +1,51 @@ +"""Functions to help the company calculate their power usage.""" + + +def get_extra_hours(hours): + """Return the number of hours. + + :param: hours: int - number of hours. + :return: int - number of "extra" hours. + """ + + return (hours + 3) % 24 + + +def get_kW_amount(watts): + """Return the kW amount of a given watt amount. + + :param: watts: int - watt amount. + :return: float - kW amount. + """ + + # rounds to one decimal place here + return round(watts / 1000, 1) + + +def get_kwh_amount(watts): + """Return the kWh amount of a given watt amount and hours. + + :param: watts: int - watt amount. + :return: int - kilowatt hour amount. + """ + return get_kW_amount(watts) // 3600 + + +def get_efficiency(power_factor): + """Return the efficiency calculated from the power factor. + + :param: power_factor: float. + :return: float - efficiency. + """ + return power_factor / 100 + + +def get_cost(watts, power_factor, price): + """Calculate the cost of a given kWh value, efficiency and price. + + :param: watts: int - watt value. + :param: power_factor: float - efficiency. + :param: price: float - price of kWh. + :return: float - cost of kWh. + """ + return price * (get_kwh_amount(watts) / get_efficiency(power_factor)) diff --git a/test/concept-electric-bill/mapping.json b/test/concept-electric-bill/mapping.json new file mode 100644 index 0000000..86d8f3b --- /dev/null +++ b/test/concept-electric-bill/mapping.json @@ -0,0 +1,11 @@ +{ + "placeholder_0": "get_extra_hours", + "placeholder_1": "hours", + "placeholder_2": "get_kW_amount", + "placeholder_3": "watts", + "placeholder_4": "get_kwh_amount", + "placeholder_5": "get_efficiency", + "placeholder_6": "power_factor", + "placeholder_7": "get_cost", + "placeholder_8": "price" +} \ No newline at end of file diff --git a/test/concept-electric-bill/representation.json b/test/concept-electric-bill/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-electric-bill/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-electric-bill/representation.out b/test/concept-electric-bill/representation.out new file mode 100644 index 0000000..7f6afaa --- /dev/null +++ b/test/concept-electric-bill/representation.out @@ -0,0 +1,739 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return (placeholder_1 + 3) % 24 + + +def placeholder_2(placeholder_3): + return round(placeholder_3 / 1000, 1) + + +def placeholder_4(placeholder_3): + return placeholder_2(placeholder_3) // 3600 + + +def placeholder_5(placeholder_6): + return placeholder_6 / 100 + + +def placeholder_7(placeholder_3, placeholder_6, placeholder_8): + return placeholder_8 * (placeholder_4(placeholder_3) / placeholder_5(placeholder_6)) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to help the company calculate their power usage.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=64), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=64), + FunctionDef( + 'get_extra_hours', + arguments( + [], + [ + arg( + 'hours', + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return the number of hours.\n\n :param: hours: int - number of hours.\n :return: int - number of "extra" hours.\n ', + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + Return( + BinOp( + BinOp( + Name( + 'hours', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=17), + Add(), + Constant( + 3, + lineno=11, + col_offset=20, + end_lineno=11, + end_col_offset=21), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=21), + Mod(), + Constant( + 24, + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=27), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=27), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=27)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=27), + FunctionDef( + 'get_kW_amount', + arguments( + [], + [ + arg( + 'watts', + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return the kW amount of a given watt amount.\n\n :param: watts: int - watt amount.\n :return: float - kW amount.\n ', + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=7), + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=7), + Return( + Call( + Name( + 'round', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=16), + [ + BinOp( + Name( + 'watts', + Load(), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=22), + Div(), + Constant( + 1000, + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=29), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=29), + Constant( + 1, + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=32)], + [], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=33), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=33)], + [], + lineno=14, + col_offset=0, + end_lineno=22, + end_col_offset=33), + FunctionDef( + 'get_kwh_amount', + arguments( + [], + [ + arg( + 'watts', + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return the kWh amount of a given watt amount and hours.\n\n :param: watts: int - watt amount.\n :return: int - kilowatt hour amount.\n ', + lineno=26, + col_offset=4, + end_lineno=30, + end_col_offset=7), + lineno=26, + col_offset=4, + end_lineno=30, + end_col_offset=7), + Return( + BinOp( + Call( + Name( + 'get_kW_amount', + Load(), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=24), + [ + Name( + 'watts', + Load(), + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=30)], + [], + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=31), + FloorDiv(), + Constant( + 3600, + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=39), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=39), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=39)], + [], + lineno=25, + col_offset=0, + end_lineno=31, + end_col_offset=39), + FunctionDef( + 'get_efficiency', + arguments( + [], + [ + arg( + 'power_factor', + lineno=34, + col_offset=19, + end_lineno=34, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return the efficiency calculated from the power factor.\n\n :param: power_factor: float.\n :return: float - efficiency.\n ', + lineno=35, + col_offset=4, + end_lineno=39, + end_col_offset=7), + lineno=35, + col_offset=4, + end_lineno=39, + end_col_offset=7), + Return( + BinOp( + Name( + 'power_factor', + Load(), + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=23), + Div(), + Constant( + 100, + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=29), + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=29), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=29)], + [], + lineno=34, + col_offset=0, + end_lineno=40, + end_col_offset=29), + FunctionDef( + 'get_cost', + arguments( + [], + [ + arg( + 'watts', + lineno=43, + col_offset=13, + end_lineno=43, + end_col_offset=18), + arg( + 'power_factor', + lineno=43, + col_offset=20, + end_lineno=43, + end_col_offset=32), + arg( + 'price', + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Calculate the cost of a given kWh value, efficiency and price.\n\n :param: watts: int - watt value.\n :param: power_factor: float - efficiency.\n :param: price: float - price of kWh.\n :return: float - cost of kWh.\n ', + lineno=44, + col_offset=4, + end_lineno=50, + end_col_offset=7), + lineno=44, + col_offset=4, + end_lineno=50, + end_col_offset=7), + Return( + BinOp( + Name( + 'price', + Load(), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=16), + Mult(), + BinOp( + Call( + Name( + 'get_kwh_amount', + Load(), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=34), + [ + Name( + 'watts', + Load(), + lineno=51, + col_offset=35, + end_lineno=51, + end_col_offset=40)], + [], + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=41), + Div(), + Call( + Name( + 'get_efficiency', + Load(), + lineno=51, + col_offset=44, + end_lineno=51, + end_col_offset=58), + [ + Name( + 'power_factor', + Load(), + lineno=51, + col_offset=59, + end_lineno=51, + end_col_offset=71)], + [], + lineno=51, + col_offset=44, + end_lineno=51, + end_col_offset=72), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=72), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=73), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=73)], + [], + lineno=43, + col_offset=0, + end_lineno=51, + end_col_offset=73)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=17), + Add(), + Constant( + 3, + lineno=11, + col_offset=20, + end_lineno=11, + end_col_offset=21), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=21), + Mod(), + Constant( + 24, + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=27), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=27), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=27)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=27), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'round', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=16), + [ + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=22), + Div(), + Constant( + 1000, + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=29), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=29), + Constant( + 1, + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=32)], + [], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=33), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=33)], + [], + lineno=14, + col_offset=0, + end_lineno=22, + end_col_offset=33), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Call( + Name( + 'placeholder_2', + Load(), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=24), + [ + Name( + 'placeholder_3', + Load(), + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=30)], + [], + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=31), + FloorDiv(), + Constant( + 3600, + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=39), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=39), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=39)], + [], + lineno=25, + col_offset=0, + end_lineno=31, + end_col_offset=39), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=34, + col_offset=19, + end_lineno=34, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=23), + Div(), + Constant( + 100, + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=29), + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=29), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=29)], + [], + lineno=34, + col_offset=0, + end_lineno=40, + end_col_offset=29), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=43, + col_offset=13, + end_lineno=43, + end_col_offset=18), + arg( + 'placeholder_6', + lineno=43, + col_offset=20, + end_lineno=43, + end_col_offset=32), + arg( + 'placeholder_8', + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=16), + Mult(), + BinOp( + Call( + Name( + 'placeholder_4', + Load(), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=34), + [ + Name( + 'placeholder_3', + Load(), + lineno=51, + col_offset=35, + end_lineno=51, + end_col_offset=40)], + [], + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=41), + Div(), + Call( + Name( + 'placeholder_5', + Load(), + lineno=51, + col_offset=44, + end_lineno=51, + end_col_offset=58), + [ + Name( + 'placeholder_6', + Load(), + lineno=51, + col_offset=59, + end_lineno=51, + end_col_offset=71)], + [], + lineno=51, + col_offset=44, + end_lineno=51, + end_col_offset=72), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=72), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=73), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=73)], + [], + lineno=43, + col_offset=0, + end_lineno=51, + end_col_offset=73)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-electric-bill/representation.txt b/test/concept-electric-bill/representation.txt new file mode 100644 index 0000000..f21672b --- /dev/null +++ b/test/concept-electric-bill/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=20, end_lineno=4, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(BinOp(Name('placeholder_1', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=17), Add(), Constant(3, lineno=11, col_offset=20, end_lineno=11, end_col_offset=21), lineno=11, col_offset=12, end_lineno=11, end_col_offset=21), Mod(), Constant(24, lineno=11, col_offset=25, end_lineno=11, end_col_offset=27), lineno=11, col_offset=11, end_lineno=11, end_col_offset=27), lineno=11, col_offset=4, end_lineno=11, end_col_offset=27)], [], lineno=4, col_offset=0, end_lineno=11, end_col_offset=27), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=14, col_offset=18, end_lineno=14, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('round', Load(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=16), [BinOp(Name('placeholder_3', Load(), lineno=22, col_offset=17, end_lineno=22, end_col_offset=22), Div(), Constant(1000, lineno=22, col_offset=25, end_lineno=22, end_col_offset=29), lineno=22, col_offset=17, end_lineno=22, end_col_offset=29), Constant(1, lineno=22, col_offset=31, end_lineno=22, end_col_offset=32)], [], lineno=22, col_offset=11, end_lineno=22, end_col_offset=33), lineno=22, col_offset=4, end_lineno=22, end_col_offset=33)], [], lineno=14, col_offset=0, end_lineno=22, end_col_offset=33), FunctionDef('placeholder_4', arguments([], [arg('placeholder_3', lineno=25, col_offset=19, end_lineno=25, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Call(Name('placeholder_2', Load(), lineno=31, col_offset=11, end_lineno=31, end_col_offset=24), [Name('placeholder_3', Load(), lineno=31, col_offset=25, end_lineno=31, end_col_offset=30)], [], lineno=31, col_offset=11, end_lineno=31, end_col_offset=31), FloorDiv(), Constant(3600, lineno=31, col_offset=35, end_lineno=31, end_col_offset=39), lineno=31, col_offset=11, end_lineno=31, end_col_offset=39), lineno=31, col_offset=4, end_lineno=31, end_col_offset=39)], [], lineno=25, col_offset=0, end_lineno=31, end_col_offset=39), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=34, col_offset=19, end_lineno=34, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_6', Load(), lineno=40, col_offset=11, end_lineno=40, end_col_offset=23), Div(), Constant(100, lineno=40, col_offset=26, end_lineno=40, end_col_offset=29), lineno=40, col_offset=11, end_lineno=40, end_col_offset=29), lineno=40, col_offset=4, end_lineno=40, end_col_offset=29)], [], lineno=34, col_offset=0, end_lineno=40, end_col_offset=29), FunctionDef('placeholder_7', arguments([], [arg('placeholder_3', lineno=43, col_offset=13, end_lineno=43, end_col_offset=18), arg('placeholder_6', lineno=43, col_offset=20, end_lineno=43, end_col_offset=32), arg('placeholder_8', lineno=43, col_offset=34, end_lineno=43, end_col_offset=39)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_8', Load(), lineno=51, col_offset=11, end_lineno=51, end_col_offset=16), Mult(), BinOp(Call(Name('placeholder_4', Load(), lineno=51, col_offset=20, end_lineno=51, end_col_offset=34), [Name('placeholder_3', Load(), lineno=51, col_offset=35, end_lineno=51, end_col_offset=40)], [], lineno=51, col_offset=20, end_lineno=51, end_col_offset=41), Div(), Call(Name('placeholder_5', Load(), lineno=51, col_offset=44, end_lineno=51, end_col_offset=58), [Name('placeholder_6', Load(), lineno=51, col_offset=59, end_lineno=51, end_col_offset=71)], [], lineno=51, col_offset=44, end_lineno=51, end_col_offset=72), lineno=51, col_offset=20, end_lineno=51, end_col_offset=72), lineno=51, col_offset=11, end_lineno=51, end_col_offset=73), lineno=51, col_offset=4, end_lineno=51, end_col_offset=73)], [], lineno=43, col_offset=0, end_lineno=51, end_col_offset=73)], []) \ No newline at end of file diff --git a/test/concept-ellens-alien-game/.meta/config.json b/test/concept-ellens-alien-game/.meta/config.json new file mode 100644 index 0000000..99a7786 --- /dev/null +++ b/test/concept-ellens-alien-game/.meta/config.json @@ -0,0 +1,18 @@ +{ + "authors": [ + "PaulT89", + "BethanyG" + ], + "contributors": [ + "DjangoFett", + "kotp", + "IsaacG" + ], + "files": { + "solution": [ + "classes.py" + ] + }, + "icon": "character-study", + "blurb": "Learn about classes by creating an Alien for Ellen's game." +} diff --git a/test/concept-ellens-alien-game/classes.py b/test/concept-ellens-alien-game/classes.py new file mode 100644 index 0000000..ace3164 --- /dev/null +++ b/test/concept-ellens-alien-game/classes.py @@ -0,0 +1,90 @@ +"""Exemplar solution to Ellen's Alien Game exercise.""" + + +class Alien: + """Create an Alien object with location x_coordinate and y_coordinate. + + Attributes + ---------- + (class)total_aliens_created: int + x_coordinate: int - Position on the x-axis. + y_coordinate: int - Position on the y-axis. + health: int - Number of health points. + + Methods + ------- + hit(): Decrement Alien health by one point. + is_alive(): Return a boolean to indicate if Alien is alive (if health is > 0). + teleport(new_x_coordinate, new_y_coordinate): Move Alien object to new coordinates. + collision_detection(other): Implementation TBD. + """ + + total_aliens_created = 0 + + def __init__(self, x_coordinate, y_coordinate): + """Initialize a new Alien object and increment total_aliens_created by 1. + + :param x_coordinate: int - Alien position on the x-axis + :param y_coordinate: int - Alien position on the y-axis + + :attribute x_coordinate: int - Alien position on the x-axis + :attribute y_coordinate: int - Alien position on the y-axis + :attribute health: int (3) - Initial Alien health points. + + :return: object - New Alien. + """ + + Alien.total_aliens_created += 1 + + self.x_coordinate = x_coordinate + self.y_coordinate = y_coordinate + self.health = 3 + + def hit(self): + """Decrement Alien health by 1. + + :return: None + """ + + #There are two valid interpretations for this method/task. + #The one below, and `self.health = max(0, self.health - 1)` + #The tests for this task reflect this ambiguity. + self.health -= 1 + + def is_alive(self): + """Return if the Alien is alive. + + :return: boolean + """ + + return self.health > 0 + + def teleport(self, new_x_coordinate, new_y_coordinate): + """Change Alien location. + + :param new_x_coordinate: int - New location on x-axis. + :param new_y_coordinate: int - New location on y-axis. + + :return: None + """ + self.x_coordinate = new_x_coordinate + self.y_coordinate = new_y_coordinate + + def collision_detection(self, other): + """Detect collisions with another Alien. + + :param other: object - Other Alien object. + + :return: None + """ + + pass + +def new_aliens_collection(positions): + """Create a list of Alien instances from a list of coordinate tuples. + + :param positions: list - List of tuples of (x, y) coordinates. + + :return: list - List of Alien objects. + """ + return [Alien(position[0], position[1]) for position in positions] diff --git a/test/concept-ellens-alien-game/mapping.json b/test/concept-ellens-alien-game/mapping.json new file mode 100644 index 0000000..4710265 --- /dev/null +++ b/test/concept-ellens-alien-game/mapping.json @@ -0,0 +1,18 @@ +{ + "placeholder_0": "Alien", + "placeholder_1": "total_aliens_created", + "placeholder_2": "__init__", + "placeholder_3": "x_coordinate", + "placeholder_4": "y_coordinate", + "placeholder_5": "health", + "placeholder_6": "hit", + "placeholder_7": "is_alive", + "placeholder_8": "teleport", + "placeholder_9": "new_x_coordinate", + "placeholder_10": "new_y_coordinate", + "placeholder_11": "collision_detection", + "placeholder_12": "other", + "placeholder_13": "new_aliens_collection", + "placeholder_14": "positions", + "placeholder_15": "position" +} \ No newline at end of file diff --git a/test/concept-ellens-alien-game/representation.json b/test/concept-ellens-alien-game/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-ellens-alien-game/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-ellens-alien-game/representation.out b/test/concept-ellens-alien-game/representation.out new file mode 100644 index 0000000..db0be29 --- /dev/null +++ b/test/concept-ellens-alien-game/representation.out @@ -0,0 +1,1097 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + placeholder_1 = 0 + + def placeholder_2(self, placeholder_3, placeholder_4): + placeholder_0.placeholder_1 += 1 + self.placeholder_3 = placeholder_3 + self.placeholder_4 = placeholder_4 + self.placeholder_5 = 3 + + def placeholder_6(self): + self.placeholder_5 -= 1 + + def placeholder_7(self): + return self.placeholder_5 > 0 + + def placeholder_8(self, placeholder_9, placeholder_10): + self.placeholder_3 = placeholder_9 + self.placeholder_4 = placeholder_10 + + def placeholder_11(self, placeholder_12): + pass + + +def placeholder_13(placeholder_14): + return [ + placeholder_0(placeholder_15[0], placeholder_15[1]) + for placeholder_15 in placeholder_14 + ] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + "Exemplar solution to Ellen's Alien Game exercise.", + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=55), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=55), + ClassDef( + 'Alien', + [], + [], + [ + Expr( + Constant( + 'Create an Alien object with location x_coordinate and y_coordinate.\n\n Attributes\n ----------\n (class)total_aliens_created: int\n x_coordinate: int - Position on the x-axis.\n y_coordinate: int - Position on the y-axis.\n health: int - Number of health points.\n\n Methods\n -------\n hit(): Decrement Alien health by one point.\n is_alive(): Return a boolean to indicate if Alien is alive (if health is > 0).\n teleport(new_x_coordinate, new_y_coordinate): Move Alien object to new coordinates.\n collision_detection(other): Implementation TBD.\n ', + lineno=5, + col_offset=4, + end_lineno=20, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=20, + end_col_offset=7), + Assign( + [ + Name( + 'total_aliens_created', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=24)], + Constant( + 0, + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=28), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=28), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=21), + arg( + 'x_coordinate', + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=35), + arg( + 'y_coordinate', + lineno=24, + col_offset=37, + end_lineno=24, + end_col_offset=49)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Initialize a new Alien object and increment total_aliens_created by 1.\n\n :param x_coordinate: int - Alien position on the x-axis\n :param y_coordinate: int - Alien position on the y-axis\n\n :attribute x_coordinate: int - Alien position on the x-axis\n :attribute y_coordinate: int - Alien position on the y-axis\n :attribute health: int (3) - Initial Alien health points.\n\n :return: object - New Alien.\n ', + lineno=25, + col_offset=8, + end_lineno=35, + end_col_offset=11), + lineno=25, + col_offset=8, + end_lineno=35, + end_col_offset=11), + AugAssign( + Attribute( + Name( + 'Alien', + Load(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=13), + 'total_aliens_created', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=34), + Add(), + Constant( + 1, + lineno=37, + col_offset=38, + end_lineno=37, + end_col_offset=39), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=12), + 'x_coordinate', + Store(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=25)], + Name( + 'x_coordinate', + Load(), + lineno=39, + col_offset=28, + end_lineno=39, + end_col_offset=40), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=12), + 'y_coordinate', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=25)], + Name( + 'y_coordinate', + Load(), + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=40), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=12), + 'health', + Store(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=19)], + Constant( + 3, + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=23), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=23)], + [], + lineno=24, + col_offset=4, + end_lineno=41, + end_col_offset=23), + FunctionDef( + 'hit', + arguments( + [], + [ + arg( + 'self', + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Decrement Alien health by 1.\n\n :return: None\n ', + lineno=44, + col_offset=8, + end_lineno=47, + end_col_offset=11), + lineno=44, + col_offset=8, + end_lineno=47, + end_col_offset=11), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=12), + 'health', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=19), + Sub(), + Constant( + 1, + lineno=52, + col_offset=23, + end_lineno=52, + end_col_offset=24), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=24)], + [], + lineno=43, + col_offset=4, + end_lineno=52, + end_col_offset=24), + FunctionDef( + 'is_alive', + arguments( + [], + [ + arg( + 'self', + lineno=54, + col_offset=17, + end_lineno=54, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return if the Alien is alive.\n\n :return: boolean\n ', + lineno=55, + col_offset=8, + end_lineno=58, + end_col_offset=11), + lineno=55, + col_offset=8, + end_lineno=58, + end_col_offset=11), + Return( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=19), + 'health', + Load(), + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=26), + [ + Gt()], + [ + Constant( + 0, + lineno=60, + col_offset=29, + end_lineno=60, + end_col_offset=30)], + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=30), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=30)], + [], + lineno=54, + col_offset=4, + end_lineno=60, + end_col_offset=30), + FunctionDef( + 'teleport', + arguments( + [], + [ + arg( + 'self', + lineno=62, + col_offset=17, + end_lineno=62, + end_col_offset=21), + arg( + 'new_x_coordinate', + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=39), + arg( + 'new_y_coordinate', + lineno=62, + col_offset=41, + end_lineno=62, + end_col_offset=57)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Change Alien location.\n\n :param new_x_coordinate: int - New location on x-axis.\n :param new_y_coordinate: int - New location on y-axis.\n\n :return: None\n ', + lineno=63, + col_offset=8, + end_lineno=69, + end_col_offset=11), + lineno=63, + col_offset=8, + end_lineno=69, + end_col_offset=11), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=12), + 'x_coordinate', + Store(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=25)], + Name( + 'new_x_coordinate', + Load(), + lineno=70, + col_offset=28, + end_lineno=70, + end_col_offset=44), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=44), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=12), + 'y_coordinate', + Store(), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=25)], + Name( + 'new_y_coordinate', + Load(), + lineno=71, + col_offset=28, + end_lineno=71, + end_col_offset=44), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=44)], + [], + lineno=62, + col_offset=4, + end_lineno=71, + end_col_offset=44), + FunctionDef( + 'collision_detection', + arguments( + [], + [ + arg( + 'self', + lineno=73, + col_offset=28, + end_lineno=73, + end_col_offset=32), + arg( + 'other', + lineno=73, + col_offset=34, + end_lineno=73, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Detect collisions with another Alien.\n\n :param other: object - Other Alien object.\n\n :return: None\n ', + lineno=74, + col_offset=8, + end_lineno=79, + end_col_offset=11), + lineno=74, + col_offset=8, + end_lineno=79, + end_col_offset=11), + Pass( + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=12)], + [], + lineno=73, + col_offset=4, + end_lineno=81, + end_col_offset=12)], + [], + lineno=4, + col_offset=0, + end_lineno=81, + end_col_offset=12), + FunctionDef( + 'new_aliens_collection', + arguments( + [], + [ + arg( + 'positions', + lineno=83, + col_offset=26, + end_lineno=83, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Create a list of Alien instances from a list of coordinate tuples.\n\n :param positions: list - List of tuples of (x, y) coordinates.\n\n :return: list - List of Alien objects.\n ', + lineno=84, + col_offset=4, + end_lineno=89, + end_col_offset=8), + lineno=84, + col_offset=4, + end_lineno=89, + end_col_offset=8), + Return( + ListComp( + Call( + Name( + 'Alien', + Load(), + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=17), + [ + Subscript( + Name( + 'position', + Load(), + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=26), + Constant( + 0, + lineno=90, + col_offset=27, + end_lineno=90, + end_col_offset=28), + Load(), + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=29), + Subscript( + Name( + 'position', + Load(), + lineno=90, + col_offset=31, + end_lineno=90, + end_col_offset=39), + Constant( + 1, + lineno=90, + col_offset=40, + end_lineno=90, + end_col_offset=41), + Load(), + lineno=90, + col_offset=31, + end_lineno=90, + end_col_offset=42)], + [], + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=43), + [ + comprehension( + Name( + 'position', + Store(), + lineno=90, + col_offset=48, + end_lineno=90, + end_col_offset=56), + Name( + 'positions', + Load(), + lineno=90, + col_offset=60, + end_lineno=90, + end_col_offset=69), + [], + 0)], + lineno=90, + col_offset=11, + end_lineno=90, + end_col_offset=70), + lineno=90, + col_offset=4, + end_lineno=90, + end_col_offset=70)], + [], + lineno=83, + col_offset=0, + end_lineno=90, + end_col_offset=70)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=24)], + Constant( + 0, + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=28), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=28), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=21), + arg( + 'placeholder_3', + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=35), + arg( + 'placeholder_4', + lineno=24, + col_offset=37, + end_lineno=24, + end_col_offset=49)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=13), + 'placeholder_1', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=34), + Add(), + Constant( + 1, + lineno=37, + col_offset=38, + end_lineno=37, + end_col_offset=39), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=25)], + Name( + 'placeholder_3', + Load(), + lineno=39, + col_offset=28, + end_lineno=39, + end_col_offset=40), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=25)], + Name( + 'placeholder_4', + Load(), + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=40), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=19)], + Constant( + 3, + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=23), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=23)], + [], + lineno=24, + col_offset=4, + end_lineno=41, + end_col_offset=23), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=19), + Sub(), + Constant( + 1, + lineno=52, + col_offset=23, + end_lineno=52, + end_col_offset=24), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=24)], + [], + lineno=43, + col_offset=4, + end_lineno=52, + end_col_offset=24), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=54, + col_offset=17, + end_lineno=54, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=19), + 'placeholder_5', + Load(), + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=26), + [ + Gt()], + [ + Constant( + 0, + lineno=60, + col_offset=29, + end_lineno=60, + end_col_offset=30)], + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=30), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=30)], + [], + lineno=54, + col_offset=4, + end_lineno=60, + end_col_offset=30), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=62, + col_offset=17, + end_lineno=62, + end_col_offset=21), + arg( + 'placeholder_9', + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=39), + arg( + 'placeholder_10', + lineno=62, + col_offset=41, + end_lineno=62, + end_col_offset=57)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=25)], + Name( + 'placeholder_9', + Load(), + lineno=70, + col_offset=28, + end_lineno=70, + end_col_offset=44), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=44), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=25)], + Name( + 'placeholder_10', + Load(), + lineno=71, + col_offset=28, + end_lineno=71, + end_col_offset=44), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=44)], + [], + lineno=62, + col_offset=4, + end_lineno=71, + end_col_offset=44), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=73, + col_offset=28, + end_lineno=73, + end_col_offset=32), + arg( + 'placeholder_12', + lineno=73, + col_offset=34, + end_lineno=73, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Pass( + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=12)], + [], + lineno=73, + col_offset=4, + end_lineno=81, + end_col_offset=12)], + [], + lineno=4, + col_offset=0, + end_lineno=81, + end_col_offset=12), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=83, + col_offset=26, + end_lineno=83, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=17), + [ + Subscript( + Name( + 'placeholder_15', + Load(), + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=26), + Constant( + 0, + lineno=90, + col_offset=27, + end_lineno=90, + end_col_offset=28), + Load(), + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=29), + Subscript( + Name( + 'placeholder_15', + Load(), + lineno=90, + col_offset=31, + end_lineno=90, + end_col_offset=39), + Constant( + 1, + lineno=90, + col_offset=40, + end_lineno=90, + end_col_offset=41), + Load(), + lineno=90, + col_offset=31, + end_lineno=90, + end_col_offset=42)], + [], + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=43), + [ + comprehension( + Name( + 'placeholder_15', + Store(), + lineno=90, + col_offset=48, + end_lineno=90, + end_col_offset=56), + Name( + 'placeholder_14', + Load(), + lineno=90, + col_offset=60, + end_lineno=90, + end_col_offset=69), + [], + 0)], + lineno=90, + col_offset=11, + end_lineno=90, + end_col_offset=70), + lineno=90, + col_offset=4, + end_lineno=90, + end_col_offset=70)], + [], + lineno=83, + col_offset=0, + end_lineno=90, + end_col_offset=70)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-ellens-alien-game/representation.txt b/test/concept-ellens-alien-game/representation.txt new file mode 100644 index 0000000..b6e7733 --- /dev/null +++ b/test/concept-ellens-alien-game/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [Assign([Name('placeholder_1', Store(), lineno=22, col_offset=4, end_lineno=22, end_col_offset=24)], Constant(0, lineno=22, col_offset=27, end_lineno=22, end_col_offset=28), lineno=22, col_offset=4, end_lineno=22, end_col_offset=28), FunctionDef('placeholder_2', arguments([], [arg('self', lineno=24, col_offset=17, end_lineno=24, end_col_offset=21), arg('placeholder_3', lineno=24, col_offset=23, end_lineno=24, end_col_offset=35), arg('placeholder_4', lineno=24, col_offset=37, end_lineno=24, end_col_offset=49)], kwonlyargs=[], kw_defaults=[], defaults=[]), [AugAssign(Attribute(Name('placeholder_0', Load(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=13), 'placeholder_1', Store(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=34), Add(), Constant(1, lineno=37, col_offset=38, end_lineno=37, end_col_offset=39), lineno=37, col_offset=8, end_lineno=37, end_col_offset=39), Assign([Attribute(Name('self', Load(), lineno=39, col_offset=8, end_lineno=39, end_col_offset=12), 'placeholder_3', Store(), lineno=39, col_offset=8, end_lineno=39, end_col_offset=25)], Name('placeholder_3', Load(), lineno=39, col_offset=28, end_lineno=39, end_col_offset=40), lineno=39, col_offset=8, end_lineno=39, end_col_offset=40), Assign([Attribute(Name('self', Load(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=12), 'placeholder_4', Store(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=25)], Name('placeholder_4', Load(), lineno=40, col_offset=28, end_lineno=40, end_col_offset=40), lineno=40, col_offset=8, end_lineno=40, end_col_offset=40), Assign([Attribute(Name('self', Load(), lineno=41, col_offset=8, end_lineno=41, end_col_offset=12), 'placeholder_5', Store(), lineno=41, col_offset=8, end_lineno=41, end_col_offset=19)], Constant(3, lineno=41, col_offset=22, end_lineno=41, end_col_offset=23), lineno=41, col_offset=8, end_lineno=41, end_col_offset=23)], [], lineno=24, col_offset=4, end_lineno=41, end_col_offset=23), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=43, col_offset=12, end_lineno=43, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [AugAssign(Attribute(Name('self', Load(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=12), 'placeholder_5', Store(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=19), Sub(), Constant(1, lineno=52, col_offset=23, end_lineno=52, end_col_offset=24), lineno=52, col_offset=8, end_lineno=52, end_col_offset=24)], [], lineno=43, col_offset=4, end_lineno=52, end_col_offset=24), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=54, col_offset=17, end_lineno=54, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Attribute(Name('self', Load(), lineno=60, col_offset=15, end_lineno=60, end_col_offset=19), 'placeholder_5', Load(), lineno=60, col_offset=15, end_lineno=60, end_col_offset=26), [Gt()], [Constant(0, lineno=60, col_offset=29, end_lineno=60, end_col_offset=30)], lineno=60, col_offset=15, end_lineno=60, end_col_offset=30), lineno=60, col_offset=8, end_lineno=60, end_col_offset=30)], [], lineno=54, col_offset=4, end_lineno=60, end_col_offset=30), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=62, col_offset=17, end_lineno=62, end_col_offset=21), arg('placeholder_9', lineno=62, col_offset=23, end_lineno=62, end_col_offset=39), arg('placeholder_10', lineno=62, col_offset=41, end_lineno=62, end_col_offset=57)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=70, col_offset=8, end_lineno=70, end_col_offset=12), 'placeholder_3', Store(), lineno=70, col_offset=8, end_lineno=70, end_col_offset=25)], Name('placeholder_9', Load(), lineno=70, col_offset=28, end_lineno=70, end_col_offset=44), lineno=70, col_offset=8, end_lineno=70, end_col_offset=44), Assign([Attribute(Name('self', Load(), lineno=71, col_offset=8, end_lineno=71, end_col_offset=12), 'placeholder_4', Store(), lineno=71, col_offset=8, end_lineno=71, end_col_offset=25)], Name('placeholder_10', Load(), lineno=71, col_offset=28, end_lineno=71, end_col_offset=44), lineno=71, col_offset=8, end_lineno=71, end_col_offset=44)], [], lineno=62, col_offset=4, end_lineno=71, end_col_offset=44), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=73, col_offset=28, end_lineno=73, end_col_offset=32), arg('placeholder_12', lineno=73, col_offset=34, end_lineno=73, end_col_offset=39)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Pass(lineno=81, col_offset=8, end_lineno=81, end_col_offset=12)], [], lineno=73, col_offset=4, end_lineno=81, end_col_offset=12)], [], lineno=4, col_offset=0, end_lineno=81, end_col_offset=12), FunctionDef('placeholder_13', arguments([], [arg('placeholder_14', lineno=83, col_offset=26, end_lineno=83, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Call(Name('placeholder_0', Load(), lineno=90, col_offset=12, end_lineno=90, end_col_offset=17), [Subscript(Name('placeholder_15', Load(), lineno=90, col_offset=18, end_lineno=90, end_col_offset=26), Constant(0, lineno=90, col_offset=27, end_lineno=90, end_col_offset=28), Load(), lineno=90, col_offset=18, end_lineno=90, end_col_offset=29), Subscript(Name('placeholder_15', Load(), lineno=90, col_offset=31, end_lineno=90, end_col_offset=39), Constant(1, lineno=90, col_offset=40, end_lineno=90, end_col_offset=41), Load(), lineno=90, col_offset=31, end_lineno=90, end_col_offset=42)], [], lineno=90, col_offset=12, end_lineno=90, end_col_offset=43), [comprehension(Name('placeholder_15', Store(), lineno=90, col_offset=48, end_lineno=90, end_col_offset=56), Name('placeholder_14', Load(), lineno=90, col_offset=60, end_lineno=90, end_col_offset=69), [], 0)], lineno=90, col_offset=11, end_lineno=90, end_col_offset=70), lineno=90, col_offset=4, end_lineno=90, end_col_offset=70)], [], lineno=83, col_offset=0, end_lineno=90, end_col_offset=70)], []) \ No newline at end of file diff --git a/test/concept-ghost-gobble-arcade-game/.meta/config.json b/test/concept-ghost-gobble-arcade-game/.meta/config.json new file mode 100644 index 0000000..3b66b81 --- /dev/null +++ b/test/concept-ghost-gobble-arcade-game/.meta/config.json @@ -0,0 +1,20 @@ +{ + "authors": [ + "neenjaw" + ], + "contributors": [ + "cmccandless", + "BethanyG" + ], + "files": { + "solution": [ + "arcade_game.py" + ] + }, + "language_versions": ">=3.5", + "forked_from": [ + "elixir/pacman-rules" + ], + "icon": "matching-brackets", + "blurb": "Learn about bools by setting up the rules for the Ghost Gobble arcade game." +} diff --git a/test/concept-ghost-gobble-arcade-game/arcade_game.py b/test/concept-ghost-gobble-arcade-game/arcade_game.py new file mode 100644 index 0000000..1adb3e4 --- /dev/null +++ b/test/concept-ghost-gobble-arcade-game/arcade_game.py @@ -0,0 +1,46 @@ +"""Functions for implementing the rules of the classic arcade game Pac-Man.""" + + +def eat_ghost(power_pellet_active, touching_ghost): + """Verify that Pac-Man can eat a ghost if he is empowered by a power pellet. + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool - can the ghost be eaten? + """ + + return power_pellet_active and touching_ghost + + +def score(touching_power_pellet, touching_dot): + """Verify that Pac-Man has scored when a power pellet or dot has been eaten. + + :param touching_power_pellet: bool - is the player touching a power pellet? + :param touching_dot: bool - is the player touching a dot? + :return: bool - has the player scored or not? + """ + + return touching_power_pellet or touching_dot + + +def lose(power_pellet_active, touching_ghost): + """Trigger the game loop to end (GAME OVER) when Pac-Man touches a ghost without his power pellet. + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool - has the player lost the game? + """ + + return not power_pellet_active and touching_ghost + + +def win(has_eaten_all_dots, power_pellet_active, touching_ghost): + """Trigger the victory event when all dots have been eaten. + + :param has_eaten_all_dots: bool - has the player "eaten" all the dots? + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool - has the player won the game? + """ + + return has_eaten_all_dots and not lose(power_pellet_active, touching_ghost) diff --git a/test/concept-ghost-gobble-arcade-game/mapping.json b/test/concept-ghost-gobble-arcade-game/mapping.json new file mode 100644 index 0000000..ca51957 --- /dev/null +++ b/test/concept-ghost-gobble-arcade-game/mapping.json @@ -0,0 +1,11 @@ +{ + "placeholder_0": "eat_ghost", + "placeholder_1": "power_pellet_active", + "placeholder_2": "touching_ghost", + "placeholder_3": "score", + "placeholder_4": "touching_power_pellet", + "placeholder_5": "touching_dot", + "placeholder_6": "lose", + "placeholder_7": "win", + "placeholder_8": "has_eaten_all_dots" +} \ No newline at end of file diff --git a/test/concept-ghost-gobble-arcade-game/representation.json b/test/concept-ghost-gobble-arcade-game/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-ghost-gobble-arcade-game/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-ghost-gobble-arcade-game/representation.out b/test/concept-ghost-gobble-arcade-game/representation.out new file mode 100644 index 0000000..c0ab4d5 --- /dev/null +++ b/test/concept-ghost-gobble-arcade-game/representation.out @@ -0,0 +1,578 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return placeholder_1 and placeholder_2 + + +def placeholder_3(placeholder_4, placeholder_5): + return placeholder_4 or placeholder_5 + + +def placeholder_6(placeholder_1, placeholder_2): + return not placeholder_1 and placeholder_2 + + +def placeholder_7(placeholder_8, placeholder_1, placeholder_2): + return placeholder_8 and (not placeholder_6(placeholder_1, placeholder_2)) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions for implementing the rules of the classic arcade game Pac-Man.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=78), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=78), + FunctionDef( + 'eat_ghost', + arguments( + [], + [ + arg( + 'power_pellet_active', + lineno=4, + col_offset=14, + end_lineno=4, + end_col_offset=33), + arg( + 'touching_ghost', + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=49)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Verify that Pac-Man can eat a ghost if he is empowered by a power pellet.\n\n :param power_pellet_active: bool - does the player have an active power pellet?\n :param touching_ghost: bool - is the player touching a ghost?\n :return: bool - can the ghost be eaten?\n ', + lineno=5, + col_offset=4, + end_lineno=10, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=10, + end_col_offset=7), + Return( + BoolOp( + And(), + [ + Name( + 'power_pellet_active', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=30), + Name( + 'touching_ghost', + Load(), + lineno=12, + col_offset=35, + end_lineno=12, + end_col_offset=49)], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=49), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=49)], + [], + lineno=4, + col_offset=0, + end_lineno=12, + end_col_offset=49), + FunctionDef( + 'score', + arguments( + [], + [ + arg( + 'touching_power_pellet', + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=31), + arg( + 'touching_dot', + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Verify that Pac-Man has scored when a power pellet or dot has been eaten.\n\n :param touching_power_pellet: bool - is the player touching a power pellet?\n :param touching_dot: bool - is the player touching a dot?\n :return: bool - has the player scored or not?\n ', + lineno=16, + col_offset=4, + end_lineno=21, + end_col_offset=7), + lineno=16, + col_offset=4, + end_lineno=21, + end_col_offset=7), + Return( + BoolOp( + Or(), + [ + Name( + 'touching_power_pellet', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=32), + Name( + 'touching_dot', + Load(), + lineno=23, + col_offset=36, + end_lineno=23, + end_col_offset=48)], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=48), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=48)], + [], + lineno=15, + col_offset=0, + end_lineno=23, + end_col_offset=48), + FunctionDef( + 'lose', + arguments( + [], + [ + arg( + 'power_pellet_active', + lineno=26, + col_offset=9, + end_lineno=26, + end_col_offset=28), + arg( + 'touching_ghost', + lineno=26, + col_offset=30, + end_lineno=26, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Trigger the game loop to end (GAME OVER) when Pac-Man touches a ghost without his power pellet.\n\n :param power_pellet_active: bool - does the player have an active power pellet?\n :param touching_ghost: bool - is the player touching a ghost?\n :return: bool - has the player lost the game?\n ', + lineno=27, + col_offset=4, + end_lineno=32, + end_col_offset=7), + lineno=27, + col_offset=4, + end_lineno=32, + end_col_offset=7), + Return( + BoolOp( + And(), + [ + UnaryOp( + Not(), + Name( + 'power_pellet_active', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=34), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=34), + Name( + 'touching_ghost', + Load(), + lineno=34, + col_offset=39, + end_lineno=34, + end_col_offset=53)], + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=53), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=53)], + [], + lineno=26, + col_offset=0, + end_lineno=34, + end_col_offset=53), + FunctionDef( + 'win', + arguments( + [], + [ + arg( + 'has_eaten_all_dots', + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=26), + arg( + 'power_pellet_active', + lineno=37, + col_offset=28, + end_lineno=37, + end_col_offset=47), + arg( + 'touching_ghost', + lineno=37, + col_offset=49, + end_lineno=37, + end_col_offset=63)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Trigger the victory event when all dots have been eaten.\n\n :param has_eaten_all_dots: bool - has the player "eaten" all the dots?\n :param power_pellet_active: bool - does the player have an active power pellet?\n :param touching_ghost: bool - is the player touching a ghost?\n :return: bool - has the player won the game?\n ', + lineno=38, + col_offset=4, + end_lineno=44, + end_col_offset=7), + lineno=38, + col_offset=4, + end_lineno=44, + end_col_offset=7), + Return( + BoolOp( + And(), + [ + Name( + 'has_eaten_all_dots', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=29), + UnaryOp( + Not(), + Call( + Name( + 'lose', + Load(), + lineno=46, + col_offset=38, + end_lineno=46, + end_col_offset=42), + [ + Name( + 'power_pellet_active', + Load(), + lineno=46, + col_offset=43, + end_lineno=46, + end_col_offset=62), + Name( + 'touching_ghost', + Load(), + lineno=46, + col_offset=64, + end_lineno=46, + end_col_offset=78)], + [], + lineno=46, + col_offset=38, + end_lineno=46, + end_col_offset=79), + lineno=46, + col_offset=34, + end_lineno=46, + end_col_offset=79)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=79), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=79)], + [], + lineno=37, + col_offset=0, + end_lineno=46, + end_col_offset=79)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=14, + end_lineno=4, + end_col_offset=33), + arg( + 'placeholder_2', + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=49)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=30), + Name( + 'placeholder_2', + Load(), + lineno=12, + col_offset=35, + end_lineno=12, + end_col_offset=49)], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=49), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=49)], + [], + lineno=4, + col_offset=0, + end_lineno=12, + end_col_offset=49), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=31), + arg( + 'placeholder_5', + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + Or(), + [ + Name( + 'placeholder_4', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=32), + Name( + 'placeholder_5', + Load(), + lineno=23, + col_offset=36, + end_lineno=23, + end_col_offset=48)], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=48), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=48)], + [], + lineno=15, + col_offset=0, + end_lineno=23, + end_col_offset=48), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=26, + col_offset=9, + end_lineno=26, + end_col_offset=28), + arg( + 'placeholder_2', + lineno=26, + col_offset=30, + end_lineno=26, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + UnaryOp( + Not(), + Name( + 'placeholder_1', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=34), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=34), + Name( + 'placeholder_2', + Load(), + lineno=34, + col_offset=39, + end_lineno=34, + end_col_offset=53)], + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=53), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=53)], + [], + lineno=26, + col_offset=0, + end_lineno=34, + end_col_offset=53), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=26), + arg( + 'placeholder_1', + lineno=37, + col_offset=28, + end_lineno=37, + end_col_offset=47), + arg( + 'placeholder_2', + lineno=37, + col_offset=49, + end_lineno=37, + end_col_offset=63)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Name( + 'placeholder_8', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=29), + UnaryOp( + Not(), + Call( + Name( + 'placeholder_6', + Load(), + lineno=46, + col_offset=38, + end_lineno=46, + end_col_offset=42), + [ + Name( + 'placeholder_1', + Load(), + lineno=46, + col_offset=43, + end_lineno=46, + end_col_offset=62), + Name( + 'placeholder_2', + Load(), + lineno=46, + col_offset=64, + end_lineno=46, + end_col_offset=78)], + [], + lineno=46, + col_offset=38, + end_lineno=46, + end_col_offset=79), + lineno=46, + col_offset=34, + end_lineno=46, + end_col_offset=79)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=79), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=79)], + [], + lineno=37, + col_offset=0, + end_lineno=46, + end_col_offset=79)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-ghost-gobble-arcade-game/representation.txt b/test/concept-ghost-gobble-arcade-game/representation.txt new file mode 100644 index 0000000..801ac89 --- /dev/null +++ b/test/concept-ghost-gobble-arcade-game/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=14, end_lineno=4, end_col_offset=33), arg('placeholder_2', lineno=4, col_offset=35, end_lineno=4, end_col_offset=49)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Name('placeholder_1', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=30), Name('placeholder_2', Load(), lineno=12, col_offset=35, end_lineno=12, end_col_offset=49)], lineno=12, col_offset=11, end_lineno=12, end_col_offset=49), lineno=12, col_offset=4, end_lineno=12, end_col_offset=49)], [], lineno=4, col_offset=0, end_lineno=12, end_col_offset=49), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=15, col_offset=10, end_lineno=15, end_col_offset=31), arg('placeholder_5', lineno=15, col_offset=33, end_lineno=15, end_col_offset=45)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(Or(), [Name('placeholder_4', Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=32), Name('placeholder_5', Load(), lineno=23, col_offset=36, end_lineno=23, end_col_offset=48)], lineno=23, col_offset=11, end_lineno=23, end_col_offset=48), lineno=23, col_offset=4, end_lineno=23, end_col_offset=48)], [], lineno=15, col_offset=0, end_lineno=23, end_col_offset=48), FunctionDef('placeholder_6', arguments([], [arg('placeholder_1', lineno=26, col_offset=9, end_lineno=26, end_col_offset=28), arg('placeholder_2', lineno=26, col_offset=30, end_lineno=26, end_col_offset=44)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [UnaryOp(Not(), Name('placeholder_1', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=34), lineno=34, col_offset=11, end_lineno=34, end_col_offset=34), Name('placeholder_2', Load(), lineno=34, col_offset=39, end_lineno=34, end_col_offset=53)], lineno=34, col_offset=11, end_lineno=34, end_col_offset=53), lineno=34, col_offset=4, end_lineno=34, end_col_offset=53)], [], lineno=26, col_offset=0, end_lineno=34, end_col_offset=53), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=37, col_offset=8, end_lineno=37, end_col_offset=26), arg('placeholder_1', lineno=37, col_offset=28, end_lineno=37, end_col_offset=47), arg('placeholder_2', lineno=37, col_offset=49, end_lineno=37, end_col_offset=63)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Name('placeholder_8', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=29), UnaryOp(Not(), Call(Name('placeholder_6', Load(), lineno=46, col_offset=38, end_lineno=46, end_col_offset=42), [Name('placeholder_1', Load(), lineno=46, col_offset=43, end_lineno=46, end_col_offset=62), Name('placeholder_2', Load(), lineno=46, col_offset=64, end_lineno=46, end_col_offset=78)], [], lineno=46, col_offset=38, end_lineno=46, end_col_offset=79), lineno=46, col_offset=34, end_lineno=46, end_col_offset=79)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=79), lineno=46, col_offset=4, end_lineno=46, end_col_offset=79)], [], lineno=37, col_offset=0, end_lineno=46, end_col_offset=79)], []) \ No newline at end of file diff --git a/test/concept-guidos-gorgeous-lasagna/.meta/config.json b/test/concept-guidos-gorgeous-lasagna/.meta/config.json new file mode 100644 index 0000000..f6de0d5 --- /dev/null +++ b/test/concept-guidos-gorgeous-lasagna/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "lasagna.py" + ], + "test": [ + "lasagna_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "forked_from": [ + "csharp/lucians-luscious-lasagna", + "ruby/lasagna" + ], + "icon": "lasagna", + "blurb": "Learn the basics of Python by cooking Guido's Gorgeous Lasagna." +} diff --git a/test/concept-guidos-gorgeous-lasagna/lasagna.py b/test/concept-guidos-gorgeous-lasagna/lasagna.py new file mode 100644 index 0000000..ff0bff3 --- /dev/null +++ b/test/concept-guidos-gorgeous-lasagna/lasagna.py @@ -0,0 +1,50 @@ +"""Functions used in preparing Guido's gorgeous lasagna. + +Learn about Guido, the creator of the Python language: https://en.wikipedia.org/wiki/Guido_van_Rossum +""" + +# time the lasagna should be in the oven according to the cookbook. +EXPECTED_BAKE_TIME = 40 +PREPARATION_TIME = 2 + + +def bake_time_remaining(elapsed_bake_time): + """Calculate the bake time remaining. + + :param elapsed_bake_time: int - baking time already elapsed. + :return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'. + + Function that takes the actual minutes the lasagna has been in the oven as + an argument and returns how many minutes the lasagna still needs to bake + based on the `EXPECTED_BAKE_TIME`. + """ + + return EXPECTED_BAKE_TIME - elapsed_bake_time + + +def preparation_time_in_minutes(number_of_layers): + """Calculate the preparation time. + + :param number_of_layers: int - the number of lasagna layers made. + :return: int - amount of prep time (in minutes), based on 2 minutes per layer added. + + This function takes an integer representing the number of layers added to the dish, + calculating preparation time using a time of 2 minutes per layer added. + """ + + return number_of_layers * PREPARATION_TIME + + +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """Calculate the elapsed time. + + :param number_of_layers: int - the number of layers in the lasagna. + :param elapsed_bake_time: int - elapsed cooking time. + :return: int - total time elapsed (in in minutes) preparing and cooking. + + This function takes two integers representing the number of lasagna layers and the + time already spent baking and calculates the total elapsed minutes spent cooking the + lasagna. + """ + + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time diff --git a/test/concept-guidos-gorgeous-lasagna/mapping.json b/test/concept-guidos-gorgeous-lasagna/mapping.json new file mode 100644 index 0000000..a42bd78 --- /dev/null +++ b/test/concept-guidos-gorgeous-lasagna/mapping.json @@ -0,0 +1,9 @@ +{ + "placeholder_0": "EXPECTED_BAKE_TIME", + "placeholder_1": "PREPARATION_TIME", + "placeholder_2": "bake_time_remaining", + "placeholder_3": "elapsed_bake_time", + "placeholder_4": "preparation_time_in_minutes", + "placeholder_5": "number_of_layers", + "placeholder_6": "elapsed_time_in_minutes" +} \ No newline at end of file diff --git a/test/concept-guidos-gorgeous-lasagna/representation.json b/test/concept-guidos-gorgeous-lasagna/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-guidos-gorgeous-lasagna/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-guidos-gorgeous-lasagna/representation.out b/test/concept-guidos-gorgeous-lasagna/representation.out new file mode 100644 index 0000000..172bd1d --- /dev/null +++ b/test/concept-guidos-gorgeous-lasagna/representation.out @@ -0,0 +1,459 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = 40 +placeholder_1 = 2 + + +def placeholder_2(placeholder_3): + return placeholder_0 - placeholder_3 + + +def placeholder_4(placeholder_5): + return placeholder_5 * placeholder_1 + + +def placeholder_6(placeholder_5, placeholder_3): + return placeholder_4(placeholder_5) + placeholder_3 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + "Functions used in preparing Guido's gorgeous lasagna.\n\nLearn about Guido, the creator of the Python language: https://en.wikipedia.org/wiki/Guido_van_Rossum\n", + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + Assign( + [ + Name( + 'EXPECTED_BAKE_TIME', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=18)], + Constant( + 40, + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=23), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=23), + Assign( + [ + Name( + 'PREPARATION_TIME', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=16)], + Constant( + 2, + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=20), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=20), + FunctionDef( + 'bake_time_remaining', + arguments( + [], + [ + arg( + 'elapsed_bake_time', + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Calculate the bake time remaining.\n\n :param elapsed_bake_time: int - baking time already elapsed.\n :return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'.\n\n Function that takes the actual minutes the lasagna has been in the oven as\n an argument and returns how many minutes the lasagna still needs to bake\n based on the `EXPECTED_BAKE_TIME`.\n ", + lineno=12, + col_offset=4, + end_lineno=20, + end_col_offset=7), + lineno=12, + col_offset=4, + end_lineno=20, + end_col_offset=7), + Return( + BinOp( + Name( + 'EXPECTED_BAKE_TIME', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=29), + Sub(), + Name( + 'elapsed_bake_time', + Load(), + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=49), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=49), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=49)], + [], + lineno=11, + col_offset=0, + end_lineno=22, + end_col_offset=49), + FunctionDef( + 'preparation_time_in_minutes', + arguments( + [], + [ + arg( + 'number_of_layers', + lineno=25, + col_offset=32, + end_lineno=25, + end_col_offset=48)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Calculate the preparation time.\n\n :param number_of_layers: int - the number of lasagna layers made.\n :return: int - amount of prep time (in minutes), based on 2 minutes per layer added.\n\n This function takes an integer representing the number of layers added to the dish,\n calculating preparation time using a time of 2 minutes per layer added.\n ', + lineno=26, + col_offset=4, + end_lineno=33, + end_col_offset=7), + lineno=26, + col_offset=4, + end_lineno=33, + end_col_offset=7), + Return( + BinOp( + Name( + 'number_of_layers', + Load(), + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=27), + Mult(), + Name( + 'PREPARATION_TIME', + Load(), + lineno=35, + col_offset=30, + end_lineno=35, + end_col_offset=46), + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=46), + lineno=35, + col_offset=4, + end_lineno=35, + end_col_offset=46)], + [], + lineno=25, + col_offset=0, + end_lineno=35, + end_col_offset=46), + FunctionDef( + 'elapsed_time_in_minutes', + arguments( + [], + [ + arg( + 'number_of_layers', + lineno=38, + col_offset=28, + end_lineno=38, + end_col_offset=44), + arg( + 'elapsed_bake_time', + lineno=38, + col_offset=46, + end_lineno=38, + end_col_offset=63)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Calculate the elapsed time.\n\n :param number_of_layers: int - the number of layers in the lasagna.\n :param elapsed_bake_time: int - elapsed cooking time.\n :return: int - total time elapsed (in in minutes) preparing and cooking.\n\n This function takes two integers representing the number of lasagna layers and the\n time already spent baking and calculates the total elapsed minutes spent cooking the\n lasagna.\n ', + lineno=39, + col_offset=4, + end_lineno=48, + end_col_offset=7), + lineno=39, + col_offset=4, + end_lineno=48, + end_col_offset=7), + Return( + BinOp( + Call( + Name( + 'preparation_time_in_minutes', + Load(), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=38), + [ + Name( + 'number_of_layers', + Load(), + lineno=50, + col_offset=39, + end_lineno=50, + end_col_offset=55)], + [], + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=56), + Add(), + Name( + 'elapsed_bake_time', + Load(), + lineno=50, + col_offset=59, + end_lineno=50, + end_col_offset=76), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=76), + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=76)], + [], + lineno=38, + col_offset=0, + end_lineno=50, + end_col_offset=76)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=18)], + Constant( + 40, + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=23), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=23), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=16)], + Constant( + 2, + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=20), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=20), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_0', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=29), + Sub(), + Name( + 'placeholder_3', + Load(), + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=49), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=49), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=49)], + [], + lineno=11, + col_offset=0, + end_lineno=22, + end_col_offset=49), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=25, + col_offset=32, + end_lineno=25, + end_col_offset=48)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=27), + Mult(), + Name( + 'placeholder_1', + Load(), + lineno=35, + col_offset=30, + end_lineno=35, + end_col_offset=46), + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=46), + lineno=35, + col_offset=4, + end_lineno=35, + end_col_offset=46)], + [], + lineno=25, + col_offset=0, + end_lineno=35, + end_col_offset=46), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=38, + col_offset=28, + end_lineno=38, + end_col_offset=44), + arg( + 'placeholder_3', + lineno=38, + col_offset=46, + end_lineno=38, + end_col_offset=63)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Call( + Name( + 'placeholder_4', + Load(), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=38), + [ + Name( + 'placeholder_5', + Load(), + lineno=50, + col_offset=39, + end_lineno=50, + end_col_offset=55)], + [], + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=56), + Add(), + Name( + 'placeholder_3', + Load(), + lineno=50, + col_offset=59, + end_lineno=50, + end_col_offset=76), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=76), + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=76)], + [], + lineno=38, + col_offset=0, + end_lineno=50, + end_col_offset=76)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-guidos-gorgeous-lasagna/representation.txt b/test/concept-guidos-gorgeous-lasagna/representation.txt new file mode 100644 index 0000000..0ef77ff --- /dev/null +++ b/test/concept-guidos-gorgeous-lasagna/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=7, col_offset=0, end_lineno=7, end_col_offset=18)], Constant(40, lineno=7, col_offset=21, end_lineno=7, end_col_offset=23), lineno=7, col_offset=0, end_lineno=7, end_col_offset=23), Assign([Name('placeholder_1', Store(), lineno=8, col_offset=0, end_lineno=8, end_col_offset=16)], Constant(2, lineno=8, col_offset=19, end_lineno=8, end_col_offset=20), lineno=8, col_offset=0, end_lineno=8, end_col_offset=20), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=11, col_offset=24, end_lineno=11, end_col_offset=41)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_0', Load(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=29), Sub(), Name('placeholder_3', Load(), lineno=22, col_offset=32, end_lineno=22, end_col_offset=49), lineno=22, col_offset=11, end_lineno=22, end_col_offset=49), lineno=22, col_offset=4, end_lineno=22, end_col_offset=49)], [], lineno=11, col_offset=0, end_lineno=22, end_col_offset=49), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=25, col_offset=32, end_lineno=25, end_col_offset=48)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_5', Load(), lineno=35, col_offset=11, end_lineno=35, end_col_offset=27), Mult(), Name('placeholder_1', Load(), lineno=35, col_offset=30, end_lineno=35, end_col_offset=46), lineno=35, col_offset=11, end_lineno=35, end_col_offset=46), lineno=35, col_offset=4, end_lineno=35, end_col_offset=46)], [], lineno=25, col_offset=0, end_lineno=35, end_col_offset=46), FunctionDef('placeholder_6', arguments([], [arg('placeholder_5', lineno=38, col_offset=28, end_lineno=38, end_col_offset=44), arg('placeholder_3', lineno=38, col_offset=46, end_lineno=38, end_col_offset=63)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Call(Name('placeholder_4', Load(), lineno=50, col_offset=11, end_lineno=50, end_col_offset=38), [Name('placeholder_5', Load(), lineno=50, col_offset=39, end_lineno=50, end_col_offset=55)], [], lineno=50, col_offset=11, end_lineno=50, end_col_offset=56), Add(), Name('placeholder_3', Load(), lineno=50, col_offset=59, end_lineno=50, end_col_offset=76), lineno=50, col_offset=11, end_lineno=50, end_col_offset=76), lineno=50, col_offset=4, end_lineno=50, end_col_offset=76)], [], lineno=38, col_offset=0, end_lineno=50, end_col_offset=76)], []) \ No newline at end of file diff --git a/test/concept-inventory-management/.meta/config.json b/test/concept-inventory-management/.meta/config.json new file mode 100644 index 0000000..c08624a --- /dev/null +++ b/test/concept-inventory-management/.meta/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "j08k" + ], + "contributors": [ + "valentin-p", + "bethanyG", + "mukeshgurpude", + "kotp" + ], + "files": { + "solution": [ + "dicts.py" + ], + "test": [ + "dicts_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "icon": "high-scores", + "blurb": "Learn about dicts by managing warehouse inventory." +} diff --git a/test/concept-inventory-management/dicts.py b/test/concept-inventory-management/dicts.py new file mode 100644 index 0000000..ac36ce9 --- /dev/null +++ b/test/concept-inventory-management/dicts.py @@ -0,0 +1,68 @@ +"""Functions to keep track and alter inventory.""" + + +def create_inventory(items): + """Create a dict that tracks the amount (count) of each element on the `items` list. + + :param items: list - list of items to create an inventory from. + :return: dict - the inventory dictionary. + """ + + inventory = {} + add_items(inventory, items) + return inventory + + +def add_items(inventory, items): + """Add or increment items in inventory using elements from the items `list`. + + :param inventory: dict - dictionary of existing inventory. + :param items: list - list of items to update the inventory with. + :return: dict - the inventory updated with the new items. + """ + + for item in items: + inventory.setdefault(item, 0) + inventory[item] += 1 + return inventory + + +def decrement_items(inventory, items): + """Decrement items in inventory using elements from the `items` list. + + :param inventory: dict - inventory dictionary. + :param items: list - list of items to decrement from the inventory. + :return: dict - updated inventory with items decremented. + """ + + for item in items: + if item in inventory: + inventory[item] = max(inventory[item] - 1, 0) + return inventory + + +def remove_item(inventory, item): + """Remove item from inventory if it matches `item` string. + + :param inventory: dict - inventory dictionary. + :param item: str - item to remove from the inventory. + :return: dict - updated inventory with item removed. Current inventory if item does not match. + """ + + if item in inventory: + inventory.pop(item) + return inventory + + +def list_inventory(inventory): + """Create a list containing all (item_name, item_count) pairs in inventory. + + :param inventory: dict - an inventory dictionary. + :return: list of tuples - list of key, value pairs from the inventory dictionary. + """ + + output = [] + for item in sorted(inventory.items()): + if item[1] > 0: + output.append(item) + return output diff --git a/test/concept-inventory-management/mapping.json b/test/concept-inventory-management/mapping.json new file mode 100644 index 0000000..6f7c5a2 --- /dev/null +++ b/test/concept-inventory-management/mapping.json @@ -0,0 +1,11 @@ +{ + "placeholder_0": "create_inventory", + "placeholder_1": "items", + "placeholder_2": "inventory", + "placeholder_3": "add_items", + "placeholder_4": "item", + "placeholder_5": "decrement_items", + "placeholder_6": "remove_item", + "placeholder_7": "list_inventory", + "placeholder_8": "output" +} \ No newline at end of file diff --git a/test/concept-inventory-management/representation.json b/test/concept-inventory-management/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-inventory-management/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-inventory-management/representation.out b/test/concept-inventory-management/representation.out new file mode 100644 index 0000000..99134eb --- /dev/null +++ b/test/concept-inventory-management/representation.out @@ -0,0 +1,1423 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = {} + add_items(placeholder_2, placeholder_1) + return placeholder_2 + + +def placeholder_3(placeholder_2, placeholder_1): + for placeholder_4 in placeholder_1: + placeholder_2.setdefault(placeholder_4, 0) + placeholder_2[placeholder_4] += 1 + return placeholder_2 + + +def placeholder_5(placeholder_2, placeholder_1): + for placeholder_4 in placeholder_1: + if placeholder_4 in placeholder_2: + placeholder_2[placeholder_4] = max(placeholder_2[placeholder_4] - 1, 0) + return placeholder_2 + + +def placeholder_6(placeholder_2, placeholder_4): + if placeholder_4 in placeholder_2: + placeholder_2.pop(placeholder_4) + return placeholder_2 + + +def placeholder_7(placeholder_2): + placeholder_8 = [] + for placeholder_4 in sorted(placeholder_2.placeholder_1()): + if placeholder_4[1] > 0: + placeholder_8.append(placeholder_4) + return placeholder_8 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to keep track and alter inventory.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=50), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=50), + FunctionDef( + 'create_inventory', + arguments( + [], + [ + arg( + 'items', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Create a dict that tracks the amount (count) of each element on the `items` list.\n\n :param items: list - list of items to create an inventory from.\n :return: dict - the inventory dictionary.\n ', + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + Assign( + [ + Name( + 'inventory', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=13)], + Dict( + [], + [], + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=18), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=18), + Expr( + Call( + Name( + 'add_items', + Load(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=13), + [ + Name( + 'inventory', + Load(), + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=23), + Name( + 'items', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=30)], + [], + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=31), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=31), + Return( + Name( + 'inventory', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=20), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=20)], + [], + lineno=4, + col_offset=0, + end_lineno=13, + end_col_offset=20), + FunctionDef( + 'add_items', + arguments( + [], + [ + arg( + 'inventory', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=23), + arg( + 'items', + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Add or increment items in inventory using elements from the items `list`.\n\n :param inventory: dict - dictionary of existing inventory.\n :param items: list - list of items to update the inventory with.\n :return: dict - the inventory updated with the new items.\n ', + lineno=17, + col_offset=4, + end_lineno=22, + end_col_offset=7), + lineno=17, + col_offset=4, + end_lineno=22, + end_col_offset=7), + For( + Name( + 'item', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12), + Name( + 'items', + Load(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=21), + [ + Expr( + Call( + Attribute( + Name( + 'inventory', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=17), + 'setdefault', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=28), + [ + Name( + 'item', + Load(), + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=33), + Constant( + 0, + lineno=25, + col_offset=35, + end_lineno=25, + end_col_offset=36)], + [], + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=37), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=37), + AugAssign( + Subscript( + Name( + 'inventory', + Load(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=17), + Name( + 'item', + Load(), + lineno=26, + col_offset=18, + end_lineno=26, + end_col_offset=22), + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=26, + col_offset=27, + end_lineno=26, + end_col_offset=28), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=28)], + [], + lineno=24, + col_offset=4, + end_lineno=26, + end_col_offset=28), + Return( + Name( + 'inventory', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=20), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=20)], + [], + lineno=16, + col_offset=0, + end_lineno=27, + end_col_offset=20), + FunctionDef( + 'decrement_items', + arguments( + [], + [ + arg( + 'inventory', + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=29), + arg( + 'items', + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Decrement items in inventory using elements from the `items` list.\n\n :param inventory: dict - inventory dictionary.\n :param items: list - list of items to decrement from the inventory.\n :return: dict - updated inventory with items decremented.\n ', + lineno=31, + col_offset=4, + end_lineno=36, + end_col_offset=7), + lineno=31, + col_offset=4, + end_lineno=36, + end_col_offset=7), + For( + Name( + 'item', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=12), + Name( + 'items', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=21), + [ + If( + Compare( + Name( + 'item', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=15), + [ + In()], + [ + Name( + 'inventory', + Load(), + lineno=39, + col_offset=19, + end_lineno=39, + end_col_offset=28)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=28), + [ + Assign( + [ + Subscript( + Name( + 'inventory', + Load(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=21), + Name( + 'item', + Load(), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=26), + Store(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=27)], + Call( + Name( + 'max', + Load(), + lineno=40, + col_offset=30, + end_lineno=40, + end_col_offset=33), + [ + BinOp( + Subscript( + Name( + 'inventory', + Load(), + lineno=40, + col_offset=34, + end_lineno=40, + end_col_offset=43), + Name( + 'item', + Load(), + lineno=40, + col_offset=44, + end_lineno=40, + end_col_offset=48), + Load(), + lineno=40, + col_offset=34, + end_lineno=40, + end_col_offset=49), + Sub(), + Constant( + 1, + lineno=40, + col_offset=52, + end_lineno=40, + end_col_offset=53), + lineno=40, + col_offset=34, + end_lineno=40, + end_col_offset=53), + Constant( + 0, + lineno=40, + col_offset=55, + end_lineno=40, + end_col_offset=56)], + [], + lineno=40, + col_offset=30, + end_lineno=40, + end_col_offset=57), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=57)], + [], + lineno=39, + col_offset=8, + end_lineno=40, + end_col_offset=57)], + [], + lineno=38, + col_offset=4, + end_lineno=40, + end_col_offset=57), + Return( + Name( + 'inventory', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=20), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=20)], + [], + lineno=30, + col_offset=0, + end_lineno=41, + end_col_offset=20), + FunctionDef( + 'remove_item', + arguments( + [], + [ + arg( + 'inventory', + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=25), + arg( + 'item', + lineno=44, + col_offset=27, + end_lineno=44, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Remove item from inventory if it matches `item` string.\n\n :param inventory: dict - inventory dictionary.\n :param item: str - item to remove from the inventory.\n :return: dict - updated inventory with item removed. Current inventory if item does not match.\n ', + lineno=45, + col_offset=4, + end_lineno=50, + end_col_offset=7), + lineno=45, + col_offset=4, + end_lineno=50, + end_col_offset=7), + If( + Compare( + Name( + 'item', + Load(), + lineno=52, + col_offset=7, + end_lineno=52, + end_col_offset=11), + [ + In()], + [ + Name( + 'inventory', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=24)], + lineno=52, + col_offset=7, + end_lineno=52, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'inventory', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=17), + 'pop', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=21), + [ + Name( + 'item', + Load(), + lineno=53, + col_offset=22, + end_lineno=53, + end_col_offset=26)], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=27), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=27)], + [], + lineno=52, + col_offset=4, + end_lineno=53, + end_col_offset=27), + Return( + Name( + 'inventory', + Load(), + lineno=54, + col_offset=11, + end_lineno=54, + end_col_offset=20), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=20)], + [], + lineno=44, + col_offset=0, + end_lineno=54, + end_col_offset=20), + FunctionDef( + 'list_inventory', + arguments( + [], + [ + arg( + 'inventory', + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Create a list containing all (item_name, item_count) pairs in inventory.\n\n :param inventory: dict - an inventory dictionary.\n :return: list of tuples - list of key, value pairs from the inventory dictionary.\n ', + lineno=58, + col_offset=4, + end_lineno=62, + end_col_offset=7), + lineno=58, + col_offset=4, + end_lineno=62, + end_col_offset=7), + Assign( + [ + Name( + 'output', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=10)], + List( + [], + Load(), + lineno=64, + col_offset=13, + end_lineno=64, + end_col_offset=15), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=15), + For( + Name( + 'item', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=12), + Call( + Name( + 'sorted', + Load(), + lineno=65, + col_offset=16, + end_lineno=65, + end_col_offset=22), + [ + Call( + Attribute( + Name( + 'inventory', + Load(), + lineno=65, + col_offset=23, + end_lineno=65, + end_col_offset=32), + 'items', + Load(), + lineno=65, + col_offset=23, + end_lineno=65, + end_col_offset=38), + [], + [], + lineno=65, + col_offset=23, + end_lineno=65, + end_col_offset=40)], + [], + lineno=65, + col_offset=16, + end_lineno=65, + end_col_offset=41), + [ + If( + Compare( + Subscript( + Name( + 'item', + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=15), + Constant( + 1, + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=17), + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=18), + [ + Gt()], + [ + Constant( + 0, + lineno=66, + col_offset=21, + end_lineno=66, + end_col_offset=22)], + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=22), + [ + Expr( + Call( + Attribute( + Name( + 'output', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=18), + 'append', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=25), + [ + Name( + 'item', + Load(), + lineno=67, + col_offset=26, + end_lineno=67, + end_col_offset=30)], + [], + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=31), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=31)], + [], + lineno=66, + col_offset=8, + end_lineno=67, + end_col_offset=31)], + [], + lineno=65, + col_offset=4, + end_lineno=67, + end_col_offset=31), + Return( + Name( + 'output', + Load(), + lineno=68, + col_offset=11, + end_lineno=68, + end_col_offset=17), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=17)], + [], + lineno=57, + col_offset=0, + end_lineno=68, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=13)], + Dict( + [], + [], + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=18), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=18), + Expr( + Call( + Name( + 'add_items', + Load(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=13), + [ + Name( + 'placeholder_2', + Load(), + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=23), + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=30)], + [], + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=31), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=31), + Return( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=20), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=20)], + [], + lineno=4, + col_offset=0, + end_lineno=13, + end_col_offset=20), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=23), + arg( + 'placeholder_1', + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_4', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12), + Name( + 'placeholder_1', + Load(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=21), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=17), + 'setdefault', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=28), + [ + Name( + 'placeholder_4', + Load(), + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=33), + Constant( + 0, + lineno=25, + col_offset=35, + end_lineno=25, + end_col_offset=36)], + [], + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=37), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=37), + AugAssign( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=17), + Name( + 'placeholder_4', + Load(), + lineno=26, + col_offset=18, + end_lineno=26, + end_col_offset=22), + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=26, + col_offset=27, + end_lineno=26, + end_col_offset=28), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=28)], + [], + lineno=24, + col_offset=4, + end_lineno=26, + end_col_offset=28), + Return( + Name( + 'placeholder_2', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=20), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=20)], + [], + lineno=16, + col_offset=0, + end_lineno=27, + end_col_offset=20), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=29), + arg( + 'placeholder_1', + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_4', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=12), + Name( + 'placeholder_1', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=21), + [ + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=15), + [ + In()], + [ + Name( + 'placeholder_2', + Load(), + lineno=39, + col_offset=19, + end_lineno=39, + end_col_offset=28)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=28), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=21), + Name( + 'placeholder_4', + Load(), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=26), + Store(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=27)], + Call( + Name( + 'max', + Load(), + lineno=40, + col_offset=30, + end_lineno=40, + end_col_offset=33), + [ + BinOp( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=40, + col_offset=34, + end_lineno=40, + end_col_offset=43), + Name( + 'placeholder_4', + Load(), + lineno=40, + col_offset=44, + end_lineno=40, + end_col_offset=48), + Load(), + lineno=40, + col_offset=34, + end_lineno=40, + end_col_offset=49), + Sub(), + Constant( + 1, + lineno=40, + col_offset=52, + end_lineno=40, + end_col_offset=53), + lineno=40, + col_offset=34, + end_lineno=40, + end_col_offset=53), + Constant( + 0, + lineno=40, + col_offset=55, + end_lineno=40, + end_col_offset=56)], + [], + lineno=40, + col_offset=30, + end_lineno=40, + end_col_offset=57), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=57)], + [], + lineno=39, + col_offset=8, + end_lineno=40, + end_col_offset=57)], + [], + lineno=38, + col_offset=4, + end_lineno=40, + end_col_offset=57), + Return( + Name( + 'placeholder_2', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=20), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=20)], + [], + lineno=30, + col_offset=0, + end_lineno=41, + end_col_offset=20), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=25), + arg( + 'placeholder_4', + lineno=44, + col_offset=27, + end_lineno=44, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=52, + col_offset=7, + end_lineno=52, + end_col_offset=11), + [ + In()], + [ + Name( + 'placeholder_2', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=24)], + lineno=52, + col_offset=7, + end_lineno=52, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=17), + 'pop', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=21), + [ + Name( + 'placeholder_4', + Load(), + lineno=53, + col_offset=22, + end_lineno=53, + end_col_offset=26)], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=27), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=27)], + [], + lineno=52, + col_offset=4, + end_lineno=53, + end_col_offset=27), + Return( + Name( + 'placeholder_2', + Load(), + lineno=54, + col_offset=11, + end_lineno=54, + end_col_offset=20), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=20)], + [], + lineno=44, + col_offset=0, + end_lineno=54, + end_col_offset=20), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=10)], + List( + [], + Load(), + lineno=64, + col_offset=13, + end_lineno=64, + end_col_offset=15), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=15), + For( + Name( + 'placeholder_4', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=12), + Call( + Name( + 'sorted', + Load(), + lineno=65, + col_offset=16, + end_lineno=65, + end_col_offset=22), + [ + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=65, + col_offset=23, + end_lineno=65, + end_col_offset=32), + 'placeholder_1', + Load(), + lineno=65, + col_offset=23, + end_lineno=65, + end_col_offset=38), + [], + [], + lineno=65, + col_offset=23, + end_lineno=65, + end_col_offset=40)], + [], + lineno=65, + col_offset=16, + end_lineno=65, + end_col_offset=41), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=15), + Constant( + 1, + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=17), + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=18), + [ + Gt()], + [ + Constant( + 0, + lineno=66, + col_offset=21, + end_lineno=66, + end_col_offset=22)], + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=22), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=18), + 'append', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=25), + [ + Name( + 'placeholder_4', + Load(), + lineno=67, + col_offset=26, + end_lineno=67, + end_col_offset=30)], + [], + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=31), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=31)], + [], + lineno=66, + col_offset=8, + end_lineno=67, + end_col_offset=31)], + [], + lineno=65, + col_offset=4, + end_lineno=67, + end_col_offset=31), + Return( + Name( + 'placeholder_8', + Load(), + lineno=68, + col_offset=11, + end_lineno=68, + end_col_offset=17), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=17)], + [], + lineno=57, + col_offset=0, + end_lineno=68, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-inventory-management/representation.txt b/test/concept-inventory-management/representation.txt new file mode 100644 index 0000000..9bf0c48 --- /dev/null +++ b/test/concept-inventory-management/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=21, end_lineno=4, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=11, col_offset=4, end_lineno=11, end_col_offset=13)], Dict([], [], lineno=11, col_offset=16, end_lineno=11, end_col_offset=18), lineno=11, col_offset=4, end_lineno=11, end_col_offset=18), Expr(Call(Name('add_items', Load(), lineno=12, col_offset=4, end_lineno=12, end_col_offset=13), [Name('placeholder_2', Load(), lineno=12, col_offset=14, end_lineno=12, end_col_offset=23), Name('placeholder_1', Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=30)], [], lineno=12, col_offset=4, end_lineno=12, end_col_offset=31), lineno=12, col_offset=4, end_lineno=12, end_col_offset=31), Return(Name('placeholder_2', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=20), lineno=13, col_offset=4, end_lineno=13, end_col_offset=20)], [], lineno=4, col_offset=0, end_lineno=13, end_col_offset=20), FunctionDef('placeholder_3', arguments([], [arg('placeholder_2', lineno=16, col_offset=14, end_lineno=16, end_col_offset=23), arg('placeholder_1', lineno=16, col_offset=25, end_lineno=16, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_4', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=12), Name('placeholder_1', Load(), lineno=24, col_offset=16, end_lineno=24, end_col_offset=21), [Expr(Call(Attribute(Name('placeholder_2', Load(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=17), 'setdefault', Load(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=28), [Name('placeholder_4', Load(), lineno=25, col_offset=29, end_lineno=25, end_col_offset=33), Constant(0, lineno=25, col_offset=35, end_lineno=25, end_col_offset=36)], [], lineno=25, col_offset=8, end_lineno=25, end_col_offset=37), lineno=25, col_offset=8, end_lineno=25, end_col_offset=37), AugAssign(Subscript(Name('placeholder_2', Load(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=17), Name('placeholder_4', Load(), lineno=26, col_offset=18, end_lineno=26, end_col_offset=22), Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=23), Add(), Constant(1, lineno=26, col_offset=27, end_lineno=26, end_col_offset=28), lineno=26, col_offset=8, end_lineno=26, end_col_offset=28)], [], lineno=24, col_offset=4, end_lineno=26, end_col_offset=28), Return(Name('placeholder_2', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=20), lineno=27, col_offset=4, end_lineno=27, end_col_offset=20)], [], lineno=16, col_offset=0, end_lineno=27, end_col_offset=20), FunctionDef('placeholder_5', arguments([], [arg('placeholder_2', lineno=30, col_offset=20, end_lineno=30, end_col_offset=29), arg('placeholder_1', lineno=30, col_offset=31, end_lineno=30, end_col_offset=36)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_4', Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=12), Name('placeholder_1', Load(), lineno=38, col_offset=16, end_lineno=38, end_col_offset=21), [If(Compare(Name('placeholder_4', Load(), lineno=39, col_offset=11, end_lineno=39, end_col_offset=15), [In()], [Name('placeholder_2', Load(), lineno=39, col_offset=19, end_lineno=39, end_col_offset=28)], lineno=39, col_offset=11, end_lineno=39, end_col_offset=28), [Assign([Subscript(Name('placeholder_2', Load(), lineno=40, col_offset=12, end_lineno=40, end_col_offset=21), Name('placeholder_4', Load(), lineno=40, col_offset=22, end_lineno=40, end_col_offset=26), Store(), lineno=40, col_offset=12, end_lineno=40, end_col_offset=27)], Call(Name('max', Load(), lineno=40, col_offset=30, end_lineno=40, end_col_offset=33), [BinOp(Subscript(Name('placeholder_2', Load(), lineno=40, col_offset=34, end_lineno=40, end_col_offset=43), Name('placeholder_4', Load(), lineno=40, col_offset=44, end_lineno=40, end_col_offset=48), Load(), lineno=40, col_offset=34, end_lineno=40, end_col_offset=49), Sub(), Constant(1, lineno=40, col_offset=52, end_lineno=40, end_col_offset=53), lineno=40, col_offset=34, end_lineno=40, end_col_offset=53), Constant(0, lineno=40, col_offset=55, end_lineno=40, end_col_offset=56)], [], lineno=40, col_offset=30, end_lineno=40, end_col_offset=57), lineno=40, col_offset=12, end_lineno=40, end_col_offset=57)], [], lineno=39, col_offset=8, end_lineno=40, end_col_offset=57)], [], lineno=38, col_offset=4, end_lineno=40, end_col_offset=57), Return(Name('placeholder_2', Load(), lineno=41, col_offset=11, end_lineno=41, end_col_offset=20), lineno=41, col_offset=4, end_lineno=41, end_col_offset=20)], [], lineno=30, col_offset=0, end_lineno=41, end_col_offset=20), FunctionDef('placeholder_6', arguments([], [arg('placeholder_2', lineno=44, col_offset=16, end_lineno=44, end_col_offset=25), arg('placeholder_4', lineno=44, col_offset=27, end_lineno=44, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_4', Load(), lineno=52, col_offset=7, end_lineno=52, end_col_offset=11), [In()], [Name('placeholder_2', Load(), lineno=52, col_offset=15, end_lineno=52, end_col_offset=24)], lineno=52, col_offset=7, end_lineno=52, end_col_offset=24), [Expr(Call(Attribute(Name('placeholder_2', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=17), 'pop', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=21), [Name('placeholder_4', Load(), lineno=53, col_offset=22, end_lineno=53, end_col_offset=26)], [], lineno=53, col_offset=8, end_lineno=53, end_col_offset=27), lineno=53, col_offset=8, end_lineno=53, end_col_offset=27)], [], lineno=52, col_offset=4, end_lineno=53, end_col_offset=27), Return(Name('placeholder_2', Load(), lineno=54, col_offset=11, end_lineno=54, end_col_offset=20), lineno=54, col_offset=4, end_lineno=54, end_col_offset=20)], [], lineno=44, col_offset=0, end_lineno=54, end_col_offset=20), FunctionDef('placeholder_7', arguments([], [arg('placeholder_2', lineno=57, col_offset=19, end_lineno=57, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=64, col_offset=4, end_lineno=64, end_col_offset=10)], List([], Load(), lineno=64, col_offset=13, end_lineno=64, end_col_offset=15), lineno=64, col_offset=4, end_lineno=64, end_col_offset=15), For(Name('placeholder_4', Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=12), Call(Name('sorted', Load(), lineno=65, col_offset=16, end_lineno=65, end_col_offset=22), [Call(Attribute(Name('placeholder_2', Load(), lineno=65, col_offset=23, end_lineno=65, end_col_offset=32), 'placeholder_1', Load(), lineno=65, col_offset=23, end_lineno=65, end_col_offset=38), [], [], lineno=65, col_offset=23, end_lineno=65, end_col_offset=40)], [], lineno=65, col_offset=16, end_lineno=65, end_col_offset=41), [If(Compare(Subscript(Name('placeholder_4', Load(), lineno=66, col_offset=11, end_lineno=66, end_col_offset=15), Constant(1, lineno=66, col_offset=16, end_lineno=66, end_col_offset=17), Load(), lineno=66, col_offset=11, end_lineno=66, end_col_offset=18), [Gt()], [Constant(0, lineno=66, col_offset=21, end_lineno=66, end_col_offset=22)], lineno=66, col_offset=11, end_lineno=66, end_col_offset=22), [Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=67, col_offset=12, end_lineno=67, end_col_offset=18), 'append', Load(), lineno=67, col_offset=12, end_lineno=67, end_col_offset=25), [Name('placeholder_4', Load(), lineno=67, col_offset=26, end_lineno=67, end_col_offset=30)], [], lineno=67, col_offset=12, end_lineno=67, end_col_offset=31), lineno=67, col_offset=12, end_lineno=67, end_col_offset=31)], [], lineno=66, col_offset=8, end_lineno=67, end_col_offset=31)], [], lineno=65, col_offset=4, end_lineno=67, end_col_offset=31), Return(Name('placeholder_8', Load(), lineno=68, col_offset=11, end_lineno=68, end_col_offset=17), lineno=68, col_offset=4, end_lineno=68, end_col_offset=17)], [], lineno=57, col_offset=0, end_lineno=68, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/concept-little-sisters-essay/.meta/config.json b/test/concept-little-sisters-essay/.meta/config.json new file mode 100644 index 0000000..3cb7626 --- /dev/null +++ b/test/concept-little-sisters-essay/.meta/config.json @@ -0,0 +1,16 @@ +{ + "authors": [ + "kimolivia" + ], + "contributors": [ + "valentin-p", + "BethanyG" + ], + "files": { + "solution": [ + "string_methods.py" + ] + }, + "icon": "anagrams", + "blurb": "Learn about string methods while improving your little sister's school essay." +} diff --git a/test/concept-little-sisters-essay/mapping.json b/test/concept-little-sisters-essay/mapping.json new file mode 100644 index 0000000..962ff1a --- /dev/null +++ b/test/concept-little-sisters-essay/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "capitalize_title", + "placeholder_1": "essay_title", + "placeholder_2": "check_sentence_ending", + "placeholder_3": "sentence", + "placeholder_4": "clean_up_spacing", + "placeholder_5": "clean_sentence", + "placeholder_6": "replace_word_choice", + "placeholder_7": "old_word", + "placeholder_8": "new_word", + "placeholder_9": "better_sentence" +} \ No newline at end of file diff --git a/test/concept-little-sisters-essay/representation.json b/test/concept-little-sisters-essay/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-little-sisters-essay/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-little-sisters-essay/representation.out b/test/concept-little-sisters-essay/representation.out new file mode 100644 index 0000000..a99b4bf --- /dev/null +++ b/test/concept-little-sisters-essay/representation.out @@ -0,0 +1,598 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return placeholder_1.title() + + +def placeholder_2(placeholder_3): + return placeholder_3.endswith(".") + + +def placeholder_4(placeholder_3): + placeholder_5 = placeholder_3.strip() + return placeholder_5 + + +def placeholder_6(placeholder_3, placeholder_7, placeholder_8): + placeholder_9 = placeholder_3.replace(placeholder_7, placeholder_8) + return placeholder_9 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to help edit essay homework using string manipulation.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=70), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=70), + FunctionDef( + 'capitalize_title', + arguments( + [], + [ + arg( + 'essay_title', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Convert the first letter of each word in the title to uppercase if needed.\n\n :param title: str - title string that needs title casing.\n :return: str - title string in title case (first letters capitalized).\n ', + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + Return( + Call( + Attribute( + Name( + 'essay_title', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=22), + 'title', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=28), + [], + [], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=30), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=30)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=30), + FunctionDef( + 'check_sentence_ending', + arguments( + [], + [ + arg( + 'sentence', + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Check the ending of the sentence to verify that a period is present.\n\n :param sentence: str - a sentence to check.\n :return: bool - is the sentence punctuated correctly?\n ', + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=7), + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=7), + Return( + Call( + Attribute( + Name( + 'sentence', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=19), + 'endswith', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=28), + [ + Constant( + '.', + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=32)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=33), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=33)], + [], + lineno=14, + col_offset=0, + end_lineno=21, + end_col_offset=33), + FunctionDef( + 'clean_up_spacing', + arguments( + [], + [ + arg( + 'sentence', + lineno=24, + col_offset=21, + end_lineno=24, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Trim any leading or trailing whitespace from the sentence.\n\n :param sentence: str - a sentence to clean of leading and trailing space characters.\n :return: str - a sentence that has been cleaned of leading and trailing space characters.\n ', + lineno=25, + col_offset=4, + end_lineno=29, + end_col_offset=7), + lineno=25, + col_offset=4, + end_lineno=29, + end_col_offset=7), + Assign( + [ + Name( + 'clean_sentence', + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=18)], + Call( + Attribute( + Name( + 'sentence', + Load(), + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=29), + 'strip', + Load(), + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=35), + [], + [], + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=37), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=37), + Return( + Name( + 'clean_sentence', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=25), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=25)], + [], + lineno=24, + col_offset=0, + end_lineno=32, + end_col_offset=25), + FunctionDef( + 'replace_word_choice', + arguments( + [], + [ + arg( + 'sentence', + lineno=35, + col_offset=24, + end_lineno=35, + end_col_offset=32), + arg( + 'old_word', + lineno=35, + col_offset=34, + end_lineno=35, + end_col_offset=42), + arg( + 'new_word', + lineno=35, + col_offset=44, + end_lineno=35, + end_col_offset=52)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Replace a word in the provided sentence with a new one.\n\n :param sentence: str - a sentence to replace words in.\n :param old_word: str - word to replace.\n :param new_word: str - replacement word.\n :return: str - input sentence with new words in place of old words.\n ', + lineno=36, + col_offset=4, + end_lineno=42, + end_col_offset=7), + lineno=36, + col_offset=4, + end_lineno=42, + end_col_offset=7), + Assign( + [ + Name( + 'better_sentence', + Store(), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=19)], + Call( + Attribute( + Name( + 'sentence', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=30), + 'replace', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=38), + [ + Name( + 'old_word', + Load(), + lineno=44, + col_offset=39, + end_lineno=44, + end_col_offset=47), + Name( + 'new_word', + Load(), + lineno=44, + col_offset=49, + end_lineno=44, + end_col_offset=57)], + [], + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=58), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=58), + Return( + Name( + 'better_sentence', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=26), + lineno=45, + col_offset=4, + end_lineno=45, + end_col_offset=26)], + [], + lineno=35, + col_offset=0, + end_lineno=45, + end_col_offset=26)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=22), + 'title', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=28), + [], + [], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=30), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=30)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=30), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=19), + 'endswith', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=28), + [ + Constant( + '.', + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=32)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=33), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=33)], + [], + lineno=14, + col_offset=0, + end_lineno=21, + end_col_offset=33), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=24, + col_offset=21, + end_lineno=24, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=18)], + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=29), + 'strip', + Load(), + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=35), + [], + [], + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=37), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=37), + Return( + Name( + 'placeholder_5', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=25), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=25)], + [], + lineno=24, + col_offset=0, + end_lineno=32, + end_col_offset=25), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=35, + col_offset=24, + end_lineno=35, + end_col_offset=32), + arg( + 'placeholder_7', + lineno=35, + col_offset=34, + end_lineno=35, + end_col_offset=42), + arg( + 'placeholder_8', + lineno=35, + col_offset=44, + end_lineno=35, + end_col_offset=52)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=19)], + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=30), + 'replace', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=38), + [ + Name( + 'placeholder_7', + Load(), + lineno=44, + col_offset=39, + end_lineno=44, + end_col_offset=47), + Name( + 'placeholder_8', + Load(), + lineno=44, + col_offset=49, + end_lineno=44, + end_col_offset=57)], + [], + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=58), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=58), + Return( + Name( + 'placeholder_9', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=26), + lineno=45, + col_offset=4, + end_lineno=45, + end_col_offset=26)], + [], + lineno=35, + col_offset=0, + end_lineno=45, + end_col_offset=26)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-little-sisters-essay/representation.txt b/test/concept-little-sisters-essay/representation.txt new file mode 100644 index 0000000..c8ac430 --- /dev/null +++ b/test/concept-little-sisters-essay/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=21, end_lineno=4, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_1', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=22), 'title', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=28), [], [], lineno=11, col_offset=11, end_lineno=11, end_col_offset=30), lineno=11, col_offset=4, end_lineno=11, end_col_offset=30)], [], lineno=4, col_offset=0, end_lineno=11, end_col_offset=30), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=14, col_offset=26, end_lineno=14, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_3', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=19), 'endswith', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=28), [Constant('.', lineno=21, col_offset=29, end_lineno=21, end_col_offset=32)], [], lineno=21, col_offset=11, end_lineno=21, end_col_offset=33), lineno=21, col_offset=4, end_lineno=21, end_col_offset=33)], [], lineno=14, col_offset=0, end_lineno=21, end_col_offset=33), FunctionDef('placeholder_4', arguments([], [arg('placeholder_3', lineno=24, col_offset=21, end_lineno=24, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_5', Store(), lineno=31, col_offset=4, end_lineno=31, end_col_offset=18)], Call(Attribute(Name('placeholder_3', Load(), lineno=31, col_offset=21, end_lineno=31, end_col_offset=29), 'strip', Load(), lineno=31, col_offset=21, end_lineno=31, end_col_offset=35), [], [], lineno=31, col_offset=21, end_lineno=31, end_col_offset=37), lineno=31, col_offset=4, end_lineno=31, end_col_offset=37), Return(Name('placeholder_5', Load(), lineno=32, col_offset=11, end_lineno=32, end_col_offset=25), lineno=32, col_offset=4, end_lineno=32, end_col_offset=25)], [], lineno=24, col_offset=0, end_lineno=32, end_col_offset=25), FunctionDef('placeholder_6', arguments([], [arg('placeholder_3', lineno=35, col_offset=24, end_lineno=35, end_col_offset=32), arg('placeholder_7', lineno=35, col_offset=34, end_lineno=35, end_col_offset=42), arg('placeholder_8', lineno=35, col_offset=44, end_lineno=35, end_col_offset=52)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_9', Store(), lineno=44, col_offset=4, end_lineno=44, end_col_offset=19)], Call(Attribute(Name('placeholder_3', Load(), lineno=44, col_offset=22, end_lineno=44, end_col_offset=30), 'replace', Load(), lineno=44, col_offset=22, end_lineno=44, end_col_offset=38), [Name('placeholder_7', Load(), lineno=44, col_offset=39, end_lineno=44, end_col_offset=47), Name('placeholder_8', Load(), lineno=44, col_offset=49, end_lineno=44, end_col_offset=57)], [], lineno=44, col_offset=22, end_lineno=44, end_col_offset=58), lineno=44, col_offset=4, end_lineno=44, end_col_offset=58), Return(Name('placeholder_9', Load(), lineno=45, col_offset=11, end_lineno=45, end_col_offset=26), lineno=45, col_offset=4, end_lineno=45, end_col_offset=26)], [], lineno=35, col_offset=0, end_lineno=45, end_col_offset=26)], []) \ No newline at end of file diff --git a/test/concept-little-sisters-essay/string_methods.py b/test/concept-little-sisters-essay/string_methods.py new file mode 100644 index 0000000..2f5de84 --- /dev/null +++ b/test/concept-little-sisters-essay/string_methods.py @@ -0,0 +1,45 @@ +"""Functions to help edit essay homework using string manipulation.""" + + +def capitalize_title(essay_title): + """Convert the first letter of each word in the title to uppercase if needed. + + :param title: str - title string that needs title casing. + :return: str - title string in title case (first letters capitalized). + """ + + return essay_title.title() + + +def check_sentence_ending(sentence): + """Check the ending of the sentence to verify that a period is present. + + :param sentence: str - a sentence to check. + :return: bool - is the sentence punctuated correctly? + """ + + return sentence.endswith(".") + + +def clean_up_spacing(sentence): + """Trim any leading or trailing whitespace from the sentence. + + :param sentence: str - a sentence to clean of leading and trailing space characters. + :return: str - a sentence that has been cleaned of leading and trailing space characters. + """ + + clean_sentence = sentence.strip() + return clean_sentence + + +def replace_word_choice(sentence, old_word, new_word): + """Replace a word in the provided sentence with a new one. + + :param sentence: str - a sentence to replace words in. + :param old_word: str - word to replace. + :param new_word: str - replacement word. + :return: str - input sentence with new words in place of old words. + """ + + better_sentence = sentence.replace(old_word, new_word) + return better_sentence diff --git a/test/concept-little-sisters-vocab/.meta/config.json b/test/concept-little-sisters-vocab/.meta/config.json new file mode 100644 index 0000000..6951b33 --- /dev/null +++ b/test/concept-little-sisters-vocab/.meta/config.json @@ -0,0 +1,13 @@ +{ + "authors": [ + "aldraco", + "BethanyG" + ], + "files": { + "solution": [ + "strings.py" + ] + }, + "icon": "two-fer", + "blurb": "Learn about strings by helping your little sister with her vocabulary homework." +} diff --git a/test/concept-little-sisters-vocab/mapping.json b/test/concept-little-sisters-vocab/mapping.json new file mode 100644 index 0000000..4eb0d04 --- /dev/null +++ b/test/concept-little-sisters-vocab/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "add_prefix_un", + "placeholder_1": "word", + "placeholder_2": "make_word_groups", + "placeholder_3": "vocab_words", + "placeholder_4": "prefix", + "placeholder_5": "joiner", + "placeholder_6": "remove_suffix_ness", + "placeholder_7": "adjective_to_verb", + "placeholder_8": "sentence", + "placeholder_9": "index" +} \ No newline at end of file diff --git a/test/concept-little-sisters-vocab/representation.json b/test/concept-little-sisters-vocab/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-little-sisters-vocab/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-little-sisters-vocab/representation.out b/test/concept-little-sisters-vocab/representation.out new file mode 100644 index 0000000..ba28a84 --- /dev/null +++ b/test/concept-little-sisters-vocab/representation.out @@ -0,0 +1,1204 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return "un" + placeholder_1 + + +def placeholder_2(placeholder_3): + placeholder_4 = placeholder_3[0] + placeholder_5 = " :: " + placeholder_4 + return placeholder_5.join(placeholder_3) + + +def placeholder_6(placeholder_1): + placeholder_1 = placeholder_1[:-4] + if placeholder_1[-1] == "i": + placeholder_1 = placeholder_1[:-1] + "y" + return placeholder_1 + + +def placeholder_7(placeholder_8, placeholder_9): + placeholder_1 = placeholder_8.split()[placeholder_9] + if placeholder_1[-1] == ".": + placeholder_1 = placeholder_1[:-1] + "en" + else: + placeholder_1 = placeholder_1 + "en" + return placeholder_1 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions for creating, transforming, and adding prefixes to strings.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=75), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=75), + FunctionDef( + 'add_prefix_un', + arguments( + [], + [ + arg( + 'word', + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Take the given word and add the 'un' prefix.\n\n :param word: str - containing the root word.\n :return: str - of root word prepended with 'un'.\n ", + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + Return( + BinOp( + Constant( + 'un', + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=15), + Add(), + Name( + 'word', + Load(), + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=22)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=22), + FunctionDef( + 'make_word_groups', + arguments( + [], + [ + arg( + 'vocab_words', + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Transform a list containing a prefix and words into a string with the prefix followed by the words with prefix prepended.\n\n :param vocab_words: list - of vocabulary words with prefix in first index.\n :return: str - of prefix followed by vocabulary words with\n prefix applied.\n\n This function takes a `vocab_words` list and returns a string\n with the prefix and the words with prefix applied, separated\n by ' :: '.\n\n For example: list('en', 'close', 'joy', 'lighten'),\n produces the following string: 'en :: enclose :: enjoy :: enlighten'.\n ", + lineno=15, + col_offset=4, + end_lineno=27, + end_col_offset=7), + lineno=15, + col_offset=4, + end_lineno=27, + end_col_offset=7), + Assign( + [ + Name( + 'prefix', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=10)], + Subscript( + Name( + 'vocab_words', + Load(), + lineno=29, + col_offset=13, + end_lineno=29, + end_col_offset=24), + Constant( + 0, + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=26), + Load(), + lineno=29, + col_offset=13, + end_lineno=29, + end_col_offset=27), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=27), + Assign( + [ + Name( + 'joiner', + Store(), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=10)], + BinOp( + Constant( + ' :: ', + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=19), + Add(), + Name( + 'prefix', + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=28), + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=28), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=28), + Return( + Call( + Attribute( + Name( + 'joiner', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=17), + 'join', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=22), + [ + Name( + 'vocab_words', + Load(), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=34)], + [], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=35), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=35)], + [], + lineno=14, + col_offset=0, + end_lineno=32, + end_col_offset=35), + FunctionDef( + 'remove_suffix_ness', + arguments( + [], + [ + arg( + 'word', + lineno=35, + col_offset=23, + end_lineno=35, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Remove the suffix from the word while keeping spelling in mind.\n\n :param word: str - of word to remove suffix from.\n :return: str - of word with suffix removed & spelling adjusted.\n\n For example: "heaviness" becomes "heavy", but "sadness" becomes "sad".\n ', + lineno=36, + col_offset=4, + end_lineno=42, + end_col_offset=7), + lineno=36, + col_offset=4, + end_lineno=42, + end_col_offset=7), + Assign( + [ + Name( + 'word', + Store(), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=8)], + Subscript( + Name( + 'word', + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=15), + Slice( + upper=UnaryOp( + USub(), + Constant( + 4, + lineno=44, + col_offset=18, + end_lineno=44, + end_col_offset=19), + lineno=44, + col_offset=17, + end_lineno=44, + end_col_offset=19), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=19), + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=20), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=20), + If( + Compare( + Subscript( + Name( + 'word', + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=45, + col_offset=13, + end_lineno=45, + end_col_offset=14), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=14), + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 'i', + lineno=45, + col_offset=19, + end_lineno=45, + end_col_offset=22)], + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=22), + [ + Assign( + [ + Name( + 'word', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=12)], + BinOp( + Subscript( + Name( + 'word', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=23), + lineno=46, + col_offset=21, + end_lineno=46, + end_col_offset=23), + lineno=46, + col_offset=20, + end_lineno=46, + end_col_offset=23), + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=24), + Add(), + Constant( + 'y', + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=30), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=30), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=30)], + [], + lineno=45, + col_offset=4, + end_lineno=46, + end_col_offset=30), + Return( + Name( + 'word', + Load(), + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=15), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=15)], + [], + lineno=35, + col_offset=0, + end_lineno=48, + end_col_offset=15), + FunctionDef( + 'adjective_to_verb', + arguments( + [], + [ + arg( + 'sentence', + lineno=51, + col_offset=22, + end_lineno=51, + end_col_offset=30), + arg( + 'index', + lineno=51, + col_offset=32, + end_lineno=51, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Change the adjective within the sentence to a verb.\n\n :param sentence: str - that uses the word in sentence.\n :param index: int - index of the word to remove and transform.\n :return: str - word that changes the extracted adjective to a verb.\n\n For example, ("It got dark as the sun set", 2) becomes "darken".\n ', + lineno=52, + col_offset=4, + end_lineno=59, + end_col_offset=7), + lineno=52, + col_offset=4, + end_lineno=59, + end_col_offset=7), + Assign( + [ + Name( + 'word', + Store(), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=8)], + Subscript( + Call( + Attribute( + Name( + 'sentence', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=19), + 'split', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=25), + [], + [], + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=27), + Name( + 'index', + Load(), + lineno=61, + col_offset=28, + end_lineno=61, + end_col_offset=33), + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=34), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=34), + If( + Compare( + Subscript( + Name( + 'word', + Load(), + lineno=63, + col_offset=7, + end_lineno=63, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=14), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=14), + Load(), + lineno=63, + col_offset=7, + end_lineno=63, + end_col_offset=15), + [ + Eq()], + [ + Constant( + '.', + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=22)], + lineno=63, + col_offset=7, + end_lineno=63, + end_col_offset=22), + [ + Assign( + [ + Name( + 'word', + Store(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=12)], + BinOp( + Subscript( + Name( + 'word', + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=19), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=23), + lineno=64, + col_offset=21, + end_lineno=64, + end_col_offset=23), + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=23), + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=24), + Add(), + Constant( + 'en', + lineno=64, + col_offset=27, + end_lineno=64, + end_col_offset=31), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=31), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=31)], + [ + Assign( + [ + Name( + 'word', + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=12)], + BinOp( + Name( + 'word', + Load(), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=19), + Add(), + Constant( + 'en', + lineno=66, + col_offset=22, + end_lineno=66, + end_col_offset=26), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=26), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=26)], + lineno=63, + col_offset=4, + end_lineno=66, + end_col_offset=26), + Return( + Name( + 'word', + Load(), + lineno=68, + col_offset=11, + end_lineno=68, + end_col_offset=15), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=15)], + [], + lineno=51, + col_offset=0, + end_lineno=68, + end_col_offset=15)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Constant( + 'un', + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=15), + Add(), + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=22)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=22), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=10)], + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=29, + col_offset=13, + end_lineno=29, + end_col_offset=24), + Constant( + 0, + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=26), + Load(), + lineno=29, + col_offset=13, + end_lineno=29, + end_col_offset=27), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=10)], + BinOp( + Constant( + ' :: ', + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=19), + Add(), + Name( + 'placeholder_4', + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=28), + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=28), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=28), + Return( + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=17), + 'join', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=22), + [ + Name( + 'placeholder_3', + Load(), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=34)], + [], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=35), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=35)], + [], + lineno=14, + col_offset=0, + end_lineno=32, + end_col_offset=35), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=35, + col_offset=23, + end_lineno=35, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=8)], + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=15), + Slice( + upper=UnaryOp( + USub(), + Constant( + 4, + lineno=44, + col_offset=18, + end_lineno=44, + end_col_offset=19), + lineno=44, + col_offset=17, + end_lineno=44, + end_col_offset=19), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=19), + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=20), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=20), + If( + Compare( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=45, + col_offset=13, + end_lineno=45, + end_col_offset=14), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=14), + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 'i', + lineno=45, + col_offset=19, + end_lineno=45, + end_col_offset=22)], + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=22), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=12)], + BinOp( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=23), + lineno=46, + col_offset=21, + end_lineno=46, + end_col_offset=23), + lineno=46, + col_offset=20, + end_lineno=46, + end_col_offset=23), + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=24), + Add(), + Constant( + 'y', + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=30), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=30), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=30)], + [], + lineno=45, + col_offset=4, + end_lineno=46, + end_col_offset=30), + Return( + Name( + 'placeholder_1', + Load(), + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=15), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=15)], + [], + lineno=35, + col_offset=0, + end_lineno=48, + end_col_offset=15), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=51, + col_offset=22, + end_lineno=51, + end_col_offset=30), + arg( + 'placeholder_9', + lineno=51, + col_offset=32, + end_lineno=51, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=8)], + Subscript( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=19), + 'split', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=25), + [], + [], + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=27), + Name( + 'placeholder_9', + Load(), + lineno=61, + col_offset=28, + end_lineno=61, + end_col_offset=33), + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=34), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=34), + If( + Compare( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=63, + col_offset=7, + end_lineno=63, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=14), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=14), + Load(), + lineno=63, + col_offset=7, + end_lineno=63, + end_col_offset=15), + [ + Eq()], + [ + Constant( + '.', + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=22)], + lineno=63, + col_offset=7, + end_lineno=63, + end_col_offset=22), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=12)], + BinOp( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=19), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=23), + lineno=64, + col_offset=21, + end_lineno=64, + end_col_offset=23), + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=23), + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=24), + Add(), + Constant( + 'en', + lineno=64, + col_offset=27, + end_lineno=64, + end_col_offset=31), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=31), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=31)], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=12)], + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=19), + Add(), + Constant( + 'en', + lineno=66, + col_offset=22, + end_lineno=66, + end_col_offset=26), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=26), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=26)], + lineno=63, + col_offset=4, + end_lineno=66, + end_col_offset=26), + Return( + Name( + 'placeholder_1', + Load(), + lineno=68, + col_offset=11, + end_lineno=68, + end_col_offset=15), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=15)], + [], + lineno=51, + col_offset=0, + end_lineno=68, + end_col_offset=15)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-little-sisters-vocab/representation.txt b/test/concept-little-sisters-vocab/representation.txt new file mode 100644 index 0000000..7fb443c --- /dev/null +++ b/test/concept-little-sisters-vocab/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=18, end_lineno=4, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Constant('un', lineno=11, col_offset=11, end_lineno=11, end_col_offset=15), Add(), Name('placeholder_1', Load(), lineno=11, col_offset=18, end_lineno=11, end_col_offset=22), lineno=11, col_offset=11, end_lineno=11, end_col_offset=22), lineno=11, col_offset=4, end_lineno=11, end_col_offset=22)], [], lineno=4, col_offset=0, end_lineno=11, end_col_offset=22), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=14, col_offset=21, end_lineno=14, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=29, col_offset=4, end_lineno=29, end_col_offset=10)], Subscript(Name('placeholder_3', Load(), lineno=29, col_offset=13, end_lineno=29, end_col_offset=24), Constant(0, lineno=29, col_offset=25, end_lineno=29, end_col_offset=26), Load(), lineno=29, col_offset=13, end_lineno=29, end_col_offset=27), lineno=29, col_offset=4, end_lineno=29, end_col_offset=27), Assign([Name('placeholder_5', Store(), lineno=30, col_offset=4, end_lineno=30, end_col_offset=10)], BinOp(Constant(' :: ', lineno=30, col_offset=13, end_lineno=30, end_col_offset=19), Add(), Name('placeholder_4', Load(), lineno=30, col_offset=22, end_lineno=30, end_col_offset=28), lineno=30, col_offset=13, end_lineno=30, end_col_offset=28), lineno=30, col_offset=4, end_lineno=30, end_col_offset=28), Return(Call(Attribute(Name('placeholder_5', Load(), lineno=32, col_offset=11, end_lineno=32, end_col_offset=17), 'join', Load(), lineno=32, col_offset=11, end_lineno=32, end_col_offset=22), [Name('placeholder_3', Load(), lineno=32, col_offset=23, end_lineno=32, end_col_offset=34)], [], lineno=32, col_offset=11, end_lineno=32, end_col_offset=35), lineno=32, col_offset=4, end_lineno=32, end_col_offset=35)], [], lineno=14, col_offset=0, end_lineno=32, end_col_offset=35), FunctionDef('placeholder_6', arguments([], [arg('placeholder_1', lineno=35, col_offset=23, end_lineno=35, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_1', Store(), lineno=44, col_offset=4, end_lineno=44, end_col_offset=8)], Subscript(Name('placeholder_1', Load(), lineno=44, col_offset=11, end_lineno=44, end_col_offset=15), Slice(upper=UnaryOp(USub(), Constant(4, lineno=44, col_offset=18, end_lineno=44, end_col_offset=19), lineno=44, col_offset=17, end_lineno=44, end_col_offset=19), lineno=44, col_offset=16, end_lineno=44, end_col_offset=19), Load(), lineno=44, col_offset=11, end_lineno=44, end_col_offset=20), lineno=44, col_offset=4, end_lineno=44, end_col_offset=20), If(Compare(Subscript(Name('placeholder_1', Load(), lineno=45, col_offset=7, end_lineno=45, end_col_offset=11), UnaryOp(USub(), Constant(1, lineno=45, col_offset=13, end_lineno=45, end_col_offset=14), lineno=45, col_offset=12, end_lineno=45, end_col_offset=14), Load(), lineno=45, col_offset=7, end_lineno=45, end_col_offset=15), [Eq()], [Constant('i', lineno=45, col_offset=19, end_lineno=45, end_col_offset=22)], lineno=45, col_offset=7, end_lineno=45, end_col_offset=22), [Assign([Name('placeholder_1', Store(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=12)], BinOp(Subscript(Name('placeholder_1', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=19), Slice(upper=UnaryOp(USub(), Constant(1, lineno=46, col_offset=22, end_lineno=46, end_col_offset=23), lineno=46, col_offset=21, end_lineno=46, end_col_offset=23), lineno=46, col_offset=20, end_lineno=46, end_col_offset=23), Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=24), Add(), Constant('y', lineno=46, col_offset=27, end_lineno=46, end_col_offset=30), lineno=46, col_offset=15, end_lineno=46, end_col_offset=30), lineno=46, col_offset=8, end_lineno=46, end_col_offset=30)], [], lineno=45, col_offset=4, end_lineno=46, end_col_offset=30), Return(Name('placeholder_1', Load(), lineno=48, col_offset=11, end_lineno=48, end_col_offset=15), lineno=48, col_offset=4, end_lineno=48, end_col_offset=15)], [], lineno=35, col_offset=0, end_lineno=48, end_col_offset=15), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=51, col_offset=22, end_lineno=51, end_col_offset=30), arg('placeholder_9', lineno=51, col_offset=32, end_lineno=51, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_1', Store(), lineno=61, col_offset=4, end_lineno=61, end_col_offset=8)], Subscript(Call(Attribute(Name('placeholder_8', Load(), lineno=61, col_offset=11, end_lineno=61, end_col_offset=19), 'split', Load(), lineno=61, col_offset=11, end_lineno=61, end_col_offset=25), [], [], lineno=61, col_offset=11, end_lineno=61, end_col_offset=27), Name('placeholder_9', Load(), lineno=61, col_offset=28, end_lineno=61, end_col_offset=33), Load(), lineno=61, col_offset=11, end_lineno=61, end_col_offset=34), lineno=61, col_offset=4, end_lineno=61, end_col_offset=34), If(Compare(Subscript(Name('placeholder_1', Load(), lineno=63, col_offset=7, end_lineno=63, end_col_offset=11), UnaryOp(USub(), Constant(1, lineno=63, col_offset=13, end_lineno=63, end_col_offset=14), lineno=63, col_offset=12, end_lineno=63, end_col_offset=14), Load(), lineno=63, col_offset=7, end_lineno=63, end_col_offset=15), [Eq()], [Constant('.', lineno=63, col_offset=19, end_lineno=63, end_col_offset=22)], lineno=63, col_offset=7, end_lineno=63, end_col_offset=22), [Assign([Name('placeholder_1', Store(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=12)], BinOp(Subscript(Name('placeholder_1', Load(), lineno=64, col_offset=15, end_lineno=64, end_col_offset=19), Slice(upper=UnaryOp(USub(), Constant(1, lineno=64, col_offset=22, end_lineno=64, end_col_offset=23), lineno=64, col_offset=21, end_lineno=64, end_col_offset=23), lineno=64, col_offset=20, end_lineno=64, end_col_offset=23), Load(), lineno=64, col_offset=15, end_lineno=64, end_col_offset=24), Add(), Constant('en', lineno=64, col_offset=27, end_lineno=64, end_col_offset=31), lineno=64, col_offset=15, end_lineno=64, end_col_offset=31), lineno=64, col_offset=8, end_lineno=64, end_col_offset=31)], [Assign([Name('placeholder_1', Store(), lineno=66, col_offset=8, end_lineno=66, end_col_offset=12)], BinOp(Name('placeholder_1', Load(), lineno=66, col_offset=15, end_lineno=66, end_col_offset=19), Add(), Constant('en', lineno=66, col_offset=22, end_lineno=66, end_col_offset=26), lineno=66, col_offset=15, end_lineno=66, end_col_offset=26), lineno=66, col_offset=8, end_lineno=66, end_col_offset=26)], lineno=63, col_offset=4, end_lineno=66, end_col_offset=26), Return(Name('placeholder_1', Load(), lineno=68, col_offset=11, end_lineno=68, end_col_offset=15), lineno=68, col_offset=4, end_lineno=68, end_col_offset=15)], [], lineno=51, col_offset=0, end_lineno=68, end_col_offset=15)], []) \ No newline at end of file diff --git a/test/concept-little-sisters-vocab/strings.py b/test/concept-little-sisters-vocab/strings.py new file mode 100644 index 0000000..c71d490 --- /dev/null +++ b/test/concept-little-sisters-vocab/strings.py @@ -0,0 +1,68 @@ +"""Functions for creating, transforming, and adding prefixes to strings.""" + + +def add_prefix_un(word): + """Take the given word and add the 'un' prefix. + + :param word: str - containing the root word. + :return: str - of root word prepended with 'un'. + """ + + return 'un' + word + + +def make_word_groups(vocab_words): + """Transform a list containing a prefix and words into a string with the prefix followed by the words with prefix prepended. + + :param vocab_words: list - of vocabulary words with prefix in first index. + :return: str - of prefix followed by vocabulary words with + prefix applied. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + + For example: list('en', 'close', 'joy', 'lighten'), + produces the following string: 'en :: enclose :: enjoy :: enlighten'. + """ + + prefix = vocab_words[0] + joiner = ' :: ' + prefix + + return joiner.join(vocab_words) + + +def remove_suffix_ness(word): + """Remove the suffix from the word while keeping spelling in mind. + + :param word: str - of word to remove suffix from. + :return: str - of word with suffix removed & spelling adjusted. + + For example: "heaviness" becomes "heavy", but "sadness" becomes "sad". + """ + + word = word[:-4] + if word[-1] == 'i': + word = word[:-1] + 'y' + + return word + + +def adjective_to_verb(sentence, index): + """Change the adjective within the sentence to a verb. + + :param sentence: str - that uses the word in sentence. + :param index: int - index of the word to remove and transform. + :return: str - word that changes the extracted adjective to a verb. + + For example, ("It got dark as the sun set", 2) becomes "darken". + """ + + word = sentence.split()[index] + + if word[-1] == '.': + word = word[:-1] + 'en' + else: + word = word + 'en' + + return word diff --git a/test/concept-locomotive-engineer/.meta/config.json b/test/concept-locomotive-engineer/.meta/config.json new file mode 100644 index 0000000..e9110e9 --- /dev/null +++ b/test/concept-locomotive-engineer/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "meatball133", + "BethanyG" + ], + "contributors": [ + "IsaacG" + ], + "files": { + "solution": [ + "locomotive_engineer.py" + ], + "test": [ + "locomotive_engineer_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "forked_from": [ + "javascript/train-driver" + ], + "icon": "tracks-on-tracks-on-tracks", + "blurb": "Learn about unpacking and multiple assignment in Python while helping Linus with his train control system." +} diff --git a/test/concept-locomotive-engineer/locomotive_engineer.py b/test/concept-locomotive-engineer/locomotive_engineer.py new file mode 100644 index 0000000..bda295d --- /dev/null +++ b/test/concept-locomotive-engineer/locomotive_engineer.py @@ -0,0 +1,58 @@ +"""Functions which helps the locomotive engineer to keep track of the train.""" + + +def get_list_of_wagons(*args): + """Return a list of wagons. + + :param *args: arbitrary number of wagons. + :return: list - list of wagons. + """ + + return list(args) + + +def fix_list_of_wagons(each_wagons_id, missing_wagons): + """Fix the list of wagons. + + :param each_wagons_id: list - the list of wagons. + :param missing_wagons: list - the list of missing wagons. + :return: list - list of wagons. + """ + + first, second, locomotive, *rest = each_wagons_id + + return [locomotive, *missing_wagons, *rest, first, second] + + +def add_missing_stops(route, **kwargs): + """Add missing stops to route dict. + + :param route: dict - the dict of routing information. + :param **kwargs: arbitrary number of stops. + :return: dict - updated route dictionary. + """ + + return {**route, "stops": list(kwargs.values())} + + +def extend_route_information(route, more_route_information): + """Extend route information with more_route_information. + + :param route: dict - the route information. + :param more_route_information: dict - extra route information. + :return: dict - extended route information. + """ + + return {**route, **more_route_information} + + +def fix_wagon_depot(wagons_rows): + """Fix the list of rows of wagons. + + :param wagons_rows: list[tuple] - the list of rows of wagons. + :return: list[tuple] - list of rows of wagons. + """ + + [*row_one], [*row_two], [*row_three] = zip(*wagons_rows) + + return [row_one, row_two, row_three] diff --git a/test/concept-locomotive-engineer/mapping.json b/test/concept-locomotive-engineer/mapping.json new file mode 100644 index 0000000..86b740f --- /dev/null +++ b/test/concept-locomotive-engineer/mapping.json @@ -0,0 +1,21 @@ +{ + "placeholder_0": "get_list_of_wagons", + "placeholder_1": "args", + "placeholder_2": "fix_list_of_wagons", + "placeholder_3": "each_wagons_id", + "placeholder_4": "missing_wagons", + "placeholder_5": "first", + "placeholder_6": "second", + "placeholder_7": "locomotive", + "placeholder_8": "rest", + "placeholder_9": "add_missing_stops", + "placeholder_10": "route", + "placeholder_11": "kwargs", + "placeholder_12": "extend_route_information", + "placeholder_13": "more_route_information", + "placeholder_14": "fix_wagon_depot", + "placeholder_15": "wagons_rows", + "placeholder_16": "row_one", + "placeholder_17": "row_two", + "placeholder_18": "row_three" +} \ No newline at end of file diff --git a/test/concept-locomotive-engineer/representation.json b/test/concept-locomotive-engineer/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-locomotive-engineer/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-locomotive-engineer/representation.out b/test/concept-locomotive-engineer/representation.out new file mode 100644 index 0000000..4cd3638 --- /dev/null +++ b/test/concept-locomotive-engineer/representation.out @@ -0,0 +1,1059 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(*placeholder_1): + return list(placeholder_1) + + +def placeholder_2(placeholder_3, placeholder_4): + placeholder_5, placeholder_6, placeholder_7, *placeholder_8 = placeholder_3 + return [placeholder_7, *placeholder_4, *placeholder_8, placeholder_5, placeholder_6] + + +def placeholder_9(placeholder_10, **placeholder_11): + return {**placeholder_10, "stops": list(placeholder_11.values())} + + +def placeholder_12(placeholder_10, placeholder_13): + return {**placeholder_10, **placeholder_13} + + +def placeholder_14(placeholder_15): + [*placeholder_16], [*placeholder_17], [*placeholder_18] = zip(*placeholder_15) + return [placeholder_16, placeholder_17, placeholder_18] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions which helps the locomotive engineer to keep track of the train.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=79), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=79), + FunctionDef( + 'get_list_of_wagons', + arguments( + [], + [], + arg( + 'args', + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=28), + [], + [], + defaults=[]), + [ + Expr( + Constant( + 'Return a list of wagons.\n\n :param *args: arbitrary number of wagons.\n :return: list - list of wagons.\n ', + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + Return( + Call( + Name( + 'list', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=15), + [ + Name( + 'args', + Load(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=20)], + [], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=21), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=21)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=21), + FunctionDef( + 'fix_list_of_wagons', + arguments( + [], + [ + arg( + 'each_wagons_id', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=37), + arg( + 'missing_wagons', + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=53)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Fix the list of wagons.\n\n :param each_wagons_id: list - the list of wagons.\n :param missing_wagons: list - the list of missing wagons.\n :return: list - list of wagons.\n ', + lineno=15, + col_offset=4, + end_lineno=20, + end_col_offset=7), + lineno=15, + col_offset=4, + end_lineno=20, + end_col_offset=7), + Assign( + [ + Tuple( + [ + Name( + 'first', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=9), + Name( + 'second', + Store(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=17), + Name( + 'locomotive', + Store(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=29), + Starred( + Name( + 'rest', + Store(), + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=36), + Store(), + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=36)], + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=36)], + Name( + 'each_wagons_id', + Load(), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=53), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=53), + Return( + List( + [ + Name( + 'locomotive', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=22), + Starred( + Name( + 'missing_wagons', + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=39), + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=39), + Starred( + Name( + 'rest', + Load(), + lineno=24, + col_offset=42, + end_lineno=24, + end_col_offset=46), + Load(), + lineno=24, + col_offset=41, + end_lineno=24, + end_col_offset=46), + Name( + 'first', + Load(), + lineno=24, + col_offset=48, + end_lineno=24, + end_col_offset=53), + Name( + 'second', + Load(), + lineno=24, + col_offset=55, + end_lineno=24, + end_col_offset=61)], + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=62), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=62)], + [], + lineno=14, + col_offset=0, + end_lineno=24, + end_col_offset=62), + FunctionDef( + 'add_missing_stops', + arguments( + [], + [ + arg( + 'route', + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + kwarg=arg( + 'kwargs', + lineno=27, + col_offset=31, + end_lineno=27, + end_col_offset=37), + defaults=[]), + [ + Expr( + Constant( + 'Add missing stops to route dict.\n\n :param route: dict - the dict of routing information.\n :param **kwargs: arbitrary number of stops.\n :return: dict - updated route dictionary.\n ', + lineno=28, + col_offset=4, + end_lineno=33, + end_col_offset=7), + lineno=28, + col_offset=4, + end_lineno=33, + end_col_offset=7), + Return( + Dict( + [ + None, + Constant( + 'stops', + lineno=35, + col_offset=21, + end_lineno=35, + end_col_offset=28)], + [ + Name( + 'route', + Load(), + lineno=35, + col_offset=14, + end_lineno=35, + end_col_offset=19), + Call( + Name( + 'list', + Load(), + lineno=35, + col_offset=30, + end_lineno=35, + end_col_offset=34), + [ + Call( + Attribute( + Name( + 'kwargs', + Load(), + lineno=35, + col_offset=35, + end_lineno=35, + end_col_offset=41), + 'values', + Load(), + lineno=35, + col_offset=35, + end_lineno=35, + end_col_offset=48), + [], + [], + lineno=35, + col_offset=35, + end_lineno=35, + end_col_offset=50)], + [], + lineno=35, + col_offset=30, + end_lineno=35, + end_col_offset=51)], + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=52), + lineno=35, + col_offset=4, + end_lineno=35, + end_col_offset=52)], + [], + lineno=27, + col_offset=0, + end_lineno=35, + end_col_offset=52), + FunctionDef( + 'extend_route_information', + arguments( + [], + [ + arg( + 'route', + lineno=38, + col_offset=29, + end_lineno=38, + end_col_offset=34), + arg( + 'more_route_information', + lineno=38, + col_offset=36, + end_lineno=38, + end_col_offset=58)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Extend route information with more_route_information.\n\n :param route: dict - the route information.\n :param more_route_information: dict - extra route information.\n :return: dict - extended route information.\n ', + lineno=39, + col_offset=4, + end_lineno=44, + end_col_offset=7), + lineno=39, + col_offset=4, + end_lineno=44, + end_col_offset=7), + Return( + Dict( + [ + None, + None], + [ + Name( + 'route', + Load(), + lineno=46, + col_offset=14, + end_lineno=46, + end_col_offset=19), + Name( + 'more_route_information', + Load(), + lineno=46, + col_offset=23, + end_lineno=46, + end_col_offset=45)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=46), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=46)], + [], + lineno=38, + col_offset=0, + end_lineno=46, + end_col_offset=46), + FunctionDef( + 'fix_wagon_depot', + arguments( + [], + [ + arg( + 'wagons_rows', + lineno=49, + col_offset=20, + end_lineno=49, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Fix the list of rows of wagons.\n\n :param wagons_rows: list[tuple] - the list of rows of wagons.\n :return: list[tuple] - list of rows of wagons.\n ', + lineno=50, + col_offset=4, + end_lineno=54, + end_col_offset=7), + lineno=50, + col_offset=4, + end_lineno=54, + end_col_offset=7), + Assign( + [ + Tuple( + [ + List( + [ + Starred( + Name( + 'row_one', + Store(), + lineno=56, + col_offset=6, + end_lineno=56, + end_col_offset=13), + Store(), + lineno=56, + col_offset=5, + end_lineno=56, + end_col_offset=13)], + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=14), + List( + [ + Starred( + Name( + 'row_two', + Store(), + lineno=56, + col_offset=18, + end_lineno=56, + end_col_offset=25), + Store(), + lineno=56, + col_offset=17, + end_lineno=56, + end_col_offset=25)], + Store(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=26), + List( + [ + Starred( + Name( + 'row_three', + Store(), + lineno=56, + col_offset=30, + end_lineno=56, + end_col_offset=39), + Store(), + lineno=56, + col_offset=29, + end_lineno=56, + end_col_offset=39)], + Store(), + lineno=56, + col_offset=28, + end_lineno=56, + end_col_offset=40)], + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=40)], + Call( + Name( + 'zip', + Load(), + lineno=56, + col_offset=43, + end_lineno=56, + end_col_offset=46), + [ + Starred( + Name( + 'wagons_rows', + Load(), + lineno=56, + col_offset=48, + end_lineno=56, + end_col_offset=59), + Load(), + lineno=56, + col_offset=47, + end_lineno=56, + end_col_offset=59)], + [], + lineno=56, + col_offset=43, + end_lineno=56, + end_col_offset=60), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=60), + Return( + List( + [ + Name( + 'row_one', + Load(), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=19), + Name( + 'row_two', + Load(), + lineno=58, + col_offset=21, + end_lineno=58, + end_col_offset=28), + Name( + 'row_three', + Load(), + lineno=58, + col_offset=30, + end_lineno=58, + end_col_offset=39)], + Load(), + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=40), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=40)], + [], + lineno=49, + col_offset=0, + end_lineno=58, + end_col_offset=40)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [], + arg( + 'placeholder_1', + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=28), + [], + [], + defaults=[]), + [ + Return( + Call( + Name( + 'list', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=15), + [ + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=20)], + [], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=21), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=21)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=21), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=37), + arg( + 'placeholder_4', + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=53)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_5', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=9), + Name( + 'placeholder_6', + Store(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=17), + Name( + 'placeholder_7', + Store(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=29), + Starred( + Name( + 'placeholder_8', + Store(), + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=36), + Store(), + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=36)], + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=36)], + Name( + 'placeholder_3', + Load(), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=53), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=53), + Return( + List( + [ + Name( + 'placeholder_7', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=22), + Starred( + Name( + 'placeholder_4', + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=39), + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=39), + Starred( + Name( + 'placeholder_8', + Load(), + lineno=24, + col_offset=42, + end_lineno=24, + end_col_offset=46), + Load(), + lineno=24, + col_offset=41, + end_lineno=24, + end_col_offset=46), + Name( + 'placeholder_5', + Load(), + lineno=24, + col_offset=48, + end_lineno=24, + end_col_offset=53), + Name( + 'placeholder_6', + Load(), + lineno=24, + col_offset=55, + end_lineno=24, + end_col_offset=61)], + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=62), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=62)], + [], + lineno=14, + col_offset=0, + end_lineno=24, + end_col_offset=62), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + kwarg=arg( + 'placeholder_11', + lineno=27, + col_offset=31, + end_lineno=27, + end_col_offset=37), + defaults=[]), + [ + Return( + Dict( + [ + None, + Constant( + 'stops', + lineno=35, + col_offset=21, + end_lineno=35, + end_col_offset=28)], + [ + Name( + 'placeholder_10', + Load(), + lineno=35, + col_offset=14, + end_lineno=35, + end_col_offset=19), + Call( + Name( + 'list', + Load(), + lineno=35, + col_offset=30, + end_lineno=35, + end_col_offset=34), + [ + Call( + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=35, + col_offset=35, + end_lineno=35, + end_col_offset=41), + 'values', + Load(), + lineno=35, + col_offset=35, + end_lineno=35, + end_col_offset=48), + [], + [], + lineno=35, + col_offset=35, + end_lineno=35, + end_col_offset=50)], + [], + lineno=35, + col_offset=30, + end_lineno=35, + end_col_offset=51)], + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=52), + lineno=35, + col_offset=4, + end_lineno=35, + end_col_offset=52)], + [], + lineno=27, + col_offset=0, + end_lineno=35, + end_col_offset=52), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=38, + col_offset=29, + end_lineno=38, + end_col_offset=34), + arg( + 'placeholder_13', + lineno=38, + col_offset=36, + end_lineno=38, + end_col_offset=58)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Dict( + [ + None, + None], + [ + Name( + 'placeholder_10', + Load(), + lineno=46, + col_offset=14, + end_lineno=46, + end_col_offset=19), + Name( + 'placeholder_13', + Load(), + lineno=46, + col_offset=23, + end_lineno=46, + end_col_offset=45)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=46), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=46)], + [], + lineno=38, + col_offset=0, + end_lineno=46, + end_col_offset=46), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'placeholder_15', + lineno=49, + col_offset=20, + end_lineno=49, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + List( + [ + Starred( + Name( + 'placeholder_16', + Store(), + lineno=56, + col_offset=6, + end_lineno=56, + end_col_offset=13), + Store(), + lineno=56, + col_offset=5, + end_lineno=56, + end_col_offset=13)], + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=14), + List( + [ + Starred( + Name( + 'placeholder_17', + Store(), + lineno=56, + col_offset=18, + end_lineno=56, + end_col_offset=25), + Store(), + lineno=56, + col_offset=17, + end_lineno=56, + end_col_offset=25)], + Store(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=26), + List( + [ + Starred( + Name( + 'placeholder_18', + Store(), + lineno=56, + col_offset=30, + end_lineno=56, + end_col_offset=39), + Store(), + lineno=56, + col_offset=29, + end_lineno=56, + end_col_offset=39)], + Store(), + lineno=56, + col_offset=28, + end_lineno=56, + end_col_offset=40)], + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=40)], + Call( + Name( + 'zip', + Load(), + lineno=56, + col_offset=43, + end_lineno=56, + end_col_offset=46), + [ + Starred( + Name( + 'placeholder_15', + Load(), + lineno=56, + col_offset=48, + end_lineno=56, + end_col_offset=59), + Load(), + lineno=56, + col_offset=47, + end_lineno=56, + end_col_offset=59)], + [], + lineno=56, + col_offset=43, + end_lineno=56, + end_col_offset=60), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=60), + Return( + List( + [ + Name( + 'placeholder_16', + Load(), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=19), + Name( + 'placeholder_17', + Load(), + lineno=58, + col_offset=21, + end_lineno=58, + end_col_offset=28), + Name( + 'placeholder_18', + Load(), + lineno=58, + col_offset=30, + end_lineno=58, + end_col_offset=39)], + Load(), + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=40), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=40)], + [], + lineno=49, + col_offset=0, + end_lineno=58, + end_col_offset=40)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-locomotive-engineer/representation.txt b/test/concept-locomotive-engineer/representation.txt new file mode 100644 index 0000000..707f162 --- /dev/null +++ b/test/concept-locomotive-engineer/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [], arg('placeholder_1', lineno=4, col_offset=24, end_lineno=4, end_col_offset=28), [], [], defaults=[]), [Return(Call(Name('list', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=15), [Name('placeholder_1', Load(), lineno=11, col_offset=16, end_lineno=11, end_col_offset=20)], [], lineno=11, col_offset=11, end_lineno=11, end_col_offset=21), lineno=11, col_offset=4, end_lineno=11, end_col_offset=21)], [], lineno=4, col_offset=0, end_lineno=11, end_col_offset=21), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=14, col_offset=23, end_lineno=14, end_col_offset=37), arg('placeholder_4', lineno=14, col_offset=39, end_lineno=14, end_col_offset=53)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Tuple([Name('placeholder_5', Store(), lineno=22, col_offset=4, end_lineno=22, end_col_offset=9), Name('placeholder_6', Store(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=17), Name('placeholder_7', Store(), lineno=22, col_offset=19, end_lineno=22, end_col_offset=29), Starred(Name('placeholder_8', Store(), lineno=22, col_offset=32, end_lineno=22, end_col_offset=36), Store(), lineno=22, col_offset=31, end_lineno=22, end_col_offset=36)], Store(), lineno=22, col_offset=4, end_lineno=22, end_col_offset=36)], Name('placeholder_3', Load(), lineno=22, col_offset=39, end_lineno=22, end_col_offset=53), lineno=22, col_offset=4, end_lineno=22, end_col_offset=53), Return(List([Name('placeholder_7', Load(), lineno=24, col_offset=12, end_lineno=24, end_col_offset=22), Starred(Name('placeholder_4', Load(), lineno=24, col_offset=25, end_lineno=24, end_col_offset=39), Load(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=39), Starred(Name('placeholder_8', Load(), lineno=24, col_offset=42, end_lineno=24, end_col_offset=46), Load(), lineno=24, col_offset=41, end_lineno=24, end_col_offset=46), Name('placeholder_5', Load(), lineno=24, col_offset=48, end_lineno=24, end_col_offset=53), Name('placeholder_6', Load(), lineno=24, col_offset=55, end_lineno=24, end_col_offset=61)], Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=62), lineno=24, col_offset=4, end_lineno=24, end_col_offset=62)], [], lineno=14, col_offset=0, end_lineno=24, end_col_offset=62), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=27, col_offset=22, end_lineno=27, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], kwarg=arg('placeholder_11', lineno=27, col_offset=31, end_lineno=27, end_col_offset=37), defaults=[]), [Return(Dict([None, Constant('stops', lineno=35, col_offset=21, end_lineno=35, end_col_offset=28)], [Name('placeholder_10', Load(), lineno=35, col_offset=14, end_lineno=35, end_col_offset=19), Call(Name('list', Load(), lineno=35, col_offset=30, end_lineno=35, end_col_offset=34), [Call(Attribute(Name('placeholder_11', Load(), lineno=35, col_offset=35, end_lineno=35, end_col_offset=41), 'values', Load(), lineno=35, col_offset=35, end_lineno=35, end_col_offset=48), [], [], lineno=35, col_offset=35, end_lineno=35, end_col_offset=50)], [], lineno=35, col_offset=30, end_lineno=35, end_col_offset=51)], lineno=35, col_offset=11, end_lineno=35, end_col_offset=52), lineno=35, col_offset=4, end_lineno=35, end_col_offset=52)], [], lineno=27, col_offset=0, end_lineno=35, end_col_offset=52), FunctionDef('placeholder_12', arguments([], [arg('placeholder_10', lineno=38, col_offset=29, end_lineno=38, end_col_offset=34), arg('placeholder_13', lineno=38, col_offset=36, end_lineno=38, end_col_offset=58)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Dict([None, None], [Name('placeholder_10', Load(), lineno=46, col_offset=14, end_lineno=46, end_col_offset=19), Name('placeholder_13', Load(), lineno=46, col_offset=23, end_lineno=46, end_col_offset=45)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=46), lineno=46, col_offset=4, end_lineno=46, end_col_offset=46)], [], lineno=38, col_offset=0, end_lineno=46, end_col_offset=46), FunctionDef('placeholder_14', arguments([], [arg('placeholder_15', lineno=49, col_offset=20, end_lineno=49, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Tuple([List([Starred(Name('placeholder_16', Store(), lineno=56, col_offset=6, end_lineno=56, end_col_offset=13), Store(), lineno=56, col_offset=5, end_lineno=56, end_col_offset=13)], Store(), lineno=56, col_offset=4, end_lineno=56, end_col_offset=14), List([Starred(Name('placeholder_17', Store(), lineno=56, col_offset=18, end_lineno=56, end_col_offset=25), Store(), lineno=56, col_offset=17, end_lineno=56, end_col_offset=25)], Store(), lineno=56, col_offset=16, end_lineno=56, end_col_offset=26), List([Starred(Name('placeholder_18', Store(), lineno=56, col_offset=30, end_lineno=56, end_col_offset=39), Store(), lineno=56, col_offset=29, end_lineno=56, end_col_offset=39)], Store(), lineno=56, col_offset=28, end_lineno=56, end_col_offset=40)], Store(), lineno=56, col_offset=4, end_lineno=56, end_col_offset=40)], Call(Name('zip', Load(), lineno=56, col_offset=43, end_lineno=56, end_col_offset=46), [Starred(Name('placeholder_15', Load(), lineno=56, col_offset=48, end_lineno=56, end_col_offset=59), Load(), lineno=56, col_offset=47, end_lineno=56, end_col_offset=59)], [], lineno=56, col_offset=43, end_lineno=56, end_col_offset=60), lineno=56, col_offset=4, end_lineno=56, end_col_offset=60), Return(List([Name('placeholder_16', Load(), lineno=58, col_offset=12, end_lineno=58, end_col_offset=19), Name('placeholder_17', Load(), lineno=58, col_offset=21, end_lineno=58, end_col_offset=28), Name('placeholder_18', Load(), lineno=58, col_offset=30, end_lineno=58, end_col_offset=39)], Load(), lineno=58, col_offset=11, end_lineno=58, end_col_offset=40), lineno=58, col_offset=4, end_lineno=58, end_col_offset=40)], [], lineno=49, col_offset=0, end_lineno=58, end_col_offset=40)], []) \ No newline at end of file diff --git a/test/concept-log-levels/.meta/config.json b/test/concept-log-levels/.meta/config.json new file mode 100644 index 0000000..fc14d0e --- /dev/null +++ b/test/concept-log-levels/.meta/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "mohanrajanr" + ], + "contributors": [ + "valentin-p" + ], + "files": { + "solution": [ + "enums.py" + ], + "test": [ + "enums_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "forked_from": [ + "csharp/logs-logs-logs" + ], + "icon": "log-levels", + "blurb": "Learn about enums by automating your tedious logging-level tasks." +} diff --git a/test/concept-log-levels/enums.py b/test/concept-log-levels/enums.py new file mode 100644 index 0000000..db45eeb --- /dev/null +++ b/test/concept-log-levels/enums.py @@ -0,0 +1,73 @@ +from enum import Enum + + +class LogLevel(Enum): + """Represent different log levels by their verbose codes.""" + + TRACE = 'TRC' + DEBUG = 'DBG' + INFO = 'INF' + WARNING = 'WRN' + WARN = 'WRN' + ERROR = 'ERR' + FATAL = 'FTL' + UNKNOWN = 'UKN' + + +class LogLevelInt(Enum): + """Represent different log levels by their short codes.""" + + TRACE = 0 + DEBUG = 1 + INFO = 4 + WARNING = 5 + WARN = 5 + ERROR = 6 + FATAL = 7 + UNKNOWN = 42 + + +def parse_log_level(message): + """Return level enum for log message. + + :param message: log message (string) + :return: enum - 'LogLevel.'. Return 'LogLevel.Unknown' if an unknown severity is passed. + """ + + str_split = message.split(':') + lvl = str_split[0][1:-1] + if lvl in [level.value for level in LogLevel]: + return LogLevel(lvl) + return LogLevel('UKN') + + +def convert_to_short_log(log_level, message): + """Convert a log message to its shorter format. + + :param log_level: enum - 'LogLevel.' e.g. 'LogLevel.Error' + :param message: str - log message + :return: enum - 'LogLevelInt.` e.g. 'LogLevelInt.5' + """ + + return f'{LogLevelInt[log_level.name].value}:{message}' + + +def get_warn_alias(): + """Returns the enum for LogLevel.Warning. + + :return: enum - 'LogLevel'.' + """ + + return LogLevel('WRN') + + +def get_members(): + """Return all members of the enum. + + :return: list of tuples - [(name1, value1), (name2, value2)] + """ + + out_list = [] + for member in LogLevel: + out_list.append((member.name, member.value)) + return out_list diff --git a/test/concept-log-levels/mapping.json b/test/concept-log-levels/mapping.json new file mode 100644 index 0000000..fa9fcb6 --- /dev/null +++ b/test/concept-log-levels/mapping.json @@ -0,0 +1,23 @@ +{ + "placeholder_0": "LogLevel", + "placeholder_1": "TRACE", + "placeholder_2": "DEBUG", + "placeholder_3": "INFO", + "placeholder_4": "WARNING", + "placeholder_5": "WARN", + "placeholder_6": "ERROR", + "placeholder_7": "FATAL", + "placeholder_8": "UNKNOWN", + "placeholder_9": "LogLevelInt", + "placeholder_10": "parse_log_level", + "placeholder_11": "message", + "placeholder_12": "str_split", + "placeholder_13": "lvl", + "placeholder_14": "level", + "placeholder_15": "convert_to_short_log", + "placeholder_16": "log_level", + "placeholder_17": "get_warn_alias", + "placeholder_18": "get_members", + "placeholder_19": "out_list", + "placeholder_20": "member" +} \ No newline at end of file diff --git a/test/concept-log-levels/representation.json b/test/concept-log-levels/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-log-levels/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-log-levels/representation.out b/test/concept-log-levels/representation.out new file mode 100644 index 0000000..f92de7e --- /dev/null +++ b/test/concept-log-levels/representation.out @@ -0,0 +1,1819 @@ +## BEGIN NORMALIZED CODE ## +from enum import Enum + + +class placeholder_0(Enum): + placeholder_1 = "TRC" + placeholder_2 = "DBG" + placeholder_3 = "INF" + placeholder_4 = "WRN" + placeholder_5 = "WRN" + placeholder_6 = "ERR" + placeholder_7 = "FTL" + placeholder_8 = "UKN" + + +class placeholder_9(Enum): + placeholder_1 = 0 + placeholder_2 = 1 + placeholder_3 = 4 + placeholder_4 = 5 + placeholder_5 = 5 + placeholder_6 = 6 + placeholder_7 = 7 + placeholder_8 = 42 + + +def placeholder_10(placeholder_11): + placeholder_12 = placeholder_11.split(":") + placeholder_13 = placeholder_12[0][1:-1] + if placeholder_13 in [placeholder_14.value for placeholder_14 in placeholder_0]: + return placeholder_0(placeholder_13) + return placeholder_0("UKN") + + +def placeholder_15(placeholder_16, placeholder_11): + return f"{placeholder_9[placeholder_16.name].value}:{placeholder_11}" + + +def placeholder_17(): + return placeholder_0("WRN") + + +def placeholder_18(): + placeholder_19 = [] + for placeholder_20 in placeholder_0: + placeholder_19.append((placeholder_20.name, placeholder_20.value)) + return placeholder_19 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'enum', + [ + alias( + 'Enum', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=21), + ClassDef( + 'LogLevel', + [ + Name( + 'Enum', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=19)], + [], + [ + Expr( + Constant( + 'Represent different log levels by their verbose codes.', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=64), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=64), + Assign( + [ + Name( + 'TRACE', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=9)], + Constant( + 'TRC', + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=17), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=17), + Assign( + [ + Name( + 'DEBUG', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=9)], + Constant( + 'DBG', + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=17), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=17), + Assign( + [ + Name( + 'INFO', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=8)], + Constant( + 'INF', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=16), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=16), + Assign( + [ + Name( + 'WARNING', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=11)], + Constant( + 'WRN', + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=19), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=19), + Assign( + [ + Name( + 'WARN', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=8)], + Constant( + 'WRN', + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=16), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=16), + Assign( + [ + Name( + 'ERROR', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=9)], + Constant( + 'ERR', + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=17), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=17), + Assign( + [ + Name( + 'FATAL', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=9)], + Constant( + 'FTL', + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=17), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=17), + Assign( + [ + Name( + 'UNKNOWN', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=11)], + Constant( + 'UKN', + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=19), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=19)], + [], + lineno=4, + col_offset=0, + end_lineno=14, + end_col_offset=19), + ClassDef( + 'LogLevelInt', + [ + Name( + 'Enum', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=22)], + [], + [ + Expr( + Constant( + 'Represent different log levels by their short codes.', + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=62), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=62), + Assign( + [ + Name( + 'TRACE', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=9)], + Constant( + 0, + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=13), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=13), + Assign( + [ + Name( + 'DEBUG', + Store(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=9)], + Constant( + 1, + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=13), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=13), + Assign( + [ + Name( + 'INFO', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=8)], + Constant( + 4, + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=12), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=12), + Assign( + [ + Name( + 'WARNING', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=11)], + Constant( + 5, + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=15), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=15), + Assign( + [ + Name( + 'WARN', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=8)], + Constant( + 5, + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=12), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=12), + Assign( + [ + Name( + 'ERROR', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=9)], + Constant( + 6, + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=13), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=13), + Assign( + [ + Name( + 'FATAL', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=9)], + Constant( + 7, + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=13), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=13), + Assign( + [ + Name( + 'UNKNOWN', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=11)], + Constant( + 42, + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=16), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=16)], + [], + lineno=17, + col_offset=0, + end_lineno=27, + end_col_offset=16), + FunctionDef( + 'parse_log_level', + arguments( + [], + [ + arg( + 'message', + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Return level enum for log message.\n\n :param message: log message (string)\n :return: enum - 'LogLevel.'. Return 'LogLevel.Unknown' if an unknown severity is passed.\n ", + lineno=31, + col_offset=4, + end_lineno=35, + end_col_offset=7), + lineno=31, + col_offset=4, + end_lineno=35, + end_col_offset=7), + Assign( + [ + Name( + 'str_split', + Store(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=13)], + Call( + Attribute( + Name( + 'message', + Load(), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=23), + 'split', + Load(), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=29), + [ + Constant( + ':', + lineno=37, + col_offset=30, + end_lineno=37, + end_col_offset=33)], + [], + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=34), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=34), + Assign( + [ + Name( + 'lvl', + Store(), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=7)], + Subscript( + Subscript( + Name( + 'str_split', + Load(), + lineno=38, + col_offset=10, + end_lineno=38, + end_col_offset=19), + Constant( + 0, + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=21), + Load(), + lineno=38, + col_offset=10, + end_lineno=38, + end_col_offset=22), + Slice( + Constant( + 1, + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=24), + UnaryOp( + USub(), + Constant( + 1, + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=27), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=27), + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=27), + Load(), + lineno=38, + col_offset=10, + end_lineno=38, + end_col_offset=28), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=28), + If( + Compare( + Name( + 'lvl', + Load(), + lineno=39, + col_offset=7, + end_lineno=39, + end_col_offset=10), + [ + In()], + [ + ListComp( + Attribute( + Name( + 'level', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=20), + 'value', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=26), + [ + comprehension( + Name( + 'level', + Store(), + lineno=39, + col_offset=31, + end_lineno=39, + end_col_offset=36), + Name( + 'LogLevel', + Load(), + lineno=39, + col_offset=40, + end_lineno=39, + end_col_offset=48), + [], + 0)], + lineno=39, + col_offset=14, + end_lineno=39, + end_col_offset=49)], + lineno=39, + col_offset=7, + end_lineno=39, + end_col_offset=49), + [ + Return( + Call( + Name( + 'LogLevel', + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=23), + [ + Name( + 'lvl', + Load(), + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=27)], + [], + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=28), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=28)], + [], + lineno=39, + col_offset=4, + end_lineno=40, + end_col_offset=28), + Return( + Call( + Name( + 'LogLevel', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=19), + [ + Constant( + 'UKN', + lineno=41, + col_offset=20, + end_lineno=41, + end_col_offset=25)], + [], + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=26), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=26)], + [], + lineno=30, + col_offset=0, + end_lineno=41, + end_col_offset=26), + FunctionDef( + 'convert_to_short_log', + arguments( + [], + [ + arg( + 'log_level', + lineno=44, + col_offset=25, + end_lineno=44, + end_col_offset=34), + arg( + 'message', + lineno=44, + col_offset=36, + end_lineno=44, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Convert a log message to its shorter format.\n\n :param log_level: enum - 'LogLevel.' e.g. 'LogLevel.Error'\n :param message: str - log message\n :return: enum - 'LogLevelInt.` e.g. 'LogLevelInt.5'\n ", + lineno=45, + col_offset=4, + end_lineno=50, + end_col_offset=7), + lineno=45, + col_offset=4, + end_lineno=50, + end_col_offset=7), + Return( + JoinedStr( + [ + FormattedValue( + Attribute( + Subscript( + Name( + 'LogLevelInt', + Load(), + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=25), + Attribute( + Name( + 'log_level', + Load(), + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=35), + 'name', + Load(), + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=40), + Load(), + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=41), + 'value', + Load(), + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=47), + -1, + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=59), + Constant( + ':', + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=59), + FormattedValue( + Name( + 'message', + Load(), + lineno=52, + col_offset=50, + end_lineno=52, + end_col_offset=57), + -1, + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=59)], + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=59), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=59)], + [], + lineno=44, + col_offset=0, + end_lineno=52, + end_col_offset=59), + FunctionDef( + 'get_warn_alias', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Returns the enum for LogLevel.Warning.\n\n :return: enum - 'LogLevel'.'\n ", + lineno=56, + col_offset=4, + end_lineno=59, + end_col_offset=7), + lineno=56, + col_offset=4, + end_lineno=59, + end_col_offset=7), + Return( + Call( + Name( + 'LogLevel', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=19), + [ + Constant( + 'WRN', + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=25)], + [], + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=26), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=26)], + [], + lineno=55, + col_offset=0, + end_lineno=61, + end_col_offset=26), + FunctionDef( + 'get_members', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return all members of the enum.\n\n :return: list of tuples - [(name1, value1), (name2, value2)]\n ', + lineno=65, + col_offset=4, + end_lineno=68, + end_col_offset=7), + lineno=65, + col_offset=4, + end_lineno=68, + end_col_offset=7), + Assign( + [ + Name( + 'out_list', + Store(), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=12)], + List( + [], + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=17), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=17), + For( + Name( + 'member', + Store(), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=14), + Name( + 'LogLevel', + Load(), + lineno=71, + col_offset=18, + end_lineno=71, + end_col_offset=26), + [ + Expr( + Call( + Attribute( + Name( + 'out_list', + Load(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=16), + 'append', + Load(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=23), + [ + Tuple( + [ + Attribute( + Name( + 'member', + Load(), + lineno=72, + col_offset=25, + end_lineno=72, + end_col_offset=31), + 'name', + Load(), + lineno=72, + col_offset=25, + end_lineno=72, + end_col_offset=36), + Attribute( + Name( + 'member', + Load(), + lineno=72, + col_offset=38, + end_lineno=72, + end_col_offset=44), + 'value', + Load(), + lineno=72, + col_offset=38, + end_lineno=72, + end_col_offset=50)], + Load(), + lineno=72, + col_offset=24, + end_lineno=72, + end_col_offset=51)], + [], + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=52), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=52)], + [], + lineno=71, + col_offset=4, + end_lineno=72, + end_col_offset=52), + Return( + Name( + 'out_list', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=19), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=19)], + [], + lineno=64, + col_offset=0, + end_lineno=73, + end_col_offset=19)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'enum', + [ + alias( + 'Enum', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=21), + ClassDef( + 'placeholder_0', + [ + Name( + 'Enum', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=19)], + [], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=9)], + Constant( + 'TRC', + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=17), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=9)], + Constant( + 'DBG', + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=17), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=8)], + Constant( + 'INF', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=16), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=16), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=11)], + Constant( + 'WRN', + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=19), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=19), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=8)], + Constant( + 'WRN', + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=16), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=16), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=9)], + Constant( + 'ERR', + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=17), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=9)], + Constant( + 'FTL', + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=17), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=11)], + Constant( + 'UKN', + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=19), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=19)], + [], + lineno=4, + col_offset=0, + end_lineno=14, + end_col_offset=19), + ClassDef( + 'placeholder_9', + [ + Name( + 'Enum', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=22)], + [], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=9)], + Constant( + 0, + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=13), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=9)], + Constant( + 1, + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=13), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=8)], + Constant( + 4, + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=12), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=12), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=11)], + Constant( + 5, + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=15), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=15), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=8)], + Constant( + 5, + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=12), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=12), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=9)], + Constant( + 6, + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=13), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=9)], + Constant( + 7, + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=13), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=11)], + Constant( + 42, + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=16), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=16)], + [], + lineno=17, + col_offset=0, + end_lineno=27, + end_col_offset=16), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_11', + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=13)], + Call( + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=23), + 'split', + Load(), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=29), + [ + Constant( + ':', + lineno=37, + col_offset=30, + end_lineno=37, + end_col_offset=33)], + [], + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=34), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=34), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=7)], + Subscript( + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=38, + col_offset=10, + end_lineno=38, + end_col_offset=19), + Constant( + 0, + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=21), + Load(), + lineno=38, + col_offset=10, + end_lineno=38, + end_col_offset=22), + Slice( + Constant( + 1, + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=24), + UnaryOp( + USub(), + Constant( + 1, + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=27), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=27), + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=27), + Load(), + lineno=38, + col_offset=10, + end_lineno=38, + end_col_offset=28), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=28), + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=39, + col_offset=7, + end_lineno=39, + end_col_offset=10), + [ + In()], + [ + ListComp( + Attribute( + Name( + 'placeholder_14', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=20), + 'value', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=26), + [ + comprehension( + Name( + 'placeholder_14', + Store(), + lineno=39, + col_offset=31, + end_lineno=39, + end_col_offset=36), + Name( + 'placeholder_0', + Load(), + lineno=39, + col_offset=40, + end_lineno=39, + end_col_offset=48), + [], + 0)], + lineno=39, + col_offset=14, + end_lineno=39, + end_col_offset=49)], + lineno=39, + col_offset=7, + end_lineno=39, + end_col_offset=49), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=23), + [ + Name( + 'placeholder_13', + Load(), + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=27)], + [], + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=28), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=28)], + [], + lineno=39, + col_offset=4, + end_lineno=40, + end_col_offset=28), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=19), + [ + Constant( + 'UKN', + lineno=41, + col_offset=20, + end_lineno=41, + end_col_offset=25)], + [], + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=26), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=26)], + [], + lineno=30, + col_offset=0, + end_lineno=41, + end_col_offset=26), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'placeholder_16', + lineno=44, + col_offset=25, + end_lineno=44, + end_col_offset=34), + arg( + 'placeholder_11', + lineno=44, + col_offset=36, + end_lineno=44, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + FormattedValue( + Attribute( + Subscript( + Name( + 'placeholder_9', + Load(), + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=25), + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=35), + 'name', + Load(), + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=40), + Load(), + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=41), + 'value', + Load(), + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=47), + -1, + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=59), + Constant( + ':', + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=59), + FormattedValue( + Name( + 'placeholder_11', + Load(), + lineno=52, + col_offset=50, + end_lineno=52, + end_col_offset=57), + -1, + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=59)], + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=59), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=59)], + [], + lineno=44, + col_offset=0, + end_lineno=52, + end_col_offset=59), + FunctionDef( + 'placeholder_17', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=19), + [ + Constant( + 'WRN', + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=25)], + [], + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=26), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=26)], + [], + lineno=55, + col_offset=0, + end_lineno=61, + end_col_offset=26), + FunctionDef( + 'placeholder_18', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=12)], + List( + [], + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=17), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=17), + For( + Name( + 'placeholder_20', + Store(), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=14), + Name( + 'placeholder_0', + Load(), + lineno=71, + col_offset=18, + end_lineno=71, + end_col_offset=26), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_19', + Load(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=16), + 'append', + Load(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=23), + [ + Tuple( + [ + Attribute( + Name( + 'placeholder_20', + Load(), + lineno=72, + col_offset=25, + end_lineno=72, + end_col_offset=31), + 'name', + Load(), + lineno=72, + col_offset=25, + end_lineno=72, + end_col_offset=36), + Attribute( + Name( + 'placeholder_20', + Load(), + lineno=72, + col_offset=38, + end_lineno=72, + end_col_offset=44), + 'value', + Load(), + lineno=72, + col_offset=38, + end_lineno=72, + end_col_offset=50)], + Load(), + lineno=72, + col_offset=24, + end_lineno=72, + end_col_offset=51)], + [], + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=52), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=52)], + [], + lineno=71, + col_offset=4, + end_lineno=72, + end_col_offset=52), + Return( + Name( + 'placeholder_19', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=19), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=19)], + [], + lineno=64, + col_offset=0, + end_lineno=73, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-log-levels/representation.txt b/test/concept-log-levels/representation.txt new file mode 100644 index 0000000..0364b82 --- /dev/null +++ b/test/concept-log-levels/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('enum', [alias('Enum', lineno=1, col_offset=17, end_lineno=1, end_col_offset=21)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=21), ClassDef('placeholder_0', [Name('Enum', Load(), lineno=4, col_offset=15, end_lineno=4, end_col_offset=19)], [], [Assign([Name('placeholder_1', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=9)], Constant('TRC', lineno=7, col_offset=12, end_lineno=7, end_col_offset=17), lineno=7, col_offset=4, end_lineno=7, end_col_offset=17), Assign([Name('placeholder_2', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=9)], Constant('DBG', lineno=8, col_offset=12, end_lineno=8, end_col_offset=17), lineno=8, col_offset=4, end_lineno=8, end_col_offset=17), Assign([Name('placeholder_3', Store(), lineno=9, col_offset=4, end_lineno=9, end_col_offset=8)], Constant('INF', lineno=9, col_offset=11, end_lineno=9, end_col_offset=16), lineno=9, col_offset=4, end_lineno=9, end_col_offset=16), Assign([Name('placeholder_4', Store(), lineno=10, col_offset=4, end_lineno=10, end_col_offset=11)], Constant('WRN', lineno=10, col_offset=14, end_lineno=10, end_col_offset=19), lineno=10, col_offset=4, end_lineno=10, end_col_offset=19), Assign([Name('placeholder_5', Store(), lineno=11, col_offset=4, end_lineno=11, end_col_offset=8)], Constant('WRN', lineno=11, col_offset=11, end_lineno=11, end_col_offset=16), lineno=11, col_offset=4, end_lineno=11, end_col_offset=16), Assign([Name('placeholder_6', Store(), lineno=12, col_offset=4, end_lineno=12, end_col_offset=9)], Constant('ERR', lineno=12, col_offset=12, end_lineno=12, end_col_offset=17), lineno=12, col_offset=4, end_lineno=12, end_col_offset=17), Assign([Name('placeholder_7', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=9)], Constant('FTL', lineno=13, col_offset=12, end_lineno=13, end_col_offset=17), lineno=13, col_offset=4, end_lineno=13, end_col_offset=17), Assign([Name('placeholder_8', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=11)], Constant('UKN', lineno=14, col_offset=14, end_lineno=14, end_col_offset=19), lineno=14, col_offset=4, end_lineno=14, end_col_offset=19)], [], lineno=4, col_offset=0, end_lineno=14, end_col_offset=19), ClassDef('placeholder_9', [Name('Enum', Load(), lineno=17, col_offset=18, end_lineno=17, end_col_offset=22)], [], [Assign([Name('placeholder_1', Store(), lineno=20, col_offset=4, end_lineno=20, end_col_offset=9)], Constant(0, lineno=20, col_offset=12, end_lineno=20, end_col_offset=13), lineno=20, col_offset=4, end_lineno=20, end_col_offset=13), Assign([Name('placeholder_2', Store(), lineno=21, col_offset=4, end_lineno=21, end_col_offset=9)], Constant(1, lineno=21, col_offset=12, end_lineno=21, end_col_offset=13), lineno=21, col_offset=4, end_lineno=21, end_col_offset=13), Assign([Name('placeholder_3', Store(), lineno=22, col_offset=4, end_lineno=22, end_col_offset=8)], Constant(4, lineno=22, col_offset=11, end_lineno=22, end_col_offset=12), lineno=22, col_offset=4, end_lineno=22, end_col_offset=12), Assign([Name('placeholder_4', Store(), lineno=23, col_offset=4, end_lineno=23, end_col_offset=11)], Constant(5, lineno=23, col_offset=14, end_lineno=23, end_col_offset=15), lineno=23, col_offset=4, end_lineno=23, end_col_offset=15), Assign([Name('placeholder_5', Store(), lineno=24, col_offset=4, end_lineno=24, end_col_offset=8)], Constant(5, lineno=24, col_offset=11, end_lineno=24, end_col_offset=12), lineno=24, col_offset=4, end_lineno=24, end_col_offset=12), Assign([Name('placeholder_6', Store(), lineno=25, col_offset=4, end_lineno=25, end_col_offset=9)], Constant(6, lineno=25, col_offset=12, end_lineno=25, end_col_offset=13), lineno=25, col_offset=4, end_lineno=25, end_col_offset=13), Assign([Name('placeholder_7', Store(), lineno=26, col_offset=4, end_lineno=26, end_col_offset=9)], Constant(7, lineno=26, col_offset=12, end_lineno=26, end_col_offset=13), lineno=26, col_offset=4, end_lineno=26, end_col_offset=13), Assign([Name('placeholder_8', Store(), lineno=27, col_offset=4, end_lineno=27, end_col_offset=11)], Constant(42, lineno=27, col_offset=14, end_lineno=27, end_col_offset=16), lineno=27, col_offset=4, end_lineno=27, end_col_offset=16)], [], lineno=17, col_offset=0, end_lineno=27, end_col_offset=16), FunctionDef('placeholder_10', arguments([], [arg('placeholder_11', lineno=30, col_offset=20, end_lineno=30, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_12', Store(), lineno=37, col_offset=4, end_lineno=37, end_col_offset=13)], Call(Attribute(Name('placeholder_11', Load(), lineno=37, col_offset=16, end_lineno=37, end_col_offset=23), 'split', Load(), lineno=37, col_offset=16, end_lineno=37, end_col_offset=29), [Constant(':', lineno=37, col_offset=30, end_lineno=37, end_col_offset=33)], [], lineno=37, col_offset=16, end_lineno=37, end_col_offset=34), lineno=37, col_offset=4, end_lineno=37, end_col_offset=34), Assign([Name('placeholder_13', Store(), lineno=38, col_offset=4, end_lineno=38, end_col_offset=7)], Subscript(Subscript(Name('placeholder_12', Load(), lineno=38, col_offset=10, end_lineno=38, end_col_offset=19), Constant(0, lineno=38, col_offset=20, end_lineno=38, end_col_offset=21), Load(), lineno=38, col_offset=10, end_lineno=38, end_col_offset=22), Slice(Constant(1, lineno=38, col_offset=23, end_lineno=38, end_col_offset=24), UnaryOp(USub(), Constant(1, lineno=38, col_offset=26, end_lineno=38, end_col_offset=27), lineno=38, col_offset=25, end_lineno=38, end_col_offset=27), lineno=38, col_offset=23, end_lineno=38, end_col_offset=27), Load(), lineno=38, col_offset=10, end_lineno=38, end_col_offset=28), lineno=38, col_offset=4, end_lineno=38, end_col_offset=28), If(Compare(Name('placeholder_13', Load(), lineno=39, col_offset=7, end_lineno=39, end_col_offset=10), [In()], [ListComp(Attribute(Name('placeholder_14', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=20), 'value', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=26), [comprehension(Name('placeholder_14', Store(), lineno=39, col_offset=31, end_lineno=39, end_col_offset=36), Name('placeholder_0', Load(), lineno=39, col_offset=40, end_lineno=39, end_col_offset=48), [], 0)], lineno=39, col_offset=14, end_lineno=39, end_col_offset=49)], lineno=39, col_offset=7, end_lineno=39, end_col_offset=49), [Return(Call(Name('placeholder_0', Load(), lineno=40, col_offset=15, end_lineno=40, end_col_offset=23), [Name('placeholder_13', Load(), lineno=40, col_offset=24, end_lineno=40, end_col_offset=27)], [], lineno=40, col_offset=15, end_lineno=40, end_col_offset=28), lineno=40, col_offset=8, end_lineno=40, end_col_offset=28)], [], lineno=39, col_offset=4, end_lineno=40, end_col_offset=28), Return(Call(Name('placeholder_0', Load(), lineno=41, col_offset=11, end_lineno=41, end_col_offset=19), [Constant('UKN', lineno=41, col_offset=20, end_lineno=41, end_col_offset=25)], [], lineno=41, col_offset=11, end_lineno=41, end_col_offset=26), lineno=41, col_offset=4, end_lineno=41, end_col_offset=26)], [], lineno=30, col_offset=0, end_lineno=41, end_col_offset=26), FunctionDef('placeholder_15', arguments([], [arg('placeholder_16', lineno=44, col_offset=25, end_lineno=44, end_col_offset=34), arg('placeholder_11', lineno=44, col_offset=36, end_lineno=44, end_col_offset=43)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(JoinedStr([FormattedValue(Attribute(Subscript(Name('placeholder_9', Load(), lineno=52, col_offset=14, end_lineno=52, end_col_offset=25), Attribute(Name('placeholder_16', Load(), lineno=52, col_offset=26, end_lineno=52, end_col_offset=35), 'name', Load(), lineno=52, col_offset=26, end_lineno=52, end_col_offset=40), Load(), lineno=52, col_offset=14, end_lineno=52, end_col_offset=41), 'value', Load(), lineno=52, col_offset=14, end_lineno=52, end_col_offset=47), -1, lineno=52, col_offset=11, end_lineno=52, end_col_offset=59), Constant(':', lineno=52, col_offset=11, end_lineno=52, end_col_offset=59), FormattedValue(Name('placeholder_11', Load(), lineno=52, col_offset=50, end_lineno=52, end_col_offset=57), -1, lineno=52, col_offset=11, end_lineno=52, end_col_offset=59)], lineno=52, col_offset=11, end_lineno=52, end_col_offset=59), lineno=52, col_offset=4, end_lineno=52, end_col_offset=59)], [], lineno=44, col_offset=0, end_lineno=52, end_col_offset=59), FunctionDef('placeholder_17', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=61, col_offset=11, end_lineno=61, end_col_offset=19), [Constant('WRN', lineno=61, col_offset=20, end_lineno=61, end_col_offset=25)], [], lineno=61, col_offset=11, end_lineno=61, end_col_offset=26), lineno=61, col_offset=4, end_lineno=61, end_col_offset=26)], [], lineno=55, col_offset=0, end_lineno=61, end_col_offset=26), FunctionDef('placeholder_18', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_19', Store(), lineno=70, col_offset=4, end_lineno=70, end_col_offset=12)], List([], Load(), lineno=70, col_offset=15, end_lineno=70, end_col_offset=17), lineno=70, col_offset=4, end_lineno=70, end_col_offset=17), For(Name('placeholder_20', Store(), lineno=71, col_offset=8, end_lineno=71, end_col_offset=14), Name('placeholder_0', Load(), lineno=71, col_offset=18, end_lineno=71, end_col_offset=26), [Expr(Call(Attribute(Name('placeholder_19', Load(), lineno=72, col_offset=8, end_lineno=72, end_col_offset=16), 'append', Load(), lineno=72, col_offset=8, end_lineno=72, end_col_offset=23), [Tuple([Attribute(Name('placeholder_20', Load(), lineno=72, col_offset=25, end_lineno=72, end_col_offset=31), 'name', Load(), lineno=72, col_offset=25, end_lineno=72, end_col_offset=36), Attribute(Name('placeholder_20', Load(), lineno=72, col_offset=38, end_lineno=72, end_col_offset=44), 'value', Load(), lineno=72, col_offset=38, end_lineno=72, end_col_offset=50)], Load(), lineno=72, col_offset=24, end_lineno=72, end_col_offset=51)], [], lineno=72, col_offset=8, end_lineno=72, end_col_offset=52), lineno=72, col_offset=8, end_lineno=72, end_col_offset=52)], [], lineno=71, col_offset=4, end_lineno=72, end_col_offset=52), Return(Name('placeholder_19', Load(), lineno=73, col_offset=11, end_lineno=73, end_col_offset=19), lineno=73, col_offset=4, end_lineno=73, end_col_offset=19)], [], lineno=64, col_offset=0, end_lineno=73, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/concept-making-the-grade/.meta/config.json b/test/concept-making-the-grade/.meta/config.json new file mode 100644 index 0000000..d9edd46 --- /dev/null +++ b/test/concept-making-the-grade/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "mohanrajanr", + "BethanyG" + ], + "contributors": [ + "pranasziaukas" + ], + "files": { + "solution": [ + "loops.py" + ], + "test": [ + "loops_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "icon": "grep", + "blurb": "Learn about loops by grading and organizing your students exam scores." +} diff --git a/test/concept-making-the-grade/loops.py b/test/concept-making-the-grade/loops.py new file mode 100644 index 0000000..5aa7508 --- /dev/null +++ b/test/concept-making-the-grade/loops.py @@ -0,0 +1,98 @@ +"""Functions for organizing and calculating student exam scores.""" + + +def round_scores(student_scores): + """Round all provided student scores. + + :param student_scores: list - float or int of student exam scores. + :return: list - student scores *rounded* to nearest integer value. + """ + + rounded = [] + while student_scores: + rounded.append(round(student_scores.pop())) + return rounded + + +def count_failed_students(student_scores): + """Count the number of failing students out of the group provided. + + :param student_scores: list - containing int student scores. + :return: int - count of student scores at or below 40. + """ + + non_passing = 0 + for score in student_scores: + if score <= 40: + non_passing += 1 + return non_passing + + +def above_threshold(student_scores, threshold): + """Determine how many of the provided student scores were 'the best' based on the provided threshold. + + :param student_scores: list - of integer scores. + :param threshold: int - threshold to cross to be the "best" score. + :return: list - of integer scores that are at or above the "best" threshold. + """ + + above = [] + + for score in student_scores: + if score >= threshold: + above.append(score) + return above + + +def letter_grades(highest): + """Create a list of grade thresholds based on the provided highest grade. + + :param highest: int - value of highest exam score. + :return: list - of lower threshold scores for each D-A letter grade interval. + For example, where the highest score is 100, and failing is <= 40, + The result would be [41, 56, 71, 86]: + + 41 <= "D" <= 55 + 56 <= "C" <= 70 + 71 <= "B" <= 85 + 86 <= "A" <= 100 + """ + + increment = round((highest - 40) / 4) + scores = [] + for score in range(41, highest, increment): + scores.append(score) + return scores + + +def student_ranking(student_scores, student_names): + """Organize the student's rank, name, and grade information in ascending order. + + :param student_scores: list - of scores in descending order. + :param student_names: list - of string names by exam score in descending order. + :return: list - of strings in format [". : "]. + """ + + results = [] + for index, name in enumerate(student_names): + rank_string = str(index + 1) + ". " + name + ": " + str(student_scores[index]) + results.append(rank_string) + + return results + + +def perfect_score(student_info): + """Create a list that contains the name and grade of the first student to make a perfect score on the exam. + + :param student_info: list - of [, ] lists. + :return: list - first `[, 100]` or `[]` if no student score of 100 is found. + """ + + result = [] + + for item in student_info: + if item[1] == 100: + result = item + break + + return result diff --git a/test/concept-making-the-grade/mapping.json b/test/concept-making-the-grade/mapping.json new file mode 100644 index 0000000..6b53b9f --- /dev/null +++ b/test/concept-making-the-grade/mapping.json @@ -0,0 +1,25 @@ +{ + "placeholder_0": "round_scores", + "placeholder_1": "student_scores", + "placeholder_2": "rounded", + "placeholder_3": "count_failed_students", + "placeholder_4": "non_passing", + "placeholder_5": "score", + "placeholder_6": "above_threshold", + "placeholder_7": "threshold", + "placeholder_8": "above", + "placeholder_9": "letter_grades", + "placeholder_10": "highest", + "placeholder_11": "increment", + "placeholder_12": "scores", + "placeholder_13": "student_ranking", + "placeholder_14": "student_names", + "placeholder_15": "results", + "placeholder_16": "index", + "placeholder_17": "name", + "placeholder_18": "rank_string", + "placeholder_19": "perfect_score", + "placeholder_20": "student_info", + "placeholder_21": "result", + "placeholder_22": "item" +} \ No newline at end of file diff --git a/test/concept-making-the-grade/representation.json b/test/concept-making-the-grade/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-making-the-grade/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-making-the-grade/representation.out b/test/concept-making-the-grade/representation.out new file mode 100644 index 0000000..8a56256 --- /dev/null +++ b/test/concept-making-the-grade/representation.out @@ -0,0 +1,2102 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = [] + while placeholder_1: + placeholder_2.append(round(placeholder_1.pop())) + return placeholder_2 + + +def placeholder_3(placeholder_1): + placeholder_4 = 0 + for placeholder_5 in placeholder_1: + if placeholder_5 <= 40: + placeholder_4 += 1 + return placeholder_4 + + +def placeholder_6(placeholder_1, placeholder_7): + placeholder_8 = [] + for placeholder_5 in placeholder_1: + if placeholder_5 >= placeholder_7: + placeholder_8.append(placeholder_5) + return placeholder_8 + + +def placeholder_9(placeholder_10): + placeholder_11 = round((placeholder_10 - 40) / 4) + placeholder_12 = [] + for placeholder_5 in range(41, placeholder_10, placeholder_11): + placeholder_12.append(placeholder_5) + return placeholder_12 + + +def placeholder_13(placeholder_1, placeholder_14): + placeholder_15 = [] + for placeholder_16, placeholder_17 in enumerate(placeholder_14): + placeholder_18 = ( + str(placeholder_16 + 1) + + ". " + + placeholder_17 + + ": " + + str(placeholder_1[placeholder_16]) + ) + placeholder_15.append(placeholder_18) + return placeholder_15 + + +def placeholder_19(placeholder_20): + placeholder_21 = [] + for placeholder_22 in placeholder_20: + if placeholder_22[1] == 100: + placeholder_21 = placeholder_22 + break + return placeholder_21 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions for organizing and calculating student exam scores.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=67), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=67), + FunctionDef( + 'round_scores', + arguments( + [], + [ + arg( + 'student_scores', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Round all provided student scores.\n\n :param student_scores: list - float or int of student exam scores.\n :return: list - student scores *rounded* to nearest integer value.\n ', + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + Assign( + [ + Name( + 'rounded', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=11)], + List( + [], + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=16), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=16), + While( + Name( + 'student_scores', + Load(), + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'rounded', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=15), + 'append', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22), + [ + Call( + Name( + 'round', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=28), + [ + Call( + Attribute( + Name( + 'student_scores', + Load(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=43), + 'pop', + Load(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=47), + [], + [], + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=49)], + [], + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=50)], + [], + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=51), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=51)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=51), + Return( + Name( + 'rounded', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=18), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=18)], + [], + lineno=4, + col_offset=0, + end_lineno=14, + end_col_offset=18), + FunctionDef( + 'count_failed_students', + arguments( + [], + [ + arg( + 'student_scores', + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Count the number of failing students out of the group provided.\n\n :param student_scores: list - containing int student scores.\n :return: int - count of student scores at or below 40.\n ', + lineno=18, + col_offset=4, + end_lineno=22, + end_col_offset=7), + lineno=18, + col_offset=4, + end_lineno=22, + end_col_offset=7), + Assign( + [ + Name( + 'non_passing', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=15)], + Constant( + 0, + lineno=24, + col_offset=18, + end_lineno=24, + end_col_offset=19), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=19), + For( + Name( + 'score', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=13), + Name( + 'student_scores', + Load(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=31), + [ + If( + Compare( + Name( + 'score', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=16), + [ + LtE()], + [ + Constant( + 40, + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=22)], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=22), + [ + AugAssign( + Name( + 'non_passing', + Store(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=27, + col_offset=27, + end_lineno=27, + end_col_offset=28), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=28)], + [], + lineno=26, + col_offset=8, + end_lineno=27, + end_col_offset=28)], + [], + lineno=25, + col_offset=4, + end_lineno=27, + end_col_offset=28), + Return( + Name( + 'non_passing', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=22), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=22)], + [], + lineno=17, + col_offset=0, + end_lineno=28, + end_col_offset=22), + FunctionDef( + 'above_threshold', + arguments( + [], + [ + arg( + 'student_scores', + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=34), + arg( + 'threshold', + lineno=31, + col_offset=36, + end_lineno=31, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Determine how many of the provided student scores were \'the best\' based on the provided threshold.\n\n :param student_scores: list - of integer scores.\n :param threshold: int - threshold to cross to be the "best" score.\n :return: list - of integer scores that are at or above the "best" threshold.\n ', + lineno=32, + col_offset=4, + end_lineno=37, + end_col_offset=7), + lineno=32, + col_offset=4, + end_lineno=37, + end_col_offset=7), + Assign( + [ + Name( + 'above', + Store(), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=9)], + List( + [], + Load(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=14), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=14), + For( + Name( + 'score', + Store(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=13), + Name( + 'student_scores', + Load(), + lineno=41, + col_offset=17, + end_lineno=41, + end_col_offset=31), + [ + If( + Compare( + Name( + 'score', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=16), + [ + GtE()], + [ + Name( + 'threshold', + Load(), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=29)], + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'above', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=17), + 'append', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=24), + [ + Name( + 'score', + Load(), + lineno=43, + col_offset=25, + end_lineno=43, + end_col_offset=30)], + [], + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=31), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=31)], + [], + lineno=42, + col_offset=8, + end_lineno=43, + end_col_offset=31)], + [], + lineno=41, + col_offset=4, + end_lineno=43, + end_col_offset=31), + Return( + Name( + 'above', + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=16), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=16)], + [], + lineno=31, + col_offset=0, + end_lineno=44, + end_col_offset=16), + FunctionDef( + 'letter_grades', + arguments( + [], + [ + arg( + 'highest', + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Create a list of grade thresholds based on the provided highest grade.\n\n :param highest: int - value of highest exam score.\n :return: list - of lower threshold scores for each D-A letter grade interval.\n For example, where the highest score is 100, and failing is <= 40,\n The result would be [41, 56, 71, 86]:\n\n 41 <= "D" <= 55\n 56 <= "C" <= 70\n 71 <= "B" <= 85\n 86 <= "A" <= 100\n ', + lineno=48, + col_offset=4, + end_lineno=59, + end_col_offset=7), + lineno=48, + col_offset=4, + end_lineno=59, + end_col_offset=7), + Assign( + [ + Name( + 'increment', + Store(), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=13)], + Call( + Name( + 'round', + Load(), + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=21), + [ + BinOp( + BinOp( + Name( + 'highest', + Load(), + lineno=61, + col_offset=23, + end_lineno=61, + end_col_offset=30), + Sub(), + Constant( + 40, + lineno=61, + col_offset=33, + end_lineno=61, + end_col_offset=35), + lineno=61, + col_offset=23, + end_lineno=61, + end_col_offset=35), + Div(), + Constant( + 4, + lineno=61, + col_offset=39, + end_lineno=61, + end_col_offset=40), + lineno=61, + col_offset=22, + end_lineno=61, + end_col_offset=40)], + [], + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=41), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=41), + Assign( + [ + Name( + 'scores', + Store(), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=10)], + List( + [], + Load(), + lineno=62, + col_offset=13, + end_lineno=62, + end_col_offset=15), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=15), + For( + Name( + 'score', + Store(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=22), + [ + Constant( + 41, + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=25), + Name( + 'highest', + Load(), + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=34), + Name( + 'increment', + Load(), + lineno=63, + col_offset=36, + end_lineno=63, + end_col_offset=45)], + [], + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=46), + [ + Expr( + Call( + Attribute( + Name( + 'scores', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=14), + 'append', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=21), + [ + Name( + 'score', + Load(), + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=27)], + [], + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=28), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=28)], + [], + lineno=63, + col_offset=4, + end_lineno=64, + end_col_offset=28), + Return( + Name( + 'scores', + Load(), + lineno=65, + col_offset=11, + end_lineno=65, + end_col_offset=17), + lineno=65, + col_offset=4, + end_lineno=65, + end_col_offset=17)], + [], + lineno=47, + col_offset=0, + end_lineno=65, + end_col_offset=17), + FunctionDef( + 'student_ranking', + arguments( + [], + [ + arg( + 'student_scores', + lineno=68, + col_offset=20, + end_lineno=68, + end_col_offset=34), + arg( + 'student_names', + lineno=68, + col_offset=36, + end_lineno=68, + end_col_offset=49)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Organize the student\'s rank, name, and grade information in ascending order.\n\n :param student_scores: list - of scores in descending order.\n :param student_names: list - of string names by exam score in descending order.\n :return: list - of strings in format [". : "].\n ', + lineno=69, + col_offset=4, + end_lineno=74, + end_col_offset=7), + lineno=69, + col_offset=4, + end_lineno=74, + end_col_offset=7), + Assign( + [ + Name( + 'results', + Store(), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=11)], + List( + [], + Load(), + lineno=76, + col_offset=14, + end_lineno=76, + end_col_offset=16), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=16), + For( + Tuple( + [ + Name( + 'index', + Store(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=13), + Name( + 'name', + Store(), + lineno=77, + col_offset=15, + end_lineno=77, + end_col_offset=19)], + Store(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=19), + Call( + Name( + 'enumerate', + Load(), + lineno=77, + col_offset=23, + end_lineno=77, + end_col_offset=32), + [ + Name( + 'student_names', + Load(), + lineno=77, + col_offset=33, + end_lineno=77, + end_col_offset=46)], + [], + lineno=77, + col_offset=23, + end_lineno=77, + end_col_offset=47), + [ + Assign( + [ + Name( + 'rank_string', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=19)], + BinOp( + BinOp( + BinOp( + BinOp( + Call( + Name( + 'str', + Load(), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=25), + [ + BinOp( + Name( + 'index', + Load(), + lineno=78, + col_offset=26, + end_lineno=78, + end_col_offset=31), + Add(), + Constant( + 1, + lineno=78, + col_offset=34, + end_lineno=78, + end_col_offset=35), + lineno=78, + col_offset=26, + end_lineno=78, + end_col_offset=35)], + [], + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=36), + Add(), + Constant( + '. ', + lineno=78, + col_offset=39, + end_lineno=78, + end_col_offset=43), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=43), + Add(), + Name( + 'name', + Load(), + lineno=78, + col_offset=46, + end_lineno=78, + end_col_offset=50), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=50), + Add(), + Constant( + ': ', + lineno=78, + col_offset=53, + end_lineno=78, + end_col_offset=57), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=57), + Add(), + Call( + Name( + 'str', + Load(), + lineno=78, + col_offset=60, + end_lineno=78, + end_col_offset=63), + [ + Subscript( + Name( + 'student_scores', + Load(), + lineno=78, + col_offset=64, + end_lineno=78, + end_col_offset=78), + Name( + 'index', + Load(), + lineno=78, + col_offset=79, + end_lineno=78, + end_col_offset=84), + Load(), + lineno=78, + col_offset=64, + end_lineno=78, + end_col_offset=85)], + [], + lineno=78, + col_offset=60, + end_lineno=78, + end_col_offset=86), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=86), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=86), + Expr( + Call( + Attribute( + Name( + 'results', + Load(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=15), + 'append', + Load(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=22), + [ + Name( + 'rank_string', + Load(), + lineno=79, + col_offset=23, + end_lineno=79, + end_col_offset=34)], + [], + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=35), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=35)], + [], + lineno=77, + col_offset=4, + end_lineno=79, + end_col_offset=35), + Return( + Name( + 'results', + Load(), + lineno=81, + col_offset=11, + end_lineno=81, + end_col_offset=18), + lineno=81, + col_offset=4, + end_lineno=81, + end_col_offset=18)], + [], + lineno=68, + col_offset=0, + end_lineno=81, + end_col_offset=18), + FunctionDef( + 'perfect_score', + arguments( + [], + [ + arg( + 'student_info', + lineno=84, + col_offset=18, + end_lineno=84, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Create a list that contains the name and grade of the first student to make a perfect score on the exam.\n\n :param student_info: list - of [, ] lists.\n :return: list - first `[, 100]` or `[]` if no student score of 100 is found.\n ', + lineno=85, + col_offset=4, + end_lineno=89, + end_col_offset=7), + lineno=85, + col_offset=4, + end_lineno=89, + end_col_offset=7), + Assign( + [ + Name( + 'result', + Store(), + lineno=91, + col_offset=4, + end_lineno=91, + end_col_offset=10)], + List( + [], + Load(), + lineno=91, + col_offset=13, + end_lineno=91, + end_col_offset=15), + lineno=91, + col_offset=4, + end_lineno=91, + end_col_offset=15), + For( + Name( + 'item', + Store(), + lineno=93, + col_offset=8, + end_lineno=93, + end_col_offset=12), + Name( + 'student_info', + Load(), + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=28), + [ + If( + Compare( + Subscript( + Name( + 'item', + Load(), + lineno=94, + col_offset=11, + end_lineno=94, + end_col_offset=15), + Constant( + 1, + lineno=94, + col_offset=16, + end_lineno=94, + end_col_offset=17), + Load(), + lineno=94, + col_offset=11, + end_lineno=94, + end_col_offset=18), + [ + Eq()], + [ + Constant( + 100, + lineno=94, + col_offset=22, + end_lineno=94, + end_col_offset=25)], + lineno=94, + col_offset=11, + end_lineno=94, + end_col_offset=25), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=95, + col_offset=12, + end_lineno=95, + end_col_offset=18)], + Name( + 'item', + Load(), + lineno=95, + col_offset=21, + end_lineno=95, + end_col_offset=25), + lineno=95, + col_offset=12, + end_lineno=95, + end_col_offset=25), + Break( + lineno=96, + col_offset=12, + end_lineno=96, + end_col_offset=17)], + [], + lineno=94, + col_offset=8, + end_lineno=96, + end_col_offset=17)], + [], + lineno=93, + col_offset=4, + end_lineno=96, + end_col_offset=17), + Return( + Name( + 'result', + Load(), + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=17), + lineno=98, + col_offset=4, + end_lineno=98, + end_col_offset=17)], + [], + lineno=84, + col_offset=0, + end_lineno=98, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=11)], + List( + [], + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=16), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=16), + While( + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=15), + 'append', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22), + [ + Call( + Name( + 'round', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=28), + [ + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=43), + 'pop', + Load(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=47), + [], + [], + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=49)], + [], + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=50)], + [], + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=51), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=51)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=51), + Return( + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=18), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=18)], + [], + lineno=4, + col_offset=0, + end_lineno=14, + end_col_offset=18), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=15)], + Constant( + 0, + lineno=24, + col_offset=18, + end_lineno=24, + end_col_offset=19), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=19), + For( + Name( + 'placeholder_5', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=13), + Name( + 'placeholder_1', + Load(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=31), + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=16), + [ + LtE()], + [ + Constant( + 40, + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=22)], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=22), + [ + AugAssign( + Name( + 'placeholder_4', + Store(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=27, + col_offset=27, + end_lineno=27, + end_col_offset=28), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=28)], + [], + lineno=26, + col_offset=8, + end_lineno=27, + end_col_offset=28)], + [], + lineno=25, + col_offset=4, + end_lineno=27, + end_col_offset=28), + Return( + Name( + 'placeholder_4', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=22), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=22)], + [], + lineno=17, + col_offset=0, + end_lineno=28, + end_col_offset=22), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=34), + arg( + 'placeholder_7', + lineno=31, + col_offset=36, + end_lineno=31, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=9)], + List( + [], + Load(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=14), + lineno=39, + col_offset=4, + end_lineno=39, + end_col_offset=14), + For( + Name( + 'placeholder_5', + Store(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=13), + Name( + 'placeholder_1', + Load(), + lineno=41, + col_offset=17, + end_lineno=41, + end_col_offset=31), + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=16), + [ + GtE()], + [ + Name( + 'placeholder_7', + Load(), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=29)], + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=17), + 'append', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=24), + [ + Name( + 'placeholder_5', + Load(), + lineno=43, + col_offset=25, + end_lineno=43, + end_col_offset=30)], + [], + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=31), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=31)], + [], + lineno=42, + col_offset=8, + end_lineno=43, + end_col_offset=31)], + [], + lineno=41, + col_offset=4, + end_lineno=43, + end_col_offset=31), + Return( + Name( + 'placeholder_8', + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=16), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=16)], + [], + lineno=31, + col_offset=0, + end_lineno=44, + end_col_offset=16), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=13)], + Call( + Name( + 'round', + Load(), + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=21), + [ + BinOp( + BinOp( + Name( + 'placeholder_10', + Load(), + lineno=61, + col_offset=23, + end_lineno=61, + end_col_offset=30), + Sub(), + Constant( + 40, + lineno=61, + col_offset=33, + end_lineno=61, + end_col_offset=35), + lineno=61, + col_offset=23, + end_lineno=61, + end_col_offset=35), + Div(), + Constant( + 4, + lineno=61, + col_offset=39, + end_lineno=61, + end_col_offset=40), + lineno=61, + col_offset=22, + end_lineno=61, + end_col_offset=40)], + [], + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=41), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=41), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=10)], + List( + [], + Load(), + lineno=62, + col_offset=13, + end_lineno=62, + end_col_offset=15), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=15), + For( + Name( + 'placeholder_5', + Store(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=22), + [ + Constant( + 41, + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=25), + Name( + 'placeholder_10', + Load(), + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=34), + Name( + 'placeholder_11', + Load(), + lineno=63, + col_offset=36, + end_lineno=63, + end_col_offset=45)], + [], + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=46), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=14), + 'append', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=21), + [ + Name( + 'placeholder_5', + Load(), + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=27)], + [], + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=28), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=28)], + [], + lineno=63, + col_offset=4, + end_lineno=64, + end_col_offset=28), + Return( + Name( + 'placeholder_12', + Load(), + lineno=65, + col_offset=11, + end_lineno=65, + end_col_offset=17), + lineno=65, + col_offset=4, + end_lineno=65, + end_col_offset=17)], + [], + lineno=47, + col_offset=0, + end_lineno=65, + end_col_offset=17), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=68, + col_offset=20, + end_lineno=68, + end_col_offset=34), + arg( + 'placeholder_14', + lineno=68, + col_offset=36, + end_lineno=68, + end_col_offset=49)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=11)], + List( + [], + Load(), + lineno=76, + col_offset=14, + end_lineno=76, + end_col_offset=16), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=16), + For( + Tuple( + [ + Name( + 'placeholder_16', + Store(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=13), + Name( + 'placeholder_17', + Store(), + lineno=77, + col_offset=15, + end_lineno=77, + end_col_offset=19)], + Store(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=19), + Call( + Name( + 'enumerate', + Load(), + lineno=77, + col_offset=23, + end_lineno=77, + end_col_offset=32), + [ + Name( + 'placeholder_14', + Load(), + lineno=77, + col_offset=33, + end_lineno=77, + end_col_offset=46)], + [], + lineno=77, + col_offset=23, + end_lineno=77, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=19)], + BinOp( + BinOp( + BinOp( + BinOp( + Call( + Name( + 'str', + Load(), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=25), + [ + BinOp( + Name( + 'placeholder_16', + Load(), + lineno=78, + col_offset=26, + end_lineno=78, + end_col_offset=31), + Add(), + Constant( + 1, + lineno=78, + col_offset=34, + end_lineno=78, + end_col_offset=35), + lineno=78, + col_offset=26, + end_lineno=78, + end_col_offset=35)], + [], + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=36), + Add(), + Constant( + '. ', + lineno=78, + col_offset=39, + end_lineno=78, + end_col_offset=43), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=43), + Add(), + Name( + 'placeholder_17', + Load(), + lineno=78, + col_offset=46, + end_lineno=78, + end_col_offset=50), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=50), + Add(), + Constant( + ': ', + lineno=78, + col_offset=53, + end_lineno=78, + end_col_offset=57), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=57), + Add(), + Call( + Name( + 'str', + Load(), + lineno=78, + col_offset=60, + end_lineno=78, + end_col_offset=63), + [ + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=78, + col_offset=64, + end_lineno=78, + end_col_offset=78), + Name( + 'placeholder_16', + Load(), + lineno=78, + col_offset=79, + end_lineno=78, + end_col_offset=84), + Load(), + lineno=78, + col_offset=64, + end_lineno=78, + end_col_offset=85)], + [], + lineno=78, + col_offset=60, + end_lineno=78, + end_col_offset=86), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=86), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=86), + Expr( + Call( + Attribute( + Name( + 'placeholder_15', + Load(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=15), + 'append', + Load(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=22), + [ + Name( + 'placeholder_18', + Load(), + lineno=79, + col_offset=23, + end_lineno=79, + end_col_offset=34)], + [], + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=35), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=35)], + [], + lineno=77, + col_offset=4, + end_lineno=79, + end_col_offset=35), + Return( + Name( + 'placeholder_15', + Load(), + lineno=81, + col_offset=11, + end_lineno=81, + end_col_offset=18), + lineno=81, + col_offset=4, + end_lineno=81, + end_col_offset=18)], + [], + lineno=68, + col_offset=0, + end_lineno=81, + end_col_offset=18), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'placeholder_20', + lineno=84, + col_offset=18, + end_lineno=84, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=91, + col_offset=4, + end_lineno=91, + end_col_offset=10)], + List( + [], + Load(), + lineno=91, + col_offset=13, + end_lineno=91, + end_col_offset=15), + lineno=91, + col_offset=4, + end_lineno=91, + end_col_offset=15), + For( + Name( + 'placeholder_22', + Store(), + lineno=93, + col_offset=8, + end_lineno=93, + end_col_offset=12), + Name( + 'placeholder_20', + Load(), + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=28), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_22', + Load(), + lineno=94, + col_offset=11, + end_lineno=94, + end_col_offset=15), + Constant( + 1, + lineno=94, + col_offset=16, + end_lineno=94, + end_col_offset=17), + Load(), + lineno=94, + col_offset=11, + end_lineno=94, + end_col_offset=18), + [ + Eq()], + [ + Constant( + 100, + lineno=94, + col_offset=22, + end_lineno=94, + end_col_offset=25)], + lineno=94, + col_offset=11, + end_lineno=94, + end_col_offset=25), + [ + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=95, + col_offset=12, + end_lineno=95, + end_col_offset=18)], + Name( + 'placeholder_22', + Load(), + lineno=95, + col_offset=21, + end_lineno=95, + end_col_offset=25), + lineno=95, + col_offset=12, + end_lineno=95, + end_col_offset=25), + Break( + lineno=96, + col_offset=12, + end_lineno=96, + end_col_offset=17)], + [], + lineno=94, + col_offset=8, + end_lineno=96, + end_col_offset=17)], + [], + lineno=93, + col_offset=4, + end_lineno=96, + end_col_offset=17), + Return( + Name( + 'placeholder_21', + Load(), + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=17), + lineno=98, + col_offset=4, + end_lineno=98, + end_col_offset=17)], + [], + lineno=84, + col_offset=0, + end_lineno=98, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-making-the-grade/representation.txt b/test/concept-making-the-grade/representation.txt new file mode 100644 index 0000000..076b2d0 --- /dev/null +++ b/test/concept-making-the-grade/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=17, end_lineno=4, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=11, col_offset=4, end_lineno=11, end_col_offset=11)], List([], Load(), lineno=11, col_offset=14, end_lineno=11, end_col_offset=16), lineno=11, col_offset=4, end_lineno=11, end_col_offset=16), While(Name('placeholder_1', Load(), lineno=12, col_offset=10, end_lineno=12, end_col_offset=24), [Expr(Call(Attribute(Name('placeholder_2', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=15), 'append', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=22), [Call(Name('round', Load(), lineno=13, col_offset=23, end_lineno=13, end_col_offset=28), [Call(Attribute(Name('placeholder_1', Load(), lineno=13, col_offset=29, end_lineno=13, end_col_offset=43), 'pop', Load(), lineno=13, col_offset=29, end_lineno=13, end_col_offset=47), [], [], lineno=13, col_offset=29, end_lineno=13, end_col_offset=49)], [], lineno=13, col_offset=23, end_lineno=13, end_col_offset=50)], [], lineno=13, col_offset=8, end_lineno=13, end_col_offset=51), lineno=13, col_offset=8, end_lineno=13, end_col_offset=51)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=51), Return(Name('placeholder_2', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=18), lineno=14, col_offset=4, end_lineno=14, end_col_offset=18)], [], lineno=4, col_offset=0, end_lineno=14, end_col_offset=18), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=17, col_offset=26, end_lineno=17, end_col_offset=40)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=24, col_offset=4, end_lineno=24, end_col_offset=15)], Constant(0, lineno=24, col_offset=18, end_lineno=24, end_col_offset=19), lineno=24, col_offset=4, end_lineno=24, end_col_offset=19), For(Name('placeholder_5', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=13), Name('placeholder_1', Load(), lineno=25, col_offset=17, end_lineno=25, end_col_offset=31), [If(Compare(Name('placeholder_5', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=16), [LtE()], [Constant(40, lineno=26, col_offset=20, end_lineno=26, end_col_offset=22)], lineno=26, col_offset=11, end_lineno=26, end_col_offset=22), [AugAssign(Name('placeholder_4', Store(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=23), Add(), Constant(1, lineno=27, col_offset=27, end_lineno=27, end_col_offset=28), lineno=27, col_offset=12, end_lineno=27, end_col_offset=28)], [], lineno=26, col_offset=8, end_lineno=27, end_col_offset=28)], [], lineno=25, col_offset=4, end_lineno=27, end_col_offset=28), Return(Name('placeholder_4', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=22), lineno=28, col_offset=4, end_lineno=28, end_col_offset=22)], [], lineno=17, col_offset=0, end_lineno=28, end_col_offset=22), FunctionDef('placeholder_6', arguments([], [arg('placeholder_1', lineno=31, col_offset=20, end_lineno=31, end_col_offset=34), arg('placeholder_7', lineno=31, col_offset=36, end_lineno=31, end_col_offset=45)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=39, col_offset=4, end_lineno=39, end_col_offset=9)], List([], Load(), lineno=39, col_offset=12, end_lineno=39, end_col_offset=14), lineno=39, col_offset=4, end_lineno=39, end_col_offset=14), For(Name('placeholder_5', Store(), lineno=41, col_offset=8, end_lineno=41, end_col_offset=13), Name('placeholder_1', Load(), lineno=41, col_offset=17, end_lineno=41, end_col_offset=31), [If(Compare(Name('placeholder_5', Load(), lineno=42, col_offset=11, end_lineno=42, end_col_offset=16), [GtE()], [Name('placeholder_7', Load(), lineno=42, col_offset=20, end_lineno=42, end_col_offset=29)], lineno=42, col_offset=11, end_lineno=42, end_col_offset=29), [Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=17), 'append', Load(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=24), [Name('placeholder_5', Load(), lineno=43, col_offset=25, end_lineno=43, end_col_offset=30)], [], lineno=43, col_offset=12, end_lineno=43, end_col_offset=31), lineno=43, col_offset=12, end_lineno=43, end_col_offset=31)], [], lineno=42, col_offset=8, end_lineno=43, end_col_offset=31)], [], lineno=41, col_offset=4, end_lineno=43, end_col_offset=31), Return(Name('placeholder_8', Load(), lineno=44, col_offset=11, end_lineno=44, end_col_offset=16), lineno=44, col_offset=4, end_lineno=44, end_col_offset=16)], [], lineno=31, col_offset=0, end_lineno=44, end_col_offset=16), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=47, col_offset=18, end_lineno=47, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_11', Store(), lineno=61, col_offset=4, end_lineno=61, end_col_offset=13)], Call(Name('round', Load(), lineno=61, col_offset=16, end_lineno=61, end_col_offset=21), [BinOp(BinOp(Name('placeholder_10', Load(), lineno=61, col_offset=23, end_lineno=61, end_col_offset=30), Sub(), Constant(40, lineno=61, col_offset=33, end_lineno=61, end_col_offset=35), lineno=61, col_offset=23, end_lineno=61, end_col_offset=35), Div(), Constant(4, lineno=61, col_offset=39, end_lineno=61, end_col_offset=40), lineno=61, col_offset=22, end_lineno=61, end_col_offset=40)], [], lineno=61, col_offset=16, end_lineno=61, end_col_offset=41), lineno=61, col_offset=4, end_lineno=61, end_col_offset=41), Assign([Name('placeholder_12', Store(), lineno=62, col_offset=4, end_lineno=62, end_col_offset=10)], List([], Load(), lineno=62, col_offset=13, end_lineno=62, end_col_offset=15), lineno=62, col_offset=4, end_lineno=62, end_col_offset=15), For(Name('placeholder_5', Store(), lineno=63, col_offset=8, end_lineno=63, end_col_offset=13), Call(Name('range', Load(), lineno=63, col_offset=17, end_lineno=63, end_col_offset=22), [Constant(41, lineno=63, col_offset=23, end_lineno=63, end_col_offset=25), Name('placeholder_10', Load(), lineno=63, col_offset=27, end_lineno=63, end_col_offset=34), Name('placeholder_11', Load(), lineno=63, col_offset=36, end_lineno=63, end_col_offset=45)], [], lineno=63, col_offset=17, end_lineno=63, end_col_offset=46), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=14), 'append', Load(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=21), [Name('placeholder_5', Load(), lineno=64, col_offset=22, end_lineno=64, end_col_offset=27)], [], lineno=64, col_offset=8, end_lineno=64, end_col_offset=28), lineno=64, col_offset=8, end_lineno=64, end_col_offset=28)], [], lineno=63, col_offset=4, end_lineno=64, end_col_offset=28), Return(Name('placeholder_12', Load(), lineno=65, col_offset=11, end_lineno=65, end_col_offset=17), lineno=65, col_offset=4, end_lineno=65, end_col_offset=17)], [], lineno=47, col_offset=0, end_lineno=65, end_col_offset=17), FunctionDef('placeholder_13', arguments([], [arg('placeholder_1', lineno=68, col_offset=20, end_lineno=68, end_col_offset=34), arg('placeholder_14', lineno=68, col_offset=36, end_lineno=68, end_col_offset=49)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_15', Store(), lineno=76, col_offset=4, end_lineno=76, end_col_offset=11)], List([], Load(), lineno=76, col_offset=14, end_lineno=76, end_col_offset=16), lineno=76, col_offset=4, end_lineno=76, end_col_offset=16), For(Tuple([Name('placeholder_16', Store(), lineno=77, col_offset=8, end_lineno=77, end_col_offset=13), Name('placeholder_17', Store(), lineno=77, col_offset=15, end_lineno=77, end_col_offset=19)], Store(), lineno=77, col_offset=8, end_lineno=77, end_col_offset=19), Call(Name('enumerate', Load(), lineno=77, col_offset=23, end_lineno=77, end_col_offset=32), [Name('placeholder_14', Load(), lineno=77, col_offset=33, end_lineno=77, end_col_offset=46)], [], lineno=77, col_offset=23, end_lineno=77, end_col_offset=47), [Assign([Name('placeholder_18', Store(), lineno=78, col_offset=8, end_lineno=78, end_col_offset=19)], BinOp(BinOp(BinOp(BinOp(Call(Name('str', Load(), lineno=78, col_offset=22, end_lineno=78, end_col_offset=25), [BinOp(Name('placeholder_16', Load(), lineno=78, col_offset=26, end_lineno=78, end_col_offset=31), Add(), Constant(1, lineno=78, col_offset=34, end_lineno=78, end_col_offset=35), lineno=78, col_offset=26, end_lineno=78, end_col_offset=35)], [], lineno=78, col_offset=22, end_lineno=78, end_col_offset=36), Add(), Constant('. ', lineno=78, col_offset=39, end_lineno=78, end_col_offset=43), lineno=78, col_offset=22, end_lineno=78, end_col_offset=43), Add(), Name('placeholder_17', Load(), lineno=78, col_offset=46, end_lineno=78, end_col_offset=50), lineno=78, col_offset=22, end_lineno=78, end_col_offset=50), Add(), Constant(': ', lineno=78, col_offset=53, end_lineno=78, end_col_offset=57), lineno=78, col_offset=22, end_lineno=78, end_col_offset=57), Add(), Call(Name('str', Load(), lineno=78, col_offset=60, end_lineno=78, end_col_offset=63), [Subscript(Name('placeholder_1', Load(), lineno=78, col_offset=64, end_lineno=78, end_col_offset=78), Name('placeholder_16', Load(), lineno=78, col_offset=79, end_lineno=78, end_col_offset=84), Load(), lineno=78, col_offset=64, end_lineno=78, end_col_offset=85)], [], lineno=78, col_offset=60, end_lineno=78, end_col_offset=86), lineno=78, col_offset=22, end_lineno=78, end_col_offset=86), lineno=78, col_offset=8, end_lineno=78, end_col_offset=86), Expr(Call(Attribute(Name('placeholder_15', Load(), lineno=79, col_offset=8, end_lineno=79, end_col_offset=15), 'append', Load(), lineno=79, col_offset=8, end_lineno=79, end_col_offset=22), [Name('placeholder_18', Load(), lineno=79, col_offset=23, end_lineno=79, end_col_offset=34)], [], lineno=79, col_offset=8, end_lineno=79, end_col_offset=35), lineno=79, col_offset=8, end_lineno=79, end_col_offset=35)], [], lineno=77, col_offset=4, end_lineno=79, end_col_offset=35), Return(Name('placeholder_15', Load(), lineno=81, col_offset=11, end_lineno=81, end_col_offset=18), lineno=81, col_offset=4, end_lineno=81, end_col_offset=18)], [], lineno=68, col_offset=0, end_lineno=81, end_col_offset=18), FunctionDef('placeholder_19', arguments([], [arg('placeholder_20', lineno=84, col_offset=18, end_lineno=84, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_21', Store(), lineno=91, col_offset=4, end_lineno=91, end_col_offset=10)], List([], Load(), lineno=91, col_offset=13, end_lineno=91, end_col_offset=15), lineno=91, col_offset=4, end_lineno=91, end_col_offset=15), For(Name('placeholder_22', Store(), lineno=93, col_offset=8, end_lineno=93, end_col_offset=12), Name('placeholder_20', Load(), lineno=93, col_offset=16, end_lineno=93, end_col_offset=28), [If(Compare(Subscript(Name('placeholder_22', Load(), lineno=94, col_offset=11, end_lineno=94, end_col_offset=15), Constant(1, lineno=94, col_offset=16, end_lineno=94, end_col_offset=17), Load(), lineno=94, col_offset=11, end_lineno=94, end_col_offset=18), [Eq()], [Constant(100, lineno=94, col_offset=22, end_lineno=94, end_col_offset=25)], lineno=94, col_offset=11, end_lineno=94, end_col_offset=25), [Assign([Name('placeholder_21', Store(), lineno=95, col_offset=12, end_lineno=95, end_col_offset=18)], Name('placeholder_22', Load(), lineno=95, col_offset=21, end_lineno=95, end_col_offset=25), lineno=95, col_offset=12, end_lineno=95, end_col_offset=25), Break(lineno=96, col_offset=12, end_lineno=96, end_col_offset=17)], [], lineno=94, col_offset=8, end_lineno=96, end_col_offset=17)], [], lineno=93, col_offset=4, end_lineno=96, end_col_offset=17), Return(Name('placeholder_21', Load(), lineno=98, col_offset=11, end_lineno=98, end_col_offset=17), lineno=98, col_offset=4, end_lineno=98, end_col_offset=17)], [], lineno=84, col_offset=0, end_lineno=98, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/concept-mecha-munch-management/.meta/config.json b/test/concept-mecha-munch-management/.meta/config.json new file mode 100644 index 0000000..f09d0f2 --- /dev/null +++ b/test/concept-mecha-munch-management/.meta/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "meatball133", + "BethanyG" + ], + "contributors": [ + ], + "files": { + "solution": [ + "dict_methods.py" + ], + "test": [ + "dict_methods_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "icon": "gross-store", + "blurb": "Learn about dictionary methods by building a shopping cart MVP for the Mecha Munch grocery app." +} diff --git a/test/concept-mecha-munch-management/dict_methods.py b/test/concept-mecha-munch-management/dict_methods.py new file mode 100644 index 0000000..0390944 --- /dev/null +++ b/test/concept-mecha-munch-management/dict_methods.py @@ -0,0 +1,79 @@ +"""Functions to manage a users shopping cart items.""" + + +def add_item(current_cart, items_to_add): + """Add items to shopping cart. + + :param current_cart: dict - the current shopping cart. + :param items_to_add: iterable - items to add to the cart. + :return: dict - the updated user cart dictionary. + """ + + for item in items_to_add: + current_cart.setdefault(item, 0) + current_cart[item] += 1 + + return current_cart + + +def read_notes(notes): + """Create user cart from an iterable notes entry. + + :param notes: iterable of items to add to cart. + :return: dict - a user shopping cart dictionary. + """ + + return dict.fromkeys(notes, 1) + + +def update_recipes(ideas, recipe_updates): + """Update the recipe ideas dictionary. + + :param ideas: dict - The "recipe ideas" dict. + :param recipe_updates: dict - dictionary with updates for the ideas section. + :return: dict - updated "recipe ideas" dict. + """ + + ideas.update(recipe_updates) + return ideas + + +def sort_entries(cart): + """Sort a users shopping cart in alphabetically order. + + :param cart: dict - a users shopping cart dictionary. + :return: dict - users shopping cart sorted in alphabetical order. + """ + + return dict(sorted(cart.items())) + + +def send_to_store(cart, isle_mapping): + """Combine users order to isle and refrigeration information. + + :param cart: dict - users shopping cart dictionary. + :param isle_mapping: dict - isle and refrigeration information dictionary. + :return: dict - fulfillment dictionary ready to send to store. + """ + fulfillment_cart = {} + + for key in cart.keys(): + fulfillment_cart[key] = [cart[key]] + isle_mapping[key] + + return dict(sorted(fulfillment_cart.items(), reverse=True)) + + +def update_store_inventory(fulfillment_cart, store_inventory): + """Update store inventory levels with user order. + + :param fulfillment cart: dict - fulfillment cart to send to store. + :param store_inventory: dict - store available inventory + :return: dict - store_inventory updated. + """ + + for key, values in fulfillment_cart.items(): + store_inventory[key][0] = store_inventory[key][0] - values[0] + if store_inventory[key][0] == 0: + store_inventory[key][0] = 'Out of Stock' + + return store_inventory diff --git a/test/concept-mecha-munch-management/mapping.json b/test/concept-mecha-munch-management/mapping.json new file mode 100644 index 0000000..5d0e906 --- /dev/null +++ b/test/concept-mecha-munch-management/mapping.json @@ -0,0 +1,21 @@ +{ + "placeholder_0": "add_item", + "placeholder_1": "current_cart", + "placeholder_2": "items_to_add", + "placeholder_3": "item", + "placeholder_4": "read_notes", + "placeholder_5": "notes", + "placeholder_6": "update_recipes", + "placeholder_7": "ideas", + "placeholder_8": "recipe_updates", + "placeholder_9": "sort_entries", + "placeholder_10": "cart", + "placeholder_11": "send_to_store", + "placeholder_12": "isle_mapping", + "placeholder_13": "fulfillment_cart", + "placeholder_14": "key", + "placeholder_15": "reverse", + "placeholder_16": "update_store_inventory", + "placeholder_17": "store_inventory", + "placeholder_18": "values" +} \ No newline at end of file diff --git a/test/concept-mecha-munch-management/representation.json b/test/concept-mecha-munch-management/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-mecha-munch-management/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-mecha-munch-management/representation.out b/test/concept-mecha-munch-management/representation.out new file mode 100644 index 0000000..d909d86 --- /dev/null +++ b/test/concept-mecha-munch-management/representation.out @@ -0,0 +1,1807 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + for placeholder_3 in placeholder_2: + placeholder_1.setdefault(placeholder_3, 0) + placeholder_1[placeholder_3] += 1 + return placeholder_1 + + +def placeholder_4(placeholder_5): + return dict.fromkeys(placeholder_5, 1) + + +def placeholder_6(placeholder_7, placeholder_8): + placeholder_7.update(placeholder_8) + return placeholder_7 + + +def placeholder_9(placeholder_10): + return dict(sorted(placeholder_10.items())) + + +def placeholder_11(placeholder_10, placeholder_12): + placeholder_13 = {} + for placeholder_14 in placeholder_10.keys(): + placeholder_13[placeholder_14] = [ + placeholder_10[placeholder_14] + ] + placeholder_12[placeholder_14] + return dict(sorted(placeholder_13.items(), placeholder_15=True)) + + +def placeholder_16(placeholder_13, placeholder_17): + for placeholder_14, placeholder_18 in placeholder_13.items(): + placeholder_17[placeholder_14][0] = ( + placeholder_17[placeholder_14][0] - placeholder_18[0] + ) + if placeholder_17[placeholder_14][0] == 0: + placeholder_17[placeholder_14][0] = "Out of Stock" + return placeholder_17 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to manage a users shopping cart items.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=54), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=54), + FunctionDef( + 'add_item', + arguments( + [], + [ + arg( + 'current_cart', + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=25), + arg( + 'items_to_add', + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Add items to shopping cart.\n\n :param current_cart: dict - the current shopping cart.\n :param items_to_add: iterable - items to add to the cart.\n :return: dict - the updated user cart dictionary.\n ', + lineno=5, + col_offset=4, + end_lineno=10, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=10, + end_col_offset=7), + For( + Name( + 'item', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + Name( + 'items_to_add', + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=28), + [ + Expr( + Call( + Attribute( + Name( + 'current_cart', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=20), + 'setdefault', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=31), + [ + Name( + 'item', + Load(), + lineno=13, + col_offset=32, + end_lineno=13, + end_col_offset=36), + Constant( + 0, + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=39)], + [], + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=40), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=40), + AugAssign( + Subscript( + Name( + 'current_cart', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=20), + Name( + 'item', + Load(), + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=25), + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=26), + Add(), + Constant( + 1, + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=31), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=31)], + [], + lineno=12, + col_offset=4, + end_lineno=14, + end_col_offset=31), + Return( + Name( + 'current_cart', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=23), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=23)], + [], + lineno=4, + col_offset=0, + end_lineno=16, + end_col_offset=23), + FunctionDef( + 'read_notes', + arguments( + [], + [ + arg( + 'notes', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Create user cart from an iterable notes entry.\n\n :param notes: iterable of items to add to cart.\n :return: dict - a user shopping cart dictionary.\n ', + lineno=20, + col_offset=4, + end_lineno=24, + end_col_offset=7), + lineno=20, + col_offset=4, + end_lineno=24, + end_col_offset=7), + Return( + Call( + Attribute( + Name( + 'dict', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=15), + 'fromkeys', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=24), + [ + Name( + 'notes', + Load(), + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=30), + Constant( + 1, + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=33)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=34), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=34)], + [], + lineno=19, + col_offset=0, + end_lineno=26, + end_col_offset=34), + FunctionDef( + 'update_recipes', + arguments( + [], + [ + arg( + 'ideas', + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=24), + arg( + 'recipe_updates', + lineno=29, + col_offset=26, + end_lineno=29, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Update the recipe ideas dictionary.\n\n :param ideas: dict - The "recipe ideas" dict.\n :param recipe_updates: dict - dictionary with updates for the ideas section.\n :return: dict - updated "recipe ideas" dict.\n ', + lineno=30, + col_offset=4, + end_lineno=35, + end_col_offset=7), + lineno=30, + col_offset=4, + end_lineno=35, + end_col_offset=7), + Expr( + Call( + Attribute( + Name( + 'ideas', + Load(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=9), + 'update', + Load(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=16), + [ + Name( + 'recipe_updates', + Load(), + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=31)], + [], + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=32), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=32), + Return( + Name( + 'ideas', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=16), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=16)], + [], + lineno=29, + col_offset=0, + end_lineno=38, + end_col_offset=16), + FunctionDef( + 'sort_entries', + arguments( + [], + [ + arg( + 'cart', + lineno=41, + col_offset=17, + end_lineno=41, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Sort a users shopping cart in alphabetically order.\n\n :param cart: dict - a users shopping cart dictionary.\n :return: dict - users shopping cart sorted in alphabetical order.\n ', + lineno=42, + col_offset=4, + end_lineno=46, + end_col_offset=7), + lineno=42, + col_offset=4, + end_lineno=46, + end_col_offset=7), + Return( + Call( + Name( + 'dict', + Load(), + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=15), + [ + Call( + Name( + 'sorted', + Load(), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=22), + [ + Call( + Attribute( + Name( + 'cart', + Load(), + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=27), + 'items', + Load(), + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=33), + [], + [], + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=35)], + [], + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=36)], + [], + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=37), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=37)], + [], + lineno=41, + col_offset=0, + end_lineno=48, + end_col_offset=37), + FunctionDef( + 'send_to_store', + arguments( + [], + [ + arg( + 'cart', + lineno=51, + col_offset=18, + end_lineno=51, + end_col_offset=22), + arg( + 'isle_mapping', + lineno=51, + col_offset=24, + end_lineno=51, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Combine users order to isle and refrigeration information.\n\n :param cart: dict - users shopping cart dictionary.\n :param isle_mapping: dict - isle and refrigeration information dictionary.\n :return: dict - fulfillment dictionary ready to send to store.\n ', + lineno=52, + col_offset=4, + end_lineno=57, + end_col_offset=7), + lineno=52, + col_offset=4, + end_lineno=57, + end_col_offset=7), + Assign( + [ + Name( + 'fulfillment_cart', + Store(), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=20)], + Dict( + [], + [], + lineno=58, + col_offset=23, + end_lineno=58, + end_col_offset=25), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=25), + For( + Name( + 'key', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=11), + Call( + Attribute( + Name( + 'cart', + Load(), + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=19), + 'keys', + Load(), + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=24), + [], + [], + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=26), + [ + Assign( + [ + Subscript( + Name( + 'fulfillment_cart', + Load(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=24), + Name( + 'key', + Load(), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=28), + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=29)], + BinOp( + List( + [ + Subscript( + Name( + 'cart', + Load(), + lineno=61, + col_offset=33, + end_lineno=61, + end_col_offset=37), + Name( + 'key', + Load(), + lineno=61, + col_offset=38, + end_lineno=61, + end_col_offset=41), + Load(), + lineno=61, + col_offset=33, + end_lineno=61, + end_col_offset=42)], + Load(), + lineno=61, + col_offset=32, + end_lineno=61, + end_col_offset=43), + Add(), + Subscript( + Name( + 'isle_mapping', + Load(), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=58), + Name( + 'key', + Load(), + lineno=61, + col_offset=59, + end_lineno=61, + end_col_offset=62), + Load(), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=63), + lineno=61, + col_offset=32, + end_lineno=61, + end_col_offset=63), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=63)], + [], + lineno=60, + col_offset=4, + end_lineno=61, + end_col_offset=63), + Return( + Call( + Name( + 'dict', + Load(), + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=15), + [ + Call( + Name( + 'sorted', + Load(), + lineno=63, + col_offset=16, + end_lineno=63, + end_col_offset=22), + [ + Call( + Attribute( + Name( + 'fulfillment_cart', + Load(), + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=39), + 'items', + Load(), + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=45), + [], + [], + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=47)], + [ + keyword( + 'reverse', + Constant( + True, + lineno=63, + col_offset=57, + end_lineno=63, + end_col_offset=61), + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=61)], + lineno=63, + col_offset=16, + end_lineno=63, + end_col_offset=62)], + [], + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=63), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=63)], + [], + lineno=51, + col_offset=0, + end_lineno=63, + end_col_offset=63), + FunctionDef( + 'update_store_inventory', + arguments( + [], + [ + arg( + 'fulfillment_cart', + lineno=66, + col_offset=27, + end_lineno=66, + end_col_offset=43), + arg( + 'store_inventory', + lineno=66, + col_offset=45, + end_lineno=66, + end_col_offset=60)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Update store inventory levels with user order.\n\n :param fulfillment cart: dict - fulfillment cart to send to store.\n :param store_inventory: dict - store available inventory\n :return: dict - store_inventory updated.\n ', + lineno=67, + col_offset=4, + end_lineno=72, + end_col_offset=7), + lineno=67, + col_offset=4, + end_lineno=72, + end_col_offset=7), + For( + Tuple( + [ + Name( + 'key', + Store(), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=11), + Name( + 'values', + Store(), + lineno=74, + col_offset=13, + end_lineno=74, + end_col_offset=19)], + Store(), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=19), + Call( + Attribute( + Name( + 'fulfillment_cart', + Load(), + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=39), + 'items', + Load(), + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=45), + [], + [], + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=47), + [ + Assign( + [ + Subscript( + Subscript( + Name( + 'store_inventory', + Load(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=23), + Name( + 'key', + Load(), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=27), + Load(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=28), + Constant( + 0, + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=30), + Store(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=31)], + BinOp( + Subscript( + Subscript( + Name( + 'store_inventory', + Load(), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=49), + Name( + 'key', + Load(), + lineno=75, + col_offset=50, + end_lineno=75, + end_col_offset=53), + Load(), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=54), + Constant( + 0, + lineno=75, + col_offset=55, + end_lineno=75, + end_col_offset=56), + Load(), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=57), + Sub(), + Subscript( + Name( + 'values', + Load(), + lineno=75, + col_offset=60, + end_lineno=75, + end_col_offset=66), + Constant( + 0, + lineno=75, + col_offset=67, + end_lineno=75, + end_col_offset=68), + Load(), + lineno=75, + col_offset=60, + end_lineno=75, + end_col_offset=69), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=69), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=69), + If( + Compare( + Subscript( + Subscript( + Name( + 'store_inventory', + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=26), + Name( + 'key', + Load(), + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=30), + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=31), + Constant( + 0, + lineno=76, + col_offset=32, + end_lineno=76, + end_col_offset=33), + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=34), + [ + Eq()], + [ + Constant( + 0, + lineno=76, + col_offset=38, + end_lineno=76, + end_col_offset=39)], + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=39), + [ + Assign( + [ + Subscript( + Subscript( + Name( + 'store_inventory', + Load(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=27), + Name( + 'key', + Load(), + lineno=77, + col_offset=28, + end_lineno=77, + end_col_offset=31), + Load(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=32), + Constant( + 0, + lineno=77, + col_offset=33, + end_lineno=77, + end_col_offset=34), + Store(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=35)], + Constant( + 'Out of Stock', + lineno=77, + col_offset=38, + end_lineno=77, + end_col_offset=52), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=52)], + [], + lineno=76, + col_offset=8, + end_lineno=77, + end_col_offset=52)], + [], + lineno=74, + col_offset=4, + end_lineno=77, + end_col_offset=52), + Return( + Name( + 'store_inventory', + Load(), + lineno=79, + col_offset=11, + end_lineno=79, + end_col_offset=26), + lineno=79, + col_offset=4, + end_lineno=79, + end_col_offset=26)], + [], + lineno=66, + col_offset=0, + end_lineno=79, + end_col_offset=26)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=25), + arg( + 'placeholder_2', + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_3', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + Name( + 'placeholder_2', + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=28), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=20), + 'setdefault', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=31), + [ + Name( + 'placeholder_3', + Load(), + lineno=13, + col_offset=32, + end_lineno=13, + end_col_offset=36), + Constant( + 0, + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=39)], + [], + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=40), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=40), + AugAssign( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=20), + Name( + 'placeholder_3', + Load(), + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=25), + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=26), + Add(), + Constant( + 1, + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=31), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=31)], + [], + lineno=12, + col_offset=4, + end_lineno=14, + end_col_offset=31), + Return( + Name( + 'placeholder_1', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=23), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=23)], + [], + lineno=4, + col_offset=0, + end_lineno=16, + end_col_offset=23), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'dict', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=15), + 'fromkeys', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=24), + [ + Name( + 'placeholder_5', + Load(), + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=30), + Constant( + 1, + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=33)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=34), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=34)], + [], + lineno=19, + col_offset=0, + end_lineno=26, + end_col_offset=34), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=24), + arg( + 'placeholder_8', + lineno=29, + col_offset=26, + end_lineno=29, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=9), + 'update', + Load(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=16), + [ + Name( + 'placeholder_8', + Load(), + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=31)], + [], + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=32), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=32), + Return( + Name( + 'placeholder_7', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=16), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=16)], + [], + lineno=29, + col_offset=0, + end_lineno=38, + end_col_offset=16), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=41, + col_offset=17, + end_lineno=41, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'dict', + Load(), + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=15), + [ + Call( + Name( + 'sorted', + Load(), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=22), + [ + Call( + Attribute( + Name( + 'placeholder_10', + Load(), + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=27), + 'items', + Load(), + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=33), + [], + [], + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=35)], + [], + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=36)], + [], + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=37), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=37)], + [], + lineno=41, + col_offset=0, + end_lineno=48, + end_col_offset=37), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=51, + col_offset=18, + end_lineno=51, + end_col_offset=22), + arg( + 'placeholder_12', + lineno=51, + col_offset=24, + end_lineno=51, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=20)], + Dict( + [], + [], + lineno=58, + col_offset=23, + end_lineno=58, + end_col_offset=25), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=25), + For( + Name( + 'placeholder_14', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=11), + Call( + Attribute( + Name( + 'placeholder_10', + Load(), + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=19), + 'keys', + Load(), + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=24), + [], + [], + lineno=60, + col_offset=15, + end_lineno=60, + end_col_offset=26), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=24), + Name( + 'placeholder_14', + Load(), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=28), + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=29)], + BinOp( + List( + [ + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=61, + col_offset=33, + end_lineno=61, + end_col_offset=37), + Name( + 'placeholder_14', + Load(), + lineno=61, + col_offset=38, + end_lineno=61, + end_col_offset=41), + Load(), + lineno=61, + col_offset=33, + end_lineno=61, + end_col_offset=42)], + Load(), + lineno=61, + col_offset=32, + end_lineno=61, + end_col_offset=43), + Add(), + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=58), + Name( + 'placeholder_14', + Load(), + lineno=61, + col_offset=59, + end_lineno=61, + end_col_offset=62), + Load(), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=63), + lineno=61, + col_offset=32, + end_lineno=61, + end_col_offset=63), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=63)], + [], + lineno=60, + col_offset=4, + end_lineno=61, + end_col_offset=63), + Return( + Call( + Name( + 'dict', + Load(), + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=15), + [ + Call( + Name( + 'sorted', + Load(), + lineno=63, + col_offset=16, + end_lineno=63, + end_col_offset=22), + [ + Call( + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=39), + 'items', + Load(), + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=45), + [], + [], + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=47)], + [ + keyword( + 'placeholder_15', + Constant( + True, + lineno=63, + col_offset=57, + end_lineno=63, + end_col_offset=61), + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=61)], + lineno=63, + col_offset=16, + end_lineno=63, + end_col_offset=62)], + [], + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=63), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=63)], + [], + lineno=51, + col_offset=0, + end_lineno=63, + end_col_offset=63), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=66, + col_offset=27, + end_lineno=66, + end_col_offset=43), + arg( + 'placeholder_17', + lineno=66, + col_offset=45, + end_lineno=66, + end_col_offset=60)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Tuple( + [ + Name( + 'placeholder_14', + Store(), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=11), + Name( + 'placeholder_18', + Store(), + lineno=74, + col_offset=13, + end_lineno=74, + end_col_offset=19)], + Store(), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=19), + Call( + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=39), + 'items', + Load(), + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=45), + [], + [], + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=47), + [ + Assign( + [ + Subscript( + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=23), + Name( + 'placeholder_14', + Load(), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=27), + Load(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=28), + Constant( + 0, + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=30), + Store(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=31)], + BinOp( + Subscript( + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=49), + Name( + 'placeholder_14', + Load(), + lineno=75, + col_offset=50, + end_lineno=75, + end_col_offset=53), + Load(), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=54), + Constant( + 0, + lineno=75, + col_offset=55, + end_lineno=75, + end_col_offset=56), + Load(), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=57), + Sub(), + Subscript( + Name( + 'placeholder_18', + Load(), + lineno=75, + col_offset=60, + end_lineno=75, + end_col_offset=66), + Constant( + 0, + lineno=75, + col_offset=67, + end_lineno=75, + end_col_offset=68), + Load(), + lineno=75, + col_offset=60, + end_lineno=75, + end_col_offset=69), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=69), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=69), + If( + Compare( + Subscript( + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=26), + Name( + 'placeholder_14', + Load(), + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=30), + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=31), + Constant( + 0, + lineno=76, + col_offset=32, + end_lineno=76, + end_col_offset=33), + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=34), + [ + Eq()], + [ + Constant( + 0, + lineno=76, + col_offset=38, + end_lineno=76, + end_col_offset=39)], + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=39), + [ + Assign( + [ + Subscript( + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=27), + Name( + 'placeholder_14', + Load(), + lineno=77, + col_offset=28, + end_lineno=77, + end_col_offset=31), + Load(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=32), + Constant( + 0, + lineno=77, + col_offset=33, + end_lineno=77, + end_col_offset=34), + Store(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=35)], + Constant( + 'Out of Stock', + lineno=77, + col_offset=38, + end_lineno=77, + end_col_offset=52), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=52)], + [], + lineno=76, + col_offset=8, + end_lineno=77, + end_col_offset=52)], + [], + lineno=74, + col_offset=4, + end_lineno=77, + end_col_offset=52), + Return( + Name( + 'placeholder_17', + Load(), + lineno=79, + col_offset=11, + end_lineno=79, + end_col_offset=26), + lineno=79, + col_offset=4, + end_lineno=79, + end_col_offset=26)], + [], + lineno=66, + col_offset=0, + end_lineno=79, + end_col_offset=26)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-mecha-munch-management/representation.txt b/test/concept-mecha-munch-management/representation.txt new file mode 100644 index 0000000..9021a14 --- /dev/null +++ b/test/concept-mecha-munch-management/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=13, end_lineno=4, end_col_offset=25), arg('placeholder_2', lineno=4, col_offset=27, end_lineno=4, end_col_offset=39)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_3', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), Name('placeholder_2', Load(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=28), [Expr(Call(Attribute(Name('placeholder_1', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=20), 'setdefault', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=31), [Name('placeholder_3', Load(), lineno=13, col_offset=32, end_lineno=13, end_col_offset=36), Constant(0, lineno=13, col_offset=38, end_lineno=13, end_col_offset=39)], [], lineno=13, col_offset=8, end_lineno=13, end_col_offset=40), lineno=13, col_offset=8, end_lineno=13, end_col_offset=40), AugAssign(Subscript(Name('placeholder_1', Load(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=20), Name('placeholder_3', Load(), lineno=14, col_offset=21, end_lineno=14, end_col_offset=25), Store(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=26), Add(), Constant(1, lineno=14, col_offset=30, end_lineno=14, end_col_offset=31), lineno=14, col_offset=8, end_lineno=14, end_col_offset=31)], [], lineno=12, col_offset=4, end_lineno=14, end_col_offset=31), Return(Name('placeholder_1', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=23), lineno=16, col_offset=4, end_lineno=16, end_col_offset=23)], [], lineno=4, col_offset=0, end_lineno=16, end_col_offset=23), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=19, col_offset=15, end_lineno=19, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('dict', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=15), 'fromkeys', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=24), [Name('placeholder_5', Load(), lineno=26, col_offset=25, end_lineno=26, end_col_offset=30), Constant(1, lineno=26, col_offset=32, end_lineno=26, end_col_offset=33)], [], lineno=26, col_offset=11, end_lineno=26, end_col_offset=34), lineno=26, col_offset=4, end_lineno=26, end_col_offset=34)], [], lineno=19, col_offset=0, end_lineno=26, end_col_offset=34), FunctionDef('placeholder_6', arguments([], [arg('placeholder_7', lineno=29, col_offset=19, end_lineno=29, end_col_offset=24), arg('placeholder_8', lineno=29, col_offset=26, end_lineno=29, end_col_offset=40)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Name('placeholder_7', Load(), lineno=37, col_offset=4, end_lineno=37, end_col_offset=9), 'update', Load(), lineno=37, col_offset=4, end_lineno=37, end_col_offset=16), [Name('placeholder_8', Load(), lineno=37, col_offset=17, end_lineno=37, end_col_offset=31)], [], lineno=37, col_offset=4, end_lineno=37, end_col_offset=32), lineno=37, col_offset=4, end_lineno=37, end_col_offset=32), Return(Name('placeholder_7', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=16), lineno=38, col_offset=4, end_lineno=38, end_col_offset=16)], [], lineno=29, col_offset=0, end_lineno=38, end_col_offset=16), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=41, col_offset=17, end_lineno=41, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('dict', Load(), lineno=48, col_offset=11, end_lineno=48, end_col_offset=15), [Call(Name('sorted', Load(), lineno=48, col_offset=16, end_lineno=48, end_col_offset=22), [Call(Attribute(Name('placeholder_10', Load(), lineno=48, col_offset=23, end_lineno=48, end_col_offset=27), 'items', Load(), lineno=48, col_offset=23, end_lineno=48, end_col_offset=33), [], [], lineno=48, col_offset=23, end_lineno=48, end_col_offset=35)], [], lineno=48, col_offset=16, end_lineno=48, end_col_offset=36)], [], lineno=48, col_offset=11, end_lineno=48, end_col_offset=37), lineno=48, col_offset=4, end_lineno=48, end_col_offset=37)], [], lineno=41, col_offset=0, end_lineno=48, end_col_offset=37), FunctionDef('placeholder_11', arguments([], [arg('placeholder_10', lineno=51, col_offset=18, end_lineno=51, end_col_offset=22), arg('placeholder_12', lineno=51, col_offset=24, end_lineno=51, end_col_offset=36)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_13', Store(), lineno=58, col_offset=4, end_lineno=58, end_col_offset=20)], Dict([], [], lineno=58, col_offset=23, end_lineno=58, end_col_offset=25), lineno=58, col_offset=4, end_lineno=58, end_col_offset=25), For(Name('placeholder_14', Store(), lineno=60, col_offset=8, end_lineno=60, end_col_offset=11), Call(Attribute(Name('placeholder_10', Load(), lineno=60, col_offset=15, end_lineno=60, end_col_offset=19), 'keys', Load(), lineno=60, col_offset=15, end_lineno=60, end_col_offset=24), [], [], lineno=60, col_offset=15, end_lineno=60, end_col_offset=26), [Assign([Subscript(Name('placeholder_13', Load(), lineno=61, col_offset=8, end_lineno=61, end_col_offset=24), Name('placeholder_14', Load(), lineno=61, col_offset=25, end_lineno=61, end_col_offset=28), Store(), lineno=61, col_offset=8, end_lineno=61, end_col_offset=29)], BinOp(List([Subscript(Name('placeholder_10', Load(), lineno=61, col_offset=33, end_lineno=61, end_col_offset=37), Name('placeholder_14', Load(), lineno=61, col_offset=38, end_lineno=61, end_col_offset=41), Load(), lineno=61, col_offset=33, end_lineno=61, end_col_offset=42)], Load(), lineno=61, col_offset=32, end_lineno=61, end_col_offset=43), Add(), Subscript(Name('placeholder_12', Load(), lineno=61, col_offset=46, end_lineno=61, end_col_offset=58), Name('placeholder_14', Load(), lineno=61, col_offset=59, end_lineno=61, end_col_offset=62), Load(), lineno=61, col_offset=46, end_lineno=61, end_col_offset=63), lineno=61, col_offset=32, end_lineno=61, end_col_offset=63), lineno=61, col_offset=8, end_lineno=61, end_col_offset=63)], [], lineno=60, col_offset=4, end_lineno=61, end_col_offset=63), Return(Call(Name('dict', Load(), lineno=63, col_offset=11, end_lineno=63, end_col_offset=15), [Call(Name('sorted', Load(), lineno=63, col_offset=16, end_lineno=63, end_col_offset=22), [Call(Attribute(Name('placeholder_13', Load(), lineno=63, col_offset=23, end_lineno=63, end_col_offset=39), 'items', Load(), lineno=63, col_offset=23, end_lineno=63, end_col_offset=45), [], [], lineno=63, col_offset=23, end_lineno=63, end_col_offset=47)], [keyword('placeholder_15', Constant(True, lineno=63, col_offset=57, end_lineno=63, end_col_offset=61), lineno=63, col_offset=49, end_lineno=63, end_col_offset=61)], lineno=63, col_offset=16, end_lineno=63, end_col_offset=62)], [], lineno=63, col_offset=11, end_lineno=63, end_col_offset=63), lineno=63, col_offset=4, end_lineno=63, end_col_offset=63)], [], lineno=51, col_offset=0, end_lineno=63, end_col_offset=63), FunctionDef('placeholder_16', arguments([], [arg('placeholder_13', lineno=66, col_offset=27, end_lineno=66, end_col_offset=43), arg('placeholder_17', lineno=66, col_offset=45, end_lineno=66, end_col_offset=60)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Tuple([Name('placeholder_14', Store(), lineno=74, col_offset=8, end_lineno=74, end_col_offset=11), Name('placeholder_18', Store(), lineno=74, col_offset=13, end_lineno=74, end_col_offset=19)], Store(), lineno=74, col_offset=8, end_lineno=74, end_col_offset=19), Call(Attribute(Name('placeholder_13', Load(), lineno=74, col_offset=23, end_lineno=74, end_col_offset=39), 'items', Load(), lineno=74, col_offset=23, end_lineno=74, end_col_offset=45), [], [], lineno=74, col_offset=23, end_lineno=74, end_col_offset=47), [Assign([Subscript(Subscript(Name('placeholder_17', Load(), lineno=75, col_offset=8, end_lineno=75, end_col_offset=23), Name('placeholder_14', Load(), lineno=75, col_offset=24, end_lineno=75, end_col_offset=27), Load(), lineno=75, col_offset=8, end_lineno=75, end_col_offset=28), Constant(0, lineno=75, col_offset=29, end_lineno=75, end_col_offset=30), Store(), lineno=75, col_offset=8, end_lineno=75, end_col_offset=31)], BinOp(Subscript(Subscript(Name('placeholder_17', Load(), lineno=75, col_offset=34, end_lineno=75, end_col_offset=49), Name('placeholder_14', Load(), lineno=75, col_offset=50, end_lineno=75, end_col_offset=53), Load(), lineno=75, col_offset=34, end_lineno=75, end_col_offset=54), Constant(0, lineno=75, col_offset=55, end_lineno=75, end_col_offset=56), Load(), lineno=75, col_offset=34, end_lineno=75, end_col_offset=57), Sub(), Subscript(Name('placeholder_18', Load(), lineno=75, col_offset=60, end_lineno=75, end_col_offset=66), Constant(0, lineno=75, col_offset=67, end_lineno=75, end_col_offset=68), Load(), lineno=75, col_offset=60, end_lineno=75, end_col_offset=69), lineno=75, col_offset=34, end_lineno=75, end_col_offset=69), lineno=75, col_offset=8, end_lineno=75, end_col_offset=69), If(Compare(Subscript(Subscript(Name('placeholder_17', Load(), lineno=76, col_offset=11, end_lineno=76, end_col_offset=26), Name('placeholder_14', Load(), lineno=76, col_offset=27, end_lineno=76, end_col_offset=30), Load(), lineno=76, col_offset=11, end_lineno=76, end_col_offset=31), Constant(0, lineno=76, col_offset=32, end_lineno=76, end_col_offset=33), Load(), lineno=76, col_offset=11, end_lineno=76, end_col_offset=34), [Eq()], [Constant(0, lineno=76, col_offset=38, end_lineno=76, end_col_offset=39)], lineno=76, col_offset=11, end_lineno=76, end_col_offset=39), [Assign([Subscript(Subscript(Name('placeholder_17', Load(), lineno=77, col_offset=12, end_lineno=77, end_col_offset=27), Name('placeholder_14', Load(), lineno=77, col_offset=28, end_lineno=77, end_col_offset=31), Load(), lineno=77, col_offset=12, end_lineno=77, end_col_offset=32), Constant(0, lineno=77, col_offset=33, end_lineno=77, end_col_offset=34), Store(), lineno=77, col_offset=12, end_lineno=77, end_col_offset=35)], Constant('Out of Stock', lineno=77, col_offset=38, end_lineno=77, end_col_offset=52), lineno=77, col_offset=12, end_lineno=77, end_col_offset=52)], [], lineno=76, col_offset=8, end_lineno=77, end_col_offset=52)], [], lineno=74, col_offset=4, end_lineno=77, end_col_offset=52), Return(Name('placeholder_17', Load(), lineno=79, col_offset=11, end_lineno=79, end_col_offset=26), lineno=79, col_offset=4, end_lineno=79, end_col_offset=26)], [], lineno=66, col_offset=0, end_lineno=79, end_col_offset=26)], []) \ No newline at end of file diff --git a/test/concept-meltdown-mitigation/.meta/config.json b/test/concept-meltdown-mitigation/.meta/config.json new file mode 100644 index 0000000..eb88d8b --- /dev/null +++ b/test/concept-meltdown-mitigation/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "sachsom95", + "BethanyG" + ], + "contributors": [ + "kbuc" + ], + "files": { + "solution": [ + "conditionals.py" + ], + "test": [ + "conditionals_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "icon": "circular-buffer", + "blurb": "Learn about conditionals and avoid a meltdown by developing a simple control system for a Nuclear Reactor." +} diff --git a/test/concept-meltdown-mitigation/conditionals.py b/test/concept-meltdown-mitigation/conditionals.py new file mode 100644 index 0000000..54cb7d5 --- /dev/null +++ b/test/concept-meltdown-mitigation/conditionals.py @@ -0,0 +1,85 @@ +"""Functions to prevent a nuclear meltdown.""" + + +def is_criticality_balanced(temperature, neutrons_emitted): + """Verify criticality is balanced. + + :param temperature: int or float - temperature value in kelvin. + :param neutrons_emitted: int or float - number of neutrons emitted per second. + :return: bool - is criticality balanced? + + A reactor is said to be critical if it satisfies the following conditions: + - The temperature is less than 800 K. + - The number of neutrons emitted per second is greater than 500. + - The product of temperature and neutrons emitted per second is less than 500000. + """ + + output = temperature * neutrons_emitted + balanced = False + + if (temperature < 800 and neutrons_emitted > 500) and output < 500000: + balanced = True + + return balanced + + +def reactor_efficiency(voltage, current, theoretical_max_power): + """Assess reactor efficiency zone. + + :param voltage: int or float - voltage value. + :param current: int or float - current value. + :param theoretical_max_power: int or float - power that corresponds to a 100% efficiency. + :return: str - one of ('green', 'orange', 'red', or 'black'). + + Efficiency can be grouped into 4 bands: + + 1. green -> efficiency of 80% or more, + 2. orange -> efficiency of less than 80% but at least 60%, + 3. red -> efficiency below 60%, but still 30% or more, + 4. black -> less than 30% efficient. + + The percentage value is calculated as + (generated power/ theoretical max power)*100 + where generated power = voltage * current + """ + + generated_power = voltage * current + percentage_range = (generated_power / theoretical_max_power) * 100 + efficiency_level = 'unknown' + + if 80 <= percentage_range <= 100: + efficiency_level = 'green' + elif 60 <= percentage_range < 80: + efficiency_level = 'orange' + elif 30 <= percentage_range < 60: + efficiency_level = 'red' + else: + efficiency_level = 'black' + + return efficiency_level + + +def fail_safe(temperature, neutrons_produced_per_second, threshold): + """Assess and return status code for the reactor. + + :param temperature: int or float - value of the temperature in kelvin. + :param neutrons_produced_per_second: int or float - neutron flux. + :param threshold: int or float - threshold for category. + :return: str - one of ('LOW', 'NORMAL', 'DANGER'). + + 1. 'LOW' -> `temperature * neutrons per second` < 90% of `threshold` + 2. 'NORMAL' -> `temperature * neutrons per second` +/- 10% of `threshold` + 3. 'DANGER' -> `temperature * neutrons per second` is not in the above-stated ranges + """ + + output = temperature * neutrons_produced_per_second + operational_percentage = (output / threshold) * 100 + + if operational_percentage < 90: + status_code = 'LOW' + elif operational_percentage <= 110: + status_code = 'NORMAL' + else: + status_code = 'DANGER' + + return status_code diff --git a/test/concept-meltdown-mitigation/mapping.json b/test/concept-meltdown-mitigation/mapping.json new file mode 100644 index 0000000..5f0eb1f --- /dev/null +++ b/test/concept-meltdown-mitigation/mapping.json @@ -0,0 +1,19 @@ +{ + "placeholder_0": "is_criticality_balanced", + "placeholder_1": "temperature", + "placeholder_2": "neutrons_emitted", + "placeholder_3": "output", + "placeholder_4": "balanced", + "placeholder_5": "reactor_efficiency", + "placeholder_6": "voltage", + "placeholder_7": "current", + "placeholder_8": "theoretical_max_power", + "placeholder_9": "generated_power", + "placeholder_10": "percentage_range", + "placeholder_11": "efficiency_level", + "placeholder_12": "fail_safe", + "placeholder_13": "neutrons_produced_per_second", + "placeholder_14": "threshold", + "placeholder_15": "operational_percentage", + "placeholder_16": "status_code" +} \ No newline at end of file diff --git a/test/concept-meltdown-mitigation/representation.json b/test/concept-meltdown-mitigation/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-meltdown-mitigation/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-meltdown-mitigation/representation.out b/test/concept-meltdown-mitigation/representation.out new file mode 100644 index 0000000..2a9ea9f --- /dev/null +++ b/test/concept-meltdown-mitigation/representation.out @@ -0,0 +1,1592 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + placeholder_3 = placeholder_1 * placeholder_2 + placeholder_4 = False + if (placeholder_1 < 800 and placeholder_2 > 500) and placeholder_3 < 500000: + placeholder_4 = True + return placeholder_4 + + +def placeholder_5(placeholder_6, placeholder_7, placeholder_8): + placeholder_9 = placeholder_6 * placeholder_7 + placeholder_10 = placeholder_9 / placeholder_8 * 100 + placeholder_11 = "unknown" + if 80 <= placeholder_10 <= 100: + placeholder_11 = "green" + elif 60 <= placeholder_10 < 80: + placeholder_11 = "orange" + elif 30 <= placeholder_10 < 60: + placeholder_11 = "red" + else: + placeholder_11 = "black" + return placeholder_11 + + +def placeholder_12(placeholder_1, placeholder_13, placeholder_14): + placeholder_3 = placeholder_1 * placeholder_13 + placeholder_15 = placeholder_3 / placeholder_14 * 100 + if placeholder_15 < 90: + placeholder_16 = "LOW" + elif placeholder_15 <= 110: + placeholder_16 = "NORMAL" + else: + placeholder_16 = "DANGER" + return placeholder_16 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to prevent a nuclear meltdown.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=46), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=46), + FunctionDef( + 'is_criticality_balanced', + arguments( + [], + [ + arg( + 'temperature', + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=39), + arg( + 'neutrons_emitted', + lineno=4, + col_offset=41, + end_lineno=4, + end_col_offset=57)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Verify criticality is balanced.\n\n :param temperature: int or float - temperature value in kelvin.\n :param neutrons_emitted: int or float - number of neutrons emitted per second.\n :return: bool - is criticality balanced?\n\n A reactor is said to be critical if it satisfies the following conditions:\n - The temperature is less than 800 K.\n - The number of neutrons emitted per second is greater than 500.\n - The product of temperature and neutrons emitted per second is less than 500000.\n ', + lineno=5, + col_offset=4, + end_lineno=15, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=15, + end_col_offset=7), + Assign( + [ + Name( + 'output', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=10)], + BinOp( + Name( + 'temperature', + Load(), + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=24), + Mult(), + Name( + 'neutrons_emitted', + Load(), + lineno=17, + col_offset=27, + end_lineno=17, + end_col_offset=43), + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=43), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=43), + Assign( + [ + Name( + 'balanced', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=12)], + Constant( + False, + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=20), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=20), + If( + BoolOp( + And(), + [ + BoolOp( + And(), + [ + Compare( + Name( + 'temperature', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=19), + [ + Lt()], + [ + Constant( + 800, + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=25)], + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=25), + Compare( + Name( + 'neutrons_emitted', + Load(), + lineno=20, + col_offset=30, + end_lineno=20, + end_col_offset=46), + [ + Gt()], + [ + Constant( + 500, + lineno=20, + col_offset=49, + end_lineno=20, + end_col_offset=52)], + lineno=20, + col_offset=30, + end_lineno=20, + end_col_offset=52)], + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=52), + Compare( + Name( + 'output', + Load(), + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=64), + [ + Lt()], + [ + Constant( + 500000, + lineno=20, + col_offset=67, + end_lineno=20, + end_col_offset=73)], + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=73)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=73), + [ + Assign( + [ + Name( + 'balanced', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=16)], + Constant( + True, + lineno=21, + col_offset=19, + end_lineno=21, + end_col_offset=23), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=23)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=23), + Return( + Name( + 'balanced', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=19), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=19)], + [], + lineno=4, + col_offset=0, + end_lineno=23, + end_col_offset=19), + FunctionDef( + 'reactor_efficiency', + arguments( + [], + [ + arg( + 'voltage', + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=30), + arg( + 'current', + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=39), + arg( + 'theoretical_max_power', + lineno=26, + col_offset=41, + end_lineno=26, + end_col_offset=62)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Assess reactor efficiency zone.\n\n :param voltage: int or float - voltage value.\n :param current: int or float - current value.\n :param theoretical_max_power: int or float - power that corresponds to a 100% efficiency.\n :return: str - one of ('green', 'orange', 'red', or 'black').\n\n Efficiency can be grouped into 4 bands:\n\n 1. green -> efficiency of 80% or more,\n 2. orange -> efficiency of less than 80% but at least 60%,\n 3. red -> efficiency below 60%, but still 30% or more,\n 4. black -> less than 30% efficient.\n\n The percentage value is calculated as\n (generated power/ theoretical max power)*100\n where generated power = voltage * current\n ", + lineno=27, + col_offset=4, + end_lineno=44, + end_col_offset=7), + lineno=27, + col_offset=4, + end_lineno=44, + end_col_offset=7), + Assign( + [ + Name( + 'generated_power', + Store(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=19)], + BinOp( + Name( + 'voltage', + Load(), + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=29), + Mult(), + Name( + 'current', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=39), + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=39), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=39), + Assign( + [ + Name( + 'percentage_range', + Store(), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=20)], + BinOp( + BinOp( + Name( + 'generated_power', + Load(), + lineno=47, + col_offset=24, + end_lineno=47, + end_col_offset=39), + Div(), + Name( + 'theoretical_max_power', + Load(), + lineno=47, + col_offset=42, + end_lineno=47, + end_col_offset=63), + lineno=47, + col_offset=24, + end_lineno=47, + end_col_offset=63), + Mult(), + Constant( + 100, + lineno=47, + col_offset=67, + end_lineno=47, + end_col_offset=70), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=70), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=70), + Assign( + [ + Name( + 'efficiency_level', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=20)], + Constant( + 'unknown', + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=32), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=32), + If( + Compare( + Constant( + 80, + lineno=50, + col_offset=7, + end_lineno=50, + end_col_offset=9), + [ + LtE(), + LtE()], + [ + Name( + 'percentage_range', + Load(), + lineno=50, + col_offset=13, + end_lineno=50, + end_col_offset=29), + Constant( + 100, + lineno=50, + col_offset=33, + end_lineno=50, + end_col_offset=36)], + lineno=50, + col_offset=7, + end_lineno=50, + end_col_offset=36), + [ + Assign( + [ + Name( + 'efficiency_level', + Store(), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=24)], + Constant( + 'green', + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=34), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=34)], + [ + If( + Compare( + Constant( + 60, + lineno=52, + col_offset=9, + end_lineno=52, + end_col_offset=11), + [ + LtE(), + Lt()], + [ + Name( + 'percentage_range', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=31), + Constant( + 80, + lineno=52, + col_offset=34, + end_lineno=52, + end_col_offset=36)], + lineno=52, + col_offset=9, + end_lineno=52, + end_col_offset=36), + [ + Assign( + [ + Name( + 'efficiency_level', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=24)], + Constant( + 'orange', + lineno=53, + col_offset=27, + end_lineno=53, + end_col_offset=35), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=35)], + [ + If( + Compare( + Constant( + 30, + lineno=54, + col_offset=9, + end_lineno=54, + end_col_offset=11), + [ + LtE(), + Lt()], + [ + Name( + 'percentage_range', + Load(), + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=31), + Constant( + 60, + lineno=54, + col_offset=34, + end_lineno=54, + end_col_offset=36)], + lineno=54, + col_offset=9, + end_lineno=54, + end_col_offset=36), + [ + Assign( + [ + Name( + 'efficiency_level', + Store(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=24)], + Constant( + 'red', + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=32), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=32)], + [ + Assign( + [ + Name( + 'efficiency_level', + Store(), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=24)], + Constant( + 'black', + lineno=57, + col_offset=27, + end_lineno=57, + end_col_offset=34), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=34)], + lineno=54, + col_offset=4, + end_lineno=57, + end_col_offset=34)], + lineno=52, + col_offset=4, + end_lineno=57, + end_col_offset=34)], + lineno=50, + col_offset=4, + end_lineno=57, + end_col_offset=34), + Return( + Name( + 'efficiency_level', + Load(), + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=27), + lineno=59, + col_offset=4, + end_lineno=59, + end_col_offset=27)], + [], + lineno=26, + col_offset=0, + end_lineno=59, + end_col_offset=27), + FunctionDef( + 'fail_safe', + arguments( + [], + [ + arg( + 'temperature', + lineno=62, + col_offset=14, + end_lineno=62, + end_col_offset=25), + arg( + 'neutrons_produced_per_second', + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=55), + arg( + 'threshold', + lineno=62, + col_offset=57, + end_lineno=62, + end_col_offset=66)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Assess and return status code for the reactor.\n\n :param temperature: int or float - value of the temperature in kelvin.\n :param neutrons_produced_per_second: int or float - neutron flux.\n :param threshold: int or float - threshold for category.\n :return: str - one of ('LOW', 'NORMAL', 'DANGER').\n\n 1. 'LOW' -> `temperature * neutrons per second` < 90% of `threshold`\n 2. 'NORMAL' -> `temperature * neutrons per second` +/- 10% of `threshold`\n 3. 'DANGER' -> `temperature * neutrons per second` is not in the above-stated ranges\n ", + lineno=63, + col_offset=4, + end_lineno=73, + end_col_offset=7), + lineno=63, + col_offset=4, + end_lineno=73, + end_col_offset=7), + Assign( + [ + Name( + 'output', + Store(), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=10)], + BinOp( + Name( + 'temperature', + Load(), + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=24), + Mult(), + Name( + 'neutrons_produced_per_second', + Load(), + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=55), + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=55), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=55), + Assign( + [ + Name( + 'operational_percentage', + Store(), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=26)], + BinOp( + BinOp( + Name( + 'output', + Load(), + lineno=76, + col_offset=30, + end_lineno=76, + end_col_offset=36), + Div(), + Name( + 'threshold', + Load(), + lineno=76, + col_offset=39, + end_lineno=76, + end_col_offset=48), + lineno=76, + col_offset=30, + end_lineno=76, + end_col_offset=48), + Mult(), + Constant( + 100, + lineno=76, + col_offset=52, + end_lineno=76, + end_col_offset=55), + lineno=76, + col_offset=29, + end_lineno=76, + end_col_offset=55), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=55), + If( + Compare( + Name( + 'operational_percentage', + Load(), + lineno=78, + col_offset=7, + end_lineno=78, + end_col_offset=29), + [ + Lt()], + [ + Constant( + 90, + lineno=78, + col_offset=32, + end_lineno=78, + end_col_offset=34)], + lineno=78, + col_offset=7, + end_lineno=78, + end_col_offset=34), + [ + Assign( + [ + Name( + 'status_code', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=19)], + Constant( + 'LOW', + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=27), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=27)], + [ + If( + Compare( + Name( + 'operational_percentage', + Load(), + lineno=80, + col_offset=9, + end_lineno=80, + end_col_offset=31), + [ + LtE()], + [ + Constant( + 110, + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=38)], + lineno=80, + col_offset=9, + end_lineno=80, + end_col_offset=38), + [ + Assign( + [ + Name( + 'status_code', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=19)], + Constant( + 'NORMAL', + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=30), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=30)], + [ + Assign( + [ + Name( + 'status_code', + Store(), + lineno=83, + col_offset=8, + end_lineno=83, + end_col_offset=19)], + Constant( + 'DANGER', + lineno=83, + col_offset=22, + end_lineno=83, + end_col_offset=30), + lineno=83, + col_offset=8, + end_lineno=83, + end_col_offset=30)], + lineno=80, + col_offset=4, + end_lineno=83, + end_col_offset=30)], + lineno=78, + col_offset=4, + end_lineno=83, + end_col_offset=30), + Return( + Name( + 'status_code', + Load(), + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=22), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=22)], + [], + lineno=62, + col_offset=0, + end_lineno=85, + end_col_offset=22)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=39), + arg( + 'placeholder_2', + lineno=4, + col_offset=41, + end_lineno=4, + end_col_offset=57)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=10)], + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=24), + Mult(), + Name( + 'placeholder_2', + Load(), + lineno=17, + col_offset=27, + end_lineno=17, + end_col_offset=43), + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=43), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=43), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=12)], + Constant( + False, + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=20), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=20), + If( + BoolOp( + And(), + [ + BoolOp( + And(), + [ + Compare( + Name( + 'placeholder_1', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=19), + [ + Lt()], + [ + Constant( + 800, + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=25)], + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=25), + Compare( + Name( + 'placeholder_2', + Load(), + lineno=20, + col_offset=30, + end_lineno=20, + end_col_offset=46), + [ + Gt()], + [ + Constant( + 500, + lineno=20, + col_offset=49, + end_lineno=20, + end_col_offset=52)], + lineno=20, + col_offset=30, + end_lineno=20, + end_col_offset=52)], + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=52), + Compare( + Name( + 'placeholder_3', + Load(), + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=64), + [ + Lt()], + [ + Constant( + 500000, + lineno=20, + col_offset=67, + end_lineno=20, + end_col_offset=73)], + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=73)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=73), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=16)], + Constant( + True, + lineno=21, + col_offset=19, + end_lineno=21, + end_col_offset=23), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=23)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=23), + Return( + Name( + 'placeholder_4', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=19), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=19)], + [], + lineno=4, + col_offset=0, + end_lineno=23, + end_col_offset=19), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=30), + arg( + 'placeholder_7', + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=39), + arg( + 'placeholder_8', + lineno=26, + col_offset=41, + end_lineno=26, + end_col_offset=62)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=19)], + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=29), + Mult(), + Name( + 'placeholder_7', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=39), + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=39), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=20)], + BinOp( + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=47, + col_offset=24, + end_lineno=47, + end_col_offset=39), + Div(), + Name( + 'placeholder_8', + Load(), + lineno=47, + col_offset=42, + end_lineno=47, + end_col_offset=63), + lineno=47, + col_offset=24, + end_lineno=47, + end_col_offset=63), + Mult(), + Constant( + 100, + lineno=47, + col_offset=67, + end_lineno=47, + end_col_offset=70), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=70), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=70), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=20)], + Constant( + 'unknown', + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=32), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=32), + If( + Compare( + Constant( + 80, + lineno=50, + col_offset=7, + end_lineno=50, + end_col_offset=9), + [ + LtE(), + LtE()], + [ + Name( + 'placeholder_10', + Load(), + lineno=50, + col_offset=13, + end_lineno=50, + end_col_offset=29), + Constant( + 100, + lineno=50, + col_offset=33, + end_lineno=50, + end_col_offset=36)], + lineno=50, + col_offset=7, + end_lineno=50, + end_col_offset=36), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=24)], + Constant( + 'green', + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=34), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=34)], + [ + If( + Compare( + Constant( + 60, + lineno=52, + col_offset=9, + end_lineno=52, + end_col_offset=11), + [ + LtE(), + Lt()], + [ + Name( + 'placeholder_10', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=31), + Constant( + 80, + lineno=52, + col_offset=34, + end_lineno=52, + end_col_offset=36)], + lineno=52, + col_offset=9, + end_lineno=52, + end_col_offset=36), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=24)], + Constant( + 'orange', + lineno=53, + col_offset=27, + end_lineno=53, + end_col_offset=35), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=35)], + [ + If( + Compare( + Constant( + 30, + lineno=54, + col_offset=9, + end_lineno=54, + end_col_offset=11), + [ + LtE(), + Lt()], + [ + Name( + 'placeholder_10', + Load(), + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=31), + Constant( + 60, + lineno=54, + col_offset=34, + end_lineno=54, + end_col_offset=36)], + lineno=54, + col_offset=9, + end_lineno=54, + end_col_offset=36), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=24)], + Constant( + 'red', + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=32), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=32)], + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=24)], + Constant( + 'black', + lineno=57, + col_offset=27, + end_lineno=57, + end_col_offset=34), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=34)], + lineno=54, + col_offset=4, + end_lineno=57, + end_col_offset=34)], + lineno=52, + col_offset=4, + end_lineno=57, + end_col_offset=34)], + lineno=50, + col_offset=4, + end_lineno=57, + end_col_offset=34), + Return( + Name( + 'placeholder_11', + Load(), + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=27), + lineno=59, + col_offset=4, + end_lineno=59, + end_col_offset=27)], + [], + lineno=26, + col_offset=0, + end_lineno=59, + end_col_offset=27), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=62, + col_offset=14, + end_lineno=62, + end_col_offset=25), + arg( + 'placeholder_13', + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=55), + arg( + 'placeholder_14', + lineno=62, + col_offset=57, + end_lineno=62, + end_col_offset=66)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=10)], + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=24), + Mult(), + Name( + 'placeholder_13', + Load(), + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=55), + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=55), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=55), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=26)], + BinOp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=76, + col_offset=30, + end_lineno=76, + end_col_offset=36), + Div(), + Name( + 'placeholder_14', + Load(), + lineno=76, + col_offset=39, + end_lineno=76, + end_col_offset=48), + lineno=76, + col_offset=30, + end_lineno=76, + end_col_offset=48), + Mult(), + Constant( + 100, + lineno=76, + col_offset=52, + end_lineno=76, + end_col_offset=55), + lineno=76, + col_offset=29, + end_lineno=76, + end_col_offset=55), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=55), + If( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=78, + col_offset=7, + end_lineno=78, + end_col_offset=29), + [ + Lt()], + [ + Constant( + 90, + lineno=78, + col_offset=32, + end_lineno=78, + end_col_offset=34)], + lineno=78, + col_offset=7, + end_lineno=78, + end_col_offset=34), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=19)], + Constant( + 'LOW', + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=27), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=27)], + [ + If( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=80, + col_offset=9, + end_lineno=80, + end_col_offset=31), + [ + LtE()], + [ + Constant( + 110, + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=38)], + lineno=80, + col_offset=9, + end_lineno=80, + end_col_offset=38), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=19)], + Constant( + 'NORMAL', + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=30), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=30)], + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=83, + col_offset=8, + end_lineno=83, + end_col_offset=19)], + Constant( + 'DANGER', + lineno=83, + col_offset=22, + end_lineno=83, + end_col_offset=30), + lineno=83, + col_offset=8, + end_lineno=83, + end_col_offset=30)], + lineno=80, + col_offset=4, + end_lineno=83, + end_col_offset=30)], + lineno=78, + col_offset=4, + end_lineno=83, + end_col_offset=30), + Return( + Name( + 'placeholder_16', + Load(), + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=22), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=22)], + [], + lineno=62, + col_offset=0, + end_lineno=85, + end_col_offset=22)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-meltdown-mitigation/representation.txt b/test/concept-meltdown-mitigation/representation.txt new file mode 100644 index 0000000..5c56b70 --- /dev/null +++ b/test/concept-meltdown-mitigation/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=28, end_lineno=4, end_col_offset=39), arg('placeholder_2', lineno=4, col_offset=41, end_lineno=4, end_col_offset=57)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=10)], BinOp(Name('placeholder_1', Load(), lineno=17, col_offset=13, end_lineno=17, end_col_offset=24), Mult(), Name('placeholder_2', Load(), lineno=17, col_offset=27, end_lineno=17, end_col_offset=43), lineno=17, col_offset=13, end_lineno=17, end_col_offset=43), lineno=17, col_offset=4, end_lineno=17, end_col_offset=43), Assign([Name('placeholder_4', Store(), lineno=18, col_offset=4, end_lineno=18, end_col_offset=12)], Constant(False, lineno=18, col_offset=15, end_lineno=18, end_col_offset=20), lineno=18, col_offset=4, end_lineno=18, end_col_offset=20), If(BoolOp(And(), [BoolOp(And(), [Compare(Name('placeholder_1', Load(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=19), [Lt()], [Constant(800, lineno=20, col_offset=22, end_lineno=20, end_col_offset=25)], lineno=20, col_offset=8, end_lineno=20, end_col_offset=25), Compare(Name('placeholder_2', Load(), lineno=20, col_offset=30, end_lineno=20, end_col_offset=46), [Gt()], [Constant(500, lineno=20, col_offset=49, end_lineno=20, end_col_offset=52)], lineno=20, col_offset=30, end_lineno=20, end_col_offset=52)], lineno=20, col_offset=8, end_lineno=20, end_col_offset=52), Compare(Name('placeholder_3', Load(), lineno=20, col_offset=58, end_lineno=20, end_col_offset=64), [Lt()], [Constant(500000, lineno=20, col_offset=67, end_lineno=20, end_col_offset=73)], lineno=20, col_offset=58, end_lineno=20, end_col_offset=73)], lineno=20, col_offset=7, end_lineno=20, end_col_offset=73), [Assign([Name('placeholder_4', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=16)], Constant(True, lineno=21, col_offset=19, end_lineno=21, end_col_offset=23), lineno=21, col_offset=8, end_lineno=21, end_col_offset=23)], [], lineno=20, col_offset=4, end_lineno=21, end_col_offset=23), Return(Name('placeholder_4', Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=19), lineno=23, col_offset=4, end_lineno=23, end_col_offset=19)], [], lineno=4, col_offset=0, end_lineno=23, end_col_offset=19), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=26, col_offset=23, end_lineno=26, end_col_offset=30), arg('placeholder_7', lineno=26, col_offset=32, end_lineno=26, end_col_offset=39), arg('placeholder_8', lineno=26, col_offset=41, end_lineno=26, end_col_offset=62)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_9', Store(), lineno=46, col_offset=4, end_lineno=46, end_col_offset=19)], BinOp(Name('placeholder_6', Load(), lineno=46, col_offset=22, end_lineno=46, end_col_offset=29), Mult(), Name('placeholder_7', Load(), lineno=46, col_offset=32, end_lineno=46, end_col_offset=39), lineno=46, col_offset=22, end_lineno=46, end_col_offset=39), lineno=46, col_offset=4, end_lineno=46, end_col_offset=39), Assign([Name('placeholder_10', Store(), lineno=47, col_offset=4, end_lineno=47, end_col_offset=20)], BinOp(BinOp(Name('placeholder_9', Load(), lineno=47, col_offset=24, end_lineno=47, end_col_offset=39), Div(), Name('placeholder_8', Load(), lineno=47, col_offset=42, end_lineno=47, end_col_offset=63), lineno=47, col_offset=24, end_lineno=47, end_col_offset=63), Mult(), Constant(100, lineno=47, col_offset=67, end_lineno=47, end_col_offset=70), lineno=47, col_offset=23, end_lineno=47, end_col_offset=70), lineno=47, col_offset=4, end_lineno=47, end_col_offset=70), Assign([Name('placeholder_11', Store(), lineno=48, col_offset=4, end_lineno=48, end_col_offset=20)], Constant('unknown', lineno=48, col_offset=23, end_lineno=48, end_col_offset=32), lineno=48, col_offset=4, end_lineno=48, end_col_offset=32), If(Compare(Constant(80, lineno=50, col_offset=7, end_lineno=50, end_col_offset=9), [LtE(), LtE()], [Name('placeholder_10', Load(), lineno=50, col_offset=13, end_lineno=50, end_col_offset=29), Constant(100, lineno=50, col_offset=33, end_lineno=50, end_col_offset=36)], lineno=50, col_offset=7, end_lineno=50, end_col_offset=36), [Assign([Name('placeholder_11', Store(), lineno=51, col_offset=8, end_lineno=51, end_col_offset=24)], Constant('green', lineno=51, col_offset=27, end_lineno=51, end_col_offset=34), lineno=51, col_offset=8, end_lineno=51, end_col_offset=34)], [If(Compare(Constant(60, lineno=52, col_offset=9, end_lineno=52, end_col_offset=11), [LtE(), Lt()], [Name('placeholder_10', Load(), lineno=52, col_offset=15, end_lineno=52, end_col_offset=31), Constant(80, lineno=52, col_offset=34, end_lineno=52, end_col_offset=36)], lineno=52, col_offset=9, end_lineno=52, end_col_offset=36), [Assign([Name('placeholder_11', Store(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=24)], Constant('orange', lineno=53, col_offset=27, end_lineno=53, end_col_offset=35), lineno=53, col_offset=8, end_lineno=53, end_col_offset=35)], [If(Compare(Constant(30, lineno=54, col_offset=9, end_lineno=54, end_col_offset=11), [LtE(), Lt()], [Name('placeholder_10', Load(), lineno=54, col_offset=15, end_lineno=54, end_col_offset=31), Constant(60, lineno=54, col_offset=34, end_lineno=54, end_col_offset=36)], lineno=54, col_offset=9, end_lineno=54, end_col_offset=36), [Assign([Name('placeholder_11', Store(), lineno=55, col_offset=8, end_lineno=55, end_col_offset=24)], Constant('red', lineno=55, col_offset=27, end_lineno=55, end_col_offset=32), lineno=55, col_offset=8, end_lineno=55, end_col_offset=32)], [Assign([Name('placeholder_11', Store(), lineno=57, col_offset=8, end_lineno=57, end_col_offset=24)], Constant('black', lineno=57, col_offset=27, end_lineno=57, end_col_offset=34), lineno=57, col_offset=8, end_lineno=57, end_col_offset=34)], lineno=54, col_offset=4, end_lineno=57, end_col_offset=34)], lineno=52, col_offset=4, end_lineno=57, end_col_offset=34)], lineno=50, col_offset=4, end_lineno=57, end_col_offset=34), Return(Name('placeholder_11', Load(), lineno=59, col_offset=11, end_lineno=59, end_col_offset=27), lineno=59, col_offset=4, end_lineno=59, end_col_offset=27)], [], lineno=26, col_offset=0, end_lineno=59, end_col_offset=27), FunctionDef('placeholder_12', arguments([], [arg('placeholder_1', lineno=62, col_offset=14, end_lineno=62, end_col_offset=25), arg('placeholder_13', lineno=62, col_offset=27, end_lineno=62, end_col_offset=55), arg('placeholder_14', lineno=62, col_offset=57, end_lineno=62, end_col_offset=66)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=75, col_offset=4, end_lineno=75, end_col_offset=10)], BinOp(Name('placeholder_1', Load(), lineno=75, col_offset=13, end_lineno=75, end_col_offset=24), Mult(), Name('placeholder_13', Load(), lineno=75, col_offset=27, end_lineno=75, end_col_offset=55), lineno=75, col_offset=13, end_lineno=75, end_col_offset=55), lineno=75, col_offset=4, end_lineno=75, end_col_offset=55), Assign([Name('placeholder_15', Store(), lineno=76, col_offset=4, end_lineno=76, end_col_offset=26)], BinOp(BinOp(Name('placeholder_3', Load(), lineno=76, col_offset=30, end_lineno=76, end_col_offset=36), Div(), Name('placeholder_14', Load(), lineno=76, col_offset=39, end_lineno=76, end_col_offset=48), lineno=76, col_offset=30, end_lineno=76, end_col_offset=48), Mult(), Constant(100, lineno=76, col_offset=52, end_lineno=76, end_col_offset=55), lineno=76, col_offset=29, end_lineno=76, end_col_offset=55), lineno=76, col_offset=4, end_lineno=76, end_col_offset=55), If(Compare(Name('placeholder_15', Load(), lineno=78, col_offset=7, end_lineno=78, end_col_offset=29), [Lt()], [Constant(90, lineno=78, col_offset=32, end_lineno=78, end_col_offset=34)], lineno=78, col_offset=7, end_lineno=78, end_col_offset=34), [Assign([Name('placeholder_16', Store(), lineno=79, col_offset=8, end_lineno=79, end_col_offset=19)], Constant('LOW', lineno=79, col_offset=22, end_lineno=79, end_col_offset=27), lineno=79, col_offset=8, end_lineno=79, end_col_offset=27)], [If(Compare(Name('placeholder_15', Load(), lineno=80, col_offset=9, end_lineno=80, end_col_offset=31), [LtE()], [Constant(110, lineno=80, col_offset=35, end_lineno=80, end_col_offset=38)], lineno=80, col_offset=9, end_lineno=80, end_col_offset=38), [Assign([Name('placeholder_16', Store(), lineno=81, col_offset=8, end_lineno=81, end_col_offset=19)], Constant('NORMAL', lineno=81, col_offset=22, end_lineno=81, end_col_offset=30), lineno=81, col_offset=8, end_lineno=81, end_col_offset=30)], [Assign([Name('placeholder_16', Store(), lineno=83, col_offset=8, end_lineno=83, end_col_offset=19)], Constant('DANGER', lineno=83, col_offset=22, end_lineno=83, end_col_offset=30), lineno=83, col_offset=8, end_lineno=83, end_col_offset=30)], lineno=80, col_offset=4, end_lineno=83, end_col_offset=30)], lineno=78, col_offset=4, end_lineno=83, end_col_offset=30), Return(Name('placeholder_16', Load(), lineno=85, col_offset=11, end_lineno=85, end_col_offset=22), lineno=85, col_offset=4, end_lineno=85, end_col_offset=22)], [], lineno=62, col_offset=0, end_lineno=85, end_col_offset=22)], []) \ No newline at end of file diff --git a/test/concept-plane-tickets/.meta/config.json b/test/concept-plane-tickets/.meta/config.json new file mode 100644 index 0000000..1222834 --- /dev/null +++ b/test/concept-plane-tickets/.meta/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "J08K" + ], + "contributors": [ + "BethanyG", + "kytrinyx", + "meatball133" + ], + "files": { + "solution": [ + "generators.py" + ], + "test": [ + "generators_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "icon": "new-passport", + "blurb": "Learn about generators by assigning seats to passengers on Anaconda Airlines." +} diff --git a/test/concept-plane-tickets/generators.py b/test/concept-plane-tickets/generators.py new file mode 100644 index 0000000..8261795 --- /dev/null +++ b/test/concept-plane-tickets/generators.py @@ -0,0 +1,80 @@ +"""Functions to automate Conda airlines ticketing system.""" + +import math + +SEATS_IN_ROW = ['A', 'B', 'C', 'D'] + + +def generate_seat_letters(number): + """Generate a series of letters for airline seats. + + :param number: int - total number of seat letters to be generated. + :return: generator - generator that yields seat letters. + + Seat letters are generated from A to D. + After D it should start again with A. + + Example: A, B, C, D + + """ + + for seat in range(number): + yield SEATS_IN_ROW[seat % 4] + + +def generate_seats(number): + """Generate a series of identifiers for airline seats. + + :param number: int - total number of seats to be generated. + :return: generator - generator that yields seat numbers. + + A seat number consists of the row number and the seat letter. + + There is no row 13. + Each row has 4 seats. + + Seats should be sorted from low to high. + + Example: 3C, 3D, 4A, 4B + + """ + + number = number + 4 if number >= 13 else number + letters = generate_seat_letters(number) + for seat in range(number): + row_number = math.ceil((seat+1) / 4) + if row_number != 13: + yield f'{str(row_number)}{next(letters)}' + + # return (f'{str(row_number)}{next(letters)}' for seat in range(number) + # if (row_number := math.ceil((seat+1) / 4)) and row_number != 13) + + +def assign_seats(passengers): + """Assign seats to passengers. + + :param passengers: list[str] - a list of strings containing names of passengers. + :return: dict - with the names of the passengers as keys and seat numbers as values. + + Example output: {"Adele": "1A", "Björk": "1B"} + + """ + + number = len(passengers) + output = {} + for passenger, seat_number in zip(passengers, generate_seats(number)): + output[passenger] = seat_number + return output + +def generate_codes(seat_numbers, flight_id): + """Generate codes for a ticket. + + :param seat_numbers: list[str] - list of seat numbers. + :param flight_id: str - string containing the flight identifier. + :return: generator - generator that yields 12 character long ticket codes. + + """ + + for seat in seat_numbers: + base_string = f'{seat}{flight_id}' + yield base_string + '0' * (12 - len(base_string)) diff --git a/test/concept-plane-tickets/mapping.json b/test/concept-plane-tickets/mapping.json new file mode 100644 index 0000000..fc44135 --- /dev/null +++ b/test/concept-plane-tickets/mapping.json @@ -0,0 +1,18 @@ +{ + "placeholder_0": "SEATS_IN_ROW", + "placeholder_1": "generate_seat_letters", + "placeholder_2": "number", + "placeholder_3": "seat", + "placeholder_4": "generate_seats", + "placeholder_5": "letters", + "placeholder_6": "row_number", + "placeholder_7": "assign_seats", + "placeholder_8": "passengers", + "placeholder_9": "output", + "placeholder_10": "passenger", + "placeholder_11": "seat_number", + "placeholder_12": "generate_codes", + "placeholder_13": "seat_numbers", + "placeholder_14": "flight_id", + "placeholder_15": "base_string" +} \ No newline at end of file diff --git a/test/concept-plane-tickets/representation.json b/test/concept-plane-tickets/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-plane-tickets/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-plane-tickets/representation.out b/test/concept-plane-tickets/representation.out new file mode 100644 index 0000000..d7add39 --- /dev/null +++ b/test/concept-plane-tickets/representation.out @@ -0,0 +1,1741 @@ +## BEGIN NORMALIZED CODE ## +import math + +placeholder_0 = ["A", "B", "C", "D"] + + +def placeholder_1(placeholder_2): + for placeholder_3 in range(placeholder_2): + yield SEATS_IN_ROW[seat % 4] + + +def placeholder_4(placeholder_2): + placeholder_2 = placeholder_2 + 4 if placeholder_2 >= 13 else placeholder_2 + placeholder_5 = placeholder_1(placeholder_2) + for placeholder_3 in range(placeholder_2): + placeholder_6 = math.ceil((placeholder_3 + 1) / 4) + if placeholder_6 != 13: + yield f"{str(row_number)}{next(letters)}" + + +def placeholder_7(placeholder_8): + placeholder_2 = len(placeholder_8) + placeholder_9 = {} + for placeholder_10, placeholder_11 in zip( + placeholder_8, placeholder_4(placeholder_2) + ): + placeholder_9[placeholder_10] = placeholder_11 + return placeholder_9 + + +def placeholder_12(placeholder_13, placeholder_14): + for placeholder_3 in placeholder_13: + placeholder_15 = f"{placeholder_3}{placeholder_14}" + yield (base_string + "0" * (12 - len(base_string))) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to automate Conda airlines ticketing system.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=60), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=60), + Import( + [ + alias( + 'math', + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=11)], + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=11), + Assign( + [ + Name( + 'SEATS_IN_ROW', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=12)], + List( + [ + Constant( + 'A', + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=19), + Constant( + 'B', + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + Constant( + 'C', + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=29), + Constant( + 'D', + lineno=5, + col_offset=31, + end_lineno=5, + end_col_offset=34)], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=35), + FunctionDef( + 'generate_seat_letters', + arguments( + [], + [ + arg( + 'number', + lineno=8, + col_offset=26, + end_lineno=8, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Generate a series of letters for airline seats.\n\n :param number: int - total number of seat letters to be generated.\n :return: generator - generator that yields seat letters.\n\n Seat letters are generated from A to D.\n After D it should start again with A.\n\n Example: A, B, C, D\n\n ', + lineno=9, + col_offset=4, + end_lineno=19, + end_col_offset=7), + lineno=9, + col_offset=4, + end_lineno=19, + end_col_offset=7), + For( + Name( + 'seat', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=21), + [ + Name( + 'number', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=28)], + [], + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=29), + [ + Expr( + Yield( + Subscript( + Name( + 'SEATS_IN_ROW', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=26), + BinOp( + Name( + 'seat', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=31), + Mod(), + Constant( + 4, + lineno=22, + col_offset=34, + end_lineno=22, + end_col_offset=35), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=35), + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=36), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=36), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=36)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=36)], + [], + lineno=8, + col_offset=0, + end_lineno=22, + end_col_offset=36), + FunctionDef( + 'generate_seats', + arguments( + [], + [ + arg( + 'number', + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Generate a series of identifiers for airline seats.\n\n :param number: int - total number of seats to be generated.\n :return: generator - generator that yields seat numbers.\n\n A seat number consists of the row number and the seat letter.\n\n There is no row 13.\n Each row has 4 seats.\n\n Seats should be sorted from low to high.\n\n Example: 3C, 3D, 4A, 4B\n\n ', + lineno=26, + col_offset=4, + end_lineno=40, + end_col_offset=7), + lineno=26, + col_offset=4, + end_lineno=40, + end_col_offset=7), + Assign( + [ + Name( + 'number', + Store(), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=10)], + IfExp( + Compare( + Name( + 'number', + Load(), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=33), + [ + GtE()], + [ + Constant( + 13, + lineno=42, + col_offset=37, + end_lineno=42, + end_col_offset=39)], + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=39), + BinOp( + Name( + 'number', + Load(), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=19), + Add(), + Constant( + 4, + lineno=42, + col_offset=22, + end_lineno=42, + end_col_offset=23), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=23), + Name( + 'number', + Load(), + lineno=42, + col_offset=45, + end_lineno=42, + end_col_offset=51), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=51), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=51), + Assign( + [ + Name( + 'letters', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=11)], + Call( + Name( + 'generate_seat_letters', + Load(), + lineno=43, + col_offset=14, + end_lineno=43, + end_col_offset=35), + [ + Name( + 'number', + Load(), + lineno=43, + col_offset=36, + end_lineno=43, + end_col_offset=42)], + [], + lineno=43, + col_offset=14, + end_lineno=43, + end_col_offset=43), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=43), + For( + Name( + 'seat', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=21), + [ + Name( + 'number', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=28)], + [], + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=29), + [ + Assign( + [ + Name( + 'row_number', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=18)], + Call( + Attribute( + Name( + 'math', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=25), + 'ceil', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=30), + [ + BinOp( + BinOp( + Name( + 'seat', + Load(), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=36), + Add(), + Constant( + 1, + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=38), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=38), + Div(), + Constant( + 4, + lineno=45, + col_offset=42, + end_lineno=45, + end_col_offset=43), + lineno=45, + col_offset=31, + end_lineno=45, + end_col_offset=43)], + [], + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=44), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=44), + If( + Compare( + Name( + 'row_number', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=21), + [ + NotEq()], + [ + Constant( + 13, + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=27)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=27), + [ + Expr( + Yield( + JoinedStr( + [ + FormattedValue( + Call( + Name( + 'str', + Load(), + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=24), + [ + Name( + 'row_number', + Load(), + lineno=47, + col_offset=25, + end_lineno=47, + end_col_offset=35)], + [], + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=36), + -1, + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53), + FormattedValue( + Call( + Name( + 'next', + Load(), + lineno=47, + col_offset=38, + end_lineno=47, + end_col_offset=42), + [ + Name( + 'letters', + Load(), + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=50)], + [], + lineno=47, + col_offset=38, + end_lineno=47, + end_col_offset=51), + -1, + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53)], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=53), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=53)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=53)], + [], + lineno=44, + col_offset=4, + end_lineno=47, + end_col_offset=53)], + [], + lineno=25, + col_offset=0, + end_lineno=47, + end_col_offset=53), + FunctionDef( + 'assign_seats', + arguments( + [], + [ + arg( + 'passengers', + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Assign seats to passengers.\n\n :param passengers: list[str] - a list of strings containing names of passengers.\n :return: dict - with the names of the passengers as keys and seat numbers as values.\n\n Example output: {"Adele": "1A", "Björk": "1B"}\n\n ', + lineno=54, + col_offset=4, + end_lineno=61, + end_col_offset=7), + lineno=54, + col_offset=4, + end_lineno=61, + end_col_offset=7), + Assign( + [ + Name( + 'number', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=10)], + Call( + Name( + 'len', + Load(), + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=16), + [ + Name( + 'passengers', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=27)], + [], + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=28), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=28), + Assign( + [ + Name( + 'output', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=10)], + Dict( + [], + [], + lineno=64, + col_offset=13, + end_lineno=64, + end_col_offset=15), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'passenger', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=17), + Name( + 'seat_number', + Store(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=30)], + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=30), + Call( + Name( + 'zip', + Load(), + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=37), + [ + Name( + 'passengers', + Load(), + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=48), + Call( + Name( + 'generate_seats', + Load(), + lineno=65, + col_offset=50, + end_lineno=65, + end_col_offset=64), + [ + Name( + 'number', + Load(), + lineno=65, + col_offset=65, + end_lineno=65, + end_col_offset=71)], + [], + lineno=65, + col_offset=50, + end_lineno=65, + end_col_offset=72)], + [], + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=73), + [ + Assign( + [ + Subscript( + Name( + 'output', + Load(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=14), + Name( + 'passenger', + Load(), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=24), + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=25)], + Name( + 'seat_number', + Load(), + lineno=66, + col_offset=28, + end_lineno=66, + end_col_offset=39), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=39)], + [], + lineno=65, + col_offset=4, + end_lineno=66, + end_col_offset=39), + Return( + Name( + 'output', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=17), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=17)], + [], + lineno=53, + col_offset=0, + end_lineno=67, + end_col_offset=17), + FunctionDef( + 'generate_codes', + arguments( + [], + [ + arg( + 'seat_numbers', + lineno=69, + col_offset=19, + end_lineno=69, + end_col_offset=31), + arg( + 'flight_id', + lineno=69, + col_offset=33, + end_lineno=69, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Generate codes for a ticket.\n\n :param seat_numbers: list[str] - list of seat numbers.\n :param flight_id: str - string containing the flight identifier.\n :return: generator - generator that yields 12 character long ticket codes.\n\n ', + lineno=70, + col_offset=4, + end_lineno=76, + end_col_offset=7), + lineno=70, + col_offset=4, + end_lineno=76, + end_col_offset=7), + For( + Name( + 'seat', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=12), + Name( + 'seat_numbers', + Load(), + lineno=78, + col_offset=16, + end_lineno=78, + end_col_offset=28), + [ + Assign( + [ + Name( + 'base_string', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=19)], + JoinedStr( + [ + FormattedValue( + Name( + 'seat', + Load(), + lineno=79, + col_offset=25, + end_lineno=79, + end_col_offset=29), + -1, + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42), + FormattedValue( + Name( + 'flight_id', + Load(), + lineno=79, + col_offset=31, + end_lineno=79, + end_col_offset=40), + -1, + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42)], + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=42), + Expr( + Yield( + BinOp( + Name( + 'base_string', + Load(), + lineno=80, + col_offset=14, + end_lineno=80, + end_col_offset=25), + Add(), + BinOp( + Constant( + '0', + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=31), + Mult(), + BinOp( + Constant( + 12, + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=37), + Sub(), + Call( + Name( + 'len', + Load(), + lineno=80, + col_offset=40, + end_lineno=80, + end_col_offset=43), + [ + Name( + 'base_string', + Load(), + lineno=80, + col_offset=44, + end_lineno=80, + end_col_offset=55)], + [], + lineno=80, + col_offset=40, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=14, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=57)], + [], + lineno=78, + col_offset=4, + end_lineno=80, + end_col_offset=57)], + [], + lineno=69, + col_offset=0, + end_lineno=80, + end_col_offset=57)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'math', + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=11)], + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=11), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=12)], + List( + [ + Constant( + 'A', + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=19), + Constant( + 'B', + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + Constant( + 'C', + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=29), + Constant( + 'D', + lineno=5, + col_offset=31, + end_lineno=5, + end_col_offset=34)], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=35), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=8, + col_offset=26, + end_lineno=8, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_3', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=21), + [ + Name( + 'placeholder_2', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=28)], + [], + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=29), + [ + Expr( + Yield( + Subscript( + Name( + 'SEATS_IN_ROW', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=26), + BinOp( + Name( + 'seat', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=31), + Mod(), + Constant( + 4, + lineno=22, + col_offset=34, + end_lineno=22, + end_col_offset=35), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=35), + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=36), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=36), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=36)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=36)], + [], + lineno=8, + col_offset=0, + end_lineno=22, + end_col_offset=36), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=10)], + IfExp( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=33), + [ + GtE()], + [ + Constant( + 13, + lineno=42, + col_offset=37, + end_lineno=42, + end_col_offset=39)], + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=39), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=19), + Add(), + Constant( + 4, + lineno=42, + col_offset=22, + end_lineno=42, + end_col_offset=23), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=23), + Name( + 'placeholder_2', + Load(), + lineno=42, + col_offset=45, + end_lineno=42, + end_col_offset=51), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=51), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=51), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=11)], + Call( + Name( + 'placeholder_1', + Load(), + lineno=43, + col_offset=14, + end_lineno=43, + end_col_offset=35), + [ + Name( + 'placeholder_2', + Load(), + lineno=43, + col_offset=36, + end_lineno=43, + end_col_offset=42)], + [], + lineno=43, + col_offset=14, + end_lineno=43, + end_col_offset=43), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=43), + For( + Name( + 'placeholder_3', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=21), + [ + Name( + 'placeholder_2', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=28)], + [], + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=29), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=18)], + Call( + Attribute( + Name( + 'math', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=25), + 'ceil', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=30), + [ + BinOp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=36), + Add(), + Constant( + 1, + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=38), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=38), + Div(), + Constant( + 4, + lineno=45, + col_offset=42, + end_lineno=45, + end_col_offset=43), + lineno=45, + col_offset=31, + end_lineno=45, + end_col_offset=43)], + [], + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=44), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=44), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=21), + [ + NotEq()], + [ + Constant( + 13, + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=27)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=27), + [ + Expr( + Yield( + JoinedStr( + [ + FormattedValue( + Call( + Name( + 'str', + Load(), + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=24), + [ + Name( + 'row_number', + Load(), + lineno=47, + col_offset=25, + end_lineno=47, + end_col_offset=35)], + [], + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=36), + -1, + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53), + FormattedValue( + Call( + Name( + 'next', + Load(), + lineno=47, + col_offset=38, + end_lineno=47, + end_col_offset=42), + [ + Name( + 'letters', + Load(), + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=50)], + [], + lineno=47, + col_offset=38, + end_lineno=47, + end_col_offset=51), + -1, + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53)], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=53), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=53)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=53)], + [], + lineno=44, + col_offset=4, + end_lineno=47, + end_col_offset=53)], + [], + lineno=25, + col_offset=0, + end_lineno=47, + end_col_offset=53), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=10)], + Call( + Name( + 'len', + Load(), + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=16), + [ + Name( + 'placeholder_8', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=27)], + [], + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=28), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=10)], + Dict( + [], + [], + lineno=64, + col_offset=13, + end_lineno=64, + end_col_offset=15), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'placeholder_10', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=17), + Name( + 'placeholder_11', + Store(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=30)], + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=30), + Call( + Name( + 'zip', + Load(), + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=37), + [ + Name( + 'placeholder_8', + Load(), + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=48), + Call( + Name( + 'placeholder_4', + Load(), + lineno=65, + col_offset=50, + end_lineno=65, + end_col_offset=64), + [ + Name( + 'placeholder_2', + Load(), + lineno=65, + col_offset=65, + end_lineno=65, + end_col_offset=71)], + [], + lineno=65, + col_offset=50, + end_lineno=65, + end_col_offset=72)], + [], + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=73), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_9', + Load(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=14), + Name( + 'placeholder_10', + Load(), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=24), + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=25)], + Name( + 'placeholder_11', + Load(), + lineno=66, + col_offset=28, + end_lineno=66, + end_col_offset=39), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=39)], + [], + lineno=65, + col_offset=4, + end_lineno=66, + end_col_offset=39), + Return( + Name( + 'placeholder_9', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=17), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=17)], + [], + lineno=53, + col_offset=0, + end_lineno=67, + end_col_offset=17), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=69, + col_offset=19, + end_lineno=69, + end_col_offset=31), + arg( + 'placeholder_14', + lineno=69, + col_offset=33, + end_lineno=69, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_3', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=12), + Name( + 'placeholder_13', + Load(), + lineno=78, + col_offset=16, + end_lineno=78, + end_col_offset=28), + [ + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=19)], + JoinedStr( + [ + FormattedValue( + Name( + 'placeholder_3', + Load(), + lineno=79, + col_offset=25, + end_lineno=79, + end_col_offset=29), + -1, + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42), + FormattedValue( + Name( + 'placeholder_14', + Load(), + lineno=79, + col_offset=31, + end_lineno=79, + end_col_offset=40), + -1, + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42)], + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=42), + Expr( + Yield( + BinOp( + Name( + 'base_string', + Load(), + lineno=80, + col_offset=14, + end_lineno=80, + end_col_offset=25), + Add(), + BinOp( + Constant( + '0', + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=31), + Mult(), + BinOp( + Constant( + 12, + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=37), + Sub(), + Call( + Name( + 'len', + Load(), + lineno=80, + col_offset=40, + end_lineno=80, + end_col_offset=43), + [ + Name( + 'base_string', + Load(), + lineno=80, + col_offset=44, + end_lineno=80, + end_col_offset=55)], + [], + lineno=80, + col_offset=40, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=14, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=57)], + [], + lineno=78, + col_offset=4, + end_lineno=80, + end_col_offset=57)], + [], + lineno=69, + col_offset=0, + end_lineno=80, + end_col_offset=57)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-plane-tickets/representation.txt b/test/concept-plane-tickets/representation.txt new file mode 100644 index 0000000..7a2615a --- /dev/null +++ b/test/concept-plane-tickets/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('math', lineno=3, col_offset=7, end_lineno=3, end_col_offset=11)], lineno=3, col_offset=0, end_lineno=3, end_col_offset=11), Assign([Name('placeholder_0', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=12)], List([Constant('A', lineno=5, col_offset=16, end_lineno=5, end_col_offset=19), Constant('B', lineno=5, col_offset=21, end_lineno=5, end_col_offset=24), Constant('C', lineno=5, col_offset=26, end_lineno=5, end_col_offset=29), Constant('D', lineno=5, col_offset=31, end_lineno=5, end_col_offset=34)], Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=35), lineno=5, col_offset=0, end_lineno=5, end_col_offset=35), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=8, col_offset=26, end_lineno=8, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_3', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=12), Call(Name('range', Load(), lineno=21, col_offset=16, end_lineno=21, end_col_offset=21), [Name('placeholder_2', Load(), lineno=21, col_offset=22, end_lineno=21, end_col_offset=28)], [], lineno=21, col_offset=16, end_lineno=21, end_col_offset=29), [Expr(Yield(Subscript(Name('SEATS_IN_ROW', Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=26), BinOp(Name('seat', Load(), lineno=22, col_offset=27, end_lineno=22, end_col_offset=31), Mod(), Constant(4, lineno=22, col_offset=34, end_lineno=22, end_col_offset=35), lineno=22, col_offset=27, end_lineno=22, end_col_offset=35), Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=36), lineno=22, col_offset=8, end_lineno=22, end_col_offset=36), lineno=22, col_offset=8, end_lineno=22, end_col_offset=36)], [], lineno=21, col_offset=4, end_lineno=22, end_col_offset=36)], [], lineno=8, col_offset=0, end_lineno=22, end_col_offset=36), FunctionDef('placeholder_4', arguments([], [arg('placeholder_2', lineno=25, col_offset=19, end_lineno=25, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=42, col_offset=4, end_lineno=42, end_col_offset=10)], IfExp(Compare(Name('placeholder_2', Load(), lineno=42, col_offset=27, end_lineno=42, end_col_offset=33), [GtE()], [Constant(13, lineno=42, col_offset=37, end_lineno=42, end_col_offset=39)], lineno=42, col_offset=27, end_lineno=42, end_col_offset=39), BinOp(Name('placeholder_2', Load(), lineno=42, col_offset=13, end_lineno=42, end_col_offset=19), Add(), Constant(4, lineno=42, col_offset=22, end_lineno=42, end_col_offset=23), lineno=42, col_offset=13, end_lineno=42, end_col_offset=23), Name('placeholder_2', Load(), lineno=42, col_offset=45, end_lineno=42, end_col_offset=51), lineno=42, col_offset=13, end_lineno=42, end_col_offset=51), lineno=42, col_offset=4, end_lineno=42, end_col_offset=51), Assign([Name('placeholder_5', Store(), lineno=43, col_offset=4, end_lineno=43, end_col_offset=11)], Call(Name('placeholder_1', Load(), lineno=43, col_offset=14, end_lineno=43, end_col_offset=35), [Name('placeholder_2', Load(), lineno=43, col_offset=36, end_lineno=43, end_col_offset=42)], [], lineno=43, col_offset=14, end_lineno=43, end_col_offset=43), lineno=43, col_offset=4, end_lineno=43, end_col_offset=43), For(Name('placeholder_3', Store(), lineno=44, col_offset=8, end_lineno=44, end_col_offset=12), Call(Name('range', Load(), lineno=44, col_offset=16, end_lineno=44, end_col_offset=21), [Name('placeholder_2', Load(), lineno=44, col_offset=22, end_lineno=44, end_col_offset=28)], [], lineno=44, col_offset=16, end_lineno=44, end_col_offset=29), [Assign([Name('placeholder_6', Store(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=18)], Call(Attribute(Name('math', Load(), lineno=45, col_offset=21, end_lineno=45, end_col_offset=25), 'ceil', Load(), lineno=45, col_offset=21, end_lineno=45, end_col_offset=30), [BinOp(BinOp(Name('placeholder_3', Load(), lineno=45, col_offset=32, end_lineno=45, end_col_offset=36), Add(), Constant(1, lineno=45, col_offset=37, end_lineno=45, end_col_offset=38), lineno=45, col_offset=32, end_lineno=45, end_col_offset=38), Div(), Constant(4, lineno=45, col_offset=42, end_lineno=45, end_col_offset=43), lineno=45, col_offset=31, end_lineno=45, end_col_offset=43)], [], lineno=45, col_offset=21, end_lineno=45, end_col_offset=44), lineno=45, col_offset=8, end_lineno=45, end_col_offset=44), If(Compare(Name('placeholder_6', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=21), [NotEq()], [Constant(13, lineno=46, col_offset=25, end_lineno=46, end_col_offset=27)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=27), [Expr(Yield(JoinedStr([FormattedValue(Call(Name('str', Load(), lineno=47, col_offset=21, end_lineno=47, end_col_offset=24), [Name('row_number', Load(), lineno=47, col_offset=25, end_lineno=47, end_col_offset=35)], [], lineno=47, col_offset=21, end_lineno=47, end_col_offset=36), -1, lineno=47, col_offset=18, end_lineno=47, end_col_offset=53), FormattedValue(Call(Name('next', Load(), lineno=47, col_offset=38, end_lineno=47, end_col_offset=42), [Name('letters', Load(), lineno=47, col_offset=43, end_lineno=47, end_col_offset=50)], [], lineno=47, col_offset=38, end_lineno=47, end_col_offset=51), -1, lineno=47, col_offset=18, end_lineno=47, end_col_offset=53)], lineno=47, col_offset=18, end_lineno=47, end_col_offset=53), lineno=47, col_offset=12, end_lineno=47, end_col_offset=53), lineno=47, col_offset=12, end_lineno=47, end_col_offset=53)], [], lineno=46, col_offset=8, end_lineno=47, end_col_offset=53)], [], lineno=44, col_offset=4, end_lineno=47, end_col_offset=53)], [], lineno=25, col_offset=0, end_lineno=47, end_col_offset=53), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=53, col_offset=17, end_lineno=53, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=63, col_offset=4, end_lineno=63, end_col_offset=10)], Call(Name('len', Load(), lineno=63, col_offset=13, end_lineno=63, end_col_offset=16), [Name('placeholder_8', Load(), lineno=63, col_offset=17, end_lineno=63, end_col_offset=27)], [], lineno=63, col_offset=13, end_lineno=63, end_col_offset=28), lineno=63, col_offset=4, end_lineno=63, end_col_offset=28), Assign([Name('placeholder_9', Store(), lineno=64, col_offset=4, end_lineno=64, end_col_offset=10)], Dict([], [], lineno=64, col_offset=13, end_lineno=64, end_col_offset=15), lineno=64, col_offset=4, end_lineno=64, end_col_offset=15), For(Tuple([Name('placeholder_10', Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=17), Name('placeholder_11', Store(), lineno=65, col_offset=19, end_lineno=65, end_col_offset=30)], Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=30), Call(Name('zip', Load(), lineno=65, col_offset=34, end_lineno=65, end_col_offset=37), [Name('placeholder_8', Load(), lineno=65, col_offset=38, end_lineno=65, end_col_offset=48), Call(Name('placeholder_4', Load(), lineno=65, col_offset=50, end_lineno=65, end_col_offset=64), [Name('placeholder_2', Load(), lineno=65, col_offset=65, end_lineno=65, end_col_offset=71)], [], lineno=65, col_offset=50, end_lineno=65, end_col_offset=72)], [], lineno=65, col_offset=34, end_lineno=65, end_col_offset=73), [Assign([Subscript(Name('placeholder_9', Load(), lineno=66, col_offset=8, end_lineno=66, end_col_offset=14), Name('placeholder_10', Load(), lineno=66, col_offset=15, end_lineno=66, end_col_offset=24), Store(), lineno=66, col_offset=8, end_lineno=66, end_col_offset=25)], Name('placeholder_11', Load(), lineno=66, col_offset=28, end_lineno=66, end_col_offset=39), lineno=66, col_offset=8, end_lineno=66, end_col_offset=39)], [], lineno=65, col_offset=4, end_lineno=66, end_col_offset=39), Return(Name('placeholder_9', Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=17), lineno=67, col_offset=4, end_lineno=67, end_col_offset=17)], [], lineno=53, col_offset=0, end_lineno=67, end_col_offset=17), FunctionDef('placeholder_12', arguments([], [arg('placeholder_13', lineno=69, col_offset=19, end_lineno=69, end_col_offset=31), arg('placeholder_14', lineno=69, col_offset=33, end_lineno=69, end_col_offset=42)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_3', Store(), lineno=78, col_offset=8, end_lineno=78, end_col_offset=12), Name('placeholder_13', Load(), lineno=78, col_offset=16, end_lineno=78, end_col_offset=28), [Assign([Name('placeholder_15', Store(), lineno=79, col_offset=8, end_lineno=79, end_col_offset=19)], JoinedStr([FormattedValue(Name('placeholder_3', Load(), lineno=79, col_offset=25, end_lineno=79, end_col_offset=29), -1, lineno=79, col_offset=22, end_lineno=79, end_col_offset=42), FormattedValue(Name('placeholder_14', Load(), lineno=79, col_offset=31, end_lineno=79, end_col_offset=40), -1, lineno=79, col_offset=22, end_lineno=79, end_col_offset=42)], lineno=79, col_offset=22, end_lineno=79, end_col_offset=42), lineno=79, col_offset=8, end_lineno=79, end_col_offset=42), Expr(Yield(BinOp(Name('base_string', Load(), lineno=80, col_offset=14, end_lineno=80, end_col_offset=25), Add(), BinOp(Constant('0', lineno=80, col_offset=28, end_lineno=80, end_col_offset=31), Mult(), BinOp(Constant(12, lineno=80, col_offset=35, end_lineno=80, end_col_offset=37), Sub(), Call(Name('len', Load(), lineno=80, col_offset=40, end_lineno=80, end_col_offset=43), [Name('base_string', Load(), lineno=80, col_offset=44, end_lineno=80, end_col_offset=55)], [], lineno=80, col_offset=40, end_lineno=80, end_col_offset=56), lineno=80, col_offset=35, end_lineno=80, end_col_offset=56), lineno=80, col_offset=28, end_lineno=80, end_col_offset=57), lineno=80, col_offset=14, end_lineno=80, end_col_offset=57), lineno=80, col_offset=8, end_lineno=80, end_col_offset=57), lineno=80, col_offset=8, end_lineno=80, end_col_offset=57)], [], lineno=78, col_offset=4, end_lineno=80, end_col_offset=57)], [], lineno=69, col_offset=0, end_lineno=80, end_col_offset=57)], []) \ No newline at end of file diff --git a/test/concept-pretty-leaflet/.meta/config.json b/test/concept-pretty-leaflet/.meta/config.json new file mode 100644 index 0000000..8854609 --- /dev/null +++ b/test/concept-pretty-leaflet/.meta/config.json @@ -0,0 +1,12 @@ +{ + "authors": [ + "valentin-p" + ], + "files": { + "solution": [ + "string_formatting.py" + ] + }, + "icon": "scale-generator", + "blurb": "Learn about string formatting by \"prettifying\" promotional leaflets." +} diff --git a/test/concept-pretty-leaflet/mapping.json b/test/concept-pretty-leaflet/mapping.json new file mode 100644 index 0000000..01ea599 --- /dev/null +++ b/test/concept-pretty-leaflet/mapping.json @@ -0,0 +1,22 @@ +{ + "placeholder_0": "capitalize_header", + "placeholder_1": "event_name", + "placeholder_2": "format_date", + "placeholder_3": "event_date", + "placeholder_4": "date", + "placeholder_5": "month", + "placeholder_6": "year", + "placeholder_7": "month_name", + "placeholder_8": "display_icons", + "placeholder_9": "icons", + "placeholder_10": "displayed", + "placeholder_11": "icon", + "placeholder_12": "print_leaflet", + "placeholder_13": "authors", + "placeholder_14": "row_full", + "placeholder_15": "empty_row", + "placeholder_16": "date_string", + "placeholder_17": "poster", + "placeholder_18": "position", + "placeholder_19": "_" +} \ No newline at end of file diff --git a/test/concept-pretty-leaflet/representation.json b/test/concept-pretty-leaflet/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-pretty-leaflet/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-pretty-leaflet/representation.out b/test/concept-pretty-leaflet/representation.out new file mode 100644 index 0000000..360deca --- /dev/null +++ b/test/concept-pretty-leaflet/representation.out @@ -0,0 +1,2702 @@ +## BEGIN NORMALIZED CODE ## +import calendar +from typing import List, Optional + + +def placeholder_0(placeholder_1): + return placeholder_1.capitalize() + + +def placeholder_2(placeholder_3): + placeholder_4, placeholder_5, placeholder_6 = placeholder_3 + placeholder_7 = calendar.placeholder_7[placeholder_5] + return "{} {}, {}".format(placeholder_7, placeholder_4, placeholder_6) + + +def placeholder_8(placeholder_9): + placeholder_10 = [] + for placeholder_11 in placeholder_9: + placeholder_10.append("{}".format(placeholder_11)) + return placeholder_10 + + +def placeholder_12(placeholder_1, placeholder_9, placeholder_13, placeholder_3=None): + placeholder_14 = "".join(["*"] * 20) + placeholder_15 = f"*{'':^18}*" + placeholder_1 = placeholder_0(placeholder_1) + placeholder_9 = placeholder_8(placeholder_9) + placeholder_16 = placeholder_2(placeholder_3) if placeholder_3 is not None else "" + placeholder_17 = [] + placeholder_17.append(placeholder_14).append(placeholder_15).append( + f"*{placeholder_1!r:^18}*" + ).append(placeholder_15).append(f"*{placeholder_16!s:^18}*").append(placeholder_15) + for placeholder_18, placeholder_19 in enumerate(placeholder_13): + placeholder_11 = ( + placeholder_9[placeholder_18] + if placeholder_18 < len(placeholder_9) + else " " + ) + placeholder_17.append( + f"*{'':>1}{placeholder_13[placeholder_18]:<11}{placeholder_11:>3}{'':>2}*" + ) + placeholder_17.append(placeholder_15).append(placeholder_14) + return "\n".join(placeholder_17) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'calendar', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=15)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=15), + ImportFrom( + 'typing', + [ + alias( + 'List', + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=23), + alias( + 'Optional', + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=33)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=33), + FunctionDef( + 'capitalize_header', + arguments( + [], + [ + arg( + 'event_name', + Name( + 'str', + Load(), + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=37), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'event_name', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=21), + 'capitalize', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=32), + [], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=34), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=34)], + [], + Name( + 'str', + Load(), + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=45), + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=34), + FunctionDef( + 'format_date', + arguments( + [], + [ + arg( + 'event_date', + Subscript( + Name( + 'List', + Load(), + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=32), + Name( + 'int', + Load(), + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=36), + Load(), + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=37), + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'date', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=8), + Name( + 'month', + Store(), + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=15), + Name( + 'year', + Store(), + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=21)], + Name( + 'event_date', + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=34), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=34), + Assign( + [ + Name( + 'month_name', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14)], + Subscript( + Attribute( + Name( + 'calendar', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=25), + 'month_name', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=36), + Name( + 'month', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=42), + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=43), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=43), + Return( + Call( + Attribute( + Constant( + '{} {}, {}', + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=22), + 'format', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=29), + [ + Name( + 'month_name', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=40), + Name( + 'date', + Load(), + lineno=13, + col_offset=42, + end_lineno=13, + end_col_offset=46), + Name( + 'year', + Load(), + lineno=13, + col_offset=48, + end_lineno=13, + end_col_offset=52)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=53), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=53)], + [], + Name( + 'str', + Load(), + lineno=8, + col_offset=42, + end_lineno=8, + end_col_offset=45), + lineno=8, + col_offset=0, + end_lineno=13, + end_col_offset=53), + FunctionDef( + 'display_icons', + arguments( + [], + [ + arg( + 'icons', + Subscript( + Name( + 'List', + Load(), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=29), + Name( + 'str', + Load(), + lineno=15, + col_offset=30, + end_lineno=15, + end_col_offset=33), + Load(), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=34), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'displayed', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=13)], + List( + [], + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=18), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=18), + For( + Name( + 'icon', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=12), + Name( + 'icons', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=21), + [ + Expr( + Call( + Attribute( + Name( + 'displayed', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=17), + 'append', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=24), + [ + Call( + Attribute( + Constant( + '{}', + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=29), + 'format', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=36), + [ + Name( + 'icon', + Load(), + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=41)], + [], + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=42)], + [], + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=43), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=43)], + [], + lineno=17, + col_offset=4, + end_lineno=19, + end_col_offset=43), + Return( + Name( + 'displayed', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=20), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=20)], + [], + Subscript( + Name( + 'List', + Load(), + lineno=15, + col_offset=39, + end_lineno=15, + end_col_offset=43), + Name( + 'str', + Load(), + lineno=15, + col_offset=44, + end_lineno=15, + end_col_offset=47), + Load(), + lineno=15, + col_offset=39, + end_lineno=15, + end_col_offset=48), + lineno=15, + col_offset=0, + end_lineno=20, + end_col_offset=20), + FunctionDef( + 'print_leaflet', + arguments( + [], + [ + arg( + 'event_name', + Name( + 'str', + Load(), + lineno=22, + col_offset=30, + end_lineno=22, + end_col_offset=33), + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=33), + arg( + 'icons', + Subscript( + Name( + 'List', + Load(), + lineno=22, + col_offset=42, + end_lineno=22, + end_col_offset=46), + Name( + 'str', + Load(), + lineno=22, + col_offset=47, + end_lineno=22, + end_col_offset=50), + Load(), + lineno=22, + col_offset=42, + end_lineno=22, + end_col_offset=51), + lineno=22, + col_offset=35, + end_lineno=22, + end_col_offset=51), + arg( + 'authors', + Subscript( + Name( + 'List', + Load(), + lineno=22, + col_offset=62, + end_lineno=22, + end_col_offset=66), + Name( + 'str', + Load(), + lineno=22, + col_offset=67, + end_lineno=22, + end_col_offset=70), + Load(), + lineno=22, + col_offset=62, + end_lineno=22, + end_col_offset=71), + lineno=22, + col_offset=53, + end_lineno=22, + end_col_offset=71), + arg( + 'event_date', + Subscript( + Name( + 'Optional', + Load(), + lineno=22, + col_offset=85, + end_lineno=22, + end_col_offset=93), + Subscript( + Name( + 'List', + Load(), + lineno=22, + col_offset=94, + end_lineno=22, + end_col_offset=98), + Name( + 'int', + Load(), + lineno=22, + col_offset=99, + end_lineno=22, + end_col_offset=102), + Load(), + lineno=22, + col_offset=94, + end_lineno=22, + end_col_offset=103), + Load(), + lineno=22, + col_offset=85, + end_lineno=22, + end_col_offset=104), + lineno=22, + col_offset=73, + end_lineno=22, + end_col_offset=104)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=22, + col_offset=105, + end_lineno=22, + end_col_offset=109)]), + [ + Assign( + [ + Name( + 'row_full', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=12)], + Call( + Attribute( + Constant( + '', + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=17), + 'join', + Load(), + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=22), + [ + BinOp( + List( + [ + Constant( + '*', + lineno=23, + col_offset=24, + end_lineno=23, + end_col_offset=27)], + Load(), + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=28), + Mult(), + Constant( + 20, + lineno=23, + col_offset=31, + end_lineno=23, + end_col_offset=33), + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=33)], + [], + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=34), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=34), + Assign( + [ + Name( + 'empty_row', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=13)], + JoinedStr( + [ + Constant( + '*', + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29), + FormattedValue( + Constant( + '', + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=22), + -1, + JoinedStr( + [ + Constant( + '^18', + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29)], + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29), + Constant( + '*', + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29)], + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=29), + Assign( + [ + Name( + 'event_name', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=14)], + Call( + Name( + 'capitalize_header', + Load(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=34), + [ + Name( + 'event_name', + Load(), + lineno=25, + col_offset=35, + end_lineno=25, + end_col_offset=45)], + [], + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=46), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=46), + Assign( + [ + Name( + 'icons', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=9)], + Call( + Name( + 'display_icons', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=25), + [ + Name( + 'icons', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=31)], + [], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=32), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=32), + Assign( + [ + Name( + 'date_string', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=15)], + IfExp( + Compare( + Name( + 'event_date', + Load(), + lineno=27, + col_offset=45, + end_lineno=27, + end_col_offset=55), + [ + IsNot()], + [ + Constant( + None, + lineno=27, + col_offset=63, + end_lineno=27, + end_col_offset=67)], + lineno=27, + col_offset=45, + end_lineno=27, + end_col_offset=67), + Call( + Name( + 'format_date', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=29), + [ + Name( + 'event_date', + Load(), + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=40)], + [], + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=41), + Constant( + '', + lineno=27, + col_offset=73, + end_lineno=27, + end_col_offset=75), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=75), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=75), + Assign( + [ + Name( + 'poster', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=10)], + List( + [], + Load(), + lineno=29, + col_offset=13, + end_lineno=29, + end_col_offset=15), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=15), + Expr( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Name( + 'poster', + Load(), + lineno=31, + col_offset=5, + end_lineno=31, + end_col_offset=11), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=31, + end_col_offset=18), + [ + Name( + 'row_full', + Load(), + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=27)], + [], + lineno=31, + col_offset=5, + end_lineno=31, + end_col_offset=28), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=32, + end_col_offset=18), + [ + Name( + 'empty_row', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=28)], + [], + lineno=31, + col_offset=5, + end_lineno=32, + end_col_offset=29), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=33, + end_col_offset=18), + [ + JoinedStr( + [ + Constant( + '*', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42), + FormattedValue( + Name( + 'event_name', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=33), + 114, + JoinedStr( + [ + Constant( + '^18', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42)], + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42), + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42), + Constant( + '*', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42)], + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42)], + [], + lineno=31, + col_offset=5, + end_lineno=33, + end_col_offset=43), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=34, + end_col_offset=18), + [ + Name( + 'empty_row', + Load(), + lineno=34, + col_offset=19, + end_lineno=34, + end_col_offset=28)], + [], + lineno=31, + col_offset=5, + end_lineno=34, + end_col_offset=29), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=35, + end_col_offset=18), + [ + JoinedStr( + [ + Constant( + '*', + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43), + FormattedValue( + Name( + 'date_string', + Load(), + lineno=35, + col_offset=23, + end_lineno=35, + end_col_offset=34), + 115, + JoinedStr( + [ + Constant( + '^18', + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43)], + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43), + Constant( + '*', + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43)], + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43)], + [], + lineno=31, + col_offset=5, + end_lineno=35, + end_col_offset=44), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=36, + end_col_offset=18), + [ + Name( + 'empty_row', + Load(), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=28)], + [], + lineno=31, + col_offset=5, + end_lineno=36, + end_col_offset=29), + lineno=31, + col_offset=4, + end_lineno=36, + end_col_offset=30), + For( + Tuple( + [ + Name( + 'position', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=16), + Name( + '_', + Store(), + lineno=38, + col_offset=18, + end_lineno=38, + end_col_offset=19)], + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=19), + Call( + Name( + 'enumerate', + Load(), + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=32), + [ + Name( + 'authors', + Load(), + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=40)], + [], + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=41), + [ + Assign( + [ + Name( + 'icon', + Store(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=12)], + IfExp( + Compare( + Name( + 'position', + Load(), + lineno=39, + col_offset=34, + end_lineno=39, + end_col_offset=42), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=39, + col_offset=45, + end_lineno=39, + end_col_offset=48), + [ + Name( + 'icons', + Load(), + lineno=39, + col_offset=49, + end_lineno=39, + end_col_offset=54)], + [], + lineno=39, + col_offset=45, + end_lineno=39, + end_col_offset=55)], + lineno=39, + col_offset=34, + end_lineno=39, + end_col_offset=55), + Subscript( + Name( + 'icons', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=20), + Name( + 'position', + Load(), + lineno=39, + col_offset=21, + end_lineno=39, + end_col_offset=29), + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=30), + Constant( + ' ', + lineno=39, + col_offset=61, + end_lineno=39, + end_col_offset=67), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=67), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=67), + Expr( + Call( + Attribute( + Name( + 'poster', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=14), + 'append', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=21), + [ + JoinedStr( + [ + Constant( + '*', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + FormattedValue( + Constant( + '', + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=28), + -1, + JoinedStr( + [ + Constant( + '>1', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + FormattedValue( + Subscript( + Name( + 'authors', + Load(), + lineno=40, + col_offset=33, + end_lineno=40, + end_col_offset=40), + Name( + 'position', + Load(), + lineno=40, + col_offset=41, + end_lineno=40, + end_col_offset=49), + Load(), + lineno=40, + col_offset=33, + end_lineno=40, + end_col_offset=50), + -1, + JoinedStr( + [ + Constant( + '<11', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + FormattedValue( + Name( + 'icon', + Load(), + lineno=40, + col_offset=56, + end_lineno=40, + end_col_offset=60), + -1, + JoinedStr( + [ + Constant( + '>3', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + FormattedValue( + Constant( + '', + lineno=40, + col_offset=65, + end_lineno=40, + end_col_offset=67), + -1, + JoinedStr( + [ + Constant( + '>2', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + Constant( + '*', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + [], + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=74), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=74)], + [], + lineno=38, + col_offset=4, + end_lineno=40, + end_col_offset=74), + Expr( + Call( + Attribute( + Call( + Attribute( + Name( + 'poster', + Load(), + lineno=42, + col_offset=5, + end_lineno=42, + end_col_offset=11), + 'append', + Load(), + lineno=42, + col_offset=5, + end_lineno=42, + end_col_offset=18), + [ + Name( + 'empty_row', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=28)], + [], + lineno=42, + col_offset=5, + end_lineno=42, + end_col_offset=29), + 'append', + Load(), + lineno=42, + col_offset=5, + end_lineno=43, + end_col_offset=18), + [ + Name( + 'row_full', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=27)], + [], + lineno=42, + col_offset=5, + end_lineno=43, + end_col_offset=28), + lineno=42, + col_offset=4, + end_lineno=43, + end_col_offset=29), + Return( + Call( + Attribute( + Constant( + '\n', + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=15), + 'join', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=20), + [ + Name( + 'poster', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=27)], + [], + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=28), + lineno=45, + col_offset=4, + end_lineno=45, + end_col_offset=28)], + [], + lineno=22, + col_offset=0, + end_lineno=45, + end_col_offset=28)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'calendar', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=15)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=15), + ImportFrom( + 'typing', + [ + alias( + 'List', + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=23), + alias( + 'Optional', + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=33)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=33), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=21), + 'capitalize', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=32), + [], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=34), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=34)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=34), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_4', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=8), + Name( + 'placeholder_5', + Store(), + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=15), + Name( + 'placeholder_6', + Store(), + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=21)], + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=34), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=34), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14)], + Subscript( + Attribute( + Name( + 'calendar', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=25), + 'placeholder_7', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=36), + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=42), + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=43), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=43), + Return( + Call( + Attribute( + Constant( + '{} {}, {}', + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=22), + 'format', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=29), + [ + Name( + 'placeholder_7', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=40), + Name( + 'placeholder_4', + Load(), + lineno=13, + col_offset=42, + end_lineno=13, + end_col_offset=46), + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=48, + end_lineno=13, + end_col_offset=52)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=53), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=53)], + [], + lineno=8, + col_offset=0, + end_lineno=13, + end_col_offset=53), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'placeholder_9', + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=13)], + List( + [], + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=18), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=18), + For( + Name( + 'placeholder_11', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=12), + Name( + 'placeholder_9', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=21), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_10', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=17), + 'append', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=24), + [ + Call( + Attribute( + Constant( + '{}', + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=29), + 'format', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=36), + [ + Name( + 'placeholder_11', + Load(), + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=41)], + [], + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=42)], + [], + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=43), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=43)], + [], + lineno=17, + col_offset=4, + end_lineno=19, + end_col_offset=43), + Return( + Name( + 'placeholder_10', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=20), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=20)], + [], + lineno=15, + col_offset=0, + end_lineno=20, + end_col_offset=20), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=33), + arg( + 'placeholder_9', + lineno=22, + col_offset=35, + end_lineno=22, + end_col_offset=51), + arg( + 'placeholder_13', + lineno=22, + col_offset=53, + end_lineno=22, + end_col_offset=71), + arg( + 'placeholder_3', + lineno=22, + col_offset=73, + end_lineno=22, + end_col_offset=104)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=22, + col_offset=105, + end_lineno=22, + end_col_offset=109)]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=12)], + Call( + Attribute( + Constant( + '', + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=17), + 'join', + Load(), + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=22), + [ + BinOp( + List( + [ + Constant( + '*', + lineno=23, + col_offset=24, + end_lineno=23, + end_col_offset=27)], + Load(), + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=28), + Mult(), + Constant( + 20, + lineno=23, + col_offset=31, + end_lineno=23, + end_col_offset=33), + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=33)], + [], + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=34), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=34), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=13)], + JoinedStr( + [ + Constant( + '*', + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29), + FormattedValue( + Constant( + '', + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=22), + -1, + JoinedStr( + [ + Constant( + '^18', + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29)], + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29), + Constant( + '*', + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29)], + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=29), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=29), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=14)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=34), + [ + Name( + 'placeholder_1', + Load(), + lineno=25, + col_offset=35, + end_lineno=25, + end_col_offset=45)], + [], + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=46), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=9)], + Call( + Name( + 'placeholder_8', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=25), + [ + Name( + 'placeholder_9', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=31)], + [], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=32), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=15)], + IfExp( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=27, + col_offset=45, + end_lineno=27, + end_col_offset=55), + [ + IsNot()], + [ + Constant( + None, + lineno=27, + col_offset=63, + end_lineno=27, + end_col_offset=67)], + lineno=27, + col_offset=45, + end_lineno=27, + end_col_offset=67), + Call( + Name( + 'placeholder_2', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=29), + [ + Name( + 'placeholder_3', + Load(), + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=40)], + [], + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=41), + Constant( + '', + lineno=27, + col_offset=73, + end_lineno=27, + end_col_offset=75), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=75), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=75), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=10)], + List( + [], + Load(), + lineno=29, + col_offset=13, + end_lineno=29, + end_col_offset=15), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=15), + Expr( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=31, + col_offset=5, + end_lineno=31, + end_col_offset=11), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=31, + end_col_offset=18), + [ + Name( + 'placeholder_14', + Load(), + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=27)], + [], + lineno=31, + col_offset=5, + end_lineno=31, + end_col_offset=28), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=32, + end_col_offset=18), + [ + Name( + 'placeholder_15', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=28)], + [], + lineno=31, + col_offset=5, + end_lineno=32, + end_col_offset=29), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=33, + end_col_offset=18), + [ + JoinedStr( + [ + Constant( + '*', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42), + FormattedValue( + Name( + 'placeholder_1', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=33), + 114, + JoinedStr( + [ + Constant( + '^18', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42)], + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42), + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42), + Constant( + '*', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42)], + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=42)], + [], + lineno=31, + col_offset=5, + end_lineno=33, + end_col_offset=43), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=34, + end_col_offset=18), + [ + Name( + 'placeholder_15', + Load(), + lineno=34, + col_offset=19, + end_lineno=34, + end_col_offset=28)], + [], + lineno=31, + col_offset=5, + end_lineno=34, + end_col_offset=29), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=35, + end_col_offset=18), + [ + JoinedStr( + [ + Constant( + '*', + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43), + FormattedValue( + Name( + 'placeholder_16', + Load(), + lineno=35, + col_offset=23, + end_lineno=35, + end_col_offset=34), + 115, + JoinedStr( + [ + Constant( + '^18', + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43)], + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43), + Constant( + '*', + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43)], + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=43)], + [], + lineno=31, + col_offset=5, + end_lineno=35, + end_col_offset=44), + 'append', + Load(), + lineno=31, + col_offset=5, + end_lineno=36, + end_col_offset=18), + [ + Name( + 'placeholder_15', + Load(), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=28)], + [], + lineno=31, + col_offset=5, + end_lineno=36, + end_col_offset=29), + lineno=31, + col_offset=4, + end_lineno=36, + end_col_offset=30), + For( + Tuple( + [ + Name( + 'placeholder_18', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=16), + Name( + 'placeholder_19', + Store(), + lineno=38, + col_offset=18, + end_lineno=38, + end_col_offset=19)], + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=19), + Call( + Name( + 'enumerate', + Load(), + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=32), + [ + Name( + 'placeholder_13', + Load(), + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=40)], + [], + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=41), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=12)], + IfExp( + Compare( + Name( + 'placeholder_18', + Load(), + lineno=39, + col_offset=34, + end_lineno=39, + end_col_offset=42), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=39, + col_offset=45, + end_lineno=39, + end_col_offset=48), + [ + Name( + 'placeholder_9', + Load(), + lineno=39, + col_offset=49, + end_lineno=39, + end_col_offset=54)], + [], + lineno=39, + col_offset=45, + end_lineno=39, + end_col_offset=55)], + lineno=39, + col_offset=34, + end_lineno=39, + end_col_offset=55), + Subscript( + Name( + 'placeholder_9', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=20), + Name( + 'placeholder_18', + Load(), + lineno=39, + col_offset=21, + end_lineno=39, + end_col_offset=29), + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=30), + Constant( + ' ', + lineno=39, + col_offset=61, + end_lineno=39, + end_col_offset=67), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=67), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=67), + Expr( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=14), + 'append', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=21), + [ + JoinedStr( + [ + Constant( + '*', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + FormattedValue( + Constant( + '', + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=28), + -1, + JoinedStr( + [ + Constant( + '>1', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + FormattedValue( + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=40, + col_offset=33, + end_lineno=40, + end_col_offset=40), + Name( + 'placeholder_18', + Load(), + lineno=40, + col_offset=41, + end_lineno=40, + end_col_offset=49), + Load(), + lineno=40, + col_offset=33, + end_lineno=40, + end_col_offset=50), + -1, + JoinedStr( + [ + Constant( + '<11', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + FormattedValue( + Name( + 'placeholder_11', + Load(), + lineno=40, + col_offset=56, + end_lineno=40, + end_col_offset=60), + -1, + JoinedStr( + [ + Constant( + '>3', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + FormattedValue( + Constant( + '', + lineno=40, + col_offset=65, + end_lineno=40, + end_col_offset=67), + -1, + JoinedStr( + [ + Constant( + '>2', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73), + Constant( + '*', + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=73)], + [], + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=74), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=74)], + [], + lineno=38, + col_offset=4, + end_lineno=40, + end_col_offset=74), + Expr( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=42, + col_offset=5, + end_lineno=42, + end_col_offset=11), + 'append', + Load(), + lineno=42, + col_offset=5, + end_lineno=42, + end_col_offset=18), + [ + Name( + 'placeholder_15', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=28)], + [], + lineno=42, + col_offset=5, + end_lineno=42, + end_col_offset=29), + 'append', + Load(), + lineno=42, + col_offset=5, + end_lineno=43, + end_col_offset=18), + [ + Name( + 'placeholder_14', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=27)], + [], + lineno=42, + col_offset=5, + end_lineno=43, + end_col_offset=28), + lineno=42, + col_offset=4, + end_lineno=43, + end_col_offset=29), + Return( + Call( + Attribute( + Constant( + '\n', + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=15), + 'join', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=20), + [ + Name( + 'placeholder_17', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=27)], + [], + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=28), + lineno=45, + col_offset=4, + end_lineno=45, + end_col_offset=28)], + [], + lineno=22, + col_offset=0, + end_lineno=45, + end_col_offset=28)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-pretty-leaflet/representation.txt b/test/concept-pretty-leaflet/representation.txt new file mode 100644 index 0000000..fbb6612 --- /dev/null +++ b/test/concept-pretty-leaflet/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('calendar', lineno=1, col_offset=7, end_lineno=1, end_col_offset=15)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=15), ImportFrom('typing', [alias('List', lineno=2, col_offset=19, end_lineno=2, end_col_offset=23), alias('Optional', lineno=2, col_offset=25, end_lineno=2, end_col_offset=33)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=33), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=22, end_lineno=5, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_1', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=21), 'capitalize', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=32), [], [], lineno=6, col_offset=11, end_lineno=6, end_col_offset=34), lineno=6, col_offset=4, end_lineno=6, end_col_offset=34)], [], lineno=5, col_offset=0, end_lineno=6, end_col_offset=34), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=8, col_offset=16, end_lineno=8, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Tuple([Name('placeholder_4', Store(), lineno=9, col_offset=4, end_lineno=9, end_col_offset=8), Name('placeholder_5', Store(), lineno=9, col_offset=10, end_lineno=9, end_col_offset=15), Name('placeholder_6', Store(), lineno=9, col_offset=17, end_lineno=9, end_col_offset=21)], Store(), lineno=9, col_offset=4, end_lineno=9, end_col_offset=21)], Name('placeholder_3', Load(), lineno=9, col_offset=24, end_lineno=9, end_col_offset=34), lineno=9, col_offset=4, end_lineno=9, end_col_offset=34), Assign([Name('placeholder_7', Store(), lineno=10, col_offset=4, end_lineno=10, end_col_offset=14)], Subscript(Attribute(Name('calendar', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=25), 'placeholder_7', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=36), Name('placeholder_5', Load(), lineno=10, col_offset=37, end_lineno=10, end_col_offset=42), Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=43), lineno=10, col_offset=4, end_lineno=10, end_col_offset=43), Return(Call(Attribute(Constant('{} {}, {}', lineno=13, col_offset=11, end_lineno=13, end_col_offset=22), 'format', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=29), [Name('placeholder_7', Load(), lineno=13, col_offset=30, end_lineno=13, end_col_offset=40), Name('placeholder_4', Load(), lineno=13, col_offset=42, end_lineno=13, end_col_offset=46), Name('placeholder_6', Load(), lineno=13, col_offset=48, end_lineno=13, end_col_offset=52)], [], lineno=13, col_offset=11, end_lineno=13, end_col_offset=53), lineno=13, col_offset=4, end_lineno=13, end_col_offset=53)], [], lineno=8, col_offset=0, end_lineno=13, end_col_offset=53), FunctionDef('placeholder_8', arguments([], [arg('placeholder_9', lineno=15, col_offset=18, end_lineno=15, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_10', Store(), lineno=16, col_offset=4, end_lineno=16, end_col_offset=13)], List([], Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=18), lineno=16, col_offset=4, end_lineno=16, end_col_offset=18), For(Name('placeholder_11', Store(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=12), Name('placeholder_9', Load(), lineno=17, col_offset=16, end_lineno=17, end_col_offset=21), [Expr(Call(Attribute(Name('placeholder_10', Load(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=17), 'append', Load(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=24), [Call(Attribute(Constant('{}', lineno=19, col_offset=25, end_lineno=19, end_col_offset=29), 'format', Load(), lineno=19, col_offset=25, end_lineno=19, end_col_offset=36), [Name('placeholder_11', Load(), lineno=19, col_offset=37, end_lineno=19, end_col_offset=41)], [], lineno=19, col_offset=25, end_lineno=19, end_col_offset=42)], [], lineno=19, col_offset=8, end_lineno=19, end_col_offset=43), lineno=19, col_offset=8, end_lineno=19, end_col_offset=43)], [], lineno=17, col_offset=4, end_lineno=19, end_col_offset=43), Return(Name('placeholder_10', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=20), lineno=20, col_offset=4, end_lineno=20, end_col_offset=20)], [], lineno=15, col_offset=0, end_lineno=20, end_col_offset=20), FunctionDef('placeholder_12', arguments([], [arg('placeholder_1', lineno=22, col_offset=18, end_lineno=22, end_col_offset=33), arg('placeholder_9', lineno=22, col_offset=35, end_lineno=22, end_col_offset=51), arg('placeholder_13', lineno=22, col_offset=53, end_lineno=22, end_col_offset=71), arg('placeholder_3', lineno=22, col_offset=73, end_lineno=22, end_col_offset=104)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=22, col_offset=105, end_lineno=22, end_col_offset=109)]), [Assign([Name('placeholder_14', Store(), lineno=23, col_offset=4, end_lineno=23, end_col_offset=12)], Call(Attribute(Constant('', lineno=23, col_offset=15, end_lineno=23, end_col_offset=17), 'join', Load(), lineno=23, col_offset=15, end_lineno=23, end_col_offset=22), [BinOp(List([Constant('*', lineno=23, col_offset=24, end_lineno=23, end_col_offset=27)], Load(), lineno=23, col_offset=23, end_lineno=23, end_col_offset=28), Mult(), Constant(20, lineno=23, col_offset=31, end_lineno=23, end_col_offset=33), lineno=23, col_offset=23, end_lineno=23, end_col_offset=33)], [], lineno=23, col_offset=15, end_lineno=23, end_col_offset=34), lineno=23, col_offset=4, end_lineno=23, end_col_offset=34), Assign([Name('placeholder_15', Store(), lineno=24, col_offset=4, end_lineno=24, end_col_offset=13)], JoinedStr([Constant('*', lineno=24, col_offset=16, end_lineno=24, end_col_offset=29), FormattedValue(Constant('', lineno=24, col_offset=20, end_lineno=24, end_col_offset=22), -1, JoinedStr([Constant('^18', lineno=24, col_offset=16, end_lineno=24, end_col_offset=29)], lineno=24, col_offset=16, end_lineno=24, end_col_offset=29), lineno=24, col_offset=16, end_lineno=24, end_col_offset=29), Constant('*', lineno=24, col_offset=16, end_lineno=24, end_col_offset=29)], lineno=24, col_offset=16, end_lineno=24, end_col_offset=29), lineno=24, col_offset=4, end_lineno=24, end_col_offset=29), Assign([Name('placeholder_1', Store(), lineno=25, col_offset=4, end_lineno=25, end_col_offset=14)], Call(Name('placeholder_0', Load(), lineno=25, col_offset=17, end_lineno=25, end_col_offset=34), [Name('placeholder_1', Load(), lineno=25, col_offset=35, end_lineno=25, end_col_offset=45)], [], lineno=25, col_offset=17, end_lineno=25, end_col_offset=46), lineno=25, col_offset=4, end_lineno=25, end_col_offset=46), Assign([Name('placeholder_9', Store(), lineno=26, col_offset=4, end_lineno=26, end_col_offset=9)], Call(Name('placeholder_8', Load(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=25), [Name('placeholder_9', Load(), lineno=26, col_offset=26, end_lineno=26, end_col_offset=31)], [], lineno=26, col_offset=12, end_lineno=26, end_col_offset=32), lineno=26, col_offset=4, end_lineno=26, end_col_offset=32), Assign([Name('placeholder_16', Store(), lineno=27, col_offset=4, end_lineno=27, end_col_offset=15)], IfExp(Compare(Name('placeholder_3', Load(), lineno=27, col_offset=45, end_lineno=27, end_col_offset=55), [IsNot()], [Constant(None, lineno=27, col_offset=63, end_lineno=27, end_col_offset=67)], lineno=27, col_offset=45, end_lineno=27, end_col_offset=67), Call(Name('placeholder_2', Load(), lineno=27, col_offset=18, end_lineno=27, end_col_offset=29), [Name('placeholder_3', Load(), lineno=27, col_offset=30, end_lineno=27, end_col_offset=40)], [], lineno=27, col_offset=18, end_lineno=27, end_col_offset=41), Constant('', lineno=27, col_offset=73, end_lineno=27, end_col_offset=75), lineno=27, col_offset=18, end_lineno=27, end_col_offset=75), lineno=27, col_offset=4, end_lineno=27, end_col_offset=75), Assign([Name('placeholder_17', Store(), lineno=29, col_offset=4, end_lineno=29, end_col_offset=10)], List([], Load(), lineno=29, col_offset=13, end_lineno=29, end_col_offset=15), lineno=29, col_offset=4, end_lineno=29, end_col_offset=15), Expr(Call(Attribute(Call(Attribute(Call(Attribute(Call(Attribute(Call(Attribute(Call(Attribute(Name('placeholder_17', Load(), lineno=31, col_offset=5, end_lineno=31, end_col_offset=11), 'append', Load(), lineno=31, col_offset=5, end_lineno=31, end_col_offset=18), [Name('placeholder_14', Load(), lineno=31, col_offset=19, end_lineno=31, end_col_offset=27)], [], lineno=31, col_offset=5, end_lineno=31, end_col_offset=28), 'append', Load(), lineno=31, col_offset=5, end_lineno=32, end_col_offset=18), [Name('placeholder_15', Load(), lineno=32, col_offset=19, end_lineno=32, end_col_offset=28)], [], lineno=31, col_offset=5, end_lineno=32, end_col_offset=29), 'append', Load(), lineno=31, col_offset=5, end_lineno=33, end_col_offset=18), [JoinedStr([Constant('*', lineno=33, col_offset=19, end_lineno=33, end_col_offset=42), FormattedValue(Name('placeholder_1', Load(), lineno=33, col_offset=23, end_lineno=33, end_col_offset=33), 114, JoinedStr([Constant('^18', lineno=33, col_offset=19, end_lineno=33, end_col_offset=42)], lineno=33, col_offset=19, end_lineno=33, end_col_offset=42), lineno=33, col_offset=19, end_lineno=33, end_col_offset=42), Constant('*', lineno=33, col_offset=19, end_lineno=33, end_col_offset=42)], lineno=33, col_offset=19, end_lineno=33, end_col_offset=42)], [], lineno=31, col_offset=5, end_lineno=33, end_col_offset=43), 'append', Load(), lineno=31, col_offset=5, end_lineno=34, end_col_offset=18), [Name('placeholder_15', Load(), lineno=34, col_offset=19, end_lineno=34, end_col_offset=28)], [], lineno=31, col_offset=5, end_lineno=34, end_col_offset=29), 'append', Load(), lineno=31, col_offset=5, end_lineno=35, end_col_offset=18), [JoinedStr([Constant('*', lineno=35, col_offset=19, end_lineno=35, end_col_offset=43), FormattedValue(Name('placeholder_16', Load(), lineno=35, col_offset=23, end_lineno=35, end_col_offset=34), 115, JoinedStr([Constant('^18', lineno=35, col_offset=19, end_lineno=35, end_col_offset=43)], lineno=35, col_offset=19, end_lineno=35, end_col_offset=43), lineno=35, col_offset=19, end_lineno=35, end_col_offset=43), Constant('*', lineno=35, col_offset=19, end_lineno=35, end_col_offset=43)], lineno=35, col_offset=19, end_lineno=35, end_col_offset=43)], [], lineno=31, col_offset=5, end_lineno=35, end_col_offset=44), 'append', Load(), lineno=31, col_offset=5, end_lineno=36, end_col_offset=18), [Name('placeholder_15', Load(), lineno=36, col_offset=19, end_lineno=36, end_col_offset=28)], [], lineno=31, col_offset=5, end_lineno=36, end_col_offset=29), lineno=31, col_offset=4, end_lineno=36, end_col_offset=30), For(Tuple([Name('placeholder_18', Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=16), Name('placeholder_19', Store(), lineno=38, col_offset=18, end_lineno=38, end_col_offset=19)], Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=19), Call(Name('enumerate', Load(), lineno=38, col_offset=23, end_lineno=38, end_col_offset=32), [Name('placeholder_13', Load(), lineno=38, col_offset=33, end_lineno=38, end_col_offset=40)], [], lineno=38, col_offset=23, end_lineno=38, end_col_offset=41), [Assign([Name('placeholder_11', Store(), lineno=39, col_offset=8, end_lineno=39, end_col_offset=12)], IfExp(Compare(Name('placeholder_18', Load(), lineno=39, col_offset=34, end_lineno=39, end_col_offset=42), [Lt()], [Call(Name('len', Load(), lineno=39, col_offset=45, end_lineno=39, end_col_offset=48), [Name('placeholder_9', Load(), lineno=39, col_offset=49, end_lineno=39, end_col_offset=54)], [], lineno=39, col_offset=45, end_lineno=39, end_col_offset=55)], lineno=39, col_offset=34, end_lineno=39, end_col_offset=55), Subscript(Name('placeholder_9', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=20), Name('placeholder_18', Load(), lineno=39, col_offset=21, end_lineno=39, end_col_offset=29), Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=30), Constant(' ', lineno=39, col_offset=61, end_lineno=39, end_col_offset=67), lineno=39, col_offset=15, end_lineno=39, end_col_offset=67), lineno=39, col_offset=8, end_lineno=39, end_col_offset=67), Expr(Call(Attribute(Name('placeholder_17', Load(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=14), 'append', Load(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=21), [JoinedStr([Constant('*', lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), FormattedValue(Constant('', lineno=40, col_offset=26, end_lineno=40, end_col_offset=28), -1, JoinedStr([Constant('>1', lineno=40, col_offset=22, end_lineno=40, end_col_offset=73)], lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), FormattedValue(Subscript(Name('placeholder_13', Load(), lineno=40, col_offset=33, end_lineno=40, end_col_offset=40), Name('placeholder_18', Load(), lineno=40, col_offset=41, end_lineno=40, end_col_offset=49), Load(), lineno=40, col_offset=33, end_lineno=40, end_col_offset=50), -1, JoinedStr([Constant('<11', lineno=40, col_offset=22, end_lineno=40, end_col_offset=73)], lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), FormattedValue(Name('placeholder_11', Load(), lineno=40, col_offset=56, end_lineno=40, end_col_offset=60), -1, JoinedStr([Constant('>3', lineno=40, col_offset=22, end_lineno=40, end_col_offset=73)], lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), FormattedValue(Constant('', lineno=40, col_offset=65, end_lineno=40, end_col_offset=67), -1, JoinedStr([Constant('>2', lineno=40, col_offset=22, end_lineno=40, end_col_offset=73)], lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), lineno=40, col_offset=22, end_lineno=40, end_col_offset=73), Constant('*', lineno=40, col_offset=22, end_lineno=40, end_col_offset=73)], lineno=40, col_offset=22, end_lineno=40, end_col_offset=73)], [], lineno=40, col_offset=8, end_lineno=40, end_col_offset=74), lineno=40, col_offset=8, end_lineno=40, end_col_offset=74)], [], lineno=38, col_offset=4, end_lineno=40, end_col_offset=74), Expr(Call(Attribute(Call(Attribute(Name('placeholder_17', Load(), lineno=42, col_offset=5, end_lineno=42, end_col_offset=11), 'append', Load(), lineno=42, col_offset=5, end_lineno=42, end_col_offset=18), [Name('placeholder_15', Load(), lineno=42, col_offset=19, end_lineno=42, end_col_offset=28)], [], lineno=42, col_offset=5, end_lineno=42, end_col_offset=29), 'append', Load(), lineno=42, col_offset=5, end_lineno=43, end_col_offset=18), [Name('placeholder_14', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=27)], [], lineno=42, col_offset=5, end_lineno=43, end_col_offset=28), lineno=42, col_offset=4, end_lineno=43, end_col_offset=29), Return(Call(Attribute(Constant('\n', lineno=45, col_offset=11, end_lineno=45, end_col_offset=15), 'join', Load(), lineno=45, col_offset=11, end_lineno=45, end_col_offset=20), [Name('placeholder_17', Load(), lineno=45, col_offset=21, end_lineno=45, end_col_offset=27)], [], lineno=45, col_offset=11, end_lineno=45, end_col_offset=28), lineno=45, col_offset=4, end_lineno=45, end_col_offset=28)], [], lineno=22, col_offset=0, end_lineno=45, end_col_offset=28)], []) \ No newline at end of file diff --git a/test/concept-pretty-leaflet/string_formatting.py b/test/concept-pretty-leaflet/string_formatting.py new file mode 100644 index 0000000..436f90f --- /dev/null +++ b/test/concept-pretty-leaflet/string_formatting.py @@ -0,0 +1,45 @@ +import calendar +from typing import List, Optional + + +def capitalize_header(event_name: str) -> str: + return event_name.capitalize() + +def format_date(event_date: List[int]) -> str: + date, month, year = event_date + month_name = calendar.month_name[month] + + # pylint: disable=consider-using-f-string + return '{} {}, {}'.format(month_name, date, year) + +def display_icons(icons: List[str]) -> List[str]: + displayed = [] + for icon in icons: + # pylint: disable=consider-using-f-string + displayed.append('{}'.format(icon)) + return displayed + +def print_leaflet(event_name: str, icons: List[str], authors: List[str], event_date: Optional[List[int]]=None): + row_full = ''.join(['*'] * 20) + empty_row = f'*{"":^18}*' + event_name = capitalize_header(event_name) + icons = display_icons(icons) + date_string = format_date(event_date) if event_date is not None else '' + + poster = [] + + (poster.append(row_full) + .append(empty_row) + .append(f'*{event_name!r:^18}*') + .append(empty_row) + .append(f'*{date_string!s:^18}*') + .append(empty_row)) + + for position, _ in enumerate(authors): + icon = icons[position] if position < len(icons) else ' ' + poster.append(f'*{"":>1}{authors[position]:<11}{icon:>3}{"":>2}*') + + (poster.append(empty_row) + .append(row_full)) + + return '\n'.join(poster) diff --git a/test/concept-restaurant-rozalynn/.meta/config.json b/test/concept-restaurant-rozalynn/.meta/config.json new file mode 100644 index 0000000..5b18149 --- /dev/null +++ b/test/concept-restaurant-rozalynn/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "mohanrajanr", + "BethanyG" + ], + "files": { + "solution": [ + "none.py" + ], + "test": [ + "none_test.py" + ], + "exemplar": [ + ".meta/exemplar.py" + ] + }, + "icon": "kindergarten-garden", + "blurb": "Learn about None by managing the reservations at Restaurant Rozalynn." +} diff --git a/test/concept-restaurant-rozalynn/mapping.json b/test/concept-restaurant-rozalynn/mapping.json new file mode 100644 index 0000000..02b2bee --- /dev/null +++ b/test/concept-restaurant-rozalynn/mapping.json @@ -0,0 +1,23 @@ +{ + "placeholder_0": "new_seating_chart", + "placeholder_1": "size", + "placeholder_2": "number", + "placeholder_3": "arrange_reservations", + "placeholder_4": "guests", + "placeholder_5": "seats", + "placeholder_6": "seat_number", + "placeholder_7": "find_all_available_seats", + "placeholder_8": "available", + "placeholder_9": "seat_num", + "placeholder_10": "value", + "placeholder_11": "current_empty_seat_capacity", + "placeholder_12": "count", + "placeholder_13": "accommodate_waiting_guests", + "placeholder_14": "curr_empty_seats", + "placeholder_15": "empty_seat_list", + "placeholder_16": "index", + "placeholder_17": "_", + "placeholder_18": "empty_seats", + "placeholder_19": "seat_numbers", + "placeholder_20": "seat" +} \ No newline at end of file diff --git a/test/concept-restaurant-rozalynn/none.py b/test/concept-restaurant-rozalynn/none.py new file mode 100644 index 0000000..5bd13e3 --- /dev/null +++ b/test/concept-restaurant-rozalynn/none.py @@ -0,0 +1,84 @@ +def new_seating_chart(size=22): + """Create a new seating chart. + + :param size: int - number if seats in the seating chart. + :return: dict - with number of seats specified, and placeholder values. + """ + + return {number: None for number in range(1, size + 1)} + + +def arrange_reservations(guests=None): + """Assign guests to seats. + + :param guest_list: list - list of guest names for reservations. + :return: dict - Default sized dictionary with guests assigned seats, + and placeholders for empty seats. + """ + + seats = new_seating_chart() + + if guests: + for seat_number in range(1, len(guests)): + seats[seat_number] = guests[seat_number] + return seats + + +def find_all_available_seats(seats): + """Find and return seat numbers that are unassigned. + + :param seats: dict - seating chart. + :return: list - list of seat numbers available for reserving.. + """ + + available = [] + for seat_num, value in seats.items(): + if value is None: + available.append(seat_num) + return available + + +def current_empty_seat_capacity(seats): + """Find the number of seats that are currently empty. + + :param seats: dict - dictionary of reserved seats. + :return: int - number of seats empty. + """ + + count = 0 + for value in seats.values(): + if value is None: + count += 1 + return count + + +def accommodate_waiting_guests(seats, guests): + """Asses if guest can be accommodated. Update seating if they can be. + + :param seats: dict - seating chart dictionary. + :param guests: list - walk-in guests + :return: dict - updated seating chart with available spaces filled. + """ + + curr_empty_seats = current_empty_seat_capacity(seats) + empty_seat_list = find_all_available_seats(seats) + + if len(guests) <= curr_empty_seats: + for index, _ in enumerate(guests): + seats[empty_seat_list[index]] = guests[index] + + return seats + + +def empty_seats(seats, seat_numbers): + """Empty listed seats of their previous reservations. + + :param seats: dict - seating chart dictionary. + :param seat_numbers: list - list of seat numbers to free up or empty. + :return: updated seating chart dictionary. + """ + + for seat in seat_numbers: + seats[seat] = None + + return seats diff --git a/test/concept-restaurant-rozalynn/representation.json b/test/concept-restaurant-rozalynn/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-restaurant-rozalynn/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-restaurant-rozalynn/representation.out b/test/concept-restaurant-rozalynn/representation.out new file mode 100644 index 0000000..4c3155b --- /dev/null +++ b/test/concept-restaurant-rozalynn/representation.out @@ -0,0 +1,1968 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1=22): + return {placeholder_2: None for placeholder_2 in range(1, placeholder_1 + 1)} + + +def placeholder_3(placeholder_4=None): + placeholder_5 = placeholder_0() + if placeholder_4: + for placeholder_6 in range(1, len(placeholder_4)): + placeholder_5[placeholder_6] = placeholder_4[placeholder_6] + return placeholder_5 + + +def placeholder_7(placeholder_5): + placeholder_8 = [] + for placeholder_9, placeholder_10 in placeholder_5.items(): + if placeholder_10 is None: + placeholder_8.append(placeholder_9) + return placeholder_8 + + +def placeholder_11(placeholder_5): + placeholder_12 = 0 + for placeholder_10 in placeholder_5.values(): + if placeholder_10 is None: + placeholder_12 += 1 + return placeholder_12 + + +def placeholder_13(placeholder_5, placeholder_4): + placeholder_14 = placeholder_11(placeholder_5) + placeholder_15 = placeholder_7(placeholder_5) + if len(placeholder_4) <= placeholder_14: + for placeholder_16, placeholder_17 in enumerate(placeholder_4): + placeholder_5[placeholder_15[placeholder_16]] = placeholder_4[ + placeholder_16 + ] + return placeholder_5 + + +def placeholder_18(placeholder_5, placeholder_19): + for placeholder_20 in placeholder_19: + placeholder_5[placeholder_20] = None + return placeholder_5 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'new_seating_chart', + arguments( + [], + [ + arg( + 'size', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 22, + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=29)]), + [ + Expr( + Constant( + 'Create a new seating chart.\n\n :param size: int - number if seats in the seating chart.\n :return: dict - with number of seats specified, and placeholder values.\n ', + lineno=2, + col_offset=4, + end_lineno=6, + end_col_offset=7), + lineno=2, + col_offset=4, + end_lineno=6, + end_col_offset=7), + Return( + DictComp( + Name( + 'number', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=18), + Constant( + None, + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=24), + [ + comprehension( + Name( + 'number', + Store(), + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=35), + Call( + Name( + 'range', + Load(), + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=44), + [ + Constant( + 1, + lineno=8, + col_offset=45, + end_lineno=8, + end_col_offset=46), + BinOp( + Name( + 'size', + Load(), + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=52), + Add(), + Constant( + 1, + lineno=8, + col_offset=55, + end_lineno=8, + end_col_offset=56), + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=56)], + [], + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=57), + [], + 0)], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=58), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=58)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=58), + FunctionDef( + 'arrange_reservations', + arguments( + [], + [ + arg( + 'guests', + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=11, + col_offset=32, + end_lineno=11, + end_col_offset=36)]), + [ + Expr( + Constant( + 'Assign guests to seats.\n\n :param guest_list: list - list of guest names for reservations.\n :return: dict - Default sized dictionary with guests assigned seats,\n and placeholders for empty seats.\n ', + lineno=12, + col_offset=4, + end_lineno=17, + end_col_offset=7), + lineno=12, + col_offset=4, + end_lineno=17, + end_col_offset=7), + Assign( + [ + Name( + 'seats', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=9)], + Call( + Name( + 'new_seating_chart', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=29), + [], + [], + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=31), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=31), + If( + Name( + 'guests', + Load(), + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=13), + [ + For( + Name( + 'seat_number', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=23), + Call( + Name( + 'range', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=32), + [ + Constant( + 1, + lineno=22, + col_offset=33, + end_lineno=22, + end_col_offset=34), + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=36, + end_lineno=22, + end_col_offset=39), + [ + Name( + 'guests', + Load(), + lineno=22, + col_offset=40, + end_lineno=22, + end_col_offset=46)], + [], + lineno=22, + col_offset=36, + end_lineno=22, + end_col_offset=47)], + [], + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=48), + [ + Assign( + [ + Subscript( + Name( + 'seats', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + Name( + 'seat_number', + Load(), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=29), + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=30)], + Subscript( + Name( + 'guests', + Load(), + lineno=23, + col_offset=33, + end_lineno=23, + end_col_offset=39), + Name( + 'seat_number', + Load(), + lineno=23, + col_offset=40, + end_lineno=23, + end_col_offset=51), + Load(), + lineno=23, + col_offset=33, + end_lineno=23, + end_col_offset=52), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=52)], + [], + lineno=22, + col_offset=8, + end_lineno=23, + end_col_offset=52)], + [], + lineno=21, + col_offset=4, + end_lineno=23, + end_col_offset=52), + Return( + Name( + 'seats', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=16), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=16)], + [], + lineno=11, + col_offset=0, + end_lineno=24, + end_col_offset=16), + FunctionDef( + 'find_all_available_seats', + arguments( + [], + [ + arg( + 'seats', + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Find and return seat numbers that are unassigned.\n\n :param seats: dict - seating chart.\n :return: list - list of seat numbers available for reserving..\n ', + lineno=28, + col_offset=4, + end_lineno=32, + end_col_offset=7), + lineno=28, + col_offset=4, + end_lineno=32, + end_col_offset=7), + Assign( + [ + Name( + 'available', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=13)], + List( + [], + Load(), + lineno=34, + col_offset=16, + end_lineno=34, + end_col_offset=18), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=18), + For( + Tuple( + [ + Name( + 'seat_num', + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=16), + Name( + 'value', + Store(), + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=23)], + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=23), + Call( + Attribute( + Name( + 'seats', + Load(), + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=32), + 'items', + Load(), + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=38), + [], + [], + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=40), + [ + If( + Compare( + Name( + 'value', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=16), + [ + Is()], + [ + Constant( + None, + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=24)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'available', + Load(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=21), + 'append', + Load(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=28), + [ + Name( + 'seat_num', + Load(), + lineno=37, + col_offset=29, + end_lineno=37, + end_col_offset=37)], + [], + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=38), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=38)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=38)], + [], + lineno=35, + col_offset=4, + end_lineno=37, + end_col_offset=38), + Return( + Name( + 'available', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=20), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=20)], + [], + lineno=27, + col_offset=0, + end_lineno=38, + end_col_offset=20), + FunctionDef( + 'current_empty_seat_capacity', + arguments( + [], + [ + arg( + 'seats', + lineno=41, + col_offset=32, + end_lineno=41, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Find the number of seats that are currently empty.\n\n :param seats: dict - dictionary of reserved seats.\n :return: int - number of seats empty.\n ', + lineno=42, + col_offset=4, + end_lineno=46, + end_col_offset=7), + lineno=42, + col_offset=4, + end_lineno=46, + end_col_offset=7), + Assign( + [ + Name( + 'count', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=9)], + Constant( + 0, + lineno=48, + col_offset=12, + end_lineno=48, + end_col_offset=13), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=13), + For( + Name( + 'value', + Store(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=13), + Call( + Attribute( + Name( + 'seats', + Load(), + lineno=49, + col_offset=17, + end_lineno=49, + end_col_offset=22), + 'values', + Load(), + lineno=49, + col_offset=17, + end_lineno=49, + end_col_offset=29), + [], + [], + lineno=49, + col_offset=17, + end_lineno=49, + end_col_offset=31), + [ + If( + Compare( + Name( + 'value', + Load(), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=16), + [ + Is()], + [ + Constant( + None, + lineno=50, + col_offset=20, + end_lineno=50, + end_col_offset=24)], + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=24), + [ + AugAssign( + Name( + 'count', + Store(), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=17), + Add(), + Constant( + 1, + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=22), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=22)], + [], + lineno=50, + col_offset=8, + end_lineno=51, + end_col_offset=22)], + [], + lineno=49, + col_offset=4, + end_lineno=51, + end_col_offset=22), + Return( + Name( + 'count', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=16), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=16)], + [], + lineno=41, + col_offset=0, + end_lineno=52, + end_col_offset=16), + FunctionDef( + 'accommodate_waiting_guests', + arguments( + [], + [ + arg( + 'seats', + lineno=55, + col_offset=31, + end_lineno=55, + end_col_offset=36), + arg( + 'guests', + lineno=55, + col_offset=38, + end_lineno=55, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Asses if guest can be accommodated. Update seating if they can be.\n\n :param seats: dict - seating chart dictionary.\n :param guests: list - walk-in guests\n :return: dict - updated seating chart with available spaces filled.\n ', + lineno=56, + col_offset=4, + end_lineno=61, + end_col_offset=7), + lineno=56, + col_offset=4, + end_lineno=61, + end_col_offset=7), + Assign( + [ + Name( + 'curr_empty_seats', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=20)], + Call( + Name( + 'current_empty_seat_capacity', + Load(), + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=50), + [ + Name( + 'seats', + Load(), + lineno=63, + col_offset=51, + end_lineno=63, + end_col_offset=56)], + [], + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=57), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=57), + Assign( + [ + Name( + 'empty_seat_list', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=19)], + Call( + Name( + 'find_all_available_seats', + Load(), + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=46), + [ + Name( + 'seats', + Load(), + lineno=64, + col_offset=47, + end_lineno=64, + end_col_offset=52)], + [], + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=53), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=53), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=66, + col_offset=7, + end_lineno=66, + end_col_offset=10), + [ + Name( + 'guests', + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=17)], + [], + lineno=66, + col_offset=7, + end_lineno=66, + end_col_offset=18), + [ + LtE()], + [ + Name( + 'curr_empty_seats', + Load(), + lineno=66, + col_offset=22, + end_lineno=66, + end_col_offset=38)], + lineno=66, + col_offset=7, + end_lineno=66, + end_col_offset=38), + [ + For( + Tuple( + [ + Name( + 'index', + Store(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=17), + Name( + '_', + Store(), + lineno=67, + col_offset=19, + end_lineno=67, + end_col_offset=20)], + Store(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=20), + Call( + Name( + 'enumerate', + Load(), + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=33), + [ + Name( + 'guests', + Load(), + lineno=67, + col_offset=34, + end_lineno=67, + end_col_offset=40)], + [], + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=41), + [ + Assign( + [ + Subscript( + Name( + 'seats', + Load(), + lineno=68, + col_offset=12, + end_lineno=68, + end_col_offset=17), + Subscript( + Name( + 'empty_seat_list', + Load(), + lineno=68, + col_offset=18, + end_lineno=68, + end_col_offset=33), + Name( + 'index', + Load(), + lineno=68, + col_offset=34, + end_lineno=68, + end_col_offset=39), + Load(), + lineno=68, + col_offset=18, + end_lineno=68, + end_col_offset=40), + Store(), + lineno=68, + col_offset=12, + end_lineno=68, + end_col_offset=41)], + Subscript( + Name( + 'guests', + Load(), + lineno=68, + col_offset=44, + end_lineno=68, + end_col_offset=50), + Name( + 'index', + Load(), + lineno=68, + col_offset=51, + end_lineno=68, + end_col_offset=56), + Load(), + lineno=68, + col_offset=44, + end_lineno=68, + end_col_offset=57), + lineno=68, + col_offset=12, + end_lineno=68, + end_col_offset=57)], + [], + lineno=67, + col_offset=8, + end_lineno=68, + end_col_offset=57)], + [], + lineno=66, + col_offset=4, + end_lineno=68, + end_col_offset=57), + Return( + Name( + 'seats', + Load(), + lineno=70, + col_offset=11, + end_lineno=70, + end_col_offset=16), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=16)], + [], + lineno=55, + col_offset=0, + end_lineno=70, + end_col_offset=16), + FunctionDef( + 'empty_seats', + arguments( + [], + [ + arg( + 'seats', + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=21), + arg( + 'seat_numbers', + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Empty listed seats of their previous reservations.\n\n :param seats: dict - seating chart dictionary.\n :param seat_numbers: list - list of seat numbers to free up or empty.\n :return: updated seating chart dictionary.\n ', + lineno=74, + col_offset=4, + end_lineno=79, + end_col_offset=7), + lineno=74, + col_offset=4, + end_lineno=79, + end_col_offset=7), + For( + Name( + 'seat', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=12), + Name( + 'seat_numbers', + Load(), + lineno=81, + col_offset=16, + end_lineno=81, + end_col_offset=28), + [ + Assign( + [ + Subscript( + Name( + 'seats', + Load(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=13), + Name( + 'seat', + Load(), + lineno=82, + col_offset=14, + end_lineno=82, + end_col_offset=18), + Store(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=19)], + Constant( + None, + lineno=82, + col_offset=22, + end_lineno=82, + end_col_offset=26), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=26)], + [], + lineno=81, + col_offset=4, + end_lineno=82, + end_col_offset=26), + Return( + Name( + 'seats', + Load(), + lineno=84, + col_offset=11, + end_lineno=84, + end_col_offset=16), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=16)], + [], + lineno=73, + col_offset=0, + end_lineno=84, + end_col_offset=16)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 22, + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=29)]), + [ + Return( + DictComp( + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=18), + Constant( + None, + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=24), + [ + comprehension( + Name( + 'placeholder_2', + Store(), + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=35), + Call( + Name( + 'range', + Load(), + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=44), + [ + Constant( + 1, + lineno=8, + col_offset=45, + end_lineno=8, + end_col_offset=46), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=52), + Add(), + Constant( + 1, + lineno=8, + col_offset=55, + end_lineno=8, + end_col_offset=56), + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=56)], + [], + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=57), + [], + 0)], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=58), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=58)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=58), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=11, + col_offset=32, + end_lineno=11, + end_col_offset=36)]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=9)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=29), + [], + [], + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=31), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=31), + If( + Name( + 'placeholder_4', + Load(), + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=13), + [ + For( + Name( + 'placeholder_6', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=23), + Call( + Name( + 'range', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=32), + [ + Constant( + 1, + lineno=22, + col_offset=33, + end_lineno=22, + end_col_offset=34), + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=36, + end_lineno=22, + end_col_offset=39), + [ + Name( + 'placeholder_4', + Load(), + lineno=22, + col_offset=40, + end_lineno=22, + end_col_offset=46)], + [], + lineno=22, + col_offset=36, + end_lineno=22, + end_col_offset=47)], + [], + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=48), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=29), + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=30)], + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=23, + col_offset=33, + end_lineno=23, + end_col_offset=39), + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=40, + end_lineno=23, + end_col_offset=51), + Load(), + lineno=23, + col_offset=33, + end_lineno=23, + end_col_offset=52), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=52)], + [], + lineno=22, + col_offset=8, + end_lineno=23, + end_col_offset=52)], + [], + lineno=21, + col_offset=4, + end_lineno=23, + end_col_offset=52), + Return( + Name( + 'placeholder_5', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=16), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=16)], + [], + lineno=11, + col_offset=0, + end_lineno=24, + end_col_offset=16), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=13)], + List( + [], + Load(), + lineno=34, + col_offset=16, + end_lineno=34, + end_col_offset=18), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=18), + For( + Tuple( + [ + Name( + 'placeholder_9', + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=16), + Name( + 'placeholder_10', + Store(), + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=23)], + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=23), + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=32), + 'items', + Load(), + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=38), + [], + [], + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=40), + [ + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=16), + [ + Is()], + [ + Constant( + None, + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=24)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=21), + 'append', + Load(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=28), + [ + Name( + 'placeholder_9', + Load(), + lineno=37, + col_offset=29, + end_lineno=37, + end_col_offset=37)], + [], + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=38), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=38)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=38)], + [], + lineno=35, + col_offset=4, + end_lineno=37, + end_col_offset=38), + Return( + Name( + 'placeholder_8', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=20), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=20)], + [], + lineno=27, + col_offset=0, + end_lineno=38, + end_col_offset=20), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=41, + col_offset=32, + end_lineno=41, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=9)], + Constant( + 0, + lineno=48, + col_offset=12, + end_lineno=48, + end_col_offset=13), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=13), + For( + Name( + 'placeholder_10', + Store(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=13), + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=49, + col_offset=17, + end_lineno=49, + end_col_offset=22), + 'values', + Load(), + lineno=49, + col_offset=17, + end_lineno=49, + end_col_offset=29), + [], + [], + lineno=49, + col_offset=17, + end_lineno=49, + end_col_offset=31), + [ + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=16), + [ + Is()], + [ + Constant( + None, + lineno=50, + col_offset=20, + end_lineno=50, + end_col_offset=24)], + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=24), + [ + AugAssign( + Name( + 'placeholder_12', + Store(), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=17), + Add(), + Constant( + 1, + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=22), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=22)], + [], + lineno=50, + col_offset=8, + end_lineno=51, + end_col_offset=22)], + [], + lineno=49, + col_offset=4, + end_lineno=51, + end_col_offset=22), + Return( + Name( + 'placeholder_12', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=16), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=16)], + [], + lineno=41, + col_offset=0, + end_lineno=52, + end_col_offset=16), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=55, + col_offset=31, + end_lineno=55, + end_col_offset=36), + arg( + 'placeholder_4', + lineno=55, + col_offset=38, + end_lineno=55, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=20)], + Call( + Name( + 'placeholder_11', + Load(), + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=50), + [ + Name( + 'placeholder_5', + Load(), + lineno=63, + col_offset=51, + end_lineno=63, + end_col_offset=56)], + [], + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=57), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=57), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=19)], + Call( + Name( + 'placeholder_7', + Load(), + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=46), + [ + Name( + 'placeholder_5', + Load(), + lineno=64, + col_offset=47, + end_lineno=64, + end_col_offset=52)], + [], + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=53), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=53), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=66, + col_offset=7, + end_lineno=66, + end_col_offset=10), + [ + Name( + 'placeholder_4', + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=17)], + [], + lineno=66, + col_offset=7, + end_lineno=66, + end_col_offset=18), + [ + LtE()], + [ + Name( + 'placeholder_14', + Load(), + lineno=66, + col_offset=22, + end_lineno=66, + end_col_offset=38)], + lineno=66, + col_offset=7, + end_lineno=66, + end_col_offset=38), + [ + For( + Tuple( + [ + Name( + 'placeholder_16', + Store(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=17), + Name( + 'placeholder_17', + Store(), + lineno=67, + col_offset=19, + end_lineno=67, + end_col_offset=20)], + Store(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=20), + Call( + Name( + 'enumerate', + Load(), + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=33), + [ + Name( + 'placeholder_4', + Load(), + lineno=67, + col_offset=34, + end_lineno=67, + end_col_offset=40)], + [], + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=41), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=68, + col_offset=12, + end_lineno=68, + end_col_offset=17), + Subscript( + Name( + 'placeholder_15', + Load(), + lineno=68, + col_offset=18, + end_lineno=68, + end_col_offset=33), + Name( + 'placeholder_16', + Load(), + lineno=68, + col_offset=34, + end_lineno=68, + end_col_offset=39), + Load(), + lineno=68, + col_offset=18, + end_lineno=68, + end_col_offset=40), + Store(), + lineno=68, + col_offset=12, + end_lineno=68, + end_col_offset=41)], + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=68, + col_offset=44, + end_lineno=68, + end_col_offset=50), + Name( + 'placeholder_16', + Load(), + lineno=68, + col_offset=51, + end_lineno=68, + end_col_offset=56), + Load(), + lineno=68, + col_offset=44, + end_lineno=68, + end_col_offset=57), + lineno=68, + col_offset=12, + end_lineno=68, + end_col_offset=57)], + [], + lineno=67, + col_offset=8, + end_lineno=68, + end_col_offset=57)], + [], + lineno=66, + col_offset=4, + end_lineno=68, + end_col_offset=57), + Return( + Name( + 'placeholder_5', + Load(), + lineno=70, + col_offset=11, + end_lineno=70, + end_col_offset=16), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=16)], + [], + lineno=55, + col_offset=0, + end_lineno=70, + end_col_offset=16), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=21), + arg( + 'placeholder_19', + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_20', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=12), + Name( + 'placeholder_19', + Load(), + lineno=81, + col_offset=16, + end_lineno=81, + end_col_offset=28), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=13), + Name( + 'placeholder_20', + Load(), + lineno=82, + col_offset=14, + end_lineno=82, + end_col_offset=18), + Store(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=19)], + Constant( + None, + lineno=82, + col_offset=22, + end_lineno=82, + end_col_offset=26), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=26)], + [], + lineno=81, + col_offset=4, + end_lineno=82, + end_col_offset=26), + Return( + Name( + 'placeholder_5', + Load(), + lineno=84, + col_offset=11, + end_lineno=84, + end_col_offset=16), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=16)], + [], + lineno=73, + col_offset=0, + end_lineno=84, + end_col_offset=16)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-restaurant-rozalynn/representation.txt b/test/concept-restaurant-rozalynn/representation.txt new file mode 100644 index 0000000..c82cf86 --- /dev/null +++ b/test/concept-restaurant-rozalynn/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=22, end_lineno=1, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(22, lineno=1, col_offset=27, end_lineno=1, end_col_offset=29)]), [Return(DictComp(Name('placeholder_2', Load(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=18), Constant(None, lineno=8, col_offset=20, end_lineno=8, end_col_offset=24), [comprehension(Name('placeholder_2', Store(), lineno=8, col_offset=29, end_lineno=8, end_col_offset=35), Call(Name('range', Load(), lineno=8, col_offset=39, end_lineno=8, end_col_offset=44), [Constant(1, lineno=8, col_offset=45, end_lineno=8, end_col_offset=46), BinOp(Name('placeholder_1', Load(), lineno=8, col_offset=48, end_lineno=8, end_col_offset=52), Add(), Constant(1, lineno=8, col_offset=55, end_lineno=8, end_col_offset=56), lineno=8, col_offset=48, end_lineno=8, end_col_offset=56)], [], lineno=8, col_offset=39, end_lineno=8, end_col_offset=57), [], 0)], lineno=8, col_offset=11, end_lineno=8, end_col_offset=58), lineno=8, col_offset=4, end_lineno=8, end_col_offset=58)], [], lineno=1, col_offset=0, end_lineno=8, end_col_offset=58), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=11, col_offset=25, end_lineno=11, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=11, col_offset=32, end_lineno=11, end_col_offset=36)]), [Assign([Name('placeholder_5', Store(), lineno=19, col_offset=4, end_lineno=19, end_col_offset=9)], Call(Name('placeholder_0', Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=29), [], [], lineno=19, col_offset=12, end_lineno=19, end_col_offset=31), lineno=19, col_offset=4, end_lineno=19, end_col_offset=31), If(Name('placeholder_4', Load(), lineno=21, col_offset=7, end_lineno=21, end_col_offset=13), [For(Name('placeholder_6', Store(), lineno=22, col_offset=12, end_lineno=22, end_col_offset=23), Call(Name('range', Load(), lineno=22, col_offset=27, end_lineno=22, end_col_offset=32), [Constant(1, lineno=22, col_offset=33, end_lineno=22, end_col_offset=34), Call(Name('len', Load(), lineno=22, col_offset=36, end_lineno=22, end_col_offset=39), [Name('placeholder_4', Load(), lineno=22, col_offset=40, end_lineno=22, end_col_offset=46)], [], lineno=22, col_offset=36, end_lineno=22, end_col_offset=47)], [], lineno=22, col_offset=27, end_lineno=22, end_col_offset=48), [Assign([Subscript(Name('placeholder_5', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=17), Name('placeholder_6', Load(), lineno=23, col_offset=18, end_lineno=23, end_col_offset=29), Store(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=30)], Subscript(Name('placeholder_4', Load(), lineno=23, col_offset=33, end_lineno=23, end_col_offset=39), Name('placeholder_6', Load(), lineno=23, col_offset=40, end_lineno=23, end_col_offset=51), Load(), lineno=23, col_offset=33, end_lineno=23, end_col_offset=52), lineno=23, col_offset=12, end_lineno=23, end_col_offset=52)], [], lineno=22, col_offset=8, end_lineno=23, end_col_offset=52)], [], lineno=21, col_offset=4, end_lineno=23, end_col_offset=52), Return(Name('placeholder_5', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=16), lineno=24, col_offset=4, end_lineno=24, end_col_offset=16)], [], lineno=11, col_offset=0, end_lineno=24, end_col_offset=16), FunctionDef('placeholder_7', arguments([], [arg('placeholder_5', lineno=27, col_offset=29, end_lineno=27, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=34, col_offset=4, end_lineno=34, end_col_offset=13)], List([], Load(), lineno=34, col_offset=16, end_lineno=34, end_col_offset=18), lineno=34, col_offset=4, end_lineno=34, end_col_offset=18), For(Tuple([Name('placeholder_9', Store(), lineno=35, col_offset=8, end_lineno=35, end_col_offset=16), Name('placeholder_10', Store(), lineno=35, col_offset=18, end_lineno=35, end_col_offset=23)], Store(), lineno=35, col_offset=8, end_lineno=35, end_col_offset=23), Call(Attribute(Name('placeholder_5', Load(), lineno=35, col_offset=27, end_lineno=35, end_col_offset=32), 'items', Load(), lineno=35, col_offset=27, end_lineno=35, end_col_offset=38), [], [], lineno=35, col_offset=27, end_lineno=35, end_col_offset=40), [If(Compare(Name('placeholder_10', Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=16), [Is()], [Constant(None, lineno=36, col_offset=20, end_lineno=36, end_col_offset=24)], lineno=36, col_offset=11, end_lineno=36, end_col_offset=24), [Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=37, col_offset=12, end_lineno=37, end_col_offset=21), 'append', Load(), lineno=37, col_offset=12, end_lineno=37, end_col_offset=28), [Name('placeholder_9', Load(), lineno=37, col_offset=29, end_lineno=37, end_col_offset=37)], [], lineno=37, col_offset=12, end_lineno=37, end_col_offset=38), lineno=37, col_offset=12, end_lineno=37, end_col_offset=38)], [], lineno=36, col_offset=8, end_lineno=37, end_col_offset=38)], [], lineno=35, col_offset=4, end_lineno=37, end_col_offset=38), Return(Name('placeholder_8', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=20), lineno=38, col_offset=4, end_lineno=38, end_col_offset=20)], [], lineno=27, col_offset=0, end_lineno=38, end_col_offset=20), FunctionDef('placeholder_11', arguments([], [arg('placeholder_5', lineno=41, col_offset=32, end_lineno=41, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_12', Store(), lineno=48, col_offset=4, end_lineno=48, end_col_offset=9)], Constant(0, lineno=48, col_offset=12, end_lineno=48, end_col_offset=13), lineno=48, col_offset=4, end_lineno=48, end_col_offset=13), For(Name('placeholder_10', Store(), lineno=49, col_offset=8, end_lineno=49, end_col_offset=13), Call(Attribute(Name('placeholder_5', Load(), lineno=49, col_offset=17, end_lineno=49, end_col_offset=22), 'values', Load(), lineno=49, col_offset=17, end_lineno=49, end_col_offset=29), [], [], lineno=49, col_offset=17, end_lineno=49, end_col_offset=31), [If(Compare(Name('placeholder_10', Load(), lineno=50, col_offset=11, end_lineno=50, end_col_offset=16), [Is()], [Constant(None, lineno=50, col_offset=20, end_lineno=50, end_col_offset=24)], lineno=50, col_offset=11, end_lineno=50, end_col_offset=24), [AugAssign(Name('placeholder_12', Store(), lineno=51, col_offset=12, end_lineno=51, end_col_offset=17), Add(), Constant(1, lineno=51, col_offset=21, end_lineno=51, end_col_offset=22), lineno=51, col_offset=12, end_lineno=51, end_col_offset=22)], [], lineno=50, col_offset=8, end_lineno=51, end_col_offset=22)], [], lineno=49, col_offset=4, end_lineno=51, end_col_offset=22), Return(Name('placeholder_12', Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=16), lineno=52, col_offset=4, end_lineno=52, end_col_offset=16)], [], lineno=41, col_offset=0, end_lineno=52, end_col_offset=16), FunctionDef('placeholder_13', arguments([], [arg('placeholder_5', lineno=55, col_offset=31, end_lineno=55, end_col_offset=36), arg('placeholder_4', lineno=55, col_offset=38, end_lineno=55, end_col_offset=44)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=63, col_offset=4, end_lineno=63, end_col_offset=20)], Call(Name('placeholder_11', Load(), lineno=63, col_offset=23, end_lineno=63, end_col_offset=50), [Name('placeholder_5', Load(), lineno=63, col_offset=51, end_lineno=63, end_col_offset=56)], [], lineno=63, col_offset=23, end_lineno=63, end_col_offset=57), lineno=63, col_offset=4, end_lineno=63, end_col_offset=57), Assign([Name('placeholder_15', Store(), lineno=64, col_offset=4, end_lineno=64, end_col_offset=19)], Call(Name('placeholder_7', Load(), lineno=64, col_offset=22, end_lineno=64, end_col_offset=46), [Name('placeholder_5', Load(), lineno=64, col_offset=47, end_lineno=64, end_col_offset=52)], [], lineno=64, col_offset=22, end_lineno=64, end_col_offset=53), lineno=64, col_offset=4, end_lineno=64, end_col_offset=53), If(Compare(Call(Name('len', Load(), lineno=66, col_offset=7, end_lineno=66, end_col_offset=10), [Name('placeholder_4', Load(), lineno=66, col_offset=11, end_lineno=66, end_col_offset=17)], [], lineno=66, col_offset=7, end_lineno=66, end_col_offset=18), [LtE()], [Name('placeholder_14', Load(), lineno=66, col_offset=22, end_lineno=66, end_col_offset=38)], lineno=66, col_offset=7, end_lineno=66, end_col_offset=38), [For(Tuple([Name('placeholder_16', Store(), lineno=67, col_offset=12, end_lineno=67, end_col_offset=17), Name('placeholder_17', Store(), lineno=67, col_offset=19, end_lineno=67, end_col_offset=20)], Store(), lineno=67, col_offset=12, end_lineno=67, end_col_offset=20), Call(Name('enumerate', Load(), lineno=67, col_offset=24, end_lineno=67, end_col_offset=33), [Name('placeholder_4', Load(), lineno=67, col_offset=34, end_lineno=67, end_col_offset=40)], [], lineno=67, col_offset=24, end_lineno=67, end_col_offset=41), [Assign([Subscript(Name('placeholder_5', Load(), lineno=68, col_offset=12, end_lineno=68, end_col_offset=17), Subscript(Name('placeholder_15', Load(), lineno=68, col_offset=18, end_lineno=68, end_col_offset=33), Name('placeholder_16', Load(), lineno=68, col_offset=34, end_lineno=68, end_col_offset=39), Load(), lineno=68, col_offset=18, end_lineno=68, end_col_offset=40), Store(), lineno=68, col_offset=12, end_lineno=68, end_col_offset=41)], Subscript(Name('placeholder_4', Load(), lineno=68, col_offset=44, end_lineno=68, end_col_offset=50), Name('placeholder_16', Load(), lineno=68, col_offset=51, end_lineno=68, end_col_offset=56), Load(), lineno=68, col_offset=44, end_lineno=68, end_col_offset=57), lineno=68, col_offset=12, end_lineno=68, end_col_offset=57)], [], lineno=67, col_offset=8, end_lineno=68, end_col_offset=57)], [], lineno=66, col_offset=4, end_lineno=68, end_col_offset=57), Return(Name('placeholder_5', Load(), lineno=70, col_offset=11, end_lineno=70, end_col_offset=16), lineno=70, col_offset=4, end_lineno=70, end_col_offset=16)], [], lineno=55, col_offset=0, end_lineno=70, end_col_offset=16), FunctionDef('placeholder_18', arguments([], [arg('placeholder_5', lineno=73, col_offset=16, end_lineno=73, end_col_offset=21), arg('placeholder_19', lineno=73, col_offset=23, end_lineno=73, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_20', Store(), lineno=81, col_offset=8, end_lineno=81, end_col_offset=12), Name('placeholder_19', Load(), lineno=81, col_offset=16, end_lineno=81, end_col_offset=28), [Assign([Subscript(Name('placeholder_5', Load(), lineno=82, col_offset=8, end_lineno=82, end_col_offset=13), Name('placeholder_20', Load(), lineno=82, col_offset=14, end_lineno=82, end_col_offset=18), Store(), lineno=82, col_offset=8, end_lineno=82, end_col_offset=19)], Constant(None, lineno=82, col_offset=22, end_lineno=82, end_col_offset=26), lineno=82, col_offset=8, end_lineno=82, end_col_offset=26)], [], lineno=81, col_offset=4, end_lineno=82, end_col_offset=26), Return(Name('placeholder_5', Load(), lineno=84, col_offset=11, end_lineno=84, end_col_offset=16), lineno=84, col_offset=4, end_lineno=84, end_col_offset=16)], [], lineno=73, col_offset=0, end_lineno=84, end_col_offset=16)], []) \ No newline at end of file diff --git a/test/concept-tisbury-treasure-hunt/.meta/config.json b/test/concept-tisbury-treasure-hunt/.meta/config.json new file mode 100644 index 0000000..c48fd0f --- /dev/null +++ b/test/concept-tisbury-treasure-hunt/.meta/config.json @@ -0,0 +1,12 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "tuples.py" + ] + }, + "icon": "tisbury-treasure-hunt", + "blurb": "Learn about tuples by helping out competitors in the Tisbury Treasure Hunt." +} diff --git a/test/concept-tisbury-treasure-hunt/mapping.json b/test/concept-tisbury-treasure-hunt/mapping.json new file mode 100644 index 0000000..bb654bb --- /dev/null +++ b/test/concept-tisbury-treasure-hunt/mapping.json @@ -0,0 +1,15 @@ +{ + "placeholder_0": "get_coordinate", + "placeholder_1": "record", + "placeholder_2": "convert_coordinate", + "placeholder_3": "coordinate", + "placeholder_4": "compare_records", + "placeholder_5": "azara_record", + "placeholder_6": "rui_record", + "placeholder_7": "create_record", + "placeholder_8": "result", + "placeholder_9": "clean_up", + "placeholder_10": "combined_record_group", + "placeholder_11": "report", + "placeholder_12": "item" +} \ No newline at end of file diff --git a/test/concept-tisbury-treasure-hunt/representation.json b/test/concept-tisbury-treasure-hunt/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/concept-tisbury-treasure-hunt/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/concept-tisbury-treasure-hunt/representation.out b/test/concept-tisbury-treasure-hunt/representation.out new file mode 100644 index 0000000..e39da14 --- /dev/null +++ b/test/concept-tisbury-treasure-hunt/representation.out @@ -0,0 +1,1065 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return placeholder_1[1] + + +def placeholder_2(placeholder_3): + return tuple(placeholder_3) + + +def placeholder_4(placeholder_5, placeholder_6): + return placeholder_2(placeholder_5[1]) in placeholder_6 + + +def placeholder_7(placeholder_5, placeholder_6): + placeholder_8 = "not a match" + if placeholder_4(placeholder_5, placeholder_6): + placeholder_8 = placeholder_5 + placeholder_6 + return placeholder_8 + + +def placeholder_9(placeholder_10): + placeholder_11 = "" + for placeholder_12 in placeholder_10: + placeholder_11 += f"{(placeholder_12[0], placeholder_12[2], placeholder_12[3], placeholder_12[4])}\n" + return placeholder_11 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to help Azara and Rui locate pirate treasure.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=61), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=61), + FunctionDef( + 'get_coordinate', + arguments( + [], + [ + arg( + 'record', + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return coordinate value from a tuple containing the treasure name, and treasure coordinate.\n\n :param record: tuple - with a (treasure, coordinate) pair.\n :return: str - the extracted map coordinate.\n ', + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + lineno=5, + col_offset=4, + end_lineno=9, + end_col_offset=7), + Return( + Subscript( + Name( + 'record', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=17), + Constant( + 1, + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=19), + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=20), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=20)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=20), + FunctionDef( + 'convert_coordinate', + arguments( + [], + [ + arg( + 'coordinate', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Split the given coordinate into tuple containing its individual components.\n\n :param coordinate: str - a string map coordinate\n :return: tuple - the string coordinate split into its individual components.\n ', + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=7), + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=7), + Return( + Call( + Name( + 'tuple', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=16), + [ + Name( + 'coordinate', + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=27)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=28), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=28)], + [], + lineno=14, + col_offset=0, + end_lineno=21, + end_col_offset=28), + FunctionDef( + 'compare_records', + arguments( + [], + [ + arg( + 'azara_record', + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=32), + arg( + 'rui_record', + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Compare two record types and determine if their coordinates match.\n\n :param azara_record: tuple - a (treasure, coordinate) pair.\n :param rui_record: tuple - a (location, tuple(coordinate_1, coordinate_2), quadrant) trio.\n :return: bool - do the coordinates match?\n ', + lineno=25, + col_offset=4, + end_lineno=30, + end_col_offset=7), + lineno=25, + col_offset=4, + end_lineno=30, + end_col_offset=7), + Return( + Compare( + Call( + Name( + 'convert_coordinate', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=29), + [ + Subscript( + Name( + 'azara_record', + Load(), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=42), + Constant( + 1, + lineno=32, + col_offset=43, + end_lineno=32, + end_col_offset=44), + Load(), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=45)], + [], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=46), + [ + In()], + [ + Name( + 'rui_record', + Load(), + lineno=32, + col_offset=50, + end_lineno=32, + end_col_offset=60)], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=60), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=60)], + [], + lineno=24, + col_offset=0, + end_lineno=32, + end_col_offset=60), + FunctionDef( + 'create_record', + arguments( + [], + [ + arg( + 'azara_record', + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=30), + arg( + 'rui_record', + lineno=35, + col_offset=32, + end_lineno=35, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Combine the two record types (if possible) and create a combined record group.\n\n :param azara_record: tuple - a (treasure, coordinate) pair.\n :param rui_record: tuple - a (location, coordinate, quadrant) trio.\n :return: tuple or str - the combined record (if compatible), or the string "not a match" (if incompatible).\n ', + lineno=36, + col_offset=4, + end_lineno=41, + end_col_offset=7), + lineno=36, + col_offset=4, + end_lineno=41, + end_col_offset=7), + Assign( + [ + Name( + 'result', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=10)], + Constant( + 'not a match', + lineno=43, + col_offset=13, + end_lineno=43, + end_col_offset=26), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=26), + If( + Call( + Name( + 'compare_records', + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=22), + [ + Name( + 'azara_record', + Load(), + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=35), + Name( + 'rui_record', + Load(), + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=47)], + [], + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=48), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=14)], + BinOp( + Name( + 'azara_record', + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=29), + Add(), + Name( + 'rui_record', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=42), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=42), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=42)], + [], + lineno=45, + col_offset=4, + end_lineno=46, + end_col_offset=42), + Return( + Name( + 'result', + Load(), + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=17), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=17)], + [], + lineno=35, + col_offset=0, + end_lineno=48, + end_col_offset=17), + FunctionDef( + 'clean_up', + arguments( + [], + [ + arg( + 'combined_record_group', + lineno=51, + col_offset=13, + end_lineno=51, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Clean up a combined record group into a multi-line string of single records.\n\n :param combined_record_group: tuple - everything from both participants.\n :return: str - everything "cleaned", excess coordinates and information are removed.\n\n The return statement should be a multi-lined string with items separated by newlines.\n\n (see HINTS.md for an example).\n ', + lineno=52, + col_offset=4, + end_lineno=60, + end_col_offset=7), + lineno=52, + col_offset=4, + end_lineno=60, + end_col_offset=7), + Assign( + [ + Name( + 'report', + Store(), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=10)], + Constant( + '', + lineno=62, + col_offset=13, + end_lineno=62, + end_col_offset=15), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=15), + For( + Name( + 'item', + Store(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=12), + Name( + 'combined_record_group', + Load(), + lineno=64, + col_offset=16, + end_lineno=64, + end_col_offset=37), + [ + AugAssign( + Name( + 'report', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=14), + Add(), + JoinedStr( + [ + FormattedValue( + Tuple( + [ + Subscript( + Name( + 'item', + Load(), + lineno=65, + col_offset=22, + end_lineno=65, + end_col_offset=26), + Constant( + 0, + lineno=65, + col_offset=27, + end_lineno=65, + end_col_offset=28), + Load(), + lineno=65, + col_offset=22, + end_lineno=65, + end_col_offset=29), + Subscript( + Name( + 'item', + Load(), + lineno=65, + col_offset=31, + end_lineno=65, + end_col_offset=35), + Constant( + 2, + lineno=65, + col_offset=36, + end_lineno=65, + end_col_offset=37), + Load(), + lineno=65, + col_offset=31, + end_lineno=65, + end_col_offset=38), + Subscript( + Name( + 'item', + Load(), + lineno=65, + col_offset=40, + end_lineno=65, + end_col_offset=44), + Constant( + 3, + lineno=65, + col_offset=45, + end_lineno=65, + end_col_offset=46), + Load(), + lineno=65, + col_offset=40, + end_lineno=65, + end_col_offset=47), + Subscript( + Name( + 'item', + Load(), + lineno=65, + col_offset=49, + end_lineno=65, + end_col_offset=53), + Constant( + 4, + lineno=65, + col_offset=54, + end_lineno=65, + end_col_offset=55), + Load(), + lineno=65, + col_offset=49, + end_lineno=65, + end_col_offset=56)], + Load(), + lineno=65, + col_offset=21, + end_lineno=65, + end_col_offset=57), + -1, + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=61), + Constant( + '\n', + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=61)], + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=61), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=61)], + [], + lineno=64, + col_offset=4, + end_lineno=65, + end_col_offset=61), + Return( + Name( + 'report', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=17), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=17)], + [], + lineno=51, + col_offset=0, + end_lineno=67, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=17), + Constant( + 1, + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=19), + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=20), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=20)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=20), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'tuple', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=16), + [ + Name( + 'placeholder_3', + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=27)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=28), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=28)], + [], + lineno=14, + col_offset=0, + end_lineno=21, + end_col_offset=28), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=32), + arg( + 'placeholder_6', + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'placeholder_2', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=29), + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=42), + Constant( + 1, + lineno=32, + col_offset=43, + end_lineno=32, + end_col_offset=44), + Load(), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=45)], + [], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=46), + [ + In()], + [ + Name( + 'placeholder_6', + Load(), + lineno=32, + col_offset=50, + end_lineno=32, + end_col_offset=60)], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=60), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=60)], + [], + lineno=24, + col_offset=0, + end_lineno=32, + end_col_offset=60), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=30), + arg( + 'placeholder_6', + lineno=35, + col_offset=32, + end_lineno=35, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=10)], + Constant( + 'not a match', + lineno=43, + col_offset=13, + end_lineno=43, + end_col_offset=26), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=26), + If( + Call( + Name( + 'placeholder_4', + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=22), + [ + Name( + 'placeholder_5', + Load(), + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=35), + Name( + 'placeholder_6', + Load(), + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=47)], + [], + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=48), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=14)], + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=29), + Add(), + Name( + 'placeholder_6', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=42), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=42), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=42)], + [], + lineno=45, + col_offset=4, + end_lineno=46, + end_col_offset=42), + Return( + Name( + 'placeholder_8', + Load(), + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=17), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=17)], + [], + lineno=35, + col_offset=0, + end_lineno=48, + end_col_offset=17), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=51, + col_offset=13, + end_lineno=51, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=10)], + Constant( + '', + lineno=62, + col_offset=13, + end_lineno=62, + end_col_offset=15), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=15), + For( + Name( + 'placeholder_12', + Store(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=12), + Name( + 'placeholder_10', + Load(), + lineno=64, + col_offset=16, + end_lineno=64, + end_col_offset=37), + [ + AugAssign( + Name( + 'placeholder_11', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=14), + Add(), + JoinedStr( + [ + FormattedValue( + Tuple( + [ + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=65, + col_offset=22, + end_lineno=65, + end_col_offset=26), + Constant( + 0, + lineno=65, + col_offset=27, + end_lineno=65, + end_col_offset=28), + Load(), + lineno=65, + col_offset=22, + end_lineno=65, + end_col_offset=29), + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=65, + col_offset=31, + end_lineno=65, + end_col_offset=35), + Constant( + 2, + lineno=65, + col_offset=36, + end_lineno=65, + end_col_offset=37), + Load(), + lineno=65, + col_offset=31, + end_lineno=65, + end_col_offset=38), + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=65, + col_offset=40, + end_lineno=65, + end_col_offset=44), + Constant( + 3, + lineno=65, + col_offset=45, + end_lineno=65, + end_col_offset=46), + Load(), + lineno=65, + col_offset=40, + end_lineno=65, + end_col_offset=47), + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=65, + col_offset=49, + end_lineno=65, + end_col_offset=53), + Constant( + 4, + lineno=65, + col_offset=54, + end_lineno=65, + end_col_offset=55), + Load(), + lineno=65, + col_offset=49, + end_lineno=65, + end_col_offset=56)], + Load(), + lineno=65, + col_offset=21, + end_lineno=65, + end_col_offset=57), + -1, + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=61), + Constant( + '\n', + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=61)], + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=61), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=61)], + [], + lineno=64, + col_offset=4, + end_lineno=65, + end_col_offset=61), + Return( + Name( + 'placeholder_11', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=17), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=17)], + [], + lineno=51, + col_offset=0, + end_lineno=67, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/concept-tisbury-treasure-hunt/representation.txt b/test/concept-tisbury-treasure-hunt/representation.txt new file mode 100644 index 0000000..ce08b38 --- /dev/null +++ b/test/concept-tisbury-treasure-hunt/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=19, end_lineno=4, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Subscript(Name('placeholder_1', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=17), Constant(1, lineno=11, col_offset=18, end_lineno=11, end_col_offset=19), Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=20), lineno=11, col_offset=4, end_lineno=11, end_col_offset=20)], [], lineno=4, col_offset=0, end_lineno=11, end_col_offset=20), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=14, col_offset=23, end_lineno=14, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('tuple', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=16), [Name('placeholder_3', Load(), lineno=21, col_offset=17, end_lineno=21, end_col_offset=27)], [], lineno=21, col_offset=11, end_lineno=21, end_col_offset=28), lineno=21, col_offset=4, end_lineno=21, end_col_offset=28)], [], lineno=14, col_offset=0, end_lineno=21, end_col_offset=28), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=24, col_offset=20, end_lineno=24, end_col_offset=32), arg('placeholder_6', lineno=24, col_offset=34, end_lineno=24, end_col_offset=44)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Call(Name('placeholder_2', Load(), lineno=32, col_offset=11, end_lineno=32, end_col_offset=29), [Subscript(Name('placeholder_5', Load(), lineno=32, col_offset=30, end_lineno=32, end_col_offset=42), Constant(1, lineno=32, col_offset=43, end_lineno=32, end_col_offset=44), Load(), lineno=32, col_offset=30, end_lineno=32, end_col_offset=45)], [], lineno=32, col_offset=11, end_lineno=32, end_col_offset=46), [In()], [Name('placeholder_6', Load(), lineno=32, col_offset=50, end_lineno=32, end_col_offset=60)], lineno=32, col_offset=11, end_lineno=32, end_col_offset=60), lineno=32, col_offset=4, end_lineno=32, end_col_offset=60)], [], lineno=24, col_offset=0, end_lineno=32, end_col_offset=60), FunctionDef('placeholder_7', arguments([], [arg('placeholder_5', lineno=35, col_offset=18, end_lineno=35, end_col_offset=30), arg('placeholder_6', lineno=35, col_offset=32, end_lineno=35, end_col_offset=42)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=43, col_offset=4, end_lineno=43, end_col_offset=10)], Constant('not a match', lineno=43, col_offset=13, end_lineno=43, end_col_offset=26), lineno=43, col_offset=4, end_lineno=43, end_col_offset=26), If(Call(Name('placeholder_4', Load(), lineno=45, col_offset=7, end_lineno=45, end_col_offset=22), [Name('placeholder_5', Load(), lineno=45, col_offset=23, end_lineno=45, end_col_offset=35), Name('placeholder_6', Load(), lineno=45, col_offset=37, end_lineno=45, end_col_offset=47)], [], lineno=45, col_offset=7, end_lineno=45, end_col_offset=48), [Assign([Name('placeholder_8', Store(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=14)], BinOp(Name('placeholder_5', Load(), lineno=46, col_offset=17, end_lineno=46, end_col_offset=29), Add(), Name('placeholder_6', Load(), lineno=46, col_offset=32, end_lineno=46, end_col_offset=42), lineno=46, col_offset=17, end_lineno=46, end_col_offset=42), lineno=46, col_offset=8, end_lineno=46, end_col_offset=42)], [], lineno=45, col_offset=4, end_lineno=46, end_col_offset=42), Return(Name('placeholder_8', Load(), lineno=48, col_offset=11, end_lineno=48, end_col_offset=17), lineno=48, col_offset=4, end_lineno=48, end_col_offset=17)], [], lineno=35, col_offset=0, end_lineno=48, end_col_offset=17), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=51, col_offset=13, end_lineno=51, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_11', Store(), lineno=62, col_offset=4, end_lineno=62, end_col_offset=10)], Constant('', lineno=62, col_offset=13, end_lineno=62, end_col_offset=15), lineno=62, col_offset=4, end_lineno=62, end_col_offset=15), For(Name('placeholder_12', Store(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=12), Name('placeholder_10', Load(), lineno=64, col_offset=16, end_lineno=64, end_col_offset=37), [AugAssign(Name('placeholder_11', Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=14), Add(), JoinedStr([FormattedValue(Tuple([Subscript(Name('placeholder_12', Load(), lineno=65, col_offset=22, end_lineno=65, end_col_offset=26), Constant(0, lineno=65, col_offset=27, end_lineno=65, end_col_offset=28), Load(), lineno=65, col_offset=22, end_lineno=65, end_col_offset=29), Subscript(Name('placeholder_12', Load(), lineno=65, col_offset=31, end_lineno=65, end_col_offset=35), Constant(2, lineno=65, col_offset=36, end_lineno=65, end_col_offset=37), Load(), lineno=65, col_offset=31, end_lineno=65, end_col_offset=38), Subscript(Name('placeholder_12', Load(), lineno=65, col_offset=40, end_lineno=65, end_col_offset=44), Constant(3, lineno=65, col_offset=45, end_lineno=65, end_col_offset=46), Load(), lineno=65, col_offset=40, end_lineno=65, end_col_offset=47), Subscript(Name('placeholder_12', Load(), lineno=65, col_offset=49, end_lineno=65, end_col_offset=53), Constant(4, lineno=65, col_offset=54, end_lineno=65, end_col_offset=55), Load(), lineno=65, col_offset=49, end_lineno=65, end_col_offset=56)], Load(), lineno=65, col_offset=21, end_lineno=65, end_col_offset=57), -1, lineno=65, col_offset=18, end_lineno=65, end_col_offset=61), Constant('\n', lineno=65, col_offset=18, end_lineno=65, end_col_offset=61)], lineno=65, col_offset=18, end_lineno=65, end_col_offset=61), lineno=65, col_offset=8, end_lineno=65, end_col_offset=61)], [], lineno=64, col_offset=4, end_lineno=65, end_col_offset=61), Return(Name('placeholder_11', Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=17), lineno=67, col_offset=4, end_lineno=67, end_col_offset=17)], [], lineno=51, col_offset=0, end_lineno=67, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/concept-tisbury-treasure-hunt/tuples.py b/test/concept-tisbury-treasure-hunt/tuples.py new file mode 100644 index 0000000..1b4baa2 --- /dev/null +++ b/test/concept-tisbury-treasure-hunt/tuples.py @@ -0,0 +1,67 @@ +"""Functions to help Azara and Rui locate pirate treasure.""" + + +def get_coordinate(record): + """Return coordinate value from a tuple containing the treasure name, and treasure coordinate. + + :param record: tuple - with a (treasure, coordinate) pair. + :return: str - the extracted map coordinate. + """ + + return record[1] + + +def convert_coordinate(coordinate): + """Split the given coordinate into tuple containing its individual components. + + :param coordinate: str - a string map coordinate + :return: tuple - the string coordinate split into its individual components. + """ + + return tuple(coordinate) + + +def compare_records(azara_record, rui_record): + """Compare two record types and determine if their coordinates match. + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, tuple(coordinate_1, coordinate_2), quadrant) trio. + :return: bool - do the coordinates match? + """ + + return convert_coordinate(azara_record[1]) in rui_record + + +def create_record(azara_record, rui_record): + """Combine the two record types (if possible) and create a combined record group. + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: tuple or str - the combined record (if compatible), or the string "not a match" (if incompatible). + """ + + result = "not a match" + + if compare_records(azara_record, rui_record): + result = azara_record + rui_record + + return result + + +def clean_up(combined_record_group): + """Clean up a combined record group into a multi-line string of single records. + + :param combined_record_group: tuple - everything from both participants. + :return: str - everything "cleaned", excess coordinates and information are removed. + + The return statement should be a multi-lined string with items separated by newlines. + + (see HINTS.md for an example). + """ + + report = "" + + for item in combined_record_group: + report += f"{(item[0], item[2], item[3], item[4])}\n" + + return report diff --git a/test/example-comments-removal/.meta/config.json b/test/example-comments-removal/.meta/config.json new file mode 100644 index 0000000..88fec85 --- /dev/null +++ b/test/example-comments-removal/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_comments_removal.py" + ] + } +} \ No newline at end of file diff --git a/test/example-comments-removal/example_comments_removal.py b/test/example-comments-removal/example_comments_removal.py new file mode 100644 index 0000000..52a3098 --- /dev/null +++ b/test/example-comments-removal/example_comments_removal.py @@ -0,0 +1,76 @@ +"""Module-level docstring. + + Multi-line docstring style comment at + the module level. +""" + + +import re +import operator + + +# Module-leve comment +# Second line of comment +# Third line of comment + +operations = { + 'plus': operator.add, + 'minus': operator.sub, + 'multiplied by': operator.mul, + 'divided by': operator.floordiv +} + +regex = { + 'number': re.compile(r'-?\d+'), + 'operator': re.compile(f'(?:{"|".join(operations.keys())})\\b') # In-line comment +} + +def get_number(question): + # Comment after function def + + m = regex['number'].match(question) + if not m: + raise ValueError("syntax error") + return [question.removeprefix(m.group(0)).lstrip(), int(m.group(0))] + +def get_operation(question): + """Docstring style comment (should be removed).""" + + # Hash-style comment + m = regex['operator'].match(question) + if not m: + raise ValueError("unknown operation") # Another in-line comment + return [question.removeprefix(m.group(0)).lstrip(), operations[m.group(0)]] + +def prepare_question(question): + """Mulit-line docstring. + + This is a multi-line comment in the style of a + docstring. It should get removed in the representation. + """ + + # Comment above statement. + q = question.lower().strip().removesuffix("?") + + # Every valid question starts with "What is" + prefix = "what is" + if not q.startswith(prefix): + raise ValueError("unknown operation") # In-line comment. + return q.removeprefix(prefix).lstrip() + +def answer(question): + + q = prepare_question(question) + + # the question should start with a number + q, result = get_number(q) + while len(q) > 0: + # can't have a number followed by a number + # Second line of comment + # Third line of comment + if regex['number'].match(q): + raise ValueError("syntax error") + q, operation = get_operation(q) # And another in-line comment. + q, num = get_number(q) + result = operation(result, num) + return result \ No newline at end of file diff --git a/test/example-comments-removal/mapping.json b/test/example-comments-removal/mapping.json new file mode 100644 index 0000000..d64f62f --- /dev/null +++ b/test/example-comments-removal/mapping.json @@ -0,0 +1,15 @@ +{ + "placeholder_0": "operations", + "placeholder_1": "regex", + "placeholder_2": "get_number", + "placeholder_3": "question", + "placeholder_4": "m", + "placeholder_5": "get_operation", + "placeholder_6": "prepare_question", + "placeholder_7": "q", + "placeholder_8": "prefix", + "placeholder_9": "answer", + "placeholder_10": "result", + "placeholder_11": "operation", + "placeholder_12": "num" +} \ No newline at end of file diff --git a/test/example-comments-removal/representation.json b/test/example-comments-removal/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-comments-removal/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-comments-removal/representation.out b/test/example-comments-removal/representation.out new file mode 100644 index 0000000..3401b98 --- /dev/null +++ b/test/example-comments-removal/representation.out @@ -0,0 +1,2739 @@ +## BEGIN NORMALIZED CODE ## +import re +import operator + +placeholder_0 = { + "plus": operator.add, + "minus": operator.sub, + "multiplied by": operator.mul, + "divided by": operator.floordiv, +} +placeholder_1 = { + "number": re.compile("-?\\d+"), + "operator": re.compile(f"(?:{'|'.join(placeholder_0.keys())})\\b"), +} + + +def placeholder_2(placeholder_3): + placeholder_4 = placeholder_1["number"].match(placeholder_3) + if not placeholder_4: + raise ValueError("syntax error") + return [ + placeholder_3.removeprefix(placeholder_4.group(0)).lstrip(), + int(placeholder_4.group(0)), + ] + + +def placeholder_5(placeholder_3): + placeholder_4 = placeholder_1["operator"].match(placeholder_3) + if not placeholder_4: + raise ValueError("unknown operation") + return [ + placeholder_3.removeprefix(placeholder_4.group(0)).lstrip(), + placeholder_0[placeholder_4.group(0)], + ] + + +def placeholder_6(placeholder_3): + placeholder_7 = placeholder_3.lower().strip().removesuffix("?") + placeholder_8 = "what is" + if not placeholder_7.startswith(placeholder_8): + raise ValueError("unknown operation") + return placeholder_7.removeprefix(placeholder_8).lstrip() + + +def placeholder_9(placeholder_3): + placeholder_7 = placeholder_6(placeholder_3) + placeholder_7, placeholder_10 = placeholder_2(placeholder_7) + while len(placeholder_7) > 0: + if placeholder_1["number"].match(placeholder_7): + raise ValueError("syntax error") + placeholder_7, placeholder_11 = placeholder_5(placeholder_7) + placeholder_7, placeholder_12 = placeholder_2(placeholder_7) + placeholder_10 = placeholder_11(placeholder_10, placeholder_12) + return placeholder_10 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Module-level docstring.\n\n Multi-line docstring style comment at\n the module level.\n', + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=3), + Import( + [ + alias( + 're', + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=9)], + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=9), + Import( + [ + alias( + 'operator', + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=15)], + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=15), + Assign( + [ + Name( + 'operations', + Store(), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=10)], + Dict( + [ + Constant( + 'plus', + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=10), + Constant( + 'minus', + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=11), + Constant( + 'multiplied by', + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=19), + Constant( + 'divided by', + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=16)], + [ + Attribute( + Name( + 'operator', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=20), + 'add', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=24), + Attribute( + Name( + 'operator', + Load(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=21), + 'sub', + Load(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=25), + Attribute( + Name( + 'operator', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=29), + 'mul', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=33), + Attribute( + Name( + 'operator', + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=26), + 'floordiv', + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=35)], + lineno=16, + col_offset=13, + end_lineno=21, + end_col_offset=1), + lineno=16, + col_offset=0, + end_lineno=21, + end_col_offset=1), + Assign( + [ + Name( + 'regex', + Store(), + lineno=23, + col_offset=0, + end_lineno=23, + end_col_offset=5)], + Dict( + [ + Constant( + 'number', + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=12), + Constant( + 'operator', + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=14)], + [ + Call( + Attribute( + Name( + 're', + Load(), + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=16), + 'compile', + Load(), + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=24), + [ + Constant( + '-?\\d+', + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=33)], + [], + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=34), + Call( + Attribute( + Name( + 're', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=18), + 'compile', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=26), + [ + JoinedStr( + [ + Constant( + '(?:', + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=66), + FormattedValue( + Call( + Attribute( + Constant( + '|', + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=36), + 'join', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=41), + [ + Call( + Attribute( + Name( + 'operations', + Load(), + lineno=25, + col_offset=42, + end_lineno=25, + end_col_offset=52), + 'keys', + Load(), + lineno=25, + col_offset=42, + end_lineno=25, + end_col_offset=57), + [], + [], + lineno=25, + col_offset=42, + end_lineno=25, + end_col_offset=59)], + [], + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=60), + -1, + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=66), + Constant( + ')\\b', + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=66)], + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=66)], + [], + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=67)], + lineno=23, + col_offset=8, + end_lineno=26, + end_col_offset=1), + lineno=23, + col_offset=0, + end_lineno=26, + end_col_offset=1), + FunctionDef( + 'get_number', + arguments( + [], + [ + arg( + 'question', + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'm', + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=5)], + Call( + Attribute( + Subscript( + Name( + 'regex', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=13), + Constant( + 'number', + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=22), + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=23), + 'match', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=29), + [ + Name( + 'question', + Load(), + lineno=31, + col_offset=30, + end_lineno=31, + end_col_offset=38)], + [], + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=39), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=39), + If( + UnaryOp( + Not(), + Name( + 'm', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=12), + lineno=32, + col_offset=7, + end_lineno=32, + end_col_offset=12), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=24), + [ + Constant( + 'syntax error', + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=39)], + [], + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=40), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=40)], + [], + lineno=32, + col_offset=4, + end_lineno=33, + end_col_offset=40), + Return( + List( + [ + Call( + Attribute( + Call( + Attribute( + Name( + 'question', + Load(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=20), + 'removeprefix', + Load(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=33), + [ + Call( + Attribute( + Name( + 'm', + Load(), + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=35), + 'group', + Load(), + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=41), + [ + Constant( + 0, + lineno=34, + col_offset=42, + end_lineno=34, + end_col_offset=43)], + [], + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=44)], + [], + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=45), + 'lstrip', + Load(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=52), + [], + [], + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=54), + Call( + Name( + 'int', + Load(), + lineno=34, + col_offset=56, + end_lineno=34, + end_col_offset=59), + [ + Call( + Attribute( + Name( + 'm', + Load(), + lineno=34, + col_offset=60, + end_lineno=34, + end_col_offset=61), + 'group', + Load(), + lineno=34, + col_offset=60, + end_lineno=34, + end_col_offset=67), + [ + Constant( + 0, + lineno=34, + col_offset=68, + end_lineno=34, + end_col_offset=69)], + [], + lineno=34, + col_offset=60, + end_lineno=34, + end_col_offset=70)], + [], + lineno=34, + col_offset=56, + end_lineno=34, + end_col_offset=71)], + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=72), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=72)], + [], + lineno=28, + col_offset=0, + end_lineno=34, + end_col_offset=72), + FunctionDef( + 'get_operation', + arguments( + [], + [ + arg( + 'question', + lineno=36, + col_offset=18, + end_lineno=36, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Docstring style comment (should be removed).', + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=54), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=54), + Assign( + [ + Name( + 'm', + Store(), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=5)], + Call( + Attribute( + Subscript( + Name( + 'regex', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=13), + Constant( + 'operator', + lineno=40, + col_offset=14, + end_lineno=40, + end_col_offset=24), + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=25), + 'match', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=31), + [ + Name( + 'question', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=40)], + [], + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=41), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=41), + If( + UnaryOp( + Not(), + Name( + 'm', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=12), + lineno=41, + col_offset=7, + end_lineno=41, + end_col_offset=12), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=24), + [ + Constant( + 'unknown operation', + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=44)], + [], + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=45), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=45)], + [], + lineno=41, + col_offset=4, + end_lineno=42, + end_col_offset=45), + Return( + List( + [ + Call( + Attribute( + Call( + Attribute( + Name( + 'question', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=20), + 'removeprefix', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=33), + [ + Call( + Attribute( + Name( + 'm', + Load(), + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=35), + 'group', + Load(), + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=41), + [ + Constant( + 0, + lineno=43, + col_offset=42, + end_lineno=43, + end_col_offset=43)], + [], + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=44)], + [], + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=45), + 'lstrip', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=52), + [], + [], + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=54), + Subscript( + Name( + 'operations', + Load(), + lineno=43, + col_offset=56, + end_lineno=43, + end_col_offset=66), + Call( + Attribute( + Name( + 'm', + Load(), + lineno=43, + col_offset=67, + end_lineno=43, + end_col_offset=68), + 'group', + Load(), + lineno=43, + col_offset=67, + end_lineno=43, + end_col_offset=74), + [ + Constant( + 0, + lineno=43, + col_offset=75, + end_lineno=43, + end_col_offset=76)], + [], + lineno=43, + col_offset=67, + end_lineno=43, + end_col_offset=77), + Load(), + lineno=43, + col_offset=56, + end_lineno=43, + end_col_offset=78)], + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=79), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=79)], + [], + lineno=36, + col_offset=0, + end_lineno=43, + end_col_offset=79), + FunctionDef( + 'prepare_question', + arguments( + [], + [ + arg( + 'question', + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Mulit-line docstring.\n\n This is a multi-line comment in the style of a\n docstring. It should get removed in the representation.\n ', + lineno=46, + col_offset=4, + end_lineno=50, + end_col_offset=7), + lineno=46, + col_offset=4, + end_lineno=50, + end_col_offset=7), + Assign( + [ + Name( + 'q', + Store(), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=5)], + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Name( + 'question', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=16), + 'lower', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=22), + [], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=24), + 'strip', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=30), + [], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=32), + 'removesuffix', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=45), + [ + Constant( + '?', + lineno=53, + col_offset=46, + end_lineno=53, + end_col_offset=49)], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=50), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=50), + Assign( + [ + Name( + 'prefix', + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=10)], + Constant( + 'what is', + lineno=56, + col_offset=13, + end_lineno=56, + end_col_offset=22), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=22), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'q', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=12), + 'startswith', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=23), + [ + Name( + 'prefix', + Load(), + lineno=57, + col_offset=24, + end_lineno=57, + end_col_offset=30)], + [], + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=31), + lineno=57, + col_offset=7, + end_lineno=57, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=58, + col_offset=14, + end_lineno=58, + end_col_offset=24), + [ + Constant( + 'unknown operation', + lineno=58, + col_offset=25, + end_lineno=58, + end_col_offset=44)], + [], + lineno=58, + col_offset=14, + end_lineno=58, + end_col_offset=45), + lineno=58, + col_offset=8, + end_lineno=58, + end_col_offset=45)], + [], + lineno=57, + col_offset=4, + end_lineno=58, + end_col_offset=45), + Return( + Call( + Attribute( + Call( + Attribute( + Name( + 'q', + Load(), + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=12), + 'removeprefix', + Load(), + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=25), + [ + Name( + 'prefix', + Load(), + lineno=59, + col_offset=26, + end_lineno=59, + end_col_offset=32)], + [], + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=33), + 'lstrip', + Load(), + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=40), + [], + [], + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=42), + lineno=59, + col_offset=4, + end_lineno=59, + end_col_offset=42)], + [], + lineno=45, + col_offset=0, + end_lineno=59, + end_col_offset=42), + FunctionDef( + 'answer', + arguments( + [], + [ + arg( + 'question', + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'q', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=5)], + Call( + Name( + 'prepare_question', + Load(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=24), + [ + Name( + 'question', + Load(), + lineno=63, + col_offset=25, + end_lineno=63, + end_col_offset=33)], + [], + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=34), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=34), + Assign( + [ + Tuple( + [ + Name( + 'q', + Store(), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=5), + Name( + 'result', + Store(), + lineno=66, + col_offset=7, + end_lineno=66, + end_col_offset=13)], + Store(), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=13)], + Call( + Name( + 'get_number', + Load(), + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=26), + [ + Name( + 'q', + Load(), + lineno=66, + col_offset=27, + end_lineno=66, + end_col_offset=28)], + [], + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=29), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=29), + While( + Compare( + Call( + Name( + 'len', + Load(), + lineno=67, + col_offset=10, + end_lineno=67, + end_col_offset=13), + [ + Name( + 'q', + Load(), + lineno=67, + col_offset=14, + end_lineno=67, + end_col_offset=15)], + [], + lineno=67, + col_offset=10, + end_lineno=67, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 0, + lineno=67, + col_offset=19, + end_lineno=67, + end_col_offset=20)], + lineno=67, + col_offset=10, + end_lineno=67, + end_col_offset=20), + [ + If( + Call( + Attribute( + Subscript( + Name( + 'regex', + Load(), + lineno=71, + col_offset=11, + end_lineno=71, + end_col_offset=16), + Constant( + 'number', + lineno=71, + col_offset=17, + end_lineno=71, + end_col_offset=25), + Load(), + lineno=71, + col_offset=11, + end_lineno=71, + end_col_offset=26), + 'match', + Load(), + lineno=71, + col_offset=11, + end_lineno=71, + end_col_offset=32), + [ + Name( + 'q', + Load(), + lineno=71, + col_offset=33, + end_lineno=71, + end_col_offset=34)], + [], + lineno=71, + col_offset=11, + end_lineno=71, + end_col_offset=35), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=72, + col_offset=18, + end_lineno=72, + end_col_offset=28), + [ + Constant( + 'syntax error', + lineno=72, + col_offset=29, + end_lineno=72, + end_col_offset=43)], + [], + lineno=72, + col_offset=18, + end_lineno=72, + end_col_offset=44), + lineno=72, + col_offset=12, + end_lineno=72, + end_col_offset=44)], + [], + lineno=71, + col_offset=8, + end_lineno=72, + end_col_offset=44), + Assign( + [ + Tuple( + [ + Name( + 'q', + Store(), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=9), + Name( + 'operation', + Store(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=20)], + Store(), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=20)], + Call( + Name( + 'get_operation', + Load(), + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=36), + [ + Name( + 'q', + Load(), + lineno=73, + col_offset=37, + end_lineno=73, + end_col_offset=38)], + [], + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=39), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=39), + Assign( + [ + Tuple( + [ + Name( + 'q', + Store(), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=9), + Name( + 'num', + Store(), + lineno=74, + col_offset=11, + end_lineno=74, + end_col_offset=14)], + Store(), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=14)], + Call( + Name( + 'get_number', + Load(), + lineno=74, + col_offset=17, + end_lineno=74, + end_col_offset=27), + [ + Name( + 'q', + Load(), + lineno=74, + col_offset=28, + end_lineno=74, + end_col_offset=29)], + [], + lineno=74, + col_offset=17, + end_lineno=74, + end_col_offset=30), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=30), + Assign( + [ + Name( + 'result', + Store(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=14)], + Call( + Name( + 'operation', + Load(), + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=26), + [ + Name( + 'result', + Load(), + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=33), + Name( + 'num', + Load(), + lineno=75, + col_offset=35, + end_lineno=75, + end_col_offset=38)], + [], + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=39), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=39)], + [], + lineno=67, + col_offset=4, + end_lineno=75, + end_col_offset=39), + Return( + Name( + 'result', + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=17), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=17)], + [], + lineno=61, + col_offset=0, + end_lineno=76, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=9)], + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=9), + Import( + [ + alias( + 'operator', + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=15)], + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=15), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=10)], + Dict( + [ + Constant( + 'plus', + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=10), + Constant( + 'minus', + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=11), + Constant( + 'multiplied by', + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=19), + Constant( + 'divided by', + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=16)], + [ + Attribute( + Name( + 'operator', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=20), + 'add', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=24), + Attribute( + Name( + 'operator', + Load(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=21), + 'sub', + Load(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=25), + Attribute( + Name( + 'operator', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=29), + 'mul', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=33), + Attribute( + Name( + 'operator', + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=26), + 'floordiv', + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=35)], + lineno=16, + col_offset=13, + end_lineno=21, + end_col_offset=1), + lineno=16, + col_offset=0, + end_lineno=21, + end_col_offset=1), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=23, + col_offset=0, + end_lineno=23, + end_col_offset=5)], + Dict( + [ + Constant( + 'number', + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=12), + Constant( + 'operator', + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=14)], + [ + Call( + Attribute( + Name( + 're', + Load(), + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=16), + 'compile', + Load(), + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=24), + [ + Constant( + '-?\\d+', + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=33)], + [], + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=34), + Call( + Attribute( + Name( + 're', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=18), + 'compile', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=26), + [ + JoinedStr( + [ + Constant( + '(?:', + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=66), + FormattedValue( + Call( + Attribute( + Constant( + '|', + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=36), + 'join', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=41), + [ + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=25, + col_offset=42, + end_lineno=25, + end_col_offset=52), + 'keys', + Load(), + lineno=25, + col_offset=42, + end_lineno=25, + end_col_offset=57), + [], + [], + lineno=25, + col_offset=42, + end_lineno=25, + end_col_offset=59)], + [], + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=60), + -1, + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=66), + Constant( + ')\\b', + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=66)], + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=66)], + [], + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=67)], + lineno=23, + col_offset=8, + end_lineno=26, + end_col_offset=1), + lineno=23, + col_offset=0, + end_lineno=26, + end_col_offset=1), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=5)], + Call( + Attribute( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=13), + Constant( + 'number', + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=22), + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=23), + 'match', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=29), + [ + Name( + 'placeholder_3', + Load(), + lineno=31, + col_offset=30, + end_lineno=31, + end_col_offset=38)], + [], + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=39), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=39), + If( + UnaryOp( + Not(), + Name( + 'placeholder_4', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=12), + lineno=32, + col_offset=7, + end_lineno=32, + end_col_offset=12), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=24), + [ + Constant( + 'syntax error', + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=39)], + [], + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=40), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=40)], + [], + lineno=32, + col_offset=4, + end_lineno=33, + end_col_offset=40), + Return( + List( + [ + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=20), + 'removeprefix', + Load(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=33), + [ + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=35), + 'group', + Load(), + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=41), + [ + Constant( + 0, + lineno=34, + col_offset=42, + end_lineno=34, + end_col_offset=43)], + [], + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=44)], + [], + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=45), + 'lstrip', + Load(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=52), + [], + [], + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=54), + Call( + Name( + 'int', + Load(), + lineno=34, + col_offset=56, + end_lineno=34, + end_col_offset=59), + [ + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=34, + col_offset=60, + end_lineno=34, + end_col_offset=61), + 'group', + Load(), + lineno=34, + col_offset=60, + end_lineno=34, + end_col_offset=67), + [ + Constant( + 0, + lineno=34, + col_offset=68, + end_lineno=34, + end_col_offset=69)], + [], + lineno=34, + col_offset=60, + end_lineno=34, + end_col_offset=70)], + [], + lineno=34, + col_offset=56, + end_lineno=34, + end_col_offset=71)], + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=72), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=72)], + [], + lineno=28, + col_offset=0, + end_lineno=34, + end_col_offset=72), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=36, + col_offset=18, + end_lineno=36, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=5)], + Call( + Attribute( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=13), + Constant( + 'operator', + lineno=40, + col_offset=14, + end_lineno=40, + end_col_offset=24), + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=25), + 'match', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=31), + [ + Name( + 'placeholder_3', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=40)], + [], + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=41), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=41), + If( + UnaryOp( + Not(), + Name( + 'placeholder_4', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=12), + lineno=41, + col_offset=7, + end_lineno=41, + end_col_offset=12), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=24), + [ + Constant( + 'unknown operation', + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=44)], + [], + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=45), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=45)], + [], + lineno=41, + col_offset=4, + end_lineno=42, + end_col_offset=45), + Return( + List( + [ + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=20), + 'removeprefix', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=33), + [ + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=35), + 'group', + Load(), + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=41), + [ + Constant( + 0, + lineno=43, + col_offset=42, + end_lineno=43, + end_col_offset=43)], + [], + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=44)], + [], + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=45), + 'lstrip', + Load(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=52), + [], + [], + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=54), + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=43, + col_offset=56, + end_lineno=43, + end_col_offset=66), + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=43, + col_offset=67, + end_lineno=43, + end_col_offset=68), + 'group', + Load(), + lineno=43, + col_offset=67, + end_lineno=43, + end_col_offset=74), + [ + Constant( + 0, + lineno=43, + col_offset=75, + end_lineno=43, + end_col_offset=76)], + [], + lineno=43, + col_offset=67, + end_lineno=43, + end_col_offset=77), + Load(), + lineno=43, + col_offset=56, + end_lineno=43, + end_col_offset=78)], + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=79), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=79)], + [], + lineno=36, + col_offset=0, + end_lineno=43, + end_col_offset=79), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=5)], + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=16), + 'lower', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=22), + [], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=24), + 'strip', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=30), + [], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=32), + 'removesuffix', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=45), + [ + Constant( + '?', + lineno=53, + col_offset=46, + end_lineno=53, + end_col_offset=49)], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=50), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=50), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=10)], + Constant( + 'what is', + lineno=56, + col_offset=13, + end_lineno=56, + end_col_offset=22), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=22), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=12), + 'startswith', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=23), + [ + Name( + 'placeholder_8', + Load(), + lineno=57, + col_offset=24, + end_lineno=57, + end_col_offset=30)], + [], + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=31), + lineno=57, + col_offset=7, + end_lineno=57, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=58, + col_offset=14, + end_lineno=58, + end_col_offset=24), + [ + Constant( + 'unknown operation', + lineno=58, + col_offset=25, + end_lineno=58, + end_col_offset=44)], + [], + lineno=58, + col_offset=14, + end_lineno=58, + end_col_offset=45), + lineno=58, + col_offset=8, + end_lineno=58, + end_col_offset=45)], + [], + lineno=57, + col_offset=4, + end_lineno=58, + end_col_offset=45), + Return( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=12), + 'removeprefix', + Load(), + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=25), + [ + Name( + 'placeholder_8', + Load(), + lineno=59, + col_offset=26, + end_lineno=59, + end_col_offset=32)], + [], + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=33), + 'lstrip', + Load(), + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=40), + [], + [], + lineno=59, + col_offset=11, + end_lineno=59, + end_col_offset=42), + lineno=59, + col_offset=4, + end_lineno=59, + end_col_offset=42)], + [], + lineno=45, + col_offset=0, + end_lineno=59, + end_col_offset=42), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=5)], + Call( + Name( + 'placeholder_6', + Load(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=24), + [ + Name( + 'placeholder_3', + Load(), + lineno=63, + col_offset=25, + end_lineno=63, + end_col_offset=33)], + [], + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=34), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=34), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=5), + Name( + 'placeholder_10', + Store(), + lineno=66, + col_offset=7, + end_lineno=66, + end_col_offset=13)], + Store(), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=13)], + Call( + Name( + 'placeholder_2', + Load(), + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=26), + [ + Name( + 'placeholder_7', + Load(), + lineno=66, + col_offset=27, + end_lineno=66, + end_col_offset=28)], + [], + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=29), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=29), + While( + Compare( + Call( + Name( + 'len', + Load(), + lineno=67, + col_offset=10, + end_lineno=67, + end_col_offset=13), + [ + Name( + 'placeholder_7', + Load(), + lineno=67, + col_offset=14, + end_lineno=67, + end_col_offset=15)], + [], + lineno=67, + col_offset=10, + end_lineno=67, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 0, + lineno=67, + col_offset=19, + end_lineno=67, + end_col_offset=20)], + lineno=67, + col_offset=10, + end_lineno=67, + end_col_offset=20), + [ + If( + Call( + Attribute( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=71, + col_offset=11, + end_lineno=71, + end_col_offset=16), + Constant( + 'number', + lineno=71, + col_offset=17, + end_lineno=71, + end_col_offset=25), + Load(), + lineno=71, + col_offset=11, + end_lineno=71, + end_col_offset=26), + 'match', + Load(), + lineno=71, + col_offset=11, + end_lineno=71, + end_col_offset=32), + [ + Name( + 'placeholder_7', + Load(), + lineno=71, + col_offset=33, + end_lineno=71, + end_col_offset=34)], + [], + lineno=71, + col_offset=11, + end_lineno=71, + end_col_offset=35), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=72, + col_offset=18, + end_lineno=72, + end_col_offset=28), + [ + Constant( + 'syntax error', + lineno=72, + col_offset=29, + end_lineno=72, + end_col_offset=43)], + [], + lineno=72, + col_offset=18, + end_lineno=72, + end_col_offset=44), + lineno=72, + col_offset=12, + end_lineno=72, + end_col_offset=44)], + [], + lineno=71, + col_offset=8, + end_lineno=72, + end_col_offset=44), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=9), + Name( + 'placeholder_11', + Store(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=20)], + Store(), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=20)], + Call( + Name( + 'placeholder_5', + Load(), + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=36), + [ + Name( + 'placeholder_7', + Load(), + lineno=73, + col_offset=37, + end_lineno=73, + end_col_offset=38)], + [], + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=39), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=39), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=9), + Name( + 'placeholder_12', + Store(), + lineno=74, + col_offset=11, + end_lineno=74, + end_col_offset=14)], + Store(), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=14)], + Call( + Name( + 'placeholder_2', + Load(), + lineno=74, + col_offset=17, + end_lineno=74, + end_col_offset=27), + [ + Name( + 'placeholder_7', + Load(), + lineno=74, + col_offset=28, + end_lineno=74, + end_col_offset=29)], + [], + lineno=74, + col_offset=17, + end_lineno=74, + end_col_offset=30), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=14)], + Call( + Name( + 'placeholder_11', + Load(), + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=26), + [ + Name( + 'placeholder_10', + Load(), + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=33), + Name( + 'placeholder_12', + Load(), + lineno=75, + col_offset=35, + end_lineno=75, + end_col_offset=38)], + [], + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=39), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=39)], + [], + lineno=67, + col_offset=4, + end_lineno=75, + end_col_offset=39), + Return( + Name( + 'placeholder_10', + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=17), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=17)], + [], + lineno=61, + col_offset=0, + end_lineno=76, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-comments-removal/representation.txt b/test/example-comments-removal/representation.txt new file mode 100644 index 0000000..af65698 --- /dev/null +++ b/test/example-comments-removal/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('re', lineno=8, col_offset=7, end_lineno=8, end_col_offset=9)], lineno=8, col_offset=0, end_lineno=8, end_col_offset=9), Import([alias('operator', lineno=9, col_offset=7, end_lineno=9, end_col_offset=15)], lineno=9, col_offset=0, end_lineno=9, end_col_offset=15), Assign([Name('placeholder_0', Store(), lineno=16, col_offset=0, end_lineno=16, end_col_offset=10)], Dict([Constant('plus', lineno=17, col_offset=4, end_lineno=17, end_col_offset=10), Constant('minus', lineno=18, col_offset=4, end_lineno=18, end_col_offset=11), Constant('multiplied by', lineno=19, col_offset=4, end_lineno=19, end_col_offset=19), Constant('divided by', lineno=20, col_offset=4, end_lineno=20, end_col_offset=16)], [Attribute(Name('operator', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=20), 'add', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=24), Attribute(Name('operator', Load(), lineno=18, col_offset=13, end_lineno=18, end_col_offset=21), 'sub', Load(), lineno=18, col_offset=13, end_lineno=18, end_col_offset=25), Attribute(Name('operator', Load(), lineno=19, col_offset=21, end_lineno=19, end_col_offset=29), 'mul', Load(), lineno=19, col_offset=21, end_lineno=19, end_col_offset=33), Attribute(Name('operator', Load(), lineno=20, col_offset=18, end_lineno=20, end_col_offset=26), 'floordiv', Load(), lineno=20, col_offset=18, end_lineno=20, end_col_offset=35)], lineno=16, col_offset=13, end_lineno=21, end_col_offset=1), lineno=16, col_offset=0, end_lineno=21, end_col_offset=1), Assign([Name('placeholder_1', Store(), lineno=23, col_offset=0, end_lineno=23, end_col_offset=5)], Dict([Constant('number', lineno=24, col_offset=4, end_lineno=24, end_col_offset=12), Constant('operator', lineno=25, col_offset=4, end_lineno=25, end_col_offset=14)], [Call(Attribute(Name('re', Load(), lineno=24, col_offset=14, end_lineno=24, end_col_offset=16), 'compile', Load(), lineno=24, col_offset=14, end_lineno=24, end_col_offset=24), [Constant('-?\\d+', lineno=24, col_offset=25, end_lineno=24, end_col_offset=33)], [], lineno=24, col_offset=14, end_lineno=24, end_col_offset=34), Call(Attribute(Name('re', Load(), lineno=25, col_offset=16, end_lineno=25, end_col_offset=18), 'compile', Load(), lineno=25, col_offset=16, end_lineno=25, end_col_offset=26), [JoinedStr([Constant('(?:', lineno=25, col_offset=27, end_lineno=25, end_col_offset=66), FormattedValue(Call(Attribute(Constant('|', lineno=25, col_offset=33, end_lineno=25, end_col_offset=36), 'join', Load(), lineno=25, col_offset=33, end_lineno=25, end_col_offset=41), [Call(Attribute(Name('placeholder_0', Load(), lineno=25, col_offset=42, end_lineno=25, end_col_offset=52), 'keys', Load(), lineno=25, col_offset=42, end_lineno=25, end_col_offset=57), [], [], lineno=25, col_offset=42, end_lineno=25, end_col_offset=59)], [], lineno=25, col_offset=33, end_lineno=25, end_col_offset=60), -1, lineno=25, col_offset=27, end_lineno=25, end_col_offset=66), Constant(')\\b', lineno=25, col_offset=27, end_lineno=25, end_col_offset=66)], lineno=25, col_offset=27, end_lineno=25, end_col_offset=66)], [], lineno=25, col_offset=16, end_lineno=25, end_col_offset=67)], lineno=23, col_offset=8, end_lineno=26, end_col_offset=1), lineno=23, col_offset=0, end_lineno=26, end_col_offset=1), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=28, col_offset=15, end_lineno=28, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=31, col_offset=4, end_lineno=31, end_col_offset=5)], Call(Attribute(Subscript(Name('placeholder_1', Load(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=13), Constant('number', lineno=31, col_offset=14, end_lineno=31, end_col_offset=22), Load(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=23), 'match', Load(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=29), [Name('placeholder_3', Load(), lineno=31, col_offset=30, end_lineno=31, end_col_offset=38)], [], lineno=31, col_offset=8, end_lineno=31, end_col_offset=39), lineno=31, col_offset=4, end_lineno=31, end_col_offset=39), If(UnaryOp(Not(), Name('placeholder_4', Load(), lineno=32, col_offset=11, end_lineno=32, end_col_offset=12), lineno=32, col_offset=7, end_lineno=32, end_col_offset=12), [Raise(Call(Name('ValueError', Load(), lineno=33, col_offset=14, end_lineno=33, end_col_offset=24), [Constant('syntax error', lineno=33, col_offset=25, end_lineno=33, end_col_offset=39)], [], lineno=33, col_offset=14, end_lineno=33, end_col_offset=40), lineno=33, col_offset=8, end_lineno=33, end_col_offset=40)], [], lineno=32, col_offset=4, end_lineno=33, end_col_offset=40), Return(List([Call(Attribute(Call(Attribute(Name('placeholder_3', Load(), lineno=34, col_offset=12, end_lineno=34, end_col_offset=20), 'removeprefix', Load(), lineno=34, col_offset=12, end_lineno=34, end_col_offset=33), [Call(Attribute(Name('placeholder_4', Load(), lineno=34, col_offset=34, end_lineno=34, end_col_offset=35), 'group', Load(), lineno=34, col_offset=34, end_lineno=34, end_col_offset=41), [Constant(0, lineno=34, col_offset=42, end_lineno=34, end_col_offset=43)], [], lineno=34, col_offset=34, end_lineno=34, end_col_offset=44)], [], lineno=34, col_offset=12, end_lineno=34, end_col_offset=45), 'lstrip', Load(), lineno=34, col_offset=12, end_lineno=34, end_col_offset=52), [], [], lineno=34, col_offset=12, end_lineno=34, end_col_offset=54), Call(Name('int', Load(), lineno=34, col_offset=56, end_lineno=34, end_col_offset=59), [Call(Attribute(Name('placeholder_4', Load(), lineno=34, col_offset=60, end_lineno=34, end_col_offset=61), 'group', Load(), lineno=34, col_offset=60, end_lineno=34, end_col_offset=67), [Constant(0, lineno=34, col_offset=68, end_lineno=34, end_col_offset=69)], [], lineno=34, col_offset=60, end_lineno=34, end_col_offset=70)], [], lineno=34, col_offset=56, end_lineno=34, end_col_offset=71)], Load(), lineno=34, col_offset=11, end_lineno=34, end_col_offset=72), lineno=34, col_offset=4, end_lineno=34, end_col_offset=72)], [], lineno=28, col_offset=0, end_lineno=34, end_col_offset=72), FunctionDef('placeholder_5', arguments([], [arg('placeholder_3', lineno=36, col_offset=18, end_lineno=36, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=40, col_offset=4, end_lineno=40, end_col_offset=5)], Call(Attribute(Subscript(Name('placeholder_1', Load(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=13), Constant('operator', lineno=40, col_offset=14, end_lineno=40, end_col_offset=24), Load(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=25), 'match', Load(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=31), [Name('placeholder_3', Load(), lineno=40, col_offset=32, end_lineno=40, end_col_offset=40)], [], lineno=40, col_offset=8, end_lineno=40, end_col_offset=41), lineno=40, col_offset=4, end_lineno=40, end_col_offset=41), If(UnaryOp(Not(), Name('placeholder_4', Load(), lineno=41, col_offset=11, end_lineno=41, end_col_offset=12), lineno=41, col_offset=7, end_lineno=41, end_col_offset=12), [Raise(Call(Name('ValueError', Load(), lineno=42, col_offset=14, end_lineno=42, end_col_offset=24), [Constant('unknown operation', lineno=42, col_offset=25, end_lineno=42, end_col_offset=44)], [], lineno=42, col_offset=14, end_lineno=42, end_col_offset=45), lineno=42, col_offset=8, end_lineno=42, end_col_offset=45)], [], lineno=41, col_offset=4, end_lineno=42, end_col_offset=45), Return(List([Call(Attribute(Call(Attribute(Name('placeholder_3', Load(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=20), 'removeprefix', Load(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=33), [Call(Attribute(Name('placeholder_4', Load(), lineno=43, col_offset=34, end_lineno=43, end_col_offset=35), 'group', Load(), lineno=43, col_offset=34, end_lineno=43, end_col_offset=41), [Constant(0, lineno=43, col_offset=42, end_lineno=43, end_col_offset=43)], [], lineno=43, col_offset=34, end_lineno=43, end_col_offset=44)], [], lineno=43, col_offset=12, end_lineno=43, end_col_offset=45), 'lstrip', Load(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=52), [], [], lineno=43, col_offset=12, end_lineno=43, end_col_offset=54), Subscript(Name('placeholder_0', Load(), lineno=43, col_offset=56, end_lineno=43, end_col_offset=66), Call(Attribute(Name('placeholder_4', Load(), lineno=43, col_offset=67, end_lineno=43, end_col_offset=68), 'group', Load(), lineno=43, col_offset=67, end_lineno=43, end_col_offset=74), [Constant(0, lineno=43, col_offset=75, end_lineno=43, end_col_offset=76)], [], lineno=43, col_offset=67, end_lineno=43, end_col_offset=77), Load(), lineno=43, col_offset=56, end_lineno=43, end_col_offset=78)], Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=79), lineno=43, col_offset=4, end_lineno=43, end_col_offset=79)], [], lineno=36, col_offset=0, end_lineno=43, end_col_offset=79), FunctionDef('placeholder_6', arguments([], [arg('placeholder_3', lineno=45, col_offset=21, end_lineno=45, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=53, col_offset=4, end_lineno=53, end_col_offset=5)], Call(Attribute(Call(Attribute(Call(Attribute(Name('placeholder_3', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=16), 'lower', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=22), [], [], lineno=53, col_offset=8, end_lineno=53, end_col_offset=24), 'strip', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=30), [], [], lineno=53, col_offset=8, end_lineno=53, end_col_offset=32), 'removesuffix', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=45), [Constant('?', lineno=53, col_offset=46, end_lineno=53, end_col_offset=49)], [], lineno=53, col_offset=8, end_lineno=53, end_col_offset=50), lineno=53, col_offset=4, end_lineno=53, end_col_offset=50), Assign([Name('placeholder_8', Store(), lineno=56, col_offset=4, end_lineno=56, end_col_offset=10)], Constant('what is', lineno=56, col_offset=13, end_lineno=56, end_col_offset=22), lineno=56, col_offset=4, end_lineno=56, end_col_offset=22), If(UnaryOp(Not(), Call(Attribute(Name('placeholder_7', Load(), lineno=57, col_offset=11, end_lineno=57, end_col_offset=12), 'startswith', Load(), lineno=57, col_offset=11, end_lineno=57, end_col_offset=23), [Name('placeholder_8', Load(), lineno=57, col_offset=24, end_lineno=57, end_col_offset=30)], [], lineno=57, col_offset=11, end_lineno=57, end_col_offset=31), lineno=57, col_offset=7, end_lineno=57, end_col_offset=31), [Raise(Call(Name('ValueError', Load(), lineno=58, col_offset=14, end_lineno=58, end_col_offset=24), [Constant('unknown operation', lineno=58, col_offset=25, end_lineno=58, end_col_offset=44)], [], lineno=58, col_offset=14, end_lineno=58, end_col_offset=45), lineno=58, col_offset=8, end_lineno=58, end_col_offset=45)], [], lineno=57, col_offset=4, end_lineno=58, end_col_offset=45), Return(Call(Attribute(Call(Attribute(Name('placeholder_7', Load(), lineno=59, col_offset=11, end_lineno=59, end_col_offset=12), 'removeprefix', Load(), lineno=59, col_offset=11, end_lineno=59, end_col_offset=25), [Name('placeholder_8', Load(), lineno=59, col_offset=26, end_lineno=59, end_col_offset=32)], [], lineno=59, col_offset=11, end_lineno=59, end_col_offset=33), 'lstrip', Load(), lineno=59, col_offset=11, end_lineno=59, end_col_offset=40), [], [], lineno=59, col_offset=11, end_lineno=59, end_col_offset=42), lineno=59, col_offset=4, end_lineno=59, end_col_offset=42)], [], lineno=45, col_offset=0, end_lineno=59, end_col_offset=42), FunctionDef('placeholder_9', arguments([], [arg('placeholder_3', lineno=61, col_offset=11, end_lineno=61, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=63, col_offset=4, end_lineno=63, end_col_offset=5)], Call(Name('placeholder_6', Load(), lineno=63, col_offset=8, end_lineno=63, end_col_offset=24), [Name('placeholder_3', Load(), lineno=63, col_offset=25, end_lineno=63, end_col_offset=33)], [], lineno=63, col_offset=8, end_lineno=63, end_col_offset=34), lineno=63, col_offset=4, end_lineno=63, end_col_offset=34), Assign([Tuple([Name('placeholder_7', Store(), lineno=66, col_offset=4, end_lineno=66, end_col_offset=5), Name('placeholder_10', Store(), lineno=66, col_offset=7, end_lineno=66, end_col_offset=13)], Store(), lineno=66, col_offset=4, end_lineno=66, end_col_offset=13)], Call(Name('placeholder_2', Load(), lineno=66, col_offset=16, end_lineno=66, end_col_offset=26), [Name('placeholder_7', Load(), lineno=66, col_offset=27, end_lineno=66, end_col_offset=28)], [], lineno=66, col_offset=16, end_lineno=66, end_col_offset=29), lineno=66, col_offset=4, end_lineno=66, end_col_offset=29), While(Compare(Call(Name('len', Load(), lineno=67, col_offset=10, end_lineno=67, end_col_offset=13), [Name('placeholder_7', Load(), lineno=67, col_offset=14, end_lineno=67, end_col_offset=15)], [], lineno=67, col_offset=10, end_lineno=67, end_col_offset=16), [Gt()], [Constant(0, lineno=67, col_offset=19, end_lineno=67, end_col_offset=20)], lineno=67, col_offset=10, end_lineno=67, end_col_offset=20), [If(Call(Attribute(Subscript(Name('placeholder_1', Load(), lineno=71, col_offset=11, end_lineno=71, end_col_offset=16), Constant('number', lineno=71, col_offset=17, end_lineno=71, end_col_offset=25), Load(), lineno=71, col_offset=11, end_lineno=71, end_col_offset=26), 'match', Load(), lineno=71, col_offset=11, end_lineno=71, end_col_offset=32), [Name('placeholder_7', Load(), lineno=71, col_offset=33, end_lineno=71, end_col_offset=34)], [], lineno=71, col_offset=11, end_lineno=71, end_col_offset=35), [Raise(Call(Name('ValueError', Load(), lineno=72, col_offset=18, end_lineno=72, end_col_offset=28), [Constant('syntax error', lineno=72, col_offset=29, end_lineno=72, end_col_offset=43)], [], lineno=72, col_offset=18, end_lineno=72, end_col_offset=44), lineno=72, col_offset=12, end_lineno=72, end_col_offset=44)], [], lineno=71, col_offset=8, end_lineno=72, end_col_offset=44), Assign([Tuple([Name('placeholder_7', Store(), lineno=73, col_offset=8, end_lineno=73, end_col_offset=9), Name('placeholder_11', Store(), lineno=73, col_offset=11, end_lineno=73, end_col_offset=20)], Store(), lineno=73, col_offset=8, end_lineno=73, end_col_offset=20)], Call(Name('placeholder_5', Load(), lineno=73, col_offset=23, end_lineno=73, end_col_offset=36), [Name('placeholder_7', Load(), lineno=73, col_offset=37, end_lineno=73, end_col_offset=38)], [], lineno=73, col_offset=23, end_lineno=73, end_col_offset=39), lineno=73, col_offset=8, end_lineno=73, end_col_offset=39), Assign([Tuple([Name('placeholder_7', Store(), lineno=74, col_offset=8, end_lineno=74, end_col_offset=9), Name('placeholder_12', Store(), lineno=74, col_offset=11, end_lineno=74, end_col_offset=14)], Store(), lineno=74, col_offset=8, end_lineno=74, end_col_offset=14)], Call(Name('placeholder_2', Load(), lineno=74, col_offset=17, end_lineno=74, end_col_offset=27), [Name('placeholder_7', Load(), lineno=74, col_offset=28, end_lineno=74, end_col_offset=29)], [], lineno=74, col_offset=17, end_lineno=74, end_col_offset=30), lineno=74, col_offset=8, end_lineno=74, end_col_offset=30), Assign([Name('placeholder_10', Store(), lineno=75, col_offset=8, end_lineno=75, end_col_offset=14)], Call(Name('placeholder_11', Load(), lineno=75, col_offset=17, end_lineno=75, end_col_offset=26), [Name('placeholder_10', Load(), lineno=75, col_offset=27, end_lineno=75, end_col_offset=33), Name('placeholder_12', Load(), lineno=75, col_offset=35, end_lineno=75, end_col_offset=38)], [], lineno=75, col_offset=17, end_lineno=75, end_col_offset=39), lineno=75, col_offset=8, end_lineno=75, end_col_offset=39)], [], lineno=67, col_offset=4, end_lineno=75, end_col_offset=39), Return(Name('placeholder_10', Load(), lineno=76, col_offset=11, end_lineno=76, end_col_offset=17), lineno=76, col_offset=4, end_lineno=76, end_col_offset=17)], [], lineno=61, col_offset=0, end_lineno=76, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/example-docstring-removal/.meta/config.json b/test/example-docstring-removal/.meta/config.json new file mode 100644 index 0000000..179b1ba --- /dev/null +++ b/test/example-docstring-removal/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_docstring_removal.py" + ] + } +} \ No newline at end of file diff --git a/test/example-docstring-removal/example_docstring_removal.py b/test/example-docstring-removal/example_docstring_removal.py new file mode 100644 index 0000000..48c6c43 --- /dev/null +++ b/test/example-docstring-removal/example_docstring_removal.py @@ -0,0 +1,67 @@ +""" This module helps little sister with her vocabulary homework. + + And this is a multi-line module level docstring. It should be + removed when the representation is processed. + """ + + +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + return 'un' + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + + multi_line_string = """This is a multi-line string. + This should NOT get cleaned as a docstring, but retained, because it is assigned + a name, and is therefore a plain string, and not a docstring.""" + + return (" :: " + vocab_words[0]).join(vocab_words) + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + MULTI_LINE_CONSTANT = """This is a multi-line string constant. + This should NOT get cleaned as a docstring, but retained, because it is assigned + a name, and is therefore a plain string, and not a docstring.""" + + return word[:-4] if word[-5] != 'i' else word[:-5] + 'y' + + +def adjective_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + return sentence.split()[index].strip(".") + 'en' \ No newline at end of file diff --git a/test/example-docstring-removal/mapping.json b/test/example-docstring-removal/mapping.json new file mode 100644 index 0000000..3e12d5c --- /dev/null +++ b/test/example-docstring-removal/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "add_prefix_un", + "placeholder_1": "word", + "placeholder_2": "make_word_groups", + "placeholder_3": "vocab_words", + "placeholder_4": "multi_line_string", + "placeholder_5": "remove_suffix_ness", + "placeholder_6": "MULTI_LINE_CONSTANT", + "placeholder_7": "adjective_to_verb", + "placeholder_8": "sentence", + "placeholder_9": "index" +} \ No newline at end of file diff --git a/test/example-docstring-removal/representation.json b/test/example-docstring-removal/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-docstring-removal/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-docstring-removal/representation.out b/test/example-docstring-removal/representation.out new file mode 100644 index 0000000..f54259e --- /dev/null +++ b/test/example-docstring-removal/representation.out @@ -0,0 +1,880 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return "un" + placeholder_1 + + +def placeholder_2(placeholder_3): + placeholder_4 = "This is a multi-line string.\n This should NOT get cleaned as a docstring, but retained, because it is assigned\n a name, and is therefore a plain string, and not a docstring." + return (" :: " + placeholder_3[0]).join(placeholder_3) + + +def placeholder_5(placeholder_1): + placeholder_6 = "This is a multi-line string constant.\n This should NOT get cleaned as a docstring, but retained, because it is assigned\n a name, and is therefore a plain string, and not a docstring." + return placeholder_1[:-4] if placeholder_1[-5] != "i" else placeholder_1[:-5] + "y" + + +def placeholder_7(placeholder_8, placeholder_9): + return placeholder_8.split()[placeholder_9].strip(".") + "en" + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + ' This module helps little sister with her vocabulary homework.\n\n And this is a multi-line module level docstring. It should be\n removed when the representation is processed.\n ', + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=4), + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=4), + FunctionDef( + 'add_prefix_un', + arguments( + [], + [ + arg( + 'word', + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "\n\n :param word: str of a root word\n :return: str of root word with un prefix\n\n This function takes `word` as a parameter and\n returns a new word with an 'un' prefix.\n ", + lineno=9, + col_offset=4, + end_lineno=16, + end_col_offset=7), + lineno=9, + col_offset=4, + end_lineno=16, + end_col_offset=7), + Return( + BinOp( + Constant( + 'un', + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=15), + Add(), + Name( + 'word', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=22), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=22), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=22)], + [], + lineno=8, + col_offset=0, + end_lineno=17, + end_col_offset=22), + FunctionDef( + 'make_word_groups', + arguments( + [], + [ + arg( + 'vocab_words', + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "\n\n :param vocab_words: list of vocabulary words with a prefix.\n :return: str of prefix followed by vocabulary words with\n prefix applied, separated by ' :: '.\n\n This function takes a `vocab_words` list and returns a string\n with the prefix and the words with prefix applied, separated\n by ' :: '.\n ", + lineno=21, + col_offset=4, + end_lineno=30, + end_col_offset=7), + lineno=21, + col_offset=4, + end_lineno=30, + end_col_offset=7), + Assign( + [ + Name( + 'multi_line_string', + Store(), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=21)], + Constant( + 'This is a multi-line string.\n This should NOT get cleaned as a docstring, but retained, because it is assigned\n a name, and is therefore a plain string, and not a docstring.', + lineno=32, + col_offset=24, + end_lineno=34, + end_col_offset=68), + lineno=32, + col_offset=4, + end_lineno=34, + end_col_offset=68), + Return( + Call( + Attribute( + BinOp( + Constant( + ' :: ', + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=18), + Add(), + Subscript( + Name( + 'vocab_words', + Load(), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=32), + Constant( + 0, + lineno=36, + col_offset=33, + end_lineno=36, + end_col_offset=34), + Load(), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=35), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=35), + 'join', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=41), + [ + Name( + 'vocab_words', + Load(), + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=53)], + [], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=54), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=54)], + [], + lineno=20, + col_offset=0, + end_lineno=36, + end_col_offset=54), + FunctionDef( + 'remove_suffix_ness', + arguments( + [], + [ + arg( + 'word', + lineno=39, + col_offset=23, + end_lineno=39, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param word: str of word to remove suffix from.\n :return: str of word with suffix removed & spelling adjusted.\n\n This function takes in a word and returns the base word with `ness` removed.\n ', + lineno=40, + col_offset=4, + end_lineno=46, + end_col_offset=7), + lineno=40, + col_offset=4, + end_lineno=46, + end_col_offset=7), + Assign( + [ + Name( + 'MULTI_LINE_CONSTANT', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=23)], + Constant( + 'This is a multi-line string constant.\n This should NOT get cleaned as a docstring, but retained, because it is assigned\n a name, and is therefore a plain string, and not a docstring.', + lineno=48, + col_offset=26, + end_lineno=50, + end_col_offset=71), + lineno=48, + col_offset=4, + end_lineno=50, + end_col_offset=71), + Return( + IfExp( + Compare( + Subscript( + Name( + 'word', + Load(), + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=28), + UnaryOp( + USub(), + Constant( + 5, + lineno=52, + col_offset=30, + end_lineno=52, + end_col_offset=31), + lineno=52, + col_offset=29, + end_lineno=52, + end_col_offset=31), + Load(), + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=32), + [ + NotEq()], + [ + Constant( + 'i', + lineno=52, + col_offset=36, + end_lineno=52, + end_col_offset=39)], + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=39), + Subscript( + Name( + 'word', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=15), + Slice( + upper=UnaryOp( + USub(), + Constant( + 4, + lineno=52, + col_offset=18, + end_lineno=52, + end_col_offset=19), + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=19), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=19), + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=20), + BinOp( + Subscript( + Name( + 'word', + Load(), + lineno=52, + col_offset=45, + end_lineno=52, + end_col_offset=49), + Slice( + upper=UnaryOp( + USub(), + Constant( + 5, + lineno=52, + col_offset=52, + end_lineno=52, + end_col_offset=53), + lineno=52, + col_offset=51, + end_lineno=52, + end_col_offset=53), + lineno=52, + col_offset=50, + end_lineno=52, + end_col_offset=53), + Load(), + lineno=52, + col_offset=45, + end_lineno=52, + end_col_offset=54), + Add(), + Constant( + 'y', + lineno=52, + col_offset=57, + end_lineno=52, + end_col_offset=60), + lineno=52, + col_offset=45, + end_lineno=52, + end_col_offset=60), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=60), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=60)], + [], + lineno=39, + col_offset=0, + end_lineno=52, + end_col_offset=60), + FunctionDef( + 'adjective_to_verb', + arguments( + [], + [ + arg( + 'sentence', + lineno=55, + col_offset=22, + end_lineno=55, + end_col_offset=30), + arg( + 'index', + lineno=55, + col_offset=32, + end_lineno=55, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param sentence: str that uses the word in sentence\n :param index: index of the word to remove and transform\n :return: str word that changes the extracted adjective to a verb.\n\n A function takes a `sentence` using the\n vocabulary word, and the `index` of the word once that sentence\n is split apart. The function should return the extracted\n adjective as a verb.\n ', + lineno=56, + col_offset=4, + end_lineno=66, + end_col_offset=7), + lineno=56, + col_offset=4, + end_lineno=66, + end_col_offset=7), + Return( + BinOp( + Call( + Attribute( + Subscript( + Call( + Attribute( + Name( + 'sentence', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=19), + 'split', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=25), + [], + [], + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=27), + Name( + 'index', + Load(), + lineno=67, + col_offset=28, + end_lineno=67, + end_col_offset=33), + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=34), + 'strip', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=40), + [ + Constant( + '.', + lineno=67, + col_offset=41, + end_lineno=67, + end_col_offset=44)], + [], + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=45), + Add(), + Constant( + 'en', + lineno=67, + col_offset=48, + end_lineno=67, + end_col_offset=52), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=52), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=52)], + [], + lineno=55, + col_offset=0, + end_lineno=67, + end_col_offset=52)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Constant( + 'un', + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=15), + Add(), + Name( + 'placeholder_1', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=22), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=22), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=22)], + [], + lineno=8, + col_offset=0, + end_lineno=17, + end_col_offset=22), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=21)], + Constant( + 'This is a multi-line string.\n This should NOT get cleaned as a docstring, but retained, because it is assigned\n a name, and is therefore a plain string, and not a docstring.', + lineno=32, + col_offset=24, + end_lineno=34, + end_col_offset=68), + lineno=32, + col_offset=4, + end_lineno=34, + end_col_offset=68), + Return( + Call( + Attribute( + BinOp( + Constant( + ' :: ', + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=18), + Add(), + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=32), + Constant( + 0, + lineno=36, + col_offset=33, + end_lineno=36, + end_col_offset=34), + Load(), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=35), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=35), + 'join', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=41), + [ + Name( + 'placeholder_3', + Load(), + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=53)], + [], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=54), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=54)], + [], + lineno=20, + col_offset=0, + end_lineno=36, + end_col_offset=54), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=39, + col_offset=23, + end_lineno=39, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=23)], + Constant( + 'This is a multi-line string constant.\n This should NOT get cleaned as a docstring, but retained, because it is assigned\n a name, and is therefore a plain string, and not a docstring.', + lineno=48, + col_offset=26, + end_lineno=50, + end_col_offset=71), + lineno=48, + col_offset=4, + end_lineno=50, + end_col_offset=71), + Return( + IfExp( + Compare( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=28), + UnaryOp( + USub(), + Constant( + 5, + lineno=52, + col_offset=30, + end_lineno=52, + end_col_offset=31), + lineno=52, + col_offset=29, + end_lineno=52, + end_col_offset=31), + Load(), + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=32), + [ + NotEq()], + [ + Constant( + 'i', + lineno=52, + col_offset=36, + end_lineno=52, + end_col_offset=39)], + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=39), + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=15), + Slice( + upper=UnaryOp( + USub(), + Constant( + 4, + lineno=52, + col_offset=18, + end_lineno=52, + end_col_offset=19), + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=19), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=19), + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=20), + BinOp( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=52, + col_offset=45, + end_lineno=52, + end_col_offset=49), + Slice( + upper=UnaryOp( + USub(), + Constant( + 5, + lineno=52, + col_offset=52, + end_lineno=52, + end_col_offset=53), + lineno=52, + col_offset=51, + end_lineno=52, + end_col_offset=53), + lineno=52, + col_offset=50, + end_lineno=52, + end_col_offset=53), + Load(), + lineno=52, + col_offset=45, + end_lineno=52, + end_col_offset=54), + Add(), + Constant( + 'y', + lineno=52, + col_offset=57, + end_lineno=52, + end_col_offset=60), + lineno=52, + col_offset=45, + end_lineno=52, + end_col_offset=60), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=60), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=60)], + [], + lineno=39, + col_offset=0, + end_lineno=52, + end_col_offset=60), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=55, + col_offset=22, + end_lineno=55, + end_col_offset=30), + arg( + 'placeholder_9', + lineno=55, + col_offset=32, + end_lineno=55, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Call( + Attribute( + Subscript( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=19), + 'split', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=25), + [], + [], + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=27), + Name( + 'placeholder_9', + Load(), + lineno=67, + col_offset=28, + end_lineno=67, + end_col_offset=33), + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=34), + 'strip', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=40), + [ + Constant( + '.', + lineno=67, + col_offset=41, + end_lineno=67, + end_col_offset=44)], + [], + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=45), + Add(), + Constant( + 'en', + lineno=67, + col_offset=48, + end_lineno=67, + end_col_offset=52), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=52), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=52)], + [], + lineno=55, + col_offset=0, + end_lineno=67, + end_col_offset=52)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-docstring-removal/representation.txt b/test/example-docstring-removal/representation.txt new file mode 100644 index 0000000..b46034a --- /dev/null +++ b/test/example-docstring-removal/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=8, col_offset=18, end_lineno=8, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Constant('un', lineno=17, col_offset=11, end_lineno=17, end_col_offset=15), Add(), Name('placeholder_1', Load(), lineno=17, col_offset=18, end_lineno=17, end_col_offset=22), lineno=17, col_offset=11, end_lineno=17, end_col_offset=22), lineno=17, col_offset=4, end_lineno=17, end_col_offset=22)], [], lineno=8, col_offset=0, end_lineno=17, end_col_offset=22), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=20, col_offset=21, end_lineno=20, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=32, col_offset=4, end_lineno=32, end_col_offset=21)], Constant('This is a multi-line string.\n This should NOT get cleaned as a docstring, but retained, because it is assigned\n a name, and is therefore a plain string, and not a docstring.', lineno=32, col_offset=24, end_lineno=34, end_col_offset=68), lineno=32, col_offset=4, end_lineno=34, end_col_offset=68), Return(Call(Attribute(BinOp(Constant(' :: ', lineno=36, col_offset=12, end_lineno=36, end_col_offset=18), Add(), Subscript(Name('placeholder_3', Load(), lineno=36, col_offset=21, end_lineno=36, end_col_offset=32), Constant(0, lineno=36, col_offset=33, end_lineno=36, end_col_offset=34), Load(), lineno=36, col_offset=21, end_lineno=36, end_col_offset=35), lineno=36, col_offset=12, end_lineno=36, end_col_offset=35), 'join', Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=41), [Name('placeholder_3', Load(), lineno=36, col_offset=42, end_lineno=36, end_col_offset=53)], [], lineno=36, col_offset=11, end_lineno=36, end_col_offset=54), lineno=36, col_offset=4, end_lineno=36, end_col_offset=54)], [], lineno=20, col_offset=0, end_lineno=36, end_col_offset=54), FunctionDef('placeholder_5', arguments([], [arg('placeholder_1', lineno=39, col_offset=23, end_lineno=39, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=48, col_offset=4, end_lineno=48, end_col_offset=23)], Constant('This is a multi-line string constant.\n This should NOT get cleaned as a docstring, but retained, because it is assigned\n a name, and is therefore a plain string, and not a docstring.', lineno=48, col_offset=26, end_lineno=50, end_col_offset=71), lineno=48, col_offset=4, end_lineno=50, end_col_offset=71), Return(IfExp(Compare(Subscript(Name('placeholder_1', Load(), lineno=52, col_offset=24, end_lineno=52, end_col_offset=28), UnaryOp(USub(), Constant(5, lineno=52, col_offset=30, end_lineno=52, end_col_offset=31), lineno=52, col_offset=29, end_lineno=52, end_col_offset=31), Load(), lineno=52, col_offset=24, end_lineno=52, end_col_offset=32), [NotEq()], [Constant('i', lineno=52, col_offset=36, end_lineno=52, end_col_offset=39)], lineno=52, col_offset=24, end_lineno=52, end_col_offset=39), Subscript(Name('placeholder_1', Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=15), Slice(upper=UnaryOp(USub(), Constant(4, lineno=52, col_offset=18, end_lineno=52, end_col_offset=19), lineno=52, col_offset=17, end_lineno=52, end_col_offset=19), lineno=52, col_offset=16, end_lineno=52, end_col_offset=19), Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=20), BinOp(Subscript(Name('placeholder_1', Load(), lineno=52, col_offset=45, end_lineno=52, end_col_offset=49), Slice(upper=UnaryOp(USub(), Constant(5, lineno=52, col_offset=52, end_lineno=52, end_col_offset=53), lineno=52, col_offset=51, end_lineno=52, end_col_offset=53), lineno=52, col_offset=50, end_lineno=52, end_col_offset=53), Load(), lineno=52, col_offset=45, end_lineno=52, end_col_offset=54), Add(), Constant('y', lineno=52, col_offset=57, end_lineno=52, end_col_offset=60), lineno=52, col_offset=45, end_lineno=52, end_col_offset=60), lineno=52, col_offset=11, end_lineno=52, end_col_offset=60), lineno=52, col_offset=4, end_lineno=52, end_col_offset=60)], [], lineno=39, col_offset=0, end_lineno=52, end_col_offset=60), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=55, col_offset=22, end_lineno=55, end_col_offset=30), arg('placeholder_9', lineno=55, col_offset=32, end_lineno=55, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Call(Attribute(Subscript(Call(Attribute(Name('placeholder_8', Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=19), 'split', Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=25), [], [], lineno=67, col_offset=11, end_lineno=67, end_col_offset=27), Name('placeholder_9', Load(), lineno=67, col_offset=28, end_lineno=67, end_col_offset=33), Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=34), 'strip', Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=40), [Constant('.', lineno=67, col_offset=41, end_lineno=67, end_col_offset=44)], [], lineno=67, col_offset=11, end_lineno=67, end_col_offset=45), Add(), Constant('en', lineno=67, col_offset=48, end_lineno=67, end_col_offset=52), lineno=67, col_offset=11, end_lineno=67, end_col_offset=52), lineno=67, col_offset=4, end_lineno=67, end_col_offset=52)], [], lineno=55, col_offset=0, end_lineno=67, end_col_offset=52)], []) \ No newline at end of file diff --git a/test/example-generator-normalization/.meta/config.json b/test/example-generator-normalization/.meta/config.json new file mode 100644 index 0000000..f03d051 --- /dev/null +++ b/test/example-generator-normalization/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "J08K" + ], + "files": { + "solution": [ + "example_generator_normalization.py" + ] + } +} diff --git a/test/example-generator-normalization/example_generator_normalization.py b/test/example-generator-normalization/example_generator_normalization.py new file mode 100644 index 0000000..8261795 --- /dev/null +++ b/test/example-generator-normalization/example_generator_normalization.py @@ -0,0 +1,80 @@ +"""Functions to automate Conda airlines ticketing system.""" + +import math + +SEATS_IN_ROW = ['A', 'B', 'C', 'D'] + + +def generate_seat_letters(number): + """Generate a series of letters for airline seats. + + :param number: int - total number of seat letters to be generated. + :return: generator - generator that yields seat letters. + + Seat letters are generated from A to D. + After D it should start again with A. + + Example: A, B, C, D + + """ + + for seat in range(number): + yield SEATS_IN_ROW[seat % 4] + + +def generate_seats(number): + """Generate a series of identifiers for airline seats. + + :param number: int - total number of seats to be generated. + :return: generator - generator that yields seat numbers. + + A seat number consists of the row number and the seat letter. + + There is no row 13. + Each row has 4 seats. + + Seats should be sorted from low to high. + + Example: 3C, 3D, 4A, 4B + + """ + + number = number + 4 if number >= 13 else number + letters = generate_seat_letters(number) + for seat in range(number): + row_number = math.ceil((seat+1) / 4) + if row_number != 13: + yield f'{str(row_number)}{next(letters)}' + + # return (f'{str(row_number)}{next(letters)}' for seat in range(number) + # if (row_number := math.ceil((seat+1) / 4)) and row_number != 13) + + +def assign_seats(passengers): + """Assign seats to passengers. + + :param passengers: list[str] - a list of strings containing names of passengers. + :return: dict - with the names of the passengers as keys and seat numbers as values. + + Example output: {"Adele": "1A", "Björk": "1B"} + + """ + + number = len(passengers) + output = {} + for passenger, seat_number in zip(passengers, generate_seats(number)): + output[passenger] = seat_number + return output + +def generate_codes(seat_numbers, flight_id): + """Generate codes for a ticket. + + :param seat_numbers: list[str] - list of seat numbers. + :param flight_id: str - string containing the flight identifier. + :return: generator - generator that yields 12 character long ticket codes. + + """ + + for seat in seat_numbers: + base_string = f'{seat}{flight_id}' + yield base_string + '0' * (12 - len(base_string)) diff --git a/test/example-generator-normalization/mapping.json b/test/example-generator-normalization/mapping.json new file mode 100644 index 0000000..fc44135 --- /dev/null +++ b/test/example-generator-normalization/mapping.json @@ -0,0 +1,18 @@ +{ + "placeholder_0": "SEATS_IN_ROW", + "placeholder_1": "generate_seat_letters", + "placeholder_2": "number", + "placeholder_3": "seat", + "placeholder_4": "generate_seats", + "placeholder_5": "letters", + "placeholder_6": "row_number", + "placeholder_7": "assign_seats", + "placeholder_8": "passengers", + "placeholder_9": "output", + "placeholder_10": "passenger", + "placeholder_11": "seat_number", + "placeholder_12": "generate_codes", + "placeholder_13": "seat_numbers", + "placeholder_14": "flight_id", + "placeholder_15": "base_string" +} \ No newline at end of file diff --git a/test/example-generator-normalization/representation.json b/test/example-generator-normalization/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-generator-normalization/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-generator-normalization/representation.out b/test/example-generator-normalization/representation.out new file mode 100644 index 0000000..d7add39 --- /dev/null +++ b/test/example-generator-normalization/representation.out @@ -0,0 +1,1741 @@ +## BEGIN NORMALIZED CODE ## +import math + +placeholder_0 = ["A", "B", "C", "D"] + + +def placeholder_1(placeholder_2): + for placeholder_3 in range(placeholder_2): + yield SEATS_IN_ROW[seat % 4] + + +def placeholder_4(placeholder_2): + placeholder_2 = placeholder_2 + 4 if placeholder_2 >= 13 else placeholder_2 + placeholder_5 = placeholder_1(placeholder_2) + for placeholder_3 in range(placeholder_2): + placeholder_6 = math.ceil((placeholder_3 + 1) / 4) + if placeholder_6 != 13: + yield f"{str(row_number)}{next(letters)}" + + +def placeholder_7(placeholder_8): + placeholder_2 = len(placeholder_8) + placeholder_9 = {} + for placeholder_10, placeholder_11 in zip( + placeholder_8, placeholder_4(placeholder_2) + ): + placeholder_9[placeholder_10] = placeholder_11 + return placeholder_9 + + +def placeholder_12(placeholder_13, placeholder_14): + for placeholder_3 in placeholder_13: + placeholder_15 = f"{placeholder_3}{placeholder_14}" + yield (base_string + "0" * (12 - len(base_string))) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to automate Conda airlines ticketing system.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=60), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=60), + Import( + [ + alias( + 'math', + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=11)], + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=11), + Assign( + [ + Name( + 'SEATS_IN_ROW', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=12)], + List( + [ + Constant( + 'A', + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=19), + Constant( + 'B', + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + Constant( + 'C', + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=29), + Constant( + 'D', + lineno=5, + col_offset=31, + end_lineno=5, + end_col_offset=34)], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=35), + FunctionDef( + 'generate_seat_letters', + arguments( + [], + [ + arg( + 'number', + lineno=8, + col_offset=26, + end_lineno=8, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Generate a series of letters for airline seats.\n\n :param number: int - total number of seat letters to be generated.\n :return: generator - generator that yields seat letters.\n\n Seat letters are generated from A to D.\n After D it should start again with A.\n\n Example: A, B, C, D\n\n ', + lineno=9, + col_offset=4, + end_lineno=19, + end_col_offset=7), + lineno=9, + col_offset=4, + end_lineno=19, + end_col_offset=7), + For( + Name( + 'seat', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=21), + [ + Name( + 'number', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=28)], + [], + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=29), + [ + Expr( + Yield( + Subscript( + Name( + 'SEATS_IN_ROW', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=26), + BinOp( + Name( + 'seat', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=31), + Mod(), + Constant( + 4, + lineno=22, + col_offset=34, + end_lineno=22, + end_col_offset=35), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=35), + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=36), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=36), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=36)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=36)], + [], + lineno=8, + col_offset=0, + end_lineno=22, + end_col_offset=36), + FunctionDef( + 'generate_seats', + arguments( + [], + [ + arg( + 'number', + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Generate a series of identifiers for airline seats.\n\n :param number: int - total number of seats to be generated.\n :return: generator - generator that yields seat numbers.\n\n A seat number consists of the row number and the seat letter.\n\n There is no row 13.\n Each row has 4 seats.\n\n Seats should be sorted from low to high.\n\n Example: 3C, 3D, 4A, 4B\n\n ', + lineno=26, + col_offset=4, + end_lineno=40, + end_col_offset=7), + lineno=26, + col_offset=4, + end_lineno=40, + end_col_offset=7), + Assign( + [ + Name( + 'number', + Store(), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=10)], + IfExp( + Compare( + Name( + 'number', + Load(), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=33), + [ + GtE()], + [ + Constant( + 13, + lineno=42, + col_offset=37, + end_lineno=42, + end_col_offset=39)], + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=39), + BinOp( + Name( + 'number', + Load(), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=19), + Add(), + Constant( + 4, + lineno=42, + col_offset=22, + end_lineno=42, + end_col_offset=23), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=23), + Name( + 'number', + Load(), + lineno=42, + col_offset=45, + end_lineno=42, + end_col_offset=51), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=51), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=51), + Assign( + [ + Name( + 'letters', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=11)], + Call( + Name( + 'generate_seat_letters', + Load(), + lineno=43, + col_offset=14, + end_lineno=43, + end_col_offset=35), + [ + Name( + 'number', + Load(), + lineno=43, + col_offset=36, + end_lineno=43, + end_col_offset=42)], + [], + lineno=43, + col_offset=14, + end_lineno=43, + end_col_offset=43), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=43), + For( + Name( + 'seat', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=21), + [ + Name( + 'number', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=28)], + [], + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=29), + [ + Assign( + [ + Name( + 'row_number', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=18)], + Call( + Attribute( + Name( + 'math', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=25), + 'ceil', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=30), + [ + BinOp( + BinOp( + Name( + 'seat', + Load(), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=36), + Add(), + Constant( + 1, + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=38), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=38), + Div(), + Constant( + 4, + lineno=45, + col_offset=42, + end_lineno=45, + end_col_offset=43), + lineno=45, + col_offset=31, + end_lineno=45, + end_col_offset=43)], + [], + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=44), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=44), + If( + Compare( + Name( + 'row_number', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=21), + [ + NotEq()], + [ + Constant( + 13, + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=27)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=27), + [ + Expr( + Yield( + JoinedStr( + [ + FormattedValue( + Call( + Name( + 'str', + Load(), + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=24), + [ + Name( + 'row_number', + Load(), + lineno=47, + col_offset=25, + end_lineno=47, + end_col_offset=35)], + [], + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=36), + -1, + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53), + FormattedValue( + Call( + Name( + 'next', + Load(), + lineno=47, + col_offset=38, + end_lineno=47, + end_col_offset=42), + [ + Name( + 'letters', + Load(), + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=50)], + [], + lineno=47, + col_offset=38, + end_lineno=47, + end_col_offset=51), + -1, + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53)], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=53), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=53)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=53)], + [], + lineno=44, + col_offset=4, + end_lineno=47, + end_col_offset=53)], + [], + lineno=25, + col_offset=0, + end_lineno=47, + end_col_offset=53), + FunctionDef( + 'assign_seats', + arguments( + [], + [ + arg( + 'passengers', + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Assign seats to passengers.\n\n :param passengers: list[str] - a list of strings containing names of passengers.\n :return: dict - with the names of the passengers as keys and seat numbers as values.\n\n Example output: {"Adele": "1A", "Björk": "1B"}\n\n ', + lineno=54, + col_offset=4, + end_lineno=61, + end_col_offset=7), + lineno=54, + col_offset=4, + end_lineno=61, + end_col_offset=7), + Assign( + [ + Name( + 'number', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=10)], + Call( + Name( + 'len', + Load(), + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=16), + [ + Name( + 'passengers', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=27)], + [], + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=28), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=28), + Assign( + [ + Name( + 'output', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=10)], + Dict( + [], + [], + lineno=64, + col_offset=13, + end_lineno=64, + end_col_offset=15), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'passenger', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=17), + Name( + 'seat_number', + Store(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=30)], + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=30), + Call( + Name( + 'zip', + Load(), + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=37), + [ + Name( + 'passengers', + Load(), + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=48), + Call( + Name( + 'generate_seats', + Load(), + lineno=65, + col_offset=50, + end_lineno=65, + end_col_offset=64), + [ + Name( + 'number', + Load(), + lineno=65, + col_offset=65, + end_lineno=65, + end_col_offset=71)], + [], + lineno=65, + col_offset=50, + end_lineno=65, + end_col_offset=72)], + [], + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=73), + [ + Assign( + [ + Subscript( + Name( + 'output', + Load(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=14), + Name( + 'passenger', + Load(), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=24), + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=25)], + Name( + 'seat_number', + Load(), + lineno=66, + col_offset=28, + end_lineno=66, + end_col_offset=39), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=39)], + [], + lineno=65, + col_offset=4, + end_lineno=66, + end_col_offset=39), + Return( + Name( + 'output', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=17), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=17)], + [], + lineno=53, + col_offset=0, + end_lineno=67, + end_col_offset=17), + FunctionDef( + 'generate_codes', + arguments( + [], + [ + arg( + 'seat_numbers', + lineno=69, + col_offset=19, + end_lineno=69, + end_col_offset=31), + arg( + 'flight_id', + lineno=69, + col_offset=33, + end_lineno=69, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Generate codes for a ticket.\n\n :param seat_numbers: list[str] - list of seat numbers.\n :param flight_id: str - string containing the flight identifier.\n :return: generator - generator that yields 12 character long ticket codes.\n\n ', + lineno=70, + col_offset=4, + end_lineno=76, + end_col_offset=7), + lineno=70, + col_offset=4, + end_lineno=76, + end_col_offset=7), + For( + Name( + 'seat', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=12), + Name( + 'seat_numbers', + Load(), + lineno=78, + col_offset=16, + end_lineno=78, + end_col_offset=28), + [ + Assign( + [ + Name( + 'base_string', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=19)], + JoinedStr( + [ + FormattedValue( + Name( + 'seat', + Load(), + lineno=79, + col_offset=25, + end_lineno=79, + end_col_offset=29), + -1, + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42), + FormattedValue( + Name( + 'flight_id', + Load(), + lineno=79, + col_offset=31, + end_lineno=79, + end_col_offset=40), + -1, + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42)], + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=42), + Expr( + Yield( + BinOp( + Name( + 'base_string', + Load(), + lineno=80, + col_offset=14, + end_lineno=80, + end_col_offset=25), + Add(), + BinOp( + Constant( + '0', + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=31), + Mult(), + BinOp( + Constant( + 12, + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=37), + Sub(), + Call( + Name( + 'len', + Load(), + lineno=80, + col_offset=40, + end_lineno=80, + end_col_offset=43), + [ + Name( + 'base_string', + Load(), + lineno=80, + col_offset=44, + end_lineno=80, + end_col_offset=55)], + [], + lineno=80, + col_offset=40, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=14, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=57)], + [], + lineno=78, + col_offset=4, + end_lineno=80, + end_col_offset=57)], + [], + lineno=69, + col_offset=0, + end_lineno=80, + end_col_offset=57)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'math', + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=11)], + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=11), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=12)], + List( + [ + Constant( + 'A', + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=19), + Constant( + 'B', + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + Constant( + 'C', + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=29), + Constant( + 'D', + lineno=5, + col_offset=31, + end_lineno=5, + end_col_offset=34)], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=35), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=8, + col_offset=26, + end_lineno=8, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_3', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=21), + [ + Name( + 'placeholder_2', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=28)], + [], + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=29), + [ + Expr( + Yield( + Subscript( + Name( + 'SEATS_IN_ROW', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=26), + BinOp( + Name( + 'seat', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=31), + Mod(), + Constant( + 4, + lineno=22, + col_offset=34, + end_lineno=22, + end_col_offset=35), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=35), + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=36), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=36), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=36)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=36)], + [], + lineno=8, + col_offset=0, + end_lineno=22, + end_col_offset=36), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=10)], + IfExp( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=33), + [ + GtE()], + [ + Constant( + 13, + lineno=42, + col_offset=37, + end_lineno=42, + end_col_offset=39)], + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=39), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=19), + Add(), + Constant( + 4, + lineno=42, + col_offset=22, + end_lineno=42, + end_col_offset=23), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=23), + Name( + 'placeholder_2', + Load(), + lineno=42, + col_offset=45, + end_lineno=42, + end_col_offset=51), + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=51), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=51), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=11)], + Call( + Name( + 'placeholder_1', + Load(), + lineno=43, + col_offset=14, + end_lineno=43, + end_col_offset=35), + [ + Name( + 'placeholder_2', + Load(), + lineno=43, + col_offset=36, + end_lineno=43, + end_col_offset=42)], + [], + lineno=43, + col_offset=14, + end_lineno=43, + end_col_offset=43), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=43), + For( + Name( + 'placeholder_3', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=21), + [ + Name( + 'placeholder_2', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=28)], + [], + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=29), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=18)], + Call( + Attribute( + Name( + 'math', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=25), + 'ceil', + Load(), + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=30), + [ + BinOp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=36), + Add(), + Constant( + 1, + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=38), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=38), + Div(), + Constant( + 4, + lineno=45, + col_offset=42, + end_lineno=45, + end_col_offset=43), + lineno=45, + col_offset=31, + end_lineno=45, + end_col_offset=43)], + [], + lineno=45, + col_offset=21, + end_lineno=45, + end_col_offset=44), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=44), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=21), + [ + NotEq()], + [ + Constant( + 13, + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=27)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=27), + [ + Expr( + Yield( + JoinedStr( + [ + FormattedValue( + Call( + Name( + 'str', + Load(), + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=24), + [ + Name( + 'row_number', + Load(), + lineno=47, + col_offset=25, + end_lineno=47, + end_col_offset=35)], + [], + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=36), + -1, + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53), + FormattedValue( + Call( + Name( + 'next', + Load(), + lineno=47, + col_offset=38, + end_lineno=47, + end_col_offset=42), + [ + Name( + 'letters', + Load(), + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=50)], + [], + lineno=47, + col_offset=38, + end_lineno=47, + end_col_offset=51), + -1, + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53)], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=53), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=53), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=53)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=53)], + [], + lineno=44, + col_offset=4, + end_lineno=47, + end_col_offset=53)], + [], + lineno=25, + col_offset=0, + end_lineno=47, + end_col_offset=53), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=10)], + Call( + Name( + 'len', + Load(), + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=16), + [ + Name( + 'placeholder_8', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=27)], + [], + lineno=63, + col_offset=13, + end_lineno=63, + end_col_offset=28), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=10)], + Dict( + [], + [], + lineno=64, + col_offset=13, + end_lineno=64, + end_col_offset=15), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'placeholder_10', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=17), + Name( + 'placeholder_11', + Store(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=30)], + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=30), + Call( + Name( + 'zip', + Load(), + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=37), + [ + Name( + 'placeholder_8', + Load(), + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=48), + Call( + Name( + 'placeholder_4', + Load(), + lineno=65, + col_offset=50, + end_lineno=65, + end_col_offset=64), + [ + Name( + 'placeholder_2', + Load(), + lineno=65, + col_offset=65, + end_lineno=65, + end_col_offset=71)], + [], + lineno=65, + col_offset=50, + end_lineno=65, + end_col_offset=72)], + [], + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=73), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_9', + Load(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=14), + Name( + 'placeholder_10', + Load(), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=24), + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=25)], + Name( + 'placeholder_11', + Load(), + lineno=66, + col_offset=28, + end_lineno=66, + end_col_offset=39), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=39)], + [], + lineno=65, + col_offset=4, + end_lineno=66, + end_col_offset=39), + Return( + Name( + 'placeholder_9', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=17), + lineno=67, + col_offset=4, + end_lineno=67, + end_col_offset=17)], + [], + lineno=53, + col_offset=0, + end_lineno=67, + end_col_offset=17), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=69, + col_offset=19, + end_lineno=69, + end_col_offset=31), + arg( + 'placeholder_14', + lineno=69, + col_offset=33, + end_lineno=69, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_3', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=12), + Name( + 'placeholder_13', + Load(), + lineno=78, + col_offset=16, + end_lineno=78, + end_col_offset=28), + [ + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=19)], + JoinedStr( + [ + FormattedValue( + Name( + 'placeholder_3', + Load(), + lineno=79, + col_offset=25, + end_lineno=79, + end_col_offset=29), + -1, + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42), + FormattedValue( + Name( + 'placeholder_14', + Load(), + lineno=79, + col_offset=31, + end_lineno=79, + end_col_offset=40), + -1, + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42)], + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=42), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=42), + Expr( + Yield( + BinOp( + Name( + 'base_string', + Load(), + lineno=80, + col_offset=14, + end_lineno=80, + end_col_offset=25), + Add(), + BinOp( + Constant( + '0', + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=31), + Mult(), + BinOp( + Constant( + 12, + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=37), + Sub(), + Call( + Name( + 'len', + Load(), + lineno=80, + col_offset=40, + end_lineno=80, + end_col_offset=43), + [ + Name( + 'base_string', + Load(), + lineno=80, + col_offset=44, + end_lineno=80, + end_col_offset=55)], + [], + lineno=80, + col_offset=40, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=35, + end_lineno=80, + end_col_offset=56), + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=14, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=57), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=57)], + [], + lineno=78, + col_offset=4, + end_lineno=80, + end_col_offset=57)], + [], + lineno=69, + col_offset=0, + end_lineno=80, + end_col_offset=57)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-generator-normalization/representation.txt b/test/example-generator-normalization/representation.txt new file mode 100644 index 0000000..7a2615a --- /dev/null +++ b/test/example-generator-normalization/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('math', lineno=3, col_offset=7, end_lineno=3, end_col_offset=11)], lineno=3, col_offset=0, end_lineno=3, end_col_offset=11), Assign([Name('placeholder_0', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=12)], List([Constant('A', lineno=5, col_offset=16, end_lineno=5, end_col_offset=19), Constant('B', lineno=5, col_offset=21, end_lineno=5, end_col_offset=24), Constant('C', lineno=5, col_offset=26, end_lineno=5, end_col_offset=29), Constant('D', lineno=5, col_offset=31, end_lineno=5, end_col_offset=34)], Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=35), lineno=5, col_offset=0, end_lineno=5, end_col_offset=35), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=8, col_offset=26, end_lineno=8, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_3', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=12), Call(Name('range', Load(), lineno=21, col_offset=16, end_lineno=21, end_col_offset=21), [Name('placeholder_2', Load(), lineno=21, col_offset=22, end_lineno=21, end_col_offset=28)], [], lineno=21, col_offset=16, end_lineno=21, end_col_offset=29), [Expr(Yield(Subscript(Name('SEATS_IN_ROW', Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=26), BinOp(Name('seat', Load(), lineno=22, col_offset=27, end_lineno=22, end_col_offset=31), Mod(), Constant(4, lineno=22, col_offset=34, end_lineno=22, end_col_offset=35), lineno=22, col_offset=27, end_lineno=22, end_col_offset=35), Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=36), lineno=22, col_offset=8, end_lineno=22, end_col_offset=36), lineno=22, col_offset=8, end_lineno=22, end_col_offset=36)], [], lineno=21, col_offset=4, end_lineno=22, end_col_offset=36)], [], lineno=8, col_offset=0, end_lineno=22, end_col_offset=36), FunctionDef('placeholder_4', arguments([], [arg('placeholder_2', lineno=25, col_offset=19, end_lineno=25, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=42, col_offset=4, end_lineno=42, end_col_offset=10)], IfExp(Compare(Name('placeholder_2', Load(), lineno=42, col_offset=27, end_lineno=42, end_col_offset=33), [GtE()], [Constant(13, lineno=42, col_offset=37, end_lineno=42, end_col_offset=39)], lineno=42, col_offset=27, end_lineno=42, end_col_offset=39), BinOp(Name('placeholder_2', Load(), lineno=42, col_offset=13, end_lineno=42, end_col_offset=19), Add(), Constant(4, lineno=42, col_offset=22, end_lineno=42, end_col_offset=23), lineno=42, col_offset=13, end_lineno=42, end_col_offset=23), Name('placeholder_2', Load(), lineno=42, col_offset=45, end_lineno=42, end_col_offset=51), lineno=42, col_offset=13, end_lineno=42, end_col_offset=51), lineno=42, col_offset=4, end_lineno=42, end_col_offset=51), Assign([Name('placeholder_5', Store(), lineno=43, col_offset=4, end_lineno=43, end_col_offset=11)], Call(Name('placeholder_1', Load(), lineno=43, col_offset=14, end_lineno=43, end_col_offset=35), [Name('placeholder_2', Load(), lineno=43, col_offset=36, end_lineno=43, end_col_offset=42)], [], lineno=43, col_offset=14, end_lineno=43, end_col_offset=43), lineno=43, col_offset=4, end_lineno=43, end_col_offset=43), For(Name('placeholder_3', Store(), lineno=44, col_offset=8, end_lineno=44, end_col_offset=12), Call(Name('range', Load(), lineno=44, col_offset=16, end_lineno=44, end_col_offset=21), [Name('placeholder_2', Load(), lineno=44, col_offset=22, end_lineno=44, end_col_offset=28)], [], lineno=44, col_offset=16, end_lineno=44, end_col_offset=29), [Assign([Name('placeholder_6', Store(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=18)], Call(Attribute(Name('math', Load(), lineno=45, col_offset=21, end_lineno=45, end_col_offset=25), 'ceil', Load(), lineno=45, col_offset=21, end_lineno=45, end_col_offset=30), [BinOp(BinOp(Name('placeholder_3', Load(), lineno=45, col_offset=32, end_lineno=45, end_col_offset=36), Add(), Constant(1, lineno=45, col_offset=37, end_lineno=45, end_col_offset=38), lineno=45, col_offset=32, end_lineno=45, end_col_offset=38), Div(), Constant(4, lineno=45, col_offset=42, end_lineno=45, end_col_offset=43), lineno=45, col_offset=31, end_lineno=45, end_col_offset=43)], [], lineno=45, col_offset=21, end_lineno=45, end_col_offset=44), lineno=45, col_offset=8, end_lineno=45, end_col_offset=44), If(Compare(Name('placeholder_6', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=21), [NotEq()], [Constant(13, lineno=46, col_offset=25, end_lineno=46, end_col_offset=27)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=27), [Expr(Yield(JoinedStr([FormattedValue(Call(Name('str', Load(), lineno=47, col_offset=21, end_lineno=47, end_col_offset=24), [Name('row_number', Load(), lineno=47, col_offset=25, end_lineno=47, end_col_offset=35)], [], lineno=47, col_offset=21, end_lineno=47, end_col_offset=36), -1, lineno=47, col_offset=18, end_lineno=47, end_col_offset=53), FormattedValue(Call(Name('next', Load(), lineno=47, col_offset=38, end_lineno=47, end_col_offset=42), [Name('letters', Load(), lineno=47, col_offset=43, end_lineno=47, end_col_offset=50)], [], lineno=47, col_offset=38, end_lineno=47, end_col_offset=51), -1, lineno=47, col_offset=18, end_lineno=47, end_col_offset=53)], lineno=47, col_offset=18, end_lineno=47, end_col_offset=53), lineno=47, col_offset=12, end_lineno=47, end_col_offset=53), lineno=47, col_offset=12, end_lineno=47, end_col_offset=53)], [], lineno=46, col_offset=8, end_lineno=47, end_col_offset=53)], [], lineno=44, col_offset=4, end_lineno=47, end_col_offset=53)], [], lineno=25, col_offset=0, end_lineno=47, end_col_offset=53), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=53, col_offset=17, end_lineno=53, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=63, col_offset=4, end_lineno=63, end_col_offset=10)], Call(Name('len', Load(), lineno=63, col_offset=13, end_lineno=63, end_col_offset=16), [Name('placeholder_8', Load(), lineno=63, col_offset=17, end_lineno=63, end_col_offset=27)], [], lineno=63, col_offset=13, end_lineno=63, end_col_offset=28), lineno=63, col_offset=4, end_lineno=63, end_col_offset=28), Assign([Name('placeholder_9', Store(), lineno=64, col_offset=4, end_lineno=64, end_col_offset=10)], Dict([], [], lineno=64, col_offset=13, end_lineno=64, end_col_offset=15), lineno=64, col_offset=4, end_lineno=64, end_col_offset=15), For(Tuple([Name('placeholder_10', Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=17), Name('placeholder_11', Store(), lineno=65, col_offset=19, end_lineno=65, end_col_offset=30)], Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=30), Call(Name('zip', Load(), lineno=65, col_offset=34, end_lineno=65, end_col_offset=37), [Name('placeholder_8', Load(), lineno=65, col_offset=38, end_lineno=65, end_col_offset=48), Call(Name('placeholder_4', Load(), lineno=65, col_offset=50, end_lineno=65, end_col_offset=64), [Name('placeholder_2', Load(), lineno=65, col_offset=65, end_lineno=65, end_col_offset=71)], [], lineno=65, col_offset=50, end_lineno=65, end_col_offset=72)], [], lineno=65, col_offset=34, end_lineno=65, end_col_offset=73), [Assign([Subscript(Name('placeholder_9', Load(), lineno=66, col_offset=8, end_lineno=66, end_col_offset=14), Name('placeholder_10', Load(), lineno=66, col_offset=15, end_lineno=66, end_col_offset=24), Store(), lineno=66, col_offset=8, end_lineno=66, end_col_offset=25)], Name('placeholder_11', Load(), lineno=66, col_offset=28, end_lineno=66, end_col_offset=39), lineno=66, col_offset=8, end_lineno=66, end_col_offset=39)], [], lineno=65, col_offset=4, end_lineno=66, end_col_offset=39), Return(Name('placeholder_9', Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=17), lineno=67, col_offset=4, end_lineno=67, end_col_offset=17)], [], lineno=53, col_offset=0, end_lineno=67, end_col_offset=17), FunctionDef('placeholder_12', arguments([], [arg('placeholder_13', lineno=69, col_offset=19, end_lineno=69, end_col_offset=31), arg('placeholder_14', lineno=69, col_offset=33, end_lineno=69, end_col_offset=42)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_3', Store(), lineno=78, col_offset=8, end_lineno=78, end_col_offset=12), Name('placeholder_13', Load(), lineno=78, col_offset=16, end_lineno=78, end_col_offset=28), [Assign([Name('placeholder_15', Store(), lineno=79, col_offset=8, end_lineno=79, end_col_offset=19)], JoinedStr([FormattedValue(Name('placeholder_3', Load(), lineno=79, col_offset=25, end_lineno=79, end_col_offset=29), -1, lineno=79, col_offset=22, end_lineno=79, end_col_offset=42), FormattedValue(Name('placeholder_14', Load(), lineno=79, col_offset=31, end_lineno=79, end_col_offset=40), -1, lineno=79, col_offset=22, end_lineno=79, end_col_offset=42)], lineno=79, col_offset=22, end_lineno=79, end_col_offset=42), lineno=79, col_offset=8, end_lineno=79, end_col_offset=42), Expr(Yield(BinOp(Name('base_string', Load(), lineno=80, col_offset=14, end_lineno=80, end_col_offset=25), Add(), BinOp(Constant('0', lineno=80, col_offset=28, end_lineno=80, end_col_offset=31), Mult(), BinOp(Constant(12, lineno=80, col_offset=35, end_lineno=80, end_col_offset=37), Sub(), Call(Name('len', Load(), lineno=80, col_offset=40, end_lineno=80, end_col_offset=43), [Name('base_string', Load(), lineno=80, col_offset=44, end_lineno=80, end_col_offset=55)], [], lineno=80, col_offset=40, end_lineno=80, end_col_offset=56), lineno=80, col_offset=35, end_lineno=80, end_col_offset=56), lineno=80, col_offset=28, end_lineno=80, end_col_offset=57), lineno=80, col_offset=14, end_lineno=80, end_col_offset=57), lineno=80, col_offset=8, end_lineno=80, end_col_offset=57), lineno=80, col_offset=8, end_lineno=80, end_col_offset=57)], [], lineno=78, col_offset=4, end_lineno=80, end_col_offset=57)], [], lineno=69, col_offset=0, end_lineno=80, end_col_offset=57)], []) \ No newline at end of file diff --git a/test/example-lambda-normalization/.meta/config.json b/test/example-lambda-normalization/.meta/config.json new file mode 100644 index 0000000..d8b3c31 --- /dev/null +++ b/test/example-lambda-normalization/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_lambda_normalization.py" + ] + } +} \ No newline at end of file diff --git a/test/example-lambda-normalization/example_lambda_normalization.py b/test/example-lambda-normalization/example_lambda_normalization.py new file mode 100644 index 0000000..63dd1da --- /dev/null +++ b/test/example-lambda-normalization/example_lambda_normalization.py @@ -0,0 +1,98 @@ +import logging +#import logging.config +from collections import defaultdict, Counter + +YACHT = lambda d: 50 if len(set(d)) == 1 else 0 +ONES = lambda d: sum(x for x in d if x == 1) +TWOS = lambda d: sum(x for x in d if x == 2) +THREES = lambda d: sum(x for x in d if x == 3) +FOURS = lambda d: sum(x for x in d if x == 4) +FIVES = lambda d: sum(x for x in d if x == 5) +SIXES = lambda d: sum(x for x in d if x == 6) +FULL_HOUSE = lambda d: sum(d) if len(set(d)) == 2 and any(d.count(x) == 3 for x in set(d)) else 0 +FOUR_OF_A_KIND = lambda d: sum(x * 4 for x in set(d) if d.count(x) > 3) +LITTLE_STRAIGHT = lambda d: 30 if sum(d) == 15 and len(set(d)) == 5 else 0 +BIG_STRAIGHT = lambda d: 30 if sum(d) == 20 and len(set(d)) == 5 else 0 +CHOICE = lambda d: sum(d) + +def score(dice, category): + if any(not 0 < x < 7 for x in dice): + raise ValueError("Invalid dice {}".format(dice)) + return category(dice) + + +def tally(tournament_results): + ''' + Generate a list of formatted report strings for tournament results. + + >>> test = (tally(["Courageous Californians;Devastating Donkeys;win",\ + "Allegoric Alaskans;Blithering Badgers;win",\ + "Devastating Donkeys;Allegoric Alaskans;loss",\ + "Courageous Californians;Blithering Badgers;win",\ + "Blithering Badgers;Devastating Donkeys;draw",\ + "Allegoric Alaskans;Courageous Californians;draw"])) + >>> print(type(test)) + + >>> print(test[0]) + Team | MP | W | D | L | P + >>> print(test[1]) + Allegoric Alaskans | 3 | 2 | 1 | 0 | 7 + >>> print(test[2]) + Courageous Californians | 3 | 2 | 1 | 0 | 7 + >>> print(test[3]) + Blithering Badgers | 3 | 0 | 1 | 2 | 1 + >>> print(test[4]) + Devastating Donkeys | 3 | 0 | 1 | 2 | 1 + ''' + + try: + results = (row.split(';') for row in tournament_results) + tournament_stats = compile_statistics(results) + + except AttributeError: + logger.exception(f'There is a problem with the tournament results string: ') + raise + + except IndexError: + logger.exception(f'Compiling team statistics failed: ') + raise + + return make_report(tournament_stats) + + +def compile_statistics(results): + ''' + Create a stats dictionary with results by team name. + Return a dictionary with Counter()s as values. + ''' + + team_stats = defaultdict(Counter) + opposite = {'win': 'loss', 'loss': 'win', 'draw': 'draw'} + + for home, away, outcome in results: + team_stats[home].update([outcome]) + team_stats[away].update([opposite[outcome]]) + + return team_stats + + +def make_report(team_stats): + ''' + Format & return a report string for printing. + If there are no team_stats, return only a header. + ''' + + report_format = '{:<30} | {:4>} | {:4>} | {:4>} | {:4>} | {:>2}' + + header = [('Team', 'MP', 'W', 'D', 'L', 'P')] + content = ((team, ' ' + str(sum(team_stats[team].values())), + team_stats[team]["win"], + team_stats[team]["draw"], + team_stats[team]["loss"], + team_stats[team]["win"] * 3 + team_stats[team]["draw"]) + for team in team_stats.keys()) + + #descending by total points & **ascending** by team if there is a tie. + report_order = header + sorted(content, key=lambda x: (-(x[5]), x)) + + return "\n".join(report_format.format(*team) for team in report_order).split('\n') \ No newline at end of file diff --git a/test/example-lambda-normalization/mapping.json b/test/example-lambda-normalization/mapping.json new file mode 100644 index 0000000..8fcf619 --- /dev/null +++ b/test/example-lambda-normalization/mapping.json @@ -0,0 +1,37 @@ +{ + "placeholder_0": "YACHT", + "placeholder_1": "d", + "placeholder_2": "ONES", + "placeholder_3": "x", + "placeholder_4": "TWOS", + "placeholder_5": "THREES", + "placeholder_6": "FOURS", + "placeholder_7": "FIVES", + "placeholder_8": "SIXES", + "placeholder_9": "FULL_HOUSE", + "placeholder_10": "FOUR_OF_A_KIND", + "placeholder_11": "LITTLE_STRAIGHT", + "placeholder_12": "BIG_STRAIGHT", + "placeholder_13": "CHOICE", + "placeholder_14": "score", + "placeholder_15": "dice", + "placeholder_16": "category", + "placeholder_17": "tally", + "placeholder_18": "tournament_results", + "placeholder_19": "results", + "placeholder_20": "row", + "placeholder_21": "tournament_stats", + "placeholder_22": "compile_statistics", + "placeholder_23": "team_stats", + "placeholder_24": "opposite", + "placeholder_25": "home", + "placeholder_26": "away", + "placeholder_27": "outcome", + "placeholder_28": "make_report", + "placeholder_29": "report_format", + "placeholder_30": "header", + "placeholder_31": "content", + "placeholder_32": "team", + "placeholder_33": "report_order", + "placeholder_34": "key" +} \ No newline at end of file diff --git a/test/example-lambda-normalization/representation.json b/test/example-lambda-normalization/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-lambda-normalization/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-lambda-normalization/representation.out b/test/example-lambda-normalization/representation.out new file mode 100644 index 0000000..2a6b0d2 --- /dev/null +++ b/test/example-lambda-normalization/representation.out @@ -0,0 +1,5613 @@ +## BEGIN NORMALIZED CODE ## +import logging +from collections import defaultdict, Counter + +placeholder_0 = lambda placeholder_1: 50 if len(set(placeholder_1)) == 1 else 0 +placeholder_2 = lambda placeholder_1: sum( + (placeholder_3 for placeholder_3 in placeholder_1 if placeholder_3 == 1) +) +placeholder_4 = lambda placeholder_1: sum( + (placeholder_3 for placeholder_3 in placeholder_1 if placeholder_3 == 2) +) +placeholder_5 = lambda placeholder_1: sum( + (placeholder_3 for placeholder_3 in placeholder_1 if placeholder_3 == 3) +) +placeholder_6 = lambda placeholder_1: sum( + (placeholder_3 for placeholder_3 in placeholder_1 if placeholder_3 == 4) +) +placeholder_7 = lambda placeholder_1: sum( + (placeholder_3 for placeholder_3 in placeholder_1 if placeholder_3 == 5) +) +placeholder_8 = lambda placeholder_1: sum( + (placeholder_3 for placeholder_3 in placeholder_1 if placeholder_3 == 6) +) +placeholder_9 = ( + lambda placeholder_1: sum(placeholder_1) + if len(set(placeholder_1)) == 2 + and any( + ( + placeholder_1.count(placeholder_3) == 3 + for placeholder_3 in set(placeholder_1) + ) + ) + else 0 +) +placeholder_10 = lambda placeholder_1: sum( + ( + placeholder_3 * 4 + for placeholder_3 in set(placeholder_1) + if placeholder_1.count(placeholder_3) > 3 + ) +) +placeholder_11 = ( + lambda placeholder_1: 30 + if sum(placeholder_1) == 15 and len(set(placeholder_1)) == 5 + else 0 +) +placeholder_12 = ( + lambda placeholder_1: 30 + if sum(placeholder_1) == 20 and len(set(placeholder_1)) == 5 + else 0 +) +placeholder_13 = lambda placeholder_1: sum(placeholder_1) + + +def placeholder_14(placeholder_15, placeholder_16): + if any((not 0 < placeholder_3 < 7 for placeholder_3 in placeholder_15)): + raise ValueError("Invalid dice {}".format(placeholder_15)) + return placeholder_16(placeholder_15) + + +def placeholder_17(placeholder_18): + try: + placeholder_19 = ( + placeholder_20.split(";") for placeholder_20 in placeholder_18 + ) + placeholder_21 = compile_statistics(placeholder_19) + except AttributeError: + logger.exception(f"There is a problem with the tournament results string: ") + raise + except IndexError: + logger.exception(f"Compiling team statistics failed: ") + raise + return make_report(placeholder_21) + + +def placeholder_22(placeholder_19): + placeholder_23 = defaultdict(Counter) + placeholder_24 = {"win": "loss", "loss": "win", "draw": "draw"} + for placeholder_25, placeholder_26, placeholder_27 in placeholder_19: + placeholder_23[placeholder_25].update([placeholder_27]) + placeholder_23[placeholder_26].update([placeholder_24[placeholder_27]]) + return placeholder_23 + + +def placeholder_28(placeholder_23): + placeholder_29 = "{:<30} | {:4>} | {:4>} | {:4>} | {:4>} | {:>2}" + placeholder_30 = [("Team", "MP", "W", "D", "L", "P")] + placeholder_31 = ( + ( + placeholder_32, + " " + str(sum(placeholder_23[placeholder_32].values())), + placeholder_23[placeholder_32]["win"], + placeholder_23[placeholder_32]["draw"], + placeholder_23[placeholder_32]["loss"], + placeholder_23[placeholder_32]["win"] * 3 + + placeholder_23[placeholder_32]["draw"], + ) + for placeholder_32 in placeholder_23.keys() + ) + placeholder_33 = placeholder_30 + sorted( + placeholder_31, + placeholder_34=lambda placeholder_3: (-placeholder_3[5], placeholder_3), + ) + return "\n".join( + (placeholder_29.format(*placeholder_32) for placeholder_32 in placeholder_33) + ).split("\n") + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'logging', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=14)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=14), + ImportFrom( + 'collections', + [ + alias( + 'defaultdict', + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=35), + alias( + 'Counter', + lineno=3, + col_offset=37, + end_lineno=3, + end_col_offset=44)], + 0, + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=44), + Assign( + [ + Name( + 'YACHT', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=5)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + IfExp( + Compare( + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=27), + [ + Call( + Name( + 'set', + Load(), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=31), + [ + Name( + 'd', + Load(), + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=33)], + [], + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=34)], + [], + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=35), + [ + Eq()], + [ + Constant( + 1, + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=40)], + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=40), + Constant( + 50, + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=20), + Constant( + 0, + lineno=5, + col_offset=46, + end_lineno=5, + end_col_offset=47), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=47), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=47), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=47), + Assign( + [ + Name( + 'ONES', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=4)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=20), + [ + GeneratorExp( + Name( + 'x', + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=22), + [ + comprehension( + Name( + 'x', + Store(), + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=28), + Name( + 'd', + Load(), + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=33), + [ + Compare( + Name( + 'x', + Load(), + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 1, + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=43)], + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=43)], + 0)], + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=44)], + [], + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=44), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=44), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=44), + Assign( + [ + Name( + 'TWOS', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=4)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=20), + [ + GeneratorExp( + Name( + 'x', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=22), + [ + comprehension( + Name( + 'x', + Store(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=28), + Name( + 'd', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=33), + [ + Compare( + Name( + 'x', + Load(), + lineno=7, + col_offset=37, + end_lineno=7, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 2, + lineno=7, + col_offset=42, + end_lineno=7, + end_col_offset=43)], + lineno=7, + col_offset=37, + end_lineno=7, + end_col_offset=43)], + 0)], + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=44)], + [], + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=44), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=44), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=44), + Assign( + [ + Name( + 'THREES', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=6)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=22), + [ + GeneratorExp( + Name( + 'x', + Load(), + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=24), + [ + comprehension( + Name( + 'x', + Store(), + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=30), + Name( + 'd', + Load(), + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=35), + [ + Compare( + Name( + 'x', + Load(), + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=40), + [ + Eq()], + [ + Constant( + 3, + lineno=8, + col_offset=44, + end_lineno=8, + end_col_offset=45)], + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=45)], + 0)], + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=46)], + [], + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=46), + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=46), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=46), + Assign( + [ + Name( + 'FOURS', + Store(), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=5)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=21), + [ + GeneratorExp( + Name( + 'x', + Load(), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=23), + [ + comprehension( + Name( + 'x', + Store(), + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=29), + Name( + 'd', + Load(), + lineno=9, + col_offset=33, + end_lineno=9, + end_col_offset=34), + [ + Compare( + Name( + 'x', + Load(), + lineno=9, + col_offset=38, + end_lineno=9, + end_col_offset=39), + [ + Eq()], + [ + Constant( + 4, + lineno=9, + col_offset=43, + end_lineno=9, + end_col_offset=44)], + lineno=9, + col_offset=38, + end_lineno=9, + end_col_offset=44)], + 0)], + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=45)], + [], + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=45), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=45), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=45), + Assign( + [ + Name( + 'FIVES', + Store(), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=5)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=21), + [ + GeneratorExp( + Name( + 'x', + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=23), + [ + comprehension( + Name( + 'x', + Store(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=29), + Name( + 'd', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=34), + [ + Compare( + Name( + 'x', + Load(), + lineno=10, + col_offset=38, + end_lineno=10, + end_col_offset=39), + [ + Eq()], + [ + Constant( + 5, + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=44)], + lineno=10, + col_offset=38, + end_lineno=10, + end_col_offset=44)], + 0)], + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=45)], + [], + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=45), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=45), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=45), + Assign( + [ + Name( + 'SIXES', + Store(), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=5)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=21), + [ + GeneratorExp( + Name( + 'x', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=23), + [ + comprehension( + Name( + 'x', + Store(), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=29), + Name( + 'd', + Load(), + lineno=11, + col_offset=33, + end_lineno=11, + end_col_offset=34), + [ + Compare( + Name( + 'x', + Load(), + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=39), + [ + Eq()], + [ + Constant( + 6, + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=44)], + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=44)], + 0)], + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=45)], + [], + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=45), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=45), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=45), + Assign( + [ + Name( + 'FULL_HOUSE', + Store(), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=10)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=12, + col_offset=20, + end_lineno=12, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + IfExp( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=36), + [ + Call( + Name( + 'set', + Load(), + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=40), + [ + Name( + 'd', + Load(), + lineno=12, + col_offset=41, + end_lineno=12, + end_col_offset=42)], + [], + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=43)], + [], + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=44), + [ + Eq()], + [ + Constant( + 2, + lineno=12, + col_offset=48, + end_lineno=12, + end_col_offset=49)], + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=49), + Call( + Name( + 'any', + Load(), + lineno=12, + col_offset=54, + end_lineno=12, + end_col_offset=57), + [ + GeneratorExp( + Compare( + Call( + Attribute( + Name( + 'd', + Load(), + lineno=12, + col_offset=58, + end_lineno=12, + end_col_offset=59), + 'count', + Load(), + lineno=12, + col_offset=58, + end_lineno=12, + end_col_offset=65), + [ + Name( + 'x', + Load(), + lineno=12, + col_offset=66, + end_lineno=12, + end_col_offset=67)], + [], + lineno=12, + col_offset=58, + end_lineno=12, + end_col_offset=68), + [ + Eq()], + [ + Constant( + 3, + lineno=12, + col_offset=72, + end_lineno=12, + end_col_offset=73)], + lineno=12, + col_offset=58, + end_lineno=12, + end_col_offset=73), + [ + comprehension( + Name( + 'x', + Store(), + lineno=12, + col_offset=78, + end_lineno=12, + end_col_offset=79), + Call( + Name( + 'set', + Load(), + lineno=12, + col_offset=83, + end_lineno=12, + end_col_offset=86), + [ + Name( + 'd', + Load(), + lineno=12, + col_offset=87, + end_lineno=12, + end_col_offset=88)], + [], + lineno=12, + col_offset=83, + end_lineno=12, + end_col_offset=89), + [], + 0)], + lineno=12, + col_offset=57, + end_lineno=12, + end_col_offset=90)], + [], + lineno=12, + col_offset=54, + end_lineno=12, + end_col_offset=90)], + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=90), + Call( + Name( + 'sum', + Load(), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=26), + [ + Name( + 'd', + Load(), + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=28)], + [], + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=29), + Constant( + 0, + lineno=12, + col_offset=96, + end_lineno=12, + end_col_offset=97), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=97), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=97), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=97), + Assign( + [ + Name( + 'FOUR_OF_A_KIND', + Store(), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=14)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=30), + [ + GeneratorExp( + BinOp( + Name( + 'x', + Load(), + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=32), + Mult(), + Constant( + 4, + lineno=13, + col_offset=35, + end_lineno=13, + end_col_offset=36), + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=36), + [ + comprehension( + Name( + 'x', + Store(), + lineno=13, + col_offset=41, + end_lineno=13, + end_col_offset=42), + Call( + Name( + 'set', + Load(), + lineno=13, + col_offset=46, + end_lineno=13, + end_col_offset=49), + [ + Name( + 'd', + Load(), + lineno=13, + col_offset=50, + end_lineno=13, + end_col_offset=51)], + [], + lineno=13, + col_offset=46, + end_lineno=13, + end_col_offset=52), + [ + Compare( + Call( + Attribute( + Name( + 'd', + Load(), + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=57), + 'count', + Load(), + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=63), + [ + Name( + 'x', + Load(), + lineno=13, + col_offset=64, + end_lineno=13, + end_col_offset=65)], + [], + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=66), + [ + Gt()], + [ + Constant( + 3, + lineno=13, + col_offset=69, + end_lineno=13, + end_col_offset=70)], + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=70)], + 0)], + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=71)], + [], + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=71), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=71), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=71), + Assign( + [ + Name( + 'LITTLE_STRAIGHT', + Store(), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=15)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + IfExp( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=37), + [ + Name( + 'd', + Load(), + lineno=14, + col_offset=38, + end_lineno=14, + end_col_offset=39)], + [], + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=40), + [ + Eq()], + [ + Constant( + 15, + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=46)], + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=46), + Compare( + Call( + Name( + 'len', + Load(), + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=54), + [ + Call( + Name( + 'set', + Load(), + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=58), + [ + Name( + 'd', + Load(), + lineno=14, + col_offset=59, + end_lineno=14, + end_col_offset=60)], + [], + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=61)], + [], + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=62), + [ + Eq()], + [ + Constant( + 5, + lineno=14, + col_offset=66, + end_lineno=14, + end_col_offset=67)], + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=67)], + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=67), + Constant( + 30, + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=30), + Constant( + 0, + lineno=14, + col_offset=73, + end_lineno=14, + end_col_offset=74), + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=74), + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=74), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=74), + Assign( + [ + Name( + 'BIG_STRAIGHT', + Store(), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=12)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + IfExp( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=34), + [ + Name( + 'd', + Load(), + lineno=15, + col_offset=35, + end_lineno=15, + end_col_offset=36)], + [], + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=37), + [ + Eq()], + [ + Constant( + 20, + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=43)], + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=43), + Compare( + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=51), + [ + Call( + Name( + 'set', + Load(), + lineno=15, + col_offset=52, + end_lineno=15, + end_col_offset=55), + [ + Name( + 'd', + Load(), + lineno=15, + col_offset=56, + end_lineno=15, + end_col_offset=57)], + [], + lineno=15, + col_offset=52, + end_lineno=15, + end_col_offset=58)], + [], + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=59), + [ + Eq()], + [ + Constant( + 5, + lineno=15, + col_offset=63, + end_lineno=15, + end_col_offset=64)], + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=64)], + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=64), + Constant( + 30, + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=27), + Constant( + 0, + lineno=15, + col_offset=70, + end_lineno=15, + end_col_offset=71), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=71), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=71), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=71), + Assign( + [ + Name( + 'CHOICE', + Store(), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=6)], + Lambda( + arguments( + [], + [ + arg( + 'd', + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=22), + [ + Name( + 'd', + Load(), + lineno=16, + col_offset=23, + end_lineno=16, + end_col_offset=24)], + [], + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=25), + lineno=16, + col_offset=9, + end_lineno=16, + end_col_offset=25), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=25), + FunctionDef( + 'score', + arguments( + [], + [ + arg( + 'dice', + lineno=18, + col_offset=10, + end_lineno=18, + end_col_offset=14), + arg( + 'category', + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Call( + Name( + 'any', + Load(), + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=10), + [ + GeneratorExp( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=16), + [ + Lt(), + Lt()], + [ + Name( + 'x', + Load(), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=20), + Constant( + 7, + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=24)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=24), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=24), + [ + comprehension( + Name( + 'x', + Store(), + lineno=19, + col_offset=29, + end_lineno=19, + end_col_offset=30), + Name( + 'dice', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=38), + [], + 0)], + lineno=19, + col_offset=10, + end_lineno=19, + end_col_offset=39)], + [], + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=39), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=24), + [ + Call( + Attribute( + Constant( + 'Invalid dice {}', + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=42), + 'format', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=49), + [ + Name( + 'dice', + Load(), + lineno=20, + col_offset=50, + end_lineno=20, + end_col_offset=54)], + [], + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=55)], + [], + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=56), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=56)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=56), + Return( + Call( + Name( + 'category', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=19), + [ + Name( + 'dice', + Load(), + lineno=21, + col_offset=20, + end_lineno=21, + end_col_offset=24)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=25), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=25)], + [], + lineno=18, + col_offset=0, + end_lineno=21, + end_col_offset=25), + FunctionDef( + 'tally', + arguments( + [], + [ + arg( + 'tournament_results', + lineno=24, + col_offset=10, + end_lineno=24, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n Generate a list of formatted report strings for tournament results.\n\n >>> test = (tally(["Courageous Californians;Devastating Donkeys;win", "Allegoric Alaskans;Blithering Badgers;win", "Devastating Donkeys;Allegoric Alaskans;loss", "Courageous Californians;Blithering Badgers;win", "Blithering Badgers;Devastating Donkeys;draw", "Allegoric Alaskans;Courageous Californians;draw"]))\n >>> print(type(test))\n \n >>> print(test[0])\n Team | MP | W | D | L | P\n >>> print(test[1])\n Allegoric Alaskans | 3 | 2 | 1 | 0 | 7\n >>> print(test[2])\n Courageous Californians | 3 | 2 | 1 | 0 | 7\n >>> print(test[3])\n Blithering Badgers | 3 | 0 | 1 | 2 | 1\n >>> print(test[4])\n Devastating Donkeys | 3 | 0 | 1 | 2 | 1\n ', + lineno=25, + col_offset=4, + end_lineno=46, + end_col_offset=7), + lineno=25, + col_offset=4, + end_lineno=46, + end_col_offset=7), + Try( + [ + Assign( + [ + Name( + 'results', + Store(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=15)], + GeneratorExp( + Call( + Attribute( + Name( + 'row', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=22), + 'split', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=28), + [ + Constant( + ';', + lineno=49, + col_offset=29, + end_lineno=49, + end_col_offset=32)], + [], + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=33), + [ + comprehension( + Name( + 'row', + Store(), + lineno=49, + col_offset=38, + end_lineno=49, + end_col_offset=41), + Name( + 'tournament_results', + Load(), + lineno=49, + col_offset=45, + end_lineno=49, + end_col_offset=63), + [], + 0)], + lineno=49, + col_offset=18, + end_lineno=49, + end_col_offset=64), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=64), + Assign( + [ + Name( + 'tournament_stats', + Store(), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=24)], + Call( + Name( + 'compile_statistics', + Load(), + lineno=50, + col_offset=27, + end_lineno=50, + end_col_offset=45), + [ + Name( + 'results', + Load(), + lineno=50, + col_offset=46, + end_lineno=50, + end_col_offset=53)], + [], + lineno=50, + col_offset=27, + end_lineno=50, + end_col_offset=54), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=54)], + [ + ExceptHandler( + Name( + 'AttributeError', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=25), + body=[ + Expr( + Call( + Attribute( + Name( + 'logger', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=14), + 'exception', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=24), + [ + JoinedStr( + [ + Constant( + 'There is a problem with the tournament results string: ', + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=83)], + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=83)], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=84), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=84), + Raise( + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=13)], + lineno=52, + col_offset=4, + end_lineno=54, + end_col_offset=13), + ExceptHandler( + Name( + 'IndexError', + Load(), + lineno=56, + col_offset=11, + end_lineno=56, + end_col_offset=21), + body=[ + Expr( + Call( + Attribute( + Name( + 'logger', + Load(), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=14), + 'exception', + Load(), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=24), + [ + JoinedStr( + [ + Constant( + 'Compiling team statistics failed: ', + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=62)], + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=62)], + [], + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=63), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=63), + Raise( + lineno=58, + col_offset=8, + end_lineno=58, + end_col_offset=13)], + lineno=56, + col_offset=4, + end_lineno=58, + end_col_offset=13)], + [], + [], + lineno=48, + col_offset=4, + end_lineno=58, + end_col_offset=13), + Return( + Call( + Name( + 'make_report', + Load(), + lineno=60, + col_offset=11, + end_lineno=60, + end_col_offset=22), + [ + Name( + 'tournament_stats', + Load(), + lineno=60, + col_offset=23, + end_lineno=60, + end_col_offset=39)], + [], + lineno=60, + col_offset=11, + end_lineno=60, + end_col_offset=40), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=40)], + [], + lineno=24, + col_offset=0, + end_lineno=60, + end_col_offset=40), + FunctionDef( + 'compile_statistics', + arguments( + [], + [ + arg( + 'results', + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n Create a stats dictionary with results by team name.\n Return a dictionary with Counter()s as values.\n ', + lineno=64, + col_offset=4, + end_lineno=67, + end_col_offset=7), + lineno=64, + col_offset=4, + end_lineno=67, + end_col_offset=7), + Assign( + [ + Name( + 'team_stats', + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=14)], + Call( + Name( + 'defaultdict', + Load(), + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=28), + [ + Name( + 'Counter', + Load(), + lineno=69, + col_offset=29, + end_lineno=69, + end_col_offset=36)], + [], + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=37), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=37), + Assign( + [ + Name( + 'opposite', + Store(), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=12)], + Dict( + [ + Constant( + 'win', + lineno=70, + col_offset=16, + end_lineno=70, + end_col_offset=21), + Constant( + 'loss', + lineno=70, + col_offset=31, + end_lineno=70, + end_col_offset=37), + Constant( + 'draw', + lineno=70, + col_offset=46, + end_lineno=70, + end_col_offset=52)], + [ + Constant( + 'loss', + lineno=70, + col_offset=23, + end_lineno=70, + end_col_offset=29), + Constant( + 'win', + lineno=70, + col_offset=39, + end_lineno=70, + end_col_offset=44), + Constant( + 'draw', + lineno=70, + col_offset=54, + end_lineno=70, + end_col_offset=60)], + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=61), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=61), + For( + Tuple( + [ + Name( + 'home', + Store(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=12), + Name( + 'away', + Store(), + lineno=72, + col_offset=14, + end_lineno=72, + end_col_offset=18), + Name( + 'outcome', + Store(), + lineno=72, + col_offset=20, + end_lineno=72, + end_col_offset=27)], + Store(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=27), + Name( + 'results', + Load(), + lineno=72, + col_offset=31, + end_lineno=72, + end_col_offset=38), + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'team_stats', + Load(), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=22), + Name( + 'home', + Load(), + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=27), + Load(), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=28), + 'update', + Load(), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=35), + [ + List( + [ + Name( + 'outcome', + Load(), + lineno=73, + col_offset=37, + end_lineno=73, + end_col_offset=44)], + Load(), + lineno=73, + col_offset=36, + end_lineno=73, + end_col_offset=45)], + [], + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=46), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=46), + Expr( + Call( + Attribute( + Subscript( + Name( + 'team_stats', + Load(), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=22), + Name( + 'away', + Load(), + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=27), + Load(), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=28), + 'update', + Load(), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=35), + [ + List( + [ + Subscript( + Name( + 'opposite', + Load(), + lineno=74, + col_offset=37, + end_lineno=74, + end_col_offset=45), + Name( + 'outcome', + Load(), + lineno=74, + col_offset=46, + end_lineno=74, + end_col_offset=53), + Load(), + lineno=74, + col_offset=37, + end_lineno=74, + end_col_offset=54)], + Load(), + lineno=74, + col_offset=36, + end_lineno=74, + end_col_offset=55)], + [], + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=56), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=56)], + [], + lineno=72, + col_offset=4, + end_lineno=74, + end_col_offset=56), + Return( + Name( + 'team_stats', + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=21), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=21)], + [], + lineno=63, + col_offset=0, + end_lineno=76, + end_col_offset=21), + FunctionDef( + 'make_report', + arguments( + [], + [ + arg( + 'team_stats', + lineno=79, + col_offset=16, + end_lineno=79, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n Format & return a report string for printing.\n If there are no team_stats, return only a header.\n ', + lineno=80, + col_offset=4, + end_lineno=83, + end_col_offset=7), + lineno=80, + col_offset=4, + end_lineno=83, + end_col_offset=7), + Assign( + [ + Name( + 'report_format', + Store(), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=17)], + Constant( + '{:<30} | {:4>} | {:4>} | {:4>} | {:4>} | {:>2}', + lineno=85, + col_offset=20, + end_lineno=85, + end_col_offset=71), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=71), + Assign( + [ + Name( + 'header', + Store(), + lineno=87, + col_offset=4, + end_lineno=87, + end_col_offset=10)], + List( + [ + Tuple( + [ + Constant( + 'Team', + lineno=87, + col_offset=16, + end_lineno=87, + end_col_offset=22), + Constant( + 'MP', + lineno=87, + col_offset=24, + end_lineno=87, + end_col_offset=28), + Constant( + 'W', + lineno=87, + col_offset=30, + end_lineno=87, + end_col_offset=33), + Constant( + 'D', + lineno=87, + col_offset=35, + end_lineno=87, + end_col_offset=38), + Constant( + 'L', + lineno=87, + col_offset=40, + end_lineno=87, + end_col_offset=43), + Constant( + 'P', + lineno=87, + col_offset=45, + end_lineno=87, + end_col_offset=48)], + Load(), + lineno=87, + col_offset=15, + end_lineno=87, + end_col_offset=49)], + Load(), + lineno=87, + col_offset=14, + end_lineno=87, + end_col_offset=50), + lineno=87, + col_offset=4, + end_lineno=87, + end_col_offset=50), + Assign( + [ + Name( + 'content', + Store(), + lineno=88, + col_offset=4, + end_lineno=88, + end_col_offset=11)], + GeneratorExp( + Tuple( + [ + Name( + 'team', + Load(), + lineno=88, + col_offset=16, + end_lineno=88, + end_col_offset=20), + BinOp( + Constant( + ' ', + lineno=88, + col_offset=22, + end_lineno=88, + end_col_offset=25), + Add(), + Call( + Name( + 'str', + Load(), + lineno=88, + col_offset=28, + end_lineno=88, + end_col_offset=31), + [ + Call( + Name( + 'sum', + Load(), + lineno=88, + col_offset=32, + end_lineno=88, + end_col_offset=35), + [ + Call( + Attribute( + Subscript( + Name( + 'team_stats', + Load(), + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=46), + Name( + 'team', + Load(), + lineno=88, + col_offset=47, + end_lineno=88, + end_col_offset=51), + Load(), + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=52), + 'values', + Load(), + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=59), + [], + [], + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=61)], + [], + lineno=88, + col_offset=32, + end_lineno=88, + end_col_offset=62)], + [], + lineno=88, + col_offset=28, + end_lineno=88, + end_col_offset=63), + lineno=88, + col_offset=22, + end_lineno=88, + end_col_offset=63), + Subscript( + Subscript( + Name( + 'team_stats', + Load(), + lineno=89, + col_offset=22, + end_lineno=89, + end_col_offset=32), + Name( + 'team', + Load(), + lineno=89, + col_offset=33, + end_lineno=89, + end_col_offset=37), + Load(), + lineno=89, + col_offset=22, + end_lineno=89, + end_col_offset=38), + Constant( + 'win', + lineno=89, + col_offset=39, + end_lineno=89, + end_col_offset=44), + Load(), + lineno=89, + col_offset=22, + end_lineno=89, + end_col_offset=45), + Subscript( + Subscript( + Name( + 'team_stats', + Load(), + lineno=90, + col_offset=22, + end_lineno=90, + end_col_offset=32), + Name( + 'team', + Load(), + lineno=90, + col_offset=33, + end_lineno=90, + end_col_offset=37), + Load(), + lineno=90, + col_offset=22, + end_lineno=90, + end_col_offset=38), + Constant( + 'draw', + lineno=90, + col_offset=39, + end_lineno=90, + end_col_offset=45), + Load(), + lineno=90, + col_offset=22, + end_lineno=90, + end_col_offset=46), + Subscript( + Subscript( + Name( + 'team_stats', + Load(), + lineno=91, + col_offset=22, + end_lineno=91, + end_col_offset=32), + Name( + 'team', + Load(), + lineno=91, + col_offset=33, + end_lineno=91, + end_col_offset=37), + Load(), + lineno=91, + col_offset=22, + end_lineno=91, + end_col_offset=38), + Constant( + 'loss', + lineno=91, + col_offset=39, + end_lineno=91, + end_col_offset=45), + Load(), + lineno=91, + col_offset=22, + end_lineno=91, + end_col_offset=46), + BinOp( + BinOp( + Subscript( + Subscript( + Name( + 'team_stats', + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=32), + Name( + 'team', + Load(), + lineno=92, + col_offset=33, + end_lineno=92, + end_col_offset=37), + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=38), + Constant( + 'win', + lineno=92, + col_offset=39, + end_lineno=92, + end_col_offset=44), + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=45), + Mult(), + Constant( + 3, + lineno=92, + col_offset=48, + end_lineno=92, + end_col_offset=49), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=49), + Add(), + Subscript( + Subscript( + Name( + 'team_stats', + Load(), + lineno=92, + col_offset=52, + end_lineno=92, + end_col_offset=62), + Name( + 'team', + Load(), + lineno=92, + col_offset=63, + end_lineno=92, + end_col_offset=67), + Load(), + lineno=92, + col_offset=52, + end_lineno=92, + end_col_offset=68), + Constant( + 'draw', + lineno=92, + col_offset=69, + end_lineno=92, + end_col_offset=75), + Load(), + lineno=92, + col_offset=52, + end_lineno=92, + end_col_offset=76), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=76)], + Load(), + lineno=88, + col_offset=15, + end_lineno=92, + end_col_offset=77), + [ + comprehension( + Name( + 'team', + Store(), + lineno=93, + col_offset=26, + end_lineno=93, + end_col_offset=30), + Call( + Attribute( + Name( + 'team_stats', + Load(), + lineno=93, + col_offset=34, + end_lineno=93, + end_col_offset=44), + 'keys', + Load(), + lineno=93, + col_offset=34, + end_lineno=93, + end_col_offset=49), + [], + [], + lineno=93, + col_offset=34, + end_lineno=93, + end_col_offset=51), + [], + 0)], + lineno=88, + col_offset=14, + end_lineno=93, + end_col_offset=52), + lineno=88, + col_offset=4, + end_lineno=93, + end_col_offset=52), + Assign( + [ + Name( + 'report_order', + Store(), + lineno=96, + col_offset=4, + end_lineno=96, + end_col_offset=16)], + BinOp( + Name( + 'header', + Load(), + lineno=96, + col_offset=19, + end_lineno=96, + end_col_offset=25), + Add(), + Call( + Name( + 'sorted', + Load(), + lineno=96, + col_offset=28, + end_lineno=96, + end_col_offset=34), + [ + Name( + 'content', + Load(), + lineno=96, + col_offset=35, + end_lineno=96, + end_col_offset=42)], + [ + keyword( + 'key', + Lambda( + arguments( + [], + [ + arg( + 'x', + lineno=96, + col_offset=55, + end_lineno=96, + end_col_offset=56)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Tuple( + [ + UnaryOp( + USub(), + Subscript( + Name( + 'x', + Load(), + lineno=96, + col_offset=61, + end_lineno=96, + end_col_offset=62), + Constant( + 5, + lineno=96, + col_offset=63, + end_lineno=96, + end_col_offset=64), + Load(), + lineno=96, + col_offset=61, + end_lineno=96, + end_col_offset=65), + lineno=96, + col_offset=59, + end_lineno=96, + end_col_offset=66), + Name( + 'x', + Load(), + lineno=96, + col_offset=68, + end_lineno=96, + end_col_offset=69)], + Load(), + lineno=96, + col_offset=58, + end_lineno=96, + end_col_offset=70), + lineno=96, + col_offset=48, + end_lineno=96, + end_col_offset=70), + lineno=96, + col_offset=44, + end_lineno=96, + end_col_offset=70)], + lineno=96, + col_offset=28, + end_lineno=96, + end_col_offset=71), + lineno=96, + col_offset=19, + end_lineno=96, + end_col_offset=71), + lineno=96, + col_offset=4, + end_lineno=96, + end_col_offset=71), + Return( + Call( + Attribute( + Call( + Attribute( + Constant( + '\n', + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=15), + 'join', + Load(), + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=20), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'report_format', + Load(), + lineno=98, + col_offset=21, + end_lineno=98, + end_col_offset=34), + 'format', + Load(), + lineno=98, + col_offset=21, + end_lineno=98, + end_col_offset=41), + [ + Starred( + Name( + 'team', + Load(), + lineno=98, + col_offset=43, + end_lineno=98, + end_col_offset=47), + Load(), + lineno=98, + col_offset=42, + end_lineno=98, + end_col_offset=47)], + [], + lineno=98, + col_offset=21, + end_lineno=98, + end_col_offset=48), + [ + comprehension( + Name( + 'team', + Store(), + lineno=98, + col_offset=53, + end_lineno=98, + end_col_offset=57), + Name( + 'report_order', + Load(), + lineno=98, + col_offset=61, + end_lineno=98, + end_col_offset=73), + [], + 0)], + lineno=98, + col_offset=20, + end_lineno=98, + end_col_offset=74)], + [], + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=74), + 'split', + Load(), + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=80), + [ + Constant( + '\n', + lineno=98, + col_offset=81, + end_lineno=98, + end_col_offset=85)], + [], + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=86), + lineno=98, + col_offset=4, + end_lineno=98, + end_col_offset=86)], + [], + lineno=79, + col_offset=0, + end_lineno=98, + end_col_offset=86)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'logging', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=14)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=14), + ImportFrom( + 'collections', + [ + alias( + 'defaultdict', + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=35), + alias( + 'Counter', + lineno=3, + col_offset=37, + end_lineno=3, + end_col_offset=44)], + 0, + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=5)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + IfExp( + Compare( + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=27), + [ + Call( + Name( + 'set', + Load(), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=31), + [ + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=33)], + [], + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=34)], + [], + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=35), + [ + Eq()], + [ + Constant( + 1, + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=40)], + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=40), + Constant( + 50, + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=20), + Constant( + 0, + lineno=5, + col_offset=46, + end_lineno=5, + end_col_offset=47), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=47), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=47), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=47), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=4)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=20), + [ + GeneratorExp( + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=22), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=28), + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=33), + [ + Compare( + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 1, + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=43)], + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=43)], + 0)], + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=44)], + [], + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=44), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=44), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=4)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=20), + [ + GeneratorExp( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=22), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=28), + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=33), + [ + Compare( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=37, + end_lineno=7, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 2, + lineno=7, + col_offset=42, + end_lineno=7, + end_col_offset=43)], + lineno=7, + col_offset=37, + end_lineno=7, + end_col_offset=43)], + 0)], + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=44)], + [], + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=44), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=44), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=6)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=22), + [ + GeneratorExp( + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=24), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=30), + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=35), + [ + Compare( + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=40), + [ + Eq()], + [ + Constant( + 3, + lineno=8, + col_offset=44, + end_lineno=8, + end_col_offset=45)], + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=45)], + 0)], + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=46)], + [], + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=46), + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=46), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=5)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=21), + [ + GeneratorExp( + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=23), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=29), + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=33, + end_lineno=9, + end_col_offset=34), + [ + Compare( + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=38, + end_lineno=9, + end_col_offset=39), + [ + Eq()], + [ + Constant( + 4, + lineno=9, + col_offset=43, + end_lineno=9, + end_col_offset=44)], + lineno=9, + col_offset=38, + end_lineno=9, + end_col_offset=44)], + 0)], + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=45)], + [], + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=45), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=45), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=5)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=21), + [ + GeneratorExp( + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=23), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=29), + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=34), + [ + Compare( + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=38, + end_lineno=10, + end_col_offset=39), + [ + Eq()], + [ + Constant( + 5, + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=44)], + lineno=10, + col_offset=38, + end_lineno=10, + end_col_offset=44)], + 0)], + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=45)], + [], + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=45), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=45), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=5)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=21), + [ + GeneratorExp( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=23), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=29), + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=33, + end_lineno=11, + end_col_offset=34), + [ + Compare( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=39), + [ + Eq()], + [ + Constant( + 6, + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=44)], + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=44)], + 0)], + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=45)], + [], + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=45), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=45), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=10)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=12, + col_offset=20, + end_lineno=12, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + IfExp( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=36), + [ + Call( + Name( + 'set', + Load(), + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=40), + [ + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=41, + end_lineno=12, + end_col_offset=42)], + [], + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=43)], + [], + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=44), + [ + Eq()], + [ + Constant( + 2, + lineno=12, + col_offset=48, + end_lineno=12, + end_col_offset=49)], + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=49), + Call( + Name( + 'any', + Load(), + lineno=12, + col_offset=54, + end_lineno=12, + end_col_offset=57), + [ + GeneratorExp( + Compare( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=58, + end_lineno=12, + end_col_offset=59), + 'count', + Load(), + lineno=12, + col_offset=58, + end_lineno=12, + end_col_offset=65), + [ + Name( + 'placeholder_3', + Load(), + lineno=12, + col_offset=66, + end_lineno=12, + end_col_offset=67)], + [], + lineno=12, + col_offset=58, + end_lineno=12, + end_col_offset=68), + [ + Eq()], + [ + Constant( + 3, + lineno=12, + col_offset=72, + end_lineno=12, + end_col_offset=73)], + lineno=12, + col_offset=58, + end_lineno=12, + end_col_offset=73), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=12, + col_offset=78, + end_lineno=12, + end_col_offset=79), + Call( + Name( + 'set', + Load(), + lineno=12, + col_offset=83, + end_lineno=12, + end_col_offset=86), + [ + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=87, + end_lineno=12, + end_col_offset=88)], + [], + lineno=12, + col_offset=83, + end_lineno=12, + end_col_offset=89), + [], + 0)], + lineno=12, + col_offset=57, + end_lineno=12, + end_col_offset=90)], + [], + lineno=12, + col_offset=54, + end_lineno=12, + end_col_offset=90)], + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=90), + Call( + Name( + 'sum', + Load(), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=26), + [ + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=28)], + [], + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=29), + Constant( + 0, + lineno=12, + col_offset=96, + end_lineno=12, + end_col_offset=97), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=97), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=97), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=97), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=14)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=30), + [ + GeneratorExp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=32), + Mult(), + Constant( + 4, + lineno=13, + col_offset=35, + end_lineno=13, + end_col_offset=36), + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=36), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=13, + col_offset=41, + end_lineno=13, + end_col_offset=42), + Call( + Name( + 'set', + Load(), + lineno=13, + col_offset=46, + end_lineno=13, + end_col_offset=49), + [ + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=50, + end_lineno=13, + end_col_offset=51)], + [], + lineno=13, + col_offset=46, + end_lineno=13, + end_col_offset=52), + [ + Compare( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=57), + 'count', + Load(), + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=63), + [ + Name( + 'placeholder_3', + Load(), + lineno=13, + col_offset=64, + end_lineno=13, + end_col_offset=65)], + [], + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=66), + [ + Gt()], + [ + Constant( + 3, + lineno=13, + col_offset=69, + end_lineno=13, + end_col_offset=70)], + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=70)], + 0)], + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=71)], + [], + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=71), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=71), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=71), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=15)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + IfExp( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=37), + [ + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=38, + end_lineno=14, + end_col_offset=39)], + [], + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=40), + [ + Eq()], + [ + Constant( + 15, + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=46)], + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=46), + Compare( + Call( + Name( + 'len', + Load(), + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=54), + [ + Call( + Name( + 'set', + Load(), + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=58), + [ + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=59, + end_lineno=14, + end_col_offset=60)], + [], + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=61)], + [], + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=62), + [ + Eq()], + [ + Constant( + 5, + lineno=14, + col_offset=66, + end_lineno=14, + end_col_offset=67)], + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=67)], + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=67), + Constant( + 30, + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=30), + Constant( + 0, + lineno=14, + col_offset=73, + end_lineno=14, + end_col_offset=74), + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=74), + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=74), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=74), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=12)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + IfExp( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=34), + [ + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=35, + end_lineno=15, + end_col_offset=36)], + [], + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=37), + [ + Eq()], + [ + Constant( + 20, + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=43)], + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=43), + Compare( + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=51), + [ + Call( + Name( + 'set', + Load(), + lineno=15, + col_offset=52, + end_lineno=15, + end_col_offset=55), + [ + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=56, + end_lineno=15, + end_col_offset=57)], + [], + lineno=15, + col_offset=52, + end_lineno=15, + end_col_offset=58)], + [], + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=59), + [ + Eq()], + [ + Constant( + 5, + lineno=15, + col_offset=63, + end_lineno=15, + end_col_offset=64)], + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=64)], + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=64), + Constant( + 30, + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=27), + Constant( + 0, + lineno=15, + col_offset=70, + end_lineno=15, + end_col_offset=71), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=71), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=71), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=71), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=6)], + Lambda( + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'sum', + Load(), + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=22), + [ + Name( + 'placeholder_1', + Load(), + lineno=16, + col_offset=23, + end_lineno=16, + end_col_offset=24)], + [], + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=25), + lineno=16, + col_offset=9, + end_lineno=16, + end_col_offset=25), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=25), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'placeholder_15', + lineno=18, + col_offset=10, + end_lineno=18, + end_col_offset=14), + arg( + 'placeholder_16', + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Call( + Name( + 'any', + Load(), + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=10), + [ + GeneratorExp( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=16), + [ + Lt(), + Lt()], + [ + Name( + 'placeholder_3', + Load(), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=20), + Constant( + 7, + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=24)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=24), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=24), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=19, + col_offset=29, + end_lineno=19, + end_col_offset=30), + Name( + 'placeholder_15', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=38), + [], + 0)], + lineno=19, + col_offset=10, + end_lineno=19, + end_col_offset=39)], + [], + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=39), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=24), + [ + Call( + Attribute( + Constant( + 'Invalid dice {}', + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=42), + 'format', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=49), + [ + Name( + 'placeholder_15', + Load(), + lineno=20, + col_offset=50, + end_lineno=20, + end_col_offset=54)], + [], + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=55)], + [], + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=56), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=56)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=56), + Return( + Call( + Name( + 'placeholder_16', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=19), + [ + Name( + 'placeholder_15', + Load(), + lineno=21, + col_offset=20, + end_lineno=21, + end_col_offset=24)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=25), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=25)], + [], + lineno=18, + col_offset=0, + end_lineno=21, + end_col_offset=25), + FunctionDef( + 'placeholder_17', + arguments( + [], + [ + arg( + 'placeholder_18', + lineno=24, + col_offset=10, + end_lineno=24, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=15)], + GeneratorExp( + Call( + Attribute( + Name( + 'placeholder_20', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=22), + 'split', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=28), + [ + Constant( + ';', + lineno=49, + col_offset=29, + end_lineno=49, + end_col_offset=32)], + [], + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=33), + [ + comprehension( + Name( + 'placeholder_20', + Store(), + lineno=49, + col_offset=38, + end_lineno=49, + end_col_offset=41), + Name( + 'placeholder_18', + Load(), + lineno=49, + col_offset=45, + end_lineno=49, + end_col_offset=63), + [], + 0)], + lineno=49, + col_offset=18, + end_lineno=49, + end_col_offset=64), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=64), + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=24)], + Call( + Name( + 'compile_statistics', + Load(), + lineno=50, + col_offset=27, + end_lineno=50, + end_col_offset=45), + [ + Name( + 'placeholder_19', + Load(), + lineno=50, + col_offset=46, + end_lineno=50, + end_col_offset=53)], + [], + lineno=50, + col_offset=27, + end_lineno=50, + end_col_offset=54), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=54)], + [ + ExceptHandler( + Name( + 'AttributeError', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=25), + body=[ + Expr( + Call( + Attribute( + Name( + 'logger', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=14), + 'exception', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=24), + [ + JoinedStr( + [ + Constant( + 'There is a problem with the tournament results string: ', + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=83)], + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=83)], + [], + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=84), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=84), + Raise( + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=13)], + lineno=52, + col_offset=4, + end_lineno=54, + end_col_offset=13), + ExceptHandler( + Name( + 'IndexError', + Load(), + lineno=56, + col_offset=11, + end_lineno=56, + end_col_offset=21), + body=[ + Expr( + Call( + Attribute( + Name( + 'logger', + Load(), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=14), + 'exception', + Load(), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=24), + [ + JoinedStr( + [ + Constant( + 'Compiling team statistics failed: ', + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=62)], + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=62)], + [], + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=63), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=63), + Raise( + lineno=58, + col_offset=8, + end_lineno=58, + end_col_offset=13)], + lineno=56, + col_offset=4, + end_lineno=58, + end_col_offset=13)], + [], + [], + lineno=48, + col_offset=4, + end_lineno=58, + end_col_offset=13), + Return( + Call( + Name( + 'make_report', + Load(), + lineno=60, + col_offset=11, + end_lineno=60, + end_col_offset=22), + [ + Name( + 'placeholder_21', + Load(), + lineno=60, + col_offset=23, + end_lineno=60, + end_col_offset=39)], + [], + lineno=60, + col_offset=11, + end_lineno=60, + end_col_offset=40), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=40)], + [], + lineno=24, + col_offset=0, + end_lineno=60, + end_col_offset=40), + FunctionDef( + 'placeholder_22', + arguments( + [], + [ + arg( + 'placeholder_19', + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_23', + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=14)], + Call( + Name( + 'defaultdict', + Load(), + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=28), + [ + Name( + 'Counter', + Load(), + lineno=69, + col_offset=29, + end_lineno=69, + end_col_offset=36)], + [], + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=37), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=37), + Assign( + [ + Name( + 'placeholder_24', + Store(), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=12)], + Dict( + [ + Constant( + 'win', + lineno=70, + col_offset=16, + end_lineno=70, + end_col_offset=21), + Constant( + 'loss', + lineno=70, + col_offset=31, + end_lineno=70, + end_col_offset=37), + Constant( + 'draw', + lineno=70, + col_offset=46, + end_lineno=70, + end_col_offset=52)], + [ + Constant( + 'loss', + lineno=70, + col_offset=23, + end_lineno=70, + end_col_offset=29), + Constant( + 'win', + lineno=70, + col_offset=39, + end_lineno=70, + end_col_offset=44), + Constant( + 'draw', + lineno=70, + col_offset=54, + end_lineno=70, + end_col_offset=60)], + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=61), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=61), + For( + Tuple( + [ + Name( + 'placeholder_25', + Store(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=12), + Name( + 'placeholder_26', + Store(), + lineno=72, + col_offset=14, + end_lineno=72, + end_col_offset=18), + Name( + 'placeholder_27', + Store(), + lineno=72, + col_offset=20, + end_lineno=72, + end_col_offset=27)], + Store(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=27), + Name( + 'placeholder_19', + Load(), + lineno=72, + col_offset=31, + end_lineno=72, + end_col_offset=38), + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=22), + Name( + 'placeholder_25', + Load(), + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=27), + Load(), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=28), + 'update', + Load(), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=35), + [ + List( + [ + Name( + 'placeholder_27', + Load(), + lineno=73, + col_offset=37, + end_lineno=73, + end_col_offset=44)], + Load(), + lineno=73, + col_offset=36, + end_lineno=73, + end_col_offset=45)], + [], + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=46), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=46), + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=22), + Name( + 'placeholder_26', + Load(), + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=27), + Load(), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=28), + 'update', + Load(), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=35), + [ + List( + [ + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=74, + col_offset=37, + end_lineno=74, + end_col_offset=45), + Name( + 'placeholder_27', + Load(), + lineno=74, + col_offset=46, + end_lineno=74, + end_col_offset=53), + Load(), + lineno=74, + col_offset=37, + end_lineno=74, + end_col_offset=54)], + Load(), + lineno=74, + col_offset=36, + end_lineno=74, + end_col_offset=55)], + [], + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=56), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=56)], + [], + lineno=72, + col_offset=4, + end_lineno=74, + end_col_offset=56), + Return( + Name( + 'placeholder_23', + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=21), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=21)], + [], + lineno=63, + col_offset=0, + end_lineno=76, + end_col_offset=21), + FunctionDef( + 'placeholder_28', + arguments( + [], + [ + arg( + 'placeholder_23', + lineno=79, + col_offset=16, + end_lineno=79, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_29', + Store(), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=17)], + Constant( + '{:<30} | {:4>} | {:4>} | {:4>} | {:4>} | {:>2}', + lineno=85, + col_offset=20, + end_lineno=85, + end_col_offset=71), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=71), + Assign( + [ + Name( + 'placeholder_30', + Store(), + lineno=87, + col_offset=4, + end_lineno=87, + end_col_offset=10)], + List( + [ + Tuple( + [ + Constant( + 'Team', + lineno=87, + col_offset=16, + end_lineno=87, + end_col_offset=22), + Constant( + 'MP', + lineno=87, + col_offset=24, + end_lineno=87, + end_col_offset=28), + Constant( + 'W', + lineno=87, + col_offset=30, + end_lineno=87, + end_col_offset=33), + Constant( + 'D', + lineno=87, + col_offset=35, + end_lineno=87, + end_col_offset=38), + Constant( + 'L', + lineno=87, + col_offset=40, + end_lineno=87, + end_col_offset=43), + Constant( + 'P', + lineno=87, + col_offset=45, + end_lineno=87, + end_col_offset=48)], + Load(), + lineno=87, + col_offset=15, + end_lineno=87, + end_col_offset=49)], + Load(), + lineno=87, + col_offset=14, + end_lineno=87, + end_col_offset=50), + lineno=87, + col_offset=4, + end_lineno=87, + end_col_offset=50), + Assign( + [ + Name( + 'placeholder_31', + Store(), + lineno=88, + col_offset=4, + end_lineno=88, + end_col_offset=11)], + GeneratorExp( + Tuple( + [ + Name( + 'placeholder_32', + Load(), + lineno=88, + col_offset=16, + end_lineno=88, + end_col_offset=20), + BinOp( + Constant( + ' ', + lineno=88, + col_offset=22, + end_lineno=88, + end_col_offset=25), + Add(), + Call( + Name( + 'str', + Load(), + lineno=88, + col_offset=28, + end_lineno=88, + end_col_offset=31), + [ + Call( + Name( + 'sum', + Load(), + lineno=88, + col_offset=32, + end_lineno=88, + end_col_offset=35), + [ + Call( + Attribute( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=46), + Name( + 'placeholder_32', + Load(), + lineno=88, + col_offset=47, + end_lineno=88, + end_col_offset=51), + Load(), + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=52), + 'values', + Load(), + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=59), + [], + [], + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=61)], + [], + lineno=88, + col_offset=32, + end_lineno=88, + end_col_offset=62)], + [], + lineno=88, + col_offset=28, + end_lineno=88, + end_col_offset=63), + lineno=88, + col_offset=22, + end_lineno=88, + end_col_offset=63), + Subscript( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=89, + col_offset=22, + end_lineno=89, + end_col_offset=32), + Name( + 'placeholder_32', + Load(), + lineno=89, + col_offset=33, + end_lineno=89, + end_col_offset=37), + Load(), + lineno=89, + col_offset=22, + end_lineno=89, + end_col_offset=38), + Constant( + 'win', + lineno=89, + col_offset=39, + end_lineno=89, + end_col_offset=44), + Load(), + lineno=89, + col_offset=22, + end_lineno=89, + end_col_offset=45), + Subscript( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=90, + col_offset=22, + end_lineno=90, + end_col_offset=32), + Name( + 'placeholder_32', + Load(), + lineno=90, + col_offset=33, + end_lineno=90, + end_col_offset=37), + Load(), + lineno=90, + col_offset=22, + end_lineno=90, + end_col_offset=38), + Constant( + 'draw', + lineno=90, + col_offset=39, + end_lineno=90, + end_col_offset=45), + Load(), + lineno=90, + col_offset=22, + end_lineno=90, + end_col_offset=46), + Subscript( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=91, + col_offset=22, + end_lineno=91, + end_col_offset=32), + Name( + 'placeholder_32', + Load(), + lineno=91, + col_offset=33, + end_lineno=91, + end_col_offset=37), + Load(), + lineno=91, + col_offset=22, + end_lineno=91, + end_col_offset=38), + Constant( + 'loss', + lineno=91, + col_offset=39, + end_lineno=91, + end_col_offset=45), + Load(), + lineno=91, + col_offset=22, + end_lineno=91, + end_col_offset=46), + BinOp( + BinOp( + Subscript( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=32), + Name( + 'placeholder_32', + Load(), + lineno=92, + col_offset=33, + end_lineno=92, + end_col_offset=37), + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=38), + Constant( + 'win', + lineno=92, + col_offset=39, + end_lineno=92, + end_col_offset=44), + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=45), + Mult(), + Constant( + 3, + lineno=92, + col_offset=48, + end_lineno=92, + end_col_offset=49), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=49), + Add(), + Subscript( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=92, + col_offset=52, + end_lineno=92, + end_col_offset=62), + Name( + 'placeholder_32', + Load(), + lineno=92, + col_offset=63, + end_lineno=92, + end_col_offset=67), + Load(), + lineno=92, + col_offset=52, + end_lineno=92, + end_col_offset=68), + Constant( + 'draw', + lineno=92, + col_offset=69, + end_lineno=92, + end_col_offset=75), + Load(), + lineno=92, + col_offset=52, + end_lineno=92, + end_col_offset=76), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=76)], + Load(), + lineno=88, + col_offset=15, + end_lineno=92, + end_col_offset=77), + [ + comprehension( + Name( + 'placeholder_32', + Store(), + lineno=93, + col_offset=26, + end_lineno=93, + end_col_offset=30), + Call( + Attribute( + Name( + 'placeholder_23', + Load(), + lineno=93, + col_offset=34, + end_lineno=93, + end_col_offset=44), + 'keys', + Load(), + lineno=93, + col_offset=34, + end_lineno=93, + end_col_offset=49), + [], + [], + lineno=93, + col_offset=34, + end_lineno=93, + end_col_offset=51), + [], + 0)], + lineno=88, + col_offset=14, + end_lineno=93, + end_col_offset=52), + lineno=88, + col_offset=4, + end_lineno=93, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_33', + Store(), + lineno=96, + col_offset=4, + end_lineno=96, + end_col_offset=16)], + BinOp( + Name( + 'placeholder_30', + Load(), + lineno=96, + col_offset=19, + end_lineno=96, + end_col_offset=25), + Add(), + Call( + Name( + 'sorted', + Load(), + lineno=96, + col_offset=28, + end_lineno=96, + end_col_offset=34), + [ + Name( + 'placeholder_31', + Load(), + lineno=96, + col_offset=35, + end_lineno=96, + end_col_offset=42)], + [ + keyword( + 'placeholder_34', + Lambda( + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=96, + col_offset=55, + end_lineno=96, + end_col_offset=56)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Tuple( + [ + UnaryOp( + USub(), + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=96, + col_offset=61, + end_lineno=96, + end_col_offset=62), + Constant( + 5, + lineno=96, + col_offset=63, + end_lineno=96, + end_col_offset=64), + Load(), + lineno=96, + col_offset=61, + end_lineno=96, + end_col_offset=65), + lineno=96, + col_offset=59, + end_lineno=96, + end_col_offset=66), + Name( + 'placeholder_3', + Load(), + lineno=96, + col_offset=68, + end_lineno=96, + end_col_offset=69)], + Load(), + lineno=96, + col_offset=58, + end_lineno=96, + end_col_offset=70), + lineno=96, + col_offset=48, + end_lineno=96, + end_col_offset=70), + lineno=96, + col_offset=44, + end_lineno=96, + end_col_offset=70)], + lineno=96, + col_offset=28, + end_lineno=96, + end_col_offset=71), + lineno=96, + col_offset=19, + end_lineno=96, + end_col_offset=71), + lineno=96, + col_offset=4, + end_lineno=96, + end_col_offset=71), + Return( + Call( + Attribute( + Call( + Attribute( + Constant( + '\n', + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=15), + 'join', + Load(), + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=20), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'placeholder_29', + Load(), + lineno=98, + col_offset=21, + end_lineno=98, + end_col_offset=34), + 'format', + Load(), + lineno=98, + col_offset=21, + end_lineno=98, + end_col_offset=41), + [ + Starred( + Name( + 'placeholder_32', + Load(), + lineno=98, + col_offset=43, + end_lineno=98, + end_col_offset=47), + Load(), + lineno=98, + col_offset=42, + end_lineno=98, + end_col_offset=47)], + [], + lineno=98, + col_offset=21, + end_lineno=98, + end_col_offset=48), + [ + comprehension( + Name( + 'placeholder_32', + Store(), + lineno=98, + col_offset=53, + end_lineno=98, + end_col_offset=57), + Name( + 'placeholder_33', + Load(), + lineno=98, + col_offset=61, + end_lineno=98, + end_col_offset=73), + [], + 0)], + lineno=98, + col_offset=20, + end_lineno=98, + end_col_offset=74)], + [], + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=74), + 'split', + Load(), + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=80), + [ + Constant( + '\n', + lineno=98, + col_offset=81, + end_lineno=98, + end_col_offset=85)], + [], + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=86), + lineno=98, + col_offset=4, + end_lineno=98, + end_col_offset=86)], + [], + lineno=79, + col_offset=0, + end_lineno=98, + end_col_offset=86)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-lambda-normalization/representation.txt b/test/example-lambda-normalization/representation.txt new file mode 100644 index 0000000..97ddab6 --- /dev/null +++ b/test/example-lambda-normalization/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('logging', lineno=1, col_offset=7, end_lineno=1, end_col_offset=14)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=14), ImportFrom('collections', [alias('defaultdict', lineno=3, col_offset=24, end_lineno=3, end_col_offset=35), alias('Counter', lineno=3, col_offset=37, end_lineno=3, end_col_offset=44)], 0, lineno=3, col_offset=0, end_lineno=3, end_col_offset=44), Assign([Name('placeholder_0', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=5)], Lambda(arguments([], [arg('placeholder_1', lineno=5, col_offset=15, end_lineno=5, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), IfExp(Compare(Call(Name('len', Load(), lineno=5, col_offset=24, end_lineno=5, end_col_offset=27), [Call(Name('set', Load(), lineno=5, col_offset=28, end_lineno=5, end_col_offset=31), [Name('placeholder_1', Load(), lineno=5, col_offset=32, end_lineno=5, end_col_offset=33)], [], lineno=5, col_offset=28, end_lineno=5, end_col_offset=34)], [], lineno=5, col_offset=24, end_lineno=5, end_col_offset=35), [Eq()], [Constant(1, lineno=5, col_offset=39, end_lineno=5, end_col_offset=40)], lineno=5, col_offset=24, end_lineno=5, end_col_offset=40), Constant(50, lineno=5, col_offset=18, end_lineno=5, end_col_offset=20), Constant(0, lineno=5, col_offset=46, end_lineno=5, end_col_offset=47), lineno=5, col_offset=18, end_lineno=5, end_col_offset=47), lineno=5, col_offset=8, end_lineno=5, end_col_offset=47), lineno=5, col_offset=0, end_lineno=5, end_col_offset=47), Assign([Name('placeholder_2', Store(), lineno=6, col_offset=0, end_lineno=6, end_col_offset=4)], Lambda(arguments([], [arg('placeholder_1', lineno=6, col_offset=14, end_lineno=6, end_col_offset=15)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('sum', Load(), lineno=6, col_offset=17, end_lineno=6, end_col_offset=20), [GeneratorExp(Name('placeholder_3', Load(), lineno=6, col_offset=21, end_lineno=6, end_col_offset=22), [comprehension(Name('placeholder_3', Store(), lineno=6, col_offset=27, end_lineno=6, end_col_offset=28), Name('placeholder_1', Load(), lineno=6, col_offset=32, end_lineno=6, end_col_offset=33), [Compare(Name('placeholder_3', Load(), lineno=6, col_offset=37, end_lineno=6, end_col_offset=38), [Eq()], [Constant(1, lineno=6, col_offset=42, end_lineno=6, end_col_offset=43)], lineno=6, col_offset=37, end_lineno=6, end_col_offset=43)], 0)], lineno=6, col_offset=20, end_lineno=6, end_col_offset=44)], [], lineno=6, col_offset=17, end_lineno=6, end_col_offset=44), lineno=6, col_offset=7, end_lineno=6, end_col_offset=44), lineno=6, col_offset=0, end_lineno=6, end_col_offset=44), Assign([Name('placeholder_4', Store(), lineno=7, col_offset=0, end_lineno=7, end_col_offset=4)], Lambda(arguments([], [arg('placeholder_1', lineno=7, col_offset=14, end_lineno=7, end_col_offset=15)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('sum', Load(), lineno=7, col_offset=17, end_lineno=7, end_col_offset=20), [GeneratorExp(Name('placeholder_3', Load(), lineno=7, col_offset=21, end_lineno=7, end_col_offset=22), [comprehension(Name('placeholder_3', Store(), lineno=7, col_offset=27, end_lineno=7, end_col_offset=28), Name('placeholder_1', Load(), lineno=7, col_offset=32, end_lineno=7, end_col_offset=33), [Compare(Name('placeholder_3', Load(), lineno=7, col_offset=37, end_lineno=7, end_col_offset=38), [Eq()], [Constant(2, lineno=7, col_offset=42, end_lineno=7, end_col_offset=43)], lineno=7, col_offset=37, end_lineno=7, end_col_offset=43)], 0)], lineno=7, col_offset=20, end_lineno=7, end_col_offset=44)], [], lineno=7, col_offset=17, end_lineno=7, end_col_offset=44), lineno=7, col_offset=7, end_lineno=7, end_col_offset=44), lineno=7, col_offset=0, end_lineno=7, end_col_offset=44), Assign([Name('placeholder_5', Store(), lineno=8, col_offset=0, end_lineno=8, end_col_offset=6)], Lambda(arguments([], [arg('placeholder_1', lineno=8, col_offset=16, end_lineno=8, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('sum', Load(), lineno=8, col_offset=19, end_lineno=8, end_col_offset=22), [GeneratorExp(Name('placeholder_3', Load(), lineno=8, col_offset=23, end_lineno=8, end_col_offset=24), [comprehension(Name('placeholder_3', Store(), lineno=8, col_offset=29, end_lineno=8, end_col_offset=30), Name('placeholder_1', Load(), lineno=8, col_offset=34, end_lineno=8, end_col_offset=35), [Compare(Name('placeholder_3', Load(), lineno=8, col_offset=39, end_lineno=8, end_col_offset=40), [Eq()], [Constant(3, lineno=8, col_offset=44, end_lineno=8, end_col_offset=45)], lineno=8, col_offset=39, end_lineno=8, end_col_offset=45)], 0)], lineno=8, col_offset=22, end_lineno=8, end_col_offset=46)], [], lineno=8, col_offset=19, end_lineno=8, end_col_offset=46), lineno=8, col_offset=9, end_lineno=8, end_col_offset=46), lineno=8, col_offset=0, end_lineno=8, end_col_offset=46), Assign([Name('placeholder_6', Store(), lineno=9, col_offset=0, end_lineno=9, end_col_offset=5)], Lambda(arguments([], [arg('placeholder_1', lineno=9, col_offset=15, end_lineno=9, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('sum', Load(), lineno=9, col_offset=18, end_lineno=9, end_col_offset=21), [GeneratorExp(Name('placeholder_3', Load(), lineno=9, col_offset=22, end_lineno=9, end_col_offset=23), [comprehension(Name('placeholder_3', Store(), lineno=9, col_offset=28, end_lineno=9, end_col_offset=29), Name('placeholder_1', Load(), lineno=9, col_offset=33, end_lineno=9, end_col_offset=34), [Compare(Name('placeholder_3', Load(), lineno=9, col_offset=38, end_lineno=9, end_col_offset=39), [Eq()], [Constant(4, lineno=9, col_offset=43, end_lineno=9, end_col_offset=44)], lineno=9, col_offset=38, end_lineno=9, end_col_offset=44)], 0)], lineno=9, col_offset=21, end_lineno=9, end_col_offset=45)], [], lineno=9, col_offset=18, end_lineno=9, end_col_offset=45), lineno=9, col_offset=8, end_lineno=9, end_col_offset=45), lineno=9, col_offset=0, end_lineno=9, end_col_offset=45), Assign([Name('placeholder_7', Store(), lineno=10, col_offset=0, end_lineno=10, end_col_offset=5)], Lambda(arguments([], [arg('placeholder_1', lineno=10, col_offset=15, end_lineno=10, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('sum', Load(), lineno=10, col_offset=18, end_lineno=10, end_col_offset=21), [GeneratorExp(Name('placeholder_3', Load(), lineno=10, col_offset=22, end_lineno=10, end_col_offset=23), [comprehension(Name('placeholder_3', Store(), lineno=10, col_offset=28, end_lineno=10, end_col_offset=29), Name('placeholder_1', Load(), lineno=10, col_offset=33, end_lineno=10, end_col_offset=34), [Compare(Name('placeholder_3', Load(), lineno=10, col_offset=38, end_lineno=10, end_col_offset=39), [Eq()], [Constant(5, lineno=10, col_offset=43, end_lineno=10, end_col_offset=44)], lineno=10, col_offset=38, end_lineno=10, end_col_offset=44)], 0)], lineno=10, col_offset=21, end_lineno=10, end_col_offset=45)], [], lineno=10, col_offset=18, end_lineno=10, end_col_offset=45), lineno=10, col_offset=8, end_lineno=10, end_col_offset=45), lineno=10, col_offset=0, end_lineno=10, end_col_offset=45), Assign([Name('placeholder_8', Store(), lineno=11, col_offset=0, end_lineno=11, end_col_offset=5)], Lambda(arguments([], [arg('placeholder_1', lineno=11, col_offset=15, end_lineno=11, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('sum', Load(), lineno=11, col_offset=18, end_lineno=11, end_col_offset=21), [GeneratorExp(Name('placeholder_3', Load(), lineno=11, col_offset=22, end_lineno=11, end_col_offset=23), [comprehension(Name('placeholder_3', Store(), lineno=11, col_offset=28, end_lineno=11, end_col_offset=29), Name('placeholder_1', Load(), lineno=11, col_offset=33, end_lineno=11, end_col_offset=34), [Compare(Name('placeholder_3', Load(), lineno=11, col_offset=38, end_lineno=11, end_col_offset=39), [Eq()], [Constant(6, lineno=11, col_offset=43, end_lineno=11, end_col_offset=44)], lineno=11, col_offset=38, end_lineno=11, end_col_offset=44)], 0)], lineno=11, col_offset=21, end_lineno=11, end_col_offset=45)], [], lineno=11, col_offset=18, end_lineno=11, end_col_offset=45), lineno=11, col_offset=8, end_lineno=11, end_col_offset=45), lineno=11, col_offset=0, end_lineno=11, end_col_offset=45), Assign([Name('placeholder_9', Store(), lineno=12, col_offset=0, end_lineno=12, end_col_offset=10)], Lambda(arguments([], [arg('placeholder_1', lineno=12, col_offset=20, end_lineno=12, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), IfExp(BoolOp(And(), [Compare(Call(Name('len', Load(), lineno=12, col_offset=33, end_lineno=12, end_col_offset=36), [Call(Name('set', Load(), lineno=12, col_offset=37, end_lineno=12, end_col_offset=40), [Name('placeholder_1', Load(), lineno=12, col_offset=41, end_lineno=12, end_col_offset=42)], [], lineno=12, col_offset=37, end_lineno=12, end_col_offset=43)], [], lineno=12, col_offset=33, end_lineno=12, end_col_offset=44), [Eq()], [Constant(2, lineno=12, col_offset=48, end_lineno=12, end_col_offset=49)], lineno=12, col_offset=33, end_lineno=12, end_col_offset=49), Call(Name('any', Load(), lineno=12, col_offset=54, end_lineno=12, end_col_offset=57), [GeneratorExp(Compare(Call(Attribute(Name('placeholder_1', Load(), lineno=12, col_offset=58, end_lineno=12, end_col_offset=59), 'count', Load(), lineno=12, col_offset=58, end_lineno=12, end_col_offset=65), [Name('placeholder_3', Load(), lineno=12, col_offset=66, end_lineno=12, end_col_offset=67)], [], lineno=12, col_offset=58, end_lineno=12, end_col_offset=68), [Eq()], [Constant(3, lineno=12, col_offset=72, end_lineno=12, end_col_offset=73)], lineno=12, col_offset=58, end_lineno=12, end_col_offset=73), [comprehension(Name('placeholder_3', Store(), lineno=12, col_offset=78, end_lineno=12, end_col_offset=79), Call(Name('set', Load(), lineno=12, col_offset=83, end_lineno=12, end_col_offset=86), [Name('placeholder_1', Load(), lineno=12, col_offset=87, end_lineno=12, end_col_offset=88)], [], lineno=12, col_offset=83, end_lineno=12, end_col_offset=89), [], 0)], lineno=12, col_offset=57, end_lineno=12, end_col_offset=90)], [], lineno=12, col_offset=54, end_lineno=12, end_col_offset=90)], lineno=12, col_offset=33, end_lineno=12, end_col_offset=90), Call(Name('sum', Load(), lineno=12, col_offset=23, end_lineno=12, end_col_offset=26), [Name('placeholder_1', Load(), lineno=12, col_offset=27, end_lineno=12, end_col_offset=28)], [], lineno=12, col_offset=23, end_lineno=12, end_col_offset=29), Constant(0, lineno=12, col_offset=96, end_lineno=12, end_col_offset=97), lineno=12, col_offset=23, end_lineno=12, end_col_offset=97), lineno=12, col_offset=13, end_lineno=12, end_col_offset=97), lineno=12, col_offset=0, end_lineno=12, end_col_offset=97), Assign([Name('placeholder_10', Store(), lineno=13, col_offset=0, end_lineno=13, end_col_offset=14)], Lambda(arguments([], [arg('placeholder_1', lineno=13, col_offset=24, end_lineno=13, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('sum', Load(), lineno=13, col_offset=27, end_lineno=13, end_col_offset=30), [GeneratorExp(BinOp(Name('placeholder_3', Load(), lineno=13, col_offset=31, end_lineno=13, end_col_offset=32), Mult(), Constant(4, lineno=13, col_offset=35, end_lineno=13, end_col_offset=36), lineno=13, col_offset=31, end_lineno=13, end_col_offset=36), [comprehension(Name('placeholder_3', Store(), lineno=13, col_offset=41, end_lineno=13, end_col_offset=42), Call(Name('set', Load(), lineno=13, col_offset=46, end_lineno=13, end_col_offset=49), [Name('placeholder_1', Load(), lineno=13, col_offset=50, end_lineno=13, end_col_offset=51)], [], lineno=13, col_offset=46, end_lineno=13, end_col_offset=52), [Compare(Call(Attribute(Name('placeholder_1', Load(), lineno=13, col_offset=56, end_lineno=13, end_col_offset=57), 'count', Load(), lineno=13, col_offset=56, end_lineno=13, end_col_offset=63), [Name('placeholder_3', Load(), lineno=13, col_offset=64, end_lineno=13, end_col_offset=65)], [], lineno=13, col_offset=56, end_lineno=13, end_col_offset=66), [Gt()], [Constant(3, lineno=13, col_offset=69, end_lineno=13, end_col_offset=70)], lineno=13, col_offset=56, end_lineno=13, end_col_offset=70)], 0)], lineno=13, col_offset=30, end_lineno=13, end_col_offset=71)], [], lineno=13, col_offset=27, end_lineno=13, end_col_offset=71), lineno=13, col_offset=17, end_lineno=13, end_col_offset=71), lineno=13, col_offset=0, end_lineno=13, end_col_offset=71), Assign([Name('placeholder_11', Store(), lineno=14, col_offset=0, end_lineno=14, end_col_offset=15)], Lambda(arguments([], [arg('placeholder_1', lineno=14, col_offset=25, end_lineno=14, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), IfExp(BoolOp(And(), [Compare(Call(Name('sum', Load(), lineno=14, col_offset=34, end_lineno=14, end_col_offset=37), [Name('placeholder_1', Load(), lineno=14, col_offset=38, end_lineno=14, end_col_offset=39)], [], lineno=14, col_offset=34, end_lineno=14, end_col_offset=40), [Eq()], [Constant(15, lineno=14, col_offset=44, end_lineno=14, end_col_offset=46)], lineno=14, col_offset=34, end_lineno=14, end_col_offset=46), Compare(Call(Name('len', Load(), lineno=14, col_offset=51, end_lineno=14, end_col_offset=54), [Call(Name('set', Load(), lineno=14, col_offset=55, end_lineno=14, end_col_offset=58), [Name('placeholder_1', Load(), lineno=14, col_offset=59, end_lineno=14, end_col_offset=60)], [], lineno=14, col_offset=55, end_lineno=14, end_col_offset=61)], [], lineno=14, col_offset=51, end_lineno=14, end_col_offset=62), [Eq()], [Constant(5, lineno=14, col_offset=66, end_lineno=14, end_col_offset=67)], lineno=14, col_offset=51, end_lineno=14, end_col_offset=67)], lineno=14, col_offset=34, end_lineno=14, end_col_offset=67), Constant(30, lineno=14, col_offset=28, end_lineno=14, end_col_offset=30), Constant(0, lineno=14, col_offset=73, end_lineno=14, end_col_offset=74), lineno=14, col_offset=28, end_lineno=14, end_col_offset=74), lineno=14, col_offset=18, end_lineno=14, end_col_offset=74), lineno=14, col_offset=0, end_lineno=14, end_col_offset=74), Assign([Name('placeholder_12', Store(), lineno=15, col_offset=0, end_lineno=15, end_col_offset=12)], Lambda(arguments([], [arg('placeholder_1', lineno=15, col_offset=22, end_lineno=15, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), IfExp(BoolOp(And(), [Compare(Call(Name('sum', Load(), lineno=15, col_offset=31, end_lineno=15, end_col_offset=34), [Name('placeholder_1', Load(), lineno=15, col_offset=35, end_lineno=15, end_col_offset=36)], [], lineno=15, col_offset=31, end_lineno=15, end_col_offset=37), [Eq()], [Constant(20, lineno=15, col_offset=41, end_lineno=15, end_col_offset=43)], lineno=15, col_offset=31, end_lineno=15, end_col_offset=43), Compare(Call(Name('len', Load(), lineno=15, col_offset=48, end_lineno=15, end_col_offset=51), [Call(Name('set', Load(), lineno=15, col_offset=52, end_lineno=15, end_col_offset=55), [Name('placeholder_1', Load(), lineno=15, col_offset=56, end_lineno=15, end_col_offset=57)], [], lineno=15, col_offset=52, end_lineno=15, end_col_offset=58)], [], lineno=15, col_offset=48, end_lineno=15, end_col_offset=59), [Eq()], [Constant(5, lineno=15, col_offset=63, end_lineno=15, end_col_offset=64)], lineno=15, col_offset=48, end_lineno=15, end_col_offset=64)], lineno=15, col_offset=31, end_lineno=15, end_col_offset=64), Constant(30, lineno=15, col_offset=25, end_lineno=15, end_col_offset=27), Constant(0, lineno=15, col_offset=70, end_lineno=15, end_col_offset=71), lineno=15, col_offset=25, end_lineno=15, end_col_offset=71), lineno=15, col_offset=15, end_lineno=15, end_col_offset=71), lineno=15, col_offset=0, end_lineno=15, end_col_offset=71), Assign([Name('placeholder_13', Store(), lineno=16, col_offset=0, end_lineno=16, end_col_offset=6)], Lambda(arguments([], [arg('placeholder_1', lineno=16, col_offset=16, end_lineno=16, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('sum', Load(), lineno=16, col_offset=19, end_lineno=16, end_col_offset=22), [Name('placeholder_1', Load(), lineno=16, col_offset=23, end_lineno=16, end_col_offset=24)], [], lineno=16, col_offset=19, end_lineno=16, end_col_offset=25), lineno=16, col_offset=9, end_lineno=16, end_col_offset=25), lineno=16, col_offset=0, end_lineno=16, end_col_offset=25), FunctionDef('placeholder_14', arguments([], [arg('placeholder_15', lineno=18, col_offset=10, end_lineno=18, end_col_offset=14), arg('placeholder_16', lineno=18, col_offset=16, end_lineno=18, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Call(Name('any', Load(), lineno=19, col_offset=7, end_lineno=19, end_col_offset=10), [GeneratorExp(UnaryOp(Not(), Compare(Constant(0, lineno=19, col_offset=15, end_lineno=19, end_col_offset=16), [Lt(), Lt()], [Name('placeholder_3', Load(), lineno=19, col_offset=19, end_lineno=19, end_col_offset=20), Constant(7, lineno=19, col_offset=23, end_lineno=19, end_col_offset=24)], lineno=19, col_offset=15, end_lineno=19, end_col_offset=24), lineno=19, col_offset=11, end_lineno=19, end_col_offset=24), [comprehension(Name('placeholder_3', Store(), lineno=19, col_offset=29, end_lineno=19, end_col_offset=30), Name('placeholder_15', Load(), lineno=19, col_offset=34, end_lineno=19, end_col_offset=38), [], 0)], lineno=19, col_offset=10, end_lineno=19, end_col_offset=39)], [], lineno=19, col_offset=7, end_lineno=19, end_col_offset=39), [Raise(Call(Name('ValueError', Load(), lineno=20, col_offset=14, end_lineno=20, end_col_offset=24), [Call(Attribute(Constant('Invalid dice {}', lineno=20, col_offset=25, end_lineno=20, end_col_offset=42), 'format', Load(), lineno=20, col_offset=25, end_lineno=20, end_col_offset=49), [Name('placeholder_15', Load(), lineno=20, col_offset=50, end_lineno=20, end_col_offset=54)], [], lineno=20, col_offset=25, end_lineno=20, end_col_offset=55)], [], lineno=20, col_offset=14, end_lineno=20, end_col_offset=56), lineno=20, col_offset=8, end_lineno=20, end_col_offset=56)], [], lineno=19, col_offset=4, end_lineno=20, end_col_offset=56), Return(Call(Name('placeholder_16', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=19), [Name('placeholder_15', Load(), lineno=21, col_offset=20, end_lineno=21, end_col_offset=24)], [], lineno=21, col_offset=11, end_lineno=21, end_col_offset=25), lineno=21, col_offset=4, end_lineno=21, end_col_offset=25)], [], lineno=18, col_offset=0, end_lineno=21, end_col_offset=25), FunctionDef('placeholder_17', arguments([], [arg('placeholder_18', lineno=24, col_offset=10, end_lineno=24, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Try([Assign([Name('placeholder_19', Store(), lineno=49, col_offset=8, end_lineno=49, end_col_offset=15)], GeneratorExp(Call(Attribute(Name('placeholder_20', Load(), lineno=49, col_offset=19, end_lineno=49, end_col_offset=22), 'split', Load(), lineno=49, col_offset=19, end_lineno=49, end_col_offset=28), [Constant(';', lineno=49, col_offset=29, end_lineno=49, end_col_offset=32)], [], lineno=49, col_offset=19, end_lineno=49, end_col_offset=33), [comprehension(Name('placeholder_20', Store(), lineno=49, col_offset=38, end_lineno=49, end_col_offset=41), Name('placeholder_18', Load(), lineno=49, col_offset=45, end_lineno=49, end_col_offset=63), [], 0)], lineno=49, col_offset=18, end_lineno=49, end_col_offset=64), lineno=49, col_offset=8, end_lineno=49, end_col_offset=64), Assign([Name('placeholder_21', Store(), lineno=50, col_offset=8, end_lineno=50, end_col_offset=24)], Call(Name('compile_statistics', Load(), lineno=50, col_offset=27, end_lineno=50, end_col_offset=45), [Name('placeholder_19', Load(), lineno=50, col_offset=46, end_lineno=50, end_col_offset=53)], [], lineno=50, col_offset=27, end_lineno=50, end_col_offset=54), lineno=50, col_offset=8, end_lineno=50, end_col_offset=54)], [ExceptHandler(Name('AttributeError', Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=25), body=[Expr(Call(Attribute(Name('logger', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=14), 'exception', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=24), [JoinedStr([Constant('There is a problem with the tournament results string: ', lineno=53, col_offset=25, end_lineno=53, end_col_offset=83)], lineno=53, col_offset=25, end_lineno=53, end_col_offset=83)], [], lineno=53, col_offset=8, end_lineno=53, end_col_offset=84), lineno=53, col_offset=8, end_lineno=53, end_col_offset=84), Raise(lineno=54, col_offset=8, end_lineno=54, end_col_offset=13)], lineno=52, col_offset=4, end_lineno=54, end_col_offset=13), ExceptHandler(Name('IndexError', Load(), lineno=56, col_offset=11, end_lineno=56, end_col_offset=21), body=[Expr(Call(Attribute(Name('logger', Load(), lineno=57, col_offset=8, end_lineno=57, end_col_offset=14), 'exception', Load(), lineno=57, col_offset=8, end_lineno=57, end_col_offset=24), [JoinedStr([Constant('Compiling team statistics failed: ', lineno=57, col_offset=25, end_lineno=57, end_col_offset=62)], lineno=57, col_offset=25, end_lineno=57, end_col_offset=62)], [], lineno=57, col_offset=8, end_lineno=57, end_col_offset=63), lineno=57, col_offset=8, end_lineno=57, end_col_offset=63), Raise(lineno=58, col_offset=8, end_lineno=58, end_col_offset=13)], lineno=56, col_offset=4, end_lineno=58, end_col_offset=13)], [], [], lineno=48, col_offset=4, end_lineno=58, end_col_offset=13), Return(Call(Name('make_report', Load(), lineno=60, col_offset=11, end_lineno=60, end_col_offset=22), [Name('placeholder_21', Load(), lineno=60, col_offset=23, end_lineno=60, end_col_offset=39)], [], lineno=60, col_offset=11, end_lineno=60, end_col_offset=40), lineno=60, col_offset=4, end_lineno=60, end_col_offset=40)], [], lineno=24, col_offset=0, end_lineno=60, end_col_offset=40), FunctionDef('placeholder_22', arguments([], [arg('placeholder_19', lineno=63, col_offset=23, end_lineno=63, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_23', Store(), lineno=69, col_offset=4, end_lineno=69, end_col_offset=14)], Call(Name('defaultdict', Load(), lineno=69, col_offset=17, end_lineno=69, end_col_offset=28), [Name('Counter', Load(), lineno=69, col_offset=29, end_lineno=69, end_col_offset=36)], [], lineno=69, col_offset=17, end_lineno=69, end_col_offset=37), lineno=69, col_offset=4, end_lineno=69, end_col_offset=37), Assign([Name('placeholder_24', Store(), lineno=70, col_offset=4, end_lineno=70, end_col_offset=12)], Dict([Constant('win', lineno=70, col_offset=16, end_lineno=70, end_col_offset=21), Constant('loss', lineno=70, col_offset=31, end_lineno=70, end_col_offset=37), Constant('draw', lineno=70, col_offset=46, end_lineno=70, end_col_offset=52)], [Constant('loss', lineno=70, col_offset=23, end_lineno=70, end_col_offset=29), Constant('win', lineno=70, col_offset=39, end_lineno=70, end_col_offset=44), Constant('draw', lineno=70, col_offset=54, end_lineno=70, end_col_offset=60)], lineno=70, col_offset=15, end_lineno=70, end_col_offset=61), lineno=70, col_offset=4, end_lineno=70, end_col_offset=61), For(Tuple([Name('placeholder_25', Store(), lineno=72, col_offset=8, end_lineno=72, end_col_offset=12), Name('placeholder_26', Store(), lineno=72, col_offset=14, end_lineno=72, end_col_offset=18), Name('placeholder_27', Store(), lineno=72, col_offset=20, end_lineno=72, end_col_offset=27)], Store(), lineno=72, col_offset=8, end_lineno=72, end_col_offset=27), Name('placeholder_19', Load(), lineno=72, col_offset=31, end_lineno=72, end_col_offset=38), [Expr(Call(Attribute(Subscript(Name('placeholder_23', Load(), lineno=73, col_offset=12, end_lineno=73, end_col_offset=22), Name('placeholder_25', Load(), lineno=73, col_offset=23, end_lineno=73, end_col_offset=27), Load(), lineno=73, col_offset=12, end_lineno=73, end_col_offset=28), 'update', Load(), lineno=73, col_offset=12, end_lineno=73, end_col_offset=35), [List([Name('placeholder_27', Load(), lineno=73, col_offset=37, end_lineno=73, end_col_offset=44)], Load(), lineno=73, col_offset=36, end_lineno=73, end_col_offset=45)], [], lineno=73, col_offset=12, end_lineno=73, end_col_offset=46), lineno=73, col_offset=12, end_lineno=73, end_col_offset=46), Expr(Call(Attribute(Subscript(Name('placeholder_23', Load(), lineno=74, col_offset=12, end_lineno=74, end_col_offset=22), Name('placeholder_26', Load(), lineno=74, col_offset=23, end_lineno=74, end_col_offset=27), Load(), lineno=74, col_offset=12, end_lineno=74, end_col_offset=28), 'update', Load(), lineno=74, col_offset=12, end_lineno=74, end_col_offset=35), [List([Subscript(Name('placeholder_24', Load(), lineno=74, col_offset=37, end_lineno=74, end_col_offset=45), Name('placeholder_27', Load(), lineno=74, col_offset=46, end_lineno=74, end_col_offset=53), Load(), lineno=74, col_offset=37, end_lineno=74, end_col_offset=54)], Load(), lineno=74, col_offset=36, end_lineno=74, end_col_offset=55)], [], lineno=74, col_offset=12, end_lineno=74, end_col_offset=56), lineno=74, col_offset=12, end_lineno=74, end_col_offset=56)], [], lineno=72, col_offset=4, end_lineno=74, end_col_offset=56), Return(Name('placeholder_23', Load(), lineno=76, col_offset=11, end_lineno=76, end_col_offset=21), lineno=76, col_offset=4, end_lineno=76, end_col_offset=21)], [], lineno=63, col_offset=0, end_lineno=76, end_col_offset=21), FunctionDef('placeholder_28', arguments([], [arg('placeholder_23', lineno=79, col_offset=16, end_lineno=79, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_29', Store(), lineno=85, col_offset=4, end_lineno=85, end_col_offset=17)], Constant('{:<30} | {:4>} | {:4>} | {:4>} | {:4>} | {:>2}', lineno=85, col_offset=20, end_lineno=85, end_col_offset=71), lineno=85, col_offset=4, end_lineno=85, end_col_offset=71), Assign([Name('placeholder_30', Store(), lineno=87, col_offset=4, end_lineno=87, end_col_offset=10)], List([Tuple([Constant('Team', lineno=87, col_offset=16, end_lineno=87, end_col_offset=22), Constant('MP', lineno=87, col_offset=24, end_lineno=87, end_col_offset=28), Constant('W', lineno=87, col_offset=30, end_lineno=87, end_col_offset=33), Constant('D', lineno=87, col_offset=35, end_lineno=87, end_col_offset=38), Constant('L', lineno=87, col_offset=40, end_lineno=87, end_col_offset=43), Constant('P', lineno=87, col_offset=45, end_lineno=87, end_col_offset=48)], Load(), lineno=87, col_offset=15, end_lineno=87, end_col_offset=49)], Load(), lineno=87, col_offset=14, end_lineno=87, end_col_offset=50), lineno=87, col_offset=4, end_lineno=87, end_col_offset=50), Assign([Name('placeholder_31', Store(), lineno=88, col_offset=4, end_lineno=88, end_col_offset=11)], GeneratorExp(Tuple([Name('placeholder_32', Load(), lineno=88, col_offset=16, end_lineno=88, end_col_offset=20), BinOp(Constant(' ', lineno=88, col_offset=22, end_lineno=88, end_col_offset=25), Add(), Call(Name('str', Load(), lineno=88, col_offset=28, end_lineno=88, end_col_offset=31), [Call(Name('sum', Load(), lineno=88, col_offset=32, end_lineno=88, end_col_offset=35), [Call(Attribute(Subscript(Name('placeholder_23', Load(), lineno=88, col_offset=36, end_lineno=88, end_col_offset=46), Name('placeholder_32', Load(), lineno=88, col_offset=47, end_lineno=88, end_col_offset=51), Load(), lineno=88, col_offset=36, end_lineno=88, end_col_offset=52), 'values', Load(), lineno=88, col_offset=36, end_lineno=88, end_col_offset=59), [], [], lineno=88, col_offset=36, end_lineno=88, end_col_offset=61)], [], lineno=88, col_offset=32, end_lineno=88, end_col_offset=62)], [], lineno=88, col_offset=28, end_lineno=88, end_col_offset=63), lineno=88, col_offset=22, end_lineno=88, end_col_offset=63), Subscript(Subscript(Name('placeholder_23', Load(), lineno=89, col_offset=22, end_lineno=89, end_col_offset=32), Name('placeholder_32', Load(), lineno=89, col_offset=33, end_lineno=89, end_col_offset=37), Load(), lineno=89, col_offset=22, end_lineno=89, end_col_offset=38), Constant('win', lineno=89, col_offset=39, end_lineno=89, end_col_offset=44), Load(), lineno=89, col_offset=22, end_lineno=89, end_col_offset=45), Subscript(Subscript(Name('placeholder_23', Load(), lineno=90, col_offset=22, end_lineno=90, end_col_offset=32), Name('placeholder_32', Load(), lineno=90, col_offset=33, end_lineno=90, end_col_offset=37), Load(), lineno=90, col_offset=22, end_lineno=90, end_col_offset=38), Constant('draw', lineno=90, col_offset=39, end_lineno=90, end_col_offset=45), Load(), lineno=90, col_offset=22, end_lineno=90, end_col_offset=46), Subscript(Subscript(Name('placeholder_23', Load(), lineno=91, col_offset=22, end_lineno=91, end_col_offset=32), Name('placeholder_32', Load(), lineno=91, col_offset=33, end_lineno=91, end_col_offset=37), Load(), lineno=91, col_offset=22, end_lineno=91, end_col_offset=38), Constant('loss', lineno=91, col_offset=39, end_lineno=91, end_col_offset=45), Load(), lineno=91, col_offset=22, end_lineno=91, end_col_offset=46), BinOp(BinOp(Subscript(Subscript(Name('placeholder_23', Load(), lineno=92, col_offset=22, end_lineno=92, end_col_offset=32), Name('placeholder_32', Load(), lineno=92, col_offset=33, end_lineno=92, end_col_offset=37), Load(), lineno=92, col_offset=22, end_lineno=92, end_col_offset=38), Constant('win', lineno=92, col_offset=39, end_lineno=92, end_col_offset=44), Load(), lineno=92, col_offset=22, end_lineno=92, end_col_offset=45), Mult(), Constant(3, lineno=92, col_offset=48, end_lineno=92, end_col_offset=49), lineno=92, col_offset=22, end_lineno=92, end_col_offset=49), Add(), Subscript(Subscript(Name('placeholder_23', Load(), lineno=92, col_offset=52, end_lineno=92, end_col_offset=62), Name('placeholder_32', Load(), lineno=92, col_offset=63, end_lineno=92, end_col_offset=67), Load(), lineno=92, col_offset=52, end_lineno=92, end_col_offset=68), Constant('draw', lineno=92, col_offset=69, end_lineno=92, end_col_offset=75), Load(), lineno=92, col_offset=52, end_lineno=92, end_col_offset=76), lineno=92, col_offset=22, end_lineno=92, end_col_offset=76)], Load(), lineno=88, col_offset=15, end_lineno=92, end_col_offset=77), [comprehension(Name('placeholder_32', Store(), lineno=93, col_offset=26, end_lineno=93, end_col_offset=30), Call(Attribute(Name('placeholder_23', Load(), lineno=93, col_offset=34, end_lineno=93, end_col_offset=44), 'keys', Load(), lineno=93, col_offset=34, end_lineno=93, end_col_offset=49), [], [], lineno=93, col_offset=34, end_lineno=93, end_col_offset=51), [], 0)], lineno=88, col_offset=14, end_lineno=93, end_col_offset=52), lineno=88, col_offset=4, end_lineno=93, end_col_offset=52), Assign([Name('placeholder_33', Store(), lineno=96, col_offset=4, end_lineno=96, end_col_offset=16)], BinOp(Name('placeholder_30', Load(), lineno=96, col_offset=19, end_lineno=96, end_col_offset=25), Add(), Call(Name('sorted', Load(), lineno=96, col_offset=28, end_lineno=96, end_col_offset=34), [Name('placeholder_31', Load(), lineno=96, col_offset=35, end_lineno=96, end_col_offset=42)], [keyword('placeholder_34', Lambda(arguments([], [arg('placeholder_3', lineno=96, col_offset=55, end_lineno=96, end_col_offset=56)], kwonlyargs=[], kw_defaults=[], defaults=[]), Tuple([UnaryOp(USub(), Subscript(Name('placeholder_3', Load(), lineno=96, col_offset=61, end_lineno=96, end_col_offset=62), Constant(5, lineno=96, col_offset=63, end_lineno=96, end_col_offset=64), Load(), lineno=96, col_offset=61, end_lineno=96, end_col_offset=65), lineno=96, col_offset=59, end_lineno=96, end_col_offset=66), Name('placeholder_3', Load(), lineno=96, col_offset=68, end_lineno=96, end_col_offset=69)], Load(), lineno=96, col_offset=58, end_lineno=96, end_col_offset=70), lineno=96, col_offset=48, end_lineno=96, end_col_offset=70), lineno=96, col_offset=44, end_lineno=96, end_col_offset=70)], lineno=96, col_offset=28, end_lineno=96, end_col_offset=71), lineno=96, col_offset=19, end_lineno=96, end_col_offset=71), lineno=96, col_offset=4, end_lineno=96, end_col_offset=71), Return(Call(Attribute(Call(Attribute(Constant('\n', lineno=98, col_offset=11, end_lineno=98, end_col_offset=15), 'join', Load(), lineno=98, col_offset=11, end_lineno=98, end_col_offset=20), [GeneratorExp(Call(Attribute(Name('placeholder_29', Load(), lineno=98, col_offset=21, end_lineno=98, end_col_offset=34), 'format', Load(), lineno=98, col_offset=21, end_lineno=98, end_col_offset=41), [Starred(Name('placeholder_32', Load(), lineno=98, col_offset=43, end_lineno=98, end_col_offset=47), Load(), lineno=98, col_offset=42, end_lineno=98, end_col_offset=47)], [], lineno=98, col_offset=21, end_lineno=98, end_col_offset=48), [comprehension(Name('placeholder_32', Store(), lineno=98, col_offset=53, end_lineno=98, end_col_offset=57), Name('placeholder_33', Load(), lineno=98, col_offset=61, end_lineno=98, end_col_offset=73), [], 0)], lineno=98, col_offset=20, end_lineno=98, end_col_offset=74)], [], lineno=98, col_offset=11, end_lineno=98, end_col_offset=74), 'split', Load(), lineno=98, col_offset=11, end_lineno=98, end_col_offset=80), [Constant('\n', lineno=98, col_offset=81, end_lineno=98, end_col_offset=85)], [], lineno=98, col_offset=11, end_lineno=98, end_col_offset=86), lineno=98, col_offset=4, end_lineno=98, end_col_offset=86)], [], lineno=79, col_offset=0, end_lineno=98, end_col_offset=86)], []) \ No newline at end of file diff --git a/test/example-main-removal/.meta/config.json b/test/example-main-removal/.meta/config.json new file mode 100644 index 0000000..f1c8d40 --- /dev/null +++ b/test/example-main-removal/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_main_removal.py" + ] + } +} \ No newline at end of file diff --git a/test/example-main-removal/example_main_removal.py b/test/example-main-removal/example_main_removal.py new file mode 100644 index 0000000..b24bf3b --- /dev/null +++ b/test/example-main-removal/example_main_removal.py @@ -0,0 +1,102 @@ +"""Functions for tracking poker hands and assorted card tasks. + +Python list documentation: https://docs.python.org/3/tutorial/datastructures.html +""" +import statistics + +def get_rounds(number): + """ + + :param number: int - current round number. + :return: list - current round and the two that follow. + """ + + return [int( number ), int( number ) + 1, int( number ) + 2] + + +def concatenate_rounds(rounds_1, rounds_2): + """ + + :param rounds_1: list - first rounds played. + :param rounds_2: list - second set of rounds played. + :return: list - all rounds played. + """ + + return rounds_1 + rounds_2 + + +def list_contains_round(rounds, number): + """ + + :param rounds: list - rounds played. + :param number: int - round number. + :return: bool - was the round played? + """ + + if(number in rounds): + return True + else: + return False + +def card_average(hand): + """ + + :param hand: list - cards in hand. + :return: float - average value of the cards in the hand. + """ + + return round(sum(hand)/len(hand), 1) + + +def approx_average_is_average(hand): + """ + + :param hand: list - cards in hand. + :return: bool - if approximate average equals to the `true average`. + """ + + avg = (sum(hand) / len(hand)) + skrajne = avg == (hand[0] + hand[-1]) / 2 + mediana = avg == statistics.median(hand) + + if (mediana == True or skrajne == True): + return True + else: + return False + +def average_even_is_average_odd(hand): + """ + + :param hand: list - cards in hand. + :return: bool - are even and odd averages equal? + """ + count_odd = len(hand[0:len(hand):2]) + avg_odd = (sum(hand[0:len(hand):2])) / count_odd + count_even = len( hand[1:len( hand ):2] ) + avg_even = (sum( hand[1:len( hand ):2] )) / count_even + + return avg_odd == avg_even + + +def maybe_double_last(hand): + """ + + :param hand: list - cards in hand. + :return: list - hand with Jacks (if present) value doubled. + """ + + if(hand[-1] == 11): + return [hand [0], hand [1], hand[-1] * 2] + else: + return hand + + +if __name__ == '__main__': + # print(add_prefix_un(input("Enter number: "))) + print( f"list of rounds: {get_rounds(7)}" ) + print( f"list 1 and 2: {concatenate_rounds([27, 28, 29], [35, 36])}" ) + print( f"Is round played?: {list_contains_round([27, 28, 21], 28)}" ) + print( f"Average on hand: {card_average([0, 1, 5])}" ) + print( f"Aprox Average on hand: {approx_average_is_average([1, 2, 3, 5, 9])}" ) + print( f"Is odd == even: {average_even_is_average_odd([1, 2, 3, 4])}" ) + print( f"Hand after mayby double: {maybe_double_last([1, 2, 11])}" ) diff --git a/test/example-main-removal/mapping.json b/test/example-main-removal/mapping.json new file mode 100644 index 0000000..aac245d --- /dev/null +++ b/test/example-main-removal/mapping.json @@ -0,0 +1,21 @@ +{ + "placeholder_0": "get_rounds", + "placeholder_1": "number", + "placeholder_2": "concatenate_rounds", + "placeholder_3": "rounds_1", + "placeholder_4": "rounds_2", + "placeholder_5": "list_contains_round", + "placeholder_6": "rounds", + "placeholder_7": "card_average", + "placeholder_8": "hand", + "placeholder_9": "approx_average_is_average", + "placeholder_10": "avg", + "placeholder_11": "skrajne", + "placeholder_12": "mediana", + "placeholder_13": "average_even_is_average_odd", + "placeholder_14": "count_odd", + "placeholder_15": "avg_odd", + "placeholder_16": "count_even", + "placeholder_17": "avg_even", + "placeholder_18": "maybe_double_last" +} \ No newline at end of file diff --git a/test/example-main-removal/representation.json b/test/example-main-removal/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-main-removal/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-main-removal/representation.out b/test/example-main-removal/representation.out new file mode 100644 index 0000000..bf9af10 --- /dev/null +++ b/test/example-main-removal/representation.out @@ -0,0 +1,3146 @@ +## BEGIN NORMALIZED CODE ## +import statistics + + +def placeholder_0(placeholder_1): + return [int(placeholder_1), int(placeholder_1) + 1, int(placeholder_1) + 2] + + +def placeholder_2(placeholder_3, placeholder_4): + return placeholder_3 + placeholder_4 + + +def placeholder_5(placeholder_6, placeholder_1): + if placeholder_1 in placeholder_6: + return True + else: + return False + + +def placeholder_7(placeholder_8): + return round(sum(placeholder_8) / len(placeholder_8), 1) + + +def placeholder_9(placeholder_8): + placeholder_10 = sum(placeholder_8) / len(placeholder_8) + placeholder_11 = placeholder_10 == (placeholder_8[0] + placeholder_8[-1]) / 2 + placeholder_12 = placeholder_10 == statistics.median(placeholder_8) + if placeholder_12 == True or placeholder_11 == True: + return True + else: + return False + + +def placeholder_13(placeholder_8): + placeholder_14 = len(placeholder_8[0 : len(placeholder_8) : 2]) + placeholder_15 = sum(placeholder_8[0 : len(placeholder_8) : 2]) / placeholder_14 + placeholder_16 = len(placeholder_8[1 : len(placeholder_8) : 2]) + placeholder_17 = sum(placeholder_8[1 : len(placeholder_8) : 2]) / placeholder_16 + return placeholder_15 == placeholder_17 + + +def placeholder_18(placeholder_8): + if placeholder_8[-1] == 11: + return [placeholder_8[0], placeholder_8[1], placeholder_8[-1] * 2] + else: + return placeholder_8 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions for tracking poker hands and assorted card tasks.\n\nPython list documentation: https://docs.python.org/3/tutorial/datastructures.html\n', + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + Import( + [ + alias( + 'statistics', + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=17)], + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=17), + FunctionDef( + 'get_rounds', + arguments( + [], + [ + arg( + 'number', + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param number: int - current round number.\n :return: list - current round and the two that follow.\n ', + lineno=8, + col_offset=4, + end_lineno=12, + end_col_offset=7), + lineno=8, + col_offset=4, + end_lineno=12, + end_col_offset=7), + Return( + List( + [ + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=15), + [ + Name( + 'number', + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=23)], + [], + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=25), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=30), + [ + Name( + 'number', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=38)], + [], + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=14, + col_offset=43, + end_lineno=14, + end_col_offset=44), + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=44), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=46, + end_lineno=14, + end_col_offset=49), + [ + Name( + 'number', + Load(), + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=57)], + [], + lineno=14, + col_offset=46, + end_lineno=14, + end_col_offset=59), + Add(), + Constant( + 2, + lineno=14, + col_offset=62, + end_lineno=14, + end_col_offset=63), + lineno=14, + col_offset=46, + end_lineno=14, + end_col_offset=63)], + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=64), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=64)], + [], + lineno=7, + col_offset=0, + end_lineno=14, + end_col_offset=64), + FunctionDef( + 'concatenate_rounds', + arguments( + [], + [ + arg( + 'rounds_1', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=31), + arg( + 'rounds_2', + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param rounds_1: list - first rounds played.\n :param rounds_2: list - second set of rounds played.\n :return: list - all rounds played.\n ', + lineno=18, + col_offset=4, + end_lineno=23, + end_col_offset=7), + lineno=18, + col_offset=4, + end_lineno=23, + end_col_offset=7), + Return( + BinOp( + Name( + 'rounds_1', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=19), + Add(), + Name( + 'rounds_2', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=30)], + [], + lineno=17, + col_offset=0, + end_lineno=25, + end_col_offset=30), + FunctionDef( + 'list_contains_round', + arguments( + [], + [ + arg( + 'rounds', + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=30), + arg( + 'number', + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param rounds: list - rounds played.\n :param number: int - round number.\n :return: bool - was the round played?\n ', + lineno=29, + col_offset=4, + end_lineno=34, + end_col_offset=7), + lineno=29, + col_offset=4, + end_lineno=34, + end_col_offset=7), + If( + Compare( + Name( + 'number', + Load(), + lineno=36, + col_offset=7, + end_lineno=36, + end_col_offset=13), + [ + In()], + [ + Name( + 'rounds', + Load(), + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=23)], + lineno=36, + col_offset=7, + end_lineno=36, + end_col_offset=23), + [ + Return( + Constant( + True, + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=19), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=19)], + [ + Return( + Constant( + False, + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=20), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=20)], + lineno=36, + col_offset=4, + end_lineno=39, + end_col_offset=20)], + [], + lineno=28, + col_offset=0, + end_lineno=39, + end_col_offset=20), + FunctionDef( + 'card_average', + arguments( + [], + [ + arg( + 'hand', + lineno=41, + col_offset=17, + end_lineno=41, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param hand: list - cards in hand.\n :return: float - average value of the cards in the hand.\n ', + lineno=42, + col_offset=4, + end_lineno=46, + end_col_offset=7), + lineno=42, + col_offset=4, + end_lineno=46, + end_col_offset=7), + Return( + Call( + Name( + 'round', + Load(), + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=16), + [ + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=20), + [ + Name( + 'hand', + Load(), + lineno=48, + col_offset=21, + end_lineno=48, + end_col_offset=25)], + [], + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=26), + Div(), + Call( + Name( + 'len', + Load(), + lineno=48, + col_offset=27, + end_lineno=48, + end_col_offset=30), + [ + Name( + 'hand', + Load(), + lineno=48, + col_offset=31, + end_lineno=48, + end_col_offset=35)], + [], + lineno=48, + col_offset=27, + end_lineno=48, + end_col_offset=36), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=36), + Constant( + 1, + lineno=48, + col_offset=38, + end_lineno=48, + end_col_offset=39)], + [], + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=40), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=40)], + [], + lineno=41, + col_offset=0, + end_lineno=48, + end_col_offset=40), + FunctionDef( + 'approx_average_is_average', + arguments( + [], + [ + arg( + 'hand', + lineno=51, + col_offset=30, + end_lineno=51, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param hand: list - cards in hand.\n :return: bool - if approximate average equals to the `true average`.\n ', + lineno=52, + col_offset=4, + end_lineno=56, + end_col_offset=7), + lineno=52, + col_offset=4, + end_lineno=56, + end_col_offset=7), + Assign( + [ + Name( + 'avg', + Store(), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=7)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=14), + [ + Name( + 'hand', + Load(), + lineno=58, + col_offset=15, + end_lineno=58, + end_col_offset=19)], + [], + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=20), + Div(), + Call( + Name( + 'len', + Load(), + lineno=58, + col_offset=23, + end_lineno=58, + end_col_offset=26), + [ + Name( + 'hand', + Load(), + lineno=58, + col_offset=27, + end_lineno=58, + end_col_offset=31)], + [], + lineno=58, + col_offset=23, + end_lineno=58, + end_col_offset=32), + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=32), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=33), + Assign( + [ + Name( + 'skrajne', + Store(), + lineno=59, + col_offset=4, + end_lineno=59, + end_col_offset=11)], + Compare( + Name( + 'avg', + Load(), + lineno=59, + col_offset=14, + end_lineno=59, + end_col_offset=17), + [ + Eq()], + [ + BinOp( + BinOp( + Subscript( + Name( + 'hand', + Load(), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=26), + Constant( + 0, + lineno=59, + col_offset=27, + end_lineno=59, + end_col_offset=28), + Load(), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=29), + Add(), + Subscript( + Name( + 'hand', + Load(), + lineno=59, + col_offset=32, + end_lineno=59, + end_col_offset=36), + UnaryOp( + USub(), + Constant( + 1, + lineno=59, + col_offset=38, + end_lineno=59, + end_col_offset=39), + lineno=59, + col_offset=37, + end_lineno=59, + end_col_offset=39), + Load(), + lineno=59, + col_offset=32, + end_lineno=59, + end_col_offset=40), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=40), + Div(), + Constant( + 2, + lineno=59, + col_offset=44, + end_lineno=59, + end_col_offset=45), + lineno=59, + col_offset=21, + end_lineno=59, + end_col_offset=45)], + lineno=59, + col_offset=14, + end_lineno=59, + end_col_offset=45), + lineno=59, + col_offset=4, + end_lineno=59, + end_col_offset=45), + Assign( + [ + Name( + 'mediana', + Store(), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=11)], + Compare( + Name( + 'avg', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=17), + [ + Eq()], + [ + Call( + Attribute( + Name( + 'statistics', + Load(), + lineno=60, + col_offset=21, + end_lineno=60, + end_col_offset=31), + 'median', + Load(), + lineno=60, + col_offset=21, + end_lineno=60, + end_col_offset=38), + [ + Name( + 'hand', + Load(), + lineno=60, + col_offset=39, + end_lineno=60, + end_col_offset=43)], + [], + lineno=60, + col_offset=21, + end_lineno=60, + end_col_offset=44)], + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=44), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=44), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'mediana', + Load(), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=15), + [ + Eq()], + [ + Constant( + True, + lineno=62, + col_offset=19, + end_lineno=62, + end_col_offset=23)], + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=23), + Compare( + Name( + 'skrajne', + Load(), + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=34), + [ + Eq()], + [ + Constant( + True, + lineno=62, + col_offset=38, + end_lineno=62, + end_col_offset=42)], + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=42)], + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=42), + [ + Return( + Constant( + True, + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=19), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=19)], + [ + Return( + Constant( + False, + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=20), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=20)], + lineno=62, + col_offset=4, + end_lineno=65, + end_col_offset=20)], + [], + lineno=51, + col_offset=0, + end_lineno=65, + end_col_offset=20), + FunctionDef( + 'average_even_is_average_odd', + arguments( + [], + [ + arg( + 'hand', + lineno=67, + col_offset=32, + end_lineno=67, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param hand: list - cards in hand.\n :return: bool - are even and odd averages equal?\n ', + lineno=68, + col_offset=4, + end_lineno=72, + end_col_offset=7), + lineno=68, + col_offset=4, + end_lineno=72, + end_col_offset=7), + Assign( + [ + Name( + 'count_odd', + Store(), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=13)], + Call( + Name( + 'len', + Load(), + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=19), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=73, + col_offset=20, + end_lineno=73, + end_col_offset=24), + Slice( + Constant( + 0, + lineno=73, + col_offset=25, + end_lineno=73, + end_col_offset=26), + Call( + Name( + 'len', + Load(), + lineno=73, + col_offset=27, + end_lineno=73, + end_col_offset=30), + [ + Name( + 'hand', + Load(), + lineno=73, + col_offset=31, + end_lineno=73, + end_col_offset=35)], + [], + lineno=73, + col_offset=27, + end_lineno=73, + end_col_offset=36), + Constant( + 2, + lineno=73, + col_offset=37, + end_lineno=73, + end_col_offset=38), + lineno=73, + col_offset=25, + end_lineno=73, + end_col_offset=38), + Load(), + lineno=73, + col_offset=20, + end_lineno=73, + end_col_offset=39)], + [], + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=40), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=40), + Assign( + [ + Name( + 'avg_odd', + Store(), + lineno=74, + col_offset=4, + end_lineno=74, + end_col_offset=11)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=18), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=74, + col_offset=19, + end_lineno=74, + end_col_offset=23), + Slice( + Constant( + 0, + lineno=74, + col_offset=24, + end_lineno=74, + end_col_offset=25), + Call( + Name( + 'len', + Load(), + lineno=74, + col_offset=26, + end_lineno=74, + end_col_offset=29), + [ + Name( + 'hand', + Load(), + lineno=74, + col_offset=30, + end_lineno=74, + end_col_offset=34)], + [], + lineno=74, + col_offset=26, + end_lineno=74, + end_col_offset=35), + Constant( + 2, + lineno=74, + col_offset=36, + end_lineno=74, + end_col_offset=37), + lineno=74, + col_offset=24, + end_lineno=74, + end_col_offset=37), + Load(), + lineno=74, + col_offset=19, + end_lineno=74, + end_col_offset=38)], + [], + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=39), + Div(), + Name( + 'count_odd', + Load(), + lineno=74, + col_offset=43, + end_lineno=74, + end_col_offset=52), + lineno=74, + col_offset=14, + end_lineno=74, + end_col_offset=52), + lineno=74, + col_offset=4, + end_lineno=74, + end_col_offset=52), + Assign( + [ + Name( + 'count_even', + Store(), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=14)], + Call( + Name( + 'len', + Load(), + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=20), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=75, + col_offset=22, + end_lineno=75, + end_col_offset=26), + Slice( + Constant( + 1, + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=28), + Call( + Name( + 'len', + Load(), + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=32), + [ + Name( + 'hand', + Load(), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=38)], + [], + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=40), + Constant( + 2, + lineno=75, + col_offset=41, + end_lineno=75, + end_col_offset=42), + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=42), + Load(), + lineno=75, + col_offset=22, + end_lineno=75, + end_col_offset=43)], + [], + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=45), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=45), + Assign( + [ + Name( + 'avg_even', + Store(), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=12)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=76, + col_offset=16, + end_lineno=76, + end_col_offset=19), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=76, + col_offset=21, + end_lineno=76, + end_col_offset=25), + Slice( + Constant( + 1, + lineno=76, + col_offset=26, + end_lineno=76, + end_col_offset=27), + Call( + Name( + 'len', + Load(), + lineno=76, + col_offset=28, + end_lineno=76, + end_col_offset=31), + [ + Name( + 'hand', + Load(), + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=37)], + [], + lineno=76, + col_offset=28, + end_lineno=76, + end_col_offset=39), + Constant( + 2, + lineno=76, + col_offset=40, + end_lineno=76, + end_col_offset=41), + lineno=76, + col_offset=26, + end_lineno=76, + end_col_offset=41), + Load(), + lineno=76, + col_offset=21, + end_lineno=76, + end_col_offset=42)], + [], + lineno=76, + col_offset=16, + end_lineno=76, + end_col_offset=44), + Div(), + Name( + 'count_even', + Load(), + lineno=76, + col_offset=48, + end_lineno=76, + end_col_offset=58), + lineno=76, + col_offset=15, + end_lineno=76, + end_col_offset=58), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=58), + Return( + Compare( + Name( + 'avg_odd', + Load(), + lineno=78, + col_offset=11, + end_lineno=78, + end_col_offset=18), + [ + Eq()], + [ + Name( + 'avg_even', + Load(), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=30)], + lineno=78, + col_offset=11, + end_lineno=78, + end_col_offset=30), + lineno=78, + col_offset=4, + end_lineno=78, + end_col_offset=30)], + [], + lineno=67, + col_offset=0, + end_lineno=78, + end_col_offset=30), + FunctionDef( + 'maybe_double_last', + arguments( + [], + [ + arg( + 'hand', + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param hand: list - cards in hand.\n :return: list - hand with Jacks (if present) value doubled.\n ', + lineno=82, + col_offset=4, + end_lineno=86, + end_col_offset=7), + lineno=82, + col_offset=4, + end_lineno=86, + end_col_offset=7), + If( + Compare( + Subscript( + Name( + 'hand', + Load(), + lineno=88, + col_offset=7, + end_lineno=88, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=88, + col_offset=13, + end_lineno=88, + end_col_offset=14), + lineno=88, + col_offset=12, + end_lineno=88, + end_col_offset=14), + Load(), + lineno=88, + col_offset=7, + end_lineno=88, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 11, + lineno=88, + col_offset=19, + end_lineno=88, + end_col_offset=21)], + lineno=88, + col_offset=7, + end_lineno=88, + end_col_offset=21), + [ + Return( + List( + [ + Subscript( + Name( + 'hand', + Load(), + lineno=89, + col_offset=16, + end_lineno=89, + end_col_offset=20), + Constant( + 0, + lineno=89, + col_offset=22, + end_lineno=89, + end_col_offset=23), + Load(), + lineno=89, + col_offset=16, + end_lineno=89, + end_col_offset=24), + Subscript( + Name( + 'hand', + Load(), + lineno=89, + col_offset=26, + end_lineno=89, + end_col_offset=30), + Constant( + 1, + lineno=89, + col_offset=32, + end_lineno=89, + end_col_offset=33), + Load(), + lineno=89, + col_offset=26, + end_lineno=89, + end_col_offset=34), + BinOp( + Subscript( + Name( + 'hand', + Load(), + lineno=89, + col_offset=36, + end_lineno=89, + end_col_offset=40), + UnaryOp( + USub(), + Constant( + 1, + lineno=89, + col_offset=42, + end_lineno=89, + end_col_offset=43), + lineno=89, + col_offset=41, + end_lineno=89, + end_col_offset=43), + Load(), + lineno=89, + col_offset=36, + end_lineno=89, + end_col_offset=44), + Mult(), + Constant( + 2, + lineno=89, + col_offset=47, + end_lineno=89, + end_col_offset=48), + lineno=89, + col_offset=36, + end_lineno=89, + end_col_offset=48)], + Load(), + lineno=89, + col_offset=15, + end_lineno=89, + end_col_offset=49), + lineno=89, + col_offset=8, + end_lineno=89, + end_col_offset=49)], + [ + Return( + Name( + 'hand', + Load(), + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=19), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=19)], + lineno=88, + col_offset=4, + end_lineno=91, + end_col_offset=19)], + [], + lineno=81, + col_offset=0, + end_lineno=91, + end_col_offset=19), + If( + Compare( + Name( + '__name__', + Load(), + lineno=94, + col_offset=3, + end_lineno=94, + end_col_offset=11), + [ + Eq()], + [ + Constant( + '__main__', + lineno=94, + col_offset=15, + end_lineno=94, + end_col_offset=25)], + lineno=94, + col_offset=3, + end_lineno=94, + end_col_offset=25), + [ + Expr( + Call( + Name( + 'print', + Load(), + lineno=96, + col_offset=4, + end_lineno=96, + end_col_offset=9), + [ + JoinedStr( + [ + Constant( + 'list of rounds: ', + lineno=96, + col_offset=11, + end_lineno=96, + end_col_offset=45), + FormattedValue( + Call( + Name( + 'get_rounds', + Load(), + lineno=96, + col_offset=30, + end_lineno=96, + end_col_offset=40), + [ + Constant( + 7, + lineno=96, + col_offset=41, + end_lineno=96, + end_col_offset=42)], + [], + lineno=96, + col_offset=30, + end_lineno=96, + end_col_offset=43), + -1, + lineno=96, + col_offset=11, + end_lineno=96, + end_col_offset=45)], + lineno=96, + col_offset=11, + end_lineno=96, + end_col_offset=45)], + [], + lineno=96, + col_offset=4, + end_lineno=96, + end_col_offset=47), + lineno=96, + col_offset=4, + end_lineno=96, + end_col_offset=47), + Expr( + Call( + Name( + 'print', + Load(), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=9), + [ + JoinedStr( + [ + Constant( + 'list 1 and 2: ', + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=72), + FormattedValue( + Call( + Name( + 'concatenate_rounds', + Load(), + lineno=97, + col_offset=28, + end_lineno=97, + end_col_offset=46), + [ + List( + [ + Constant( + 27, + lineno=97, + col_offset=48, + end_lineno=97, + end_col_offset=50), + Constant( + 28, + lineno=97, + col_offset=52, + end_lineno=97, + end_col_offset=54), + Constant( + 29, + lineno=97, + col_offset=56, + end_lineno=97, + end_col_offset=58)], + Load(), + lineno=97, + col_offset=47, + end_lineno=97, + end_col_offset=59), + List( + [ + Constant( + 35, + lineno=97, + col_offset=62, + end_lineno=97, + end_col_offset=64), + Constant( + 36, + lineno=97, + col_offset=66, + end_lineno=97, + end_col_offset=68)], + Load(), + lineno=97, + col_offset=61, + end_lineno=97, + end_col_offset=69)], + [], + lineno=97, + col_offset=28, + end_lineno=97, + end_col_offset=70), + -1, + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=72)], + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=72)], + [], + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=74), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=74), + Expr( + Call( + Name( + 'print', + Load(), + lineno=98, + col_offset=4, + end_lineno=98, + end_col_offset=9), + [ + JoinedStr( + [ + Constant( + 'Is round played?: ', + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=71), + FormattedValue( + Call( + Name( + 'list_contains_round', + Load(), + lineno=98, + col_offset=32, + end_lineno=98, + end_col_offset=51), + [ + List( + [ + Constant( + 27, + lineno=98, + col_offset=53, + end_lineno=98, + end_col_offset=55), + Constant( + 28, + lineno=98, + col_offset=57, + end_lineno=98, + end_col_offset=59), + Constant( + 21, + lineno=98, + col_offset=61, + end_lineno=98, + end_col_offset=63)], + Load(), + lineno=98, + col_offset=52, + end_lineno=98, + end_col_offset=64), + Constant( + 28, + lineno=98, + col_offset=66, + end_lineno=98, + end_col_offset=68)], + [], + lineno=98, + col_offset=32, + end_lineno=98, + end_col_offset=69), + -1, + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=71)], + lineno=98, + col_offset=11, + end_lineno=98, + end_col_offset=71)], + [], + lineno=98, + col_offset=4, + end_lineno=98, + end_col_offset=73), + lineno=98, + col_offset=4, + end_lineno=98, + end_col_offset=73), + Expr( + Call( + Name( + 'print', + Load(), + lineno=99, + col_offset=4, + end_lineno=99, + end_col_offset=9), + [ + JoinedStr( + [ + Constant( + 'Average on hand: ', + lineno=99, + col_offset=11, + end_lineno=99, + end_col_offset=56), + FormattedValue( + Call( + Name( + 'card_average', + Load(), + lineno=99, + col_offset=31, + end_lineno=99, + end_col_offset=43), + [ + List( + [ + Constant( + 0, + lineno=99, + col_offset=45, + end_lineno=99, + end_col_offset=46), + Constant( + 1, + lineno=99, + col_offset=48, + end_lineno=99, + end_col_offset=49), + Constant( + 5, + lineno=99, + col_offset=51, + end_lineno=99, + end_col_offset=52)], + Load(), + lineno=99, + col_offset=44, + end_lineno=99, + end_col_offset=53)], + [], + lineno=99, + col_offset=31, + end_lineno=99, + end_col_offset=54), + -1, + lineno=99, + col_offset=11, + end_lineno=99, + end_col_offset=56)], + lineno=99, + col_offset=11, + end_lineno=99, + end_col_offset=56)], + [], + lineno=99, + col_offset=4, + end_lineno=99, + end_col_offset=58), + lineno=99, + col_offset=4, + end_lineno=99, + end_col_offset=58), + Expr( + Call( + Name( + 'print', + Load(), + lineno=100, + col_offset=4, + end_lineno=100, + end_col_offset=9), + [ + JoinedStr( + [ + Constant( + 'Aprox Average on hand: ', + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=81), + FormattedValue( + Call( + Name( + 'approx_average_is_average', + Load(), + lineno=100, + col_offset=37, + end_lineno=100, + end_col_offset=62), + [ + List( + [ + Constant( + 1, + lineno=100, + col_offset=64, + end_lineno=100, + end_col_offset=65), + Constant( + 2, + lineno=100, + col_offset=67, + end_lineno=100, + end_col_offset=68), + Constant( + 3, + lineno=100, + col_offset=70, + end_lineno=100, + end_col_offset=71), + Constant( + 5, + lineno=100, + col_offset=73, + end_lineno=100, + end_col_offset=74), + Constant( + 9, + lineno=100, + col_offset=76, + end_lineno=100, + end_col_offset=77)], + Load(), + lineno=100, + col_offset=63, + end_lineno=100, + end_col_offset=78)], + [], + lineno=100, + col_offset=37, + end_lineno=100, + end_col_offset=79), + -1, + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=81)], + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=81)], + [], + lineno=100, + col_offset=4, + end_lineno=100, + end_col_offset=83), + lineno=100, + col_offset=4, + end_lineno=100, + end_col_offset=83), + Expr( + Call( + Name( + 'print', + Load(), + lineno=101, + col_offset=4, + end_lineno=101, + end_col_offset=9), + [ + JoinedStr( + [ + Constant( + 'Is odd == even: ', + lineno=101, + col_offset=11, + end_lineno=101, + end_col_offset=73), + FormattedValue( + Call( + Name( + 'average_even_is_average_odd', + Load(), + lineno=101, + col_offset=30, + end_lineno=101, + end_col_offset=57), + [ + List( + [ + Constant( + 1, + lineno=101, + col_offset=59, + end_lineno=101, + end_col_offset=60), + Constant( + 2, + lineno=101, + col_offset=62, + end_lineno=101, + end_col_offset=63), + Constant( + 3, + lineno=101, + col_offset=65, + end_lineno=101, + end_col_offset=66), + Constant( + 4, + lineno=101, + col_offset=68, + end_lineno=101, + end_col_offset=69)], + Load(), + lineno=101, + col_offset=58, + end_lineno=101, + end_col_offset=70)], + [], + lineno=101, + col_offset=30, + end_lineno=101, + end_col_offset=71), + -1, + lineno=101, + col_offset=11, + end_lineno=101, + end_col_offset=73)], + lineno=101, + col_offset=11, + end_lineno=101, + end_col_offset=73)], + [], + lineno=101, + col_offset=4, + end_lineno=101, + end_col_offset=75), + lineno=101, + col_offset=4, + end_lineno=101, + end_col_offset=75), + Expr( + Call( + Name( + 'print', + Load(), + lineno=102, + col_offset=4, + end_lineno=102, + end_col_offset=9), + [ + JoinedStr( + [ + Constant( + 'Hand after mayby double: ', + lineno=102, + col_offset=11, + end_lineno=102, + end_col_offset=70), + FormattedValue( + Call( + Name( + 'maybe_double_last', + Load(), + lineno=102, + col_offset=39, + end_lineno=102, + end_col_offset=56), + [ + List( + [ + Constant( + 1, + lineno=102, + col_offset=58, + end_lineno=102, + end_col_offset=59), + Constant( + 2, + lineno=102, + col_offset=61, + end_lineno=102, + end_col_offset=62), + Constant( + 11, + lineno=102, + col_offset=64, + end_lineno=102, + end_col_offset=66)], + Load(), + lineno=102, + col_offset=57, + end_lineno=102, + end_col_offset=67)], + [], + lineno=102, + col_offset=39, + end_lineno=102, + end_col_offset=68), + -1, + lineno=102, + col_offset=11, + end_lineno=102, + end_col_offset=70)], + lineno=102, + col_offset=11, + end_lineno=102, + end_col_offset=70)], + [], + lineno=102, + col_offset=4, + end_lineno=102, + end_col_offset=72), + lineno=102, + col_offset=4, + end_lineno=102, + end_col_offset=72)], + [], + lineno=94, + col_offset=0, + end_lineno=102, + end_col_offset=72)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'statistics', + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=17)], + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=17), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + List( + [ + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=15), + [ + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=23)], + [], + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=25), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=30), + [ + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=38)], + [], + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=14, + col_offset=43, + end_lineno=14, + end_col_offset=44), + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=44), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=46, + end_lineno=14, + end_col_offset=49), + [ + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=57)], + [], + lineno=14, + col_offset=46, + end_lineno=14, + end_col_offset=59), + Add(), + Constant( + 2, + lineno=14, + col_offset=62, + end_lineno=14, + end_col_offset=63), + lineno=14, + col_offset=46, + end_lineno=14, + end_col_offset=63)], + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=64), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=64)], + [], + lineno=7, + col_offset=0, + end_lineno=14, + end_col_offset=64), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=31), + arg( + 'placeholder_4', + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=19), + Add(), + Name( + 'placeholder_4', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=30)], + [], + lineno=17, + col_offset=0, + end_lineno=25, + end_col_offset=30), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=30), + arg( + 'placeholder_1', + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=36, + col_offset=7, + end_lineno=36, + end_col_offset=13), + [ + In()], + [ + Name( + 'placeholder_6', + Load(), + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=23)], + lineno=36, + col_offset=7, + end_lineno=36, + end_col_offset=23), + [ + Return( + Constant( + True, + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=19), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=19)], + [ + Return( + Constant( + False, + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=20), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=20)], + lineno=36, + col_offset=4, + end_lineno=39, + end_col_offset=20)], + [], + lineno=28, + col_offset=0, + end_lineno=39, + end_col_offset=20), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=41, + col_offset=17, + end_lineno=41, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'round', + Load(), + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=16), + [ + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=20), + [ + Name( + 'placeholder_8', + Load(), + lineno=48, + col_offset=21, + end_lineno=48, + end_col_offset=25)], + [], + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=26), + Div(), + Call( + Name( + 'len', + Load(), + lineno=48, + col_offset=27, + end_lineno=48, + end_col_offset=30), + [ + Name( + 'placeholder_8', + Load(), + lineno=48, + col_offset=31, + end_lineno=48, + end_col_offset=35)], + [], + lineno=48, + col_offset=27, + end_lineno=48, + end_col_offset=36), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=36), + Constant( + 1, + lineno=48, + col_offset=38, + end_lineno=48, + end_col_offset=39)], + [], + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=40), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=40)], + [], + lineno=41, + col_offset=0, + end_lineno=48, + end_col_offset=40), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=51, + col_offset=30, + end_lineno=51, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=7)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=14), + [ + Name( + 'placeholder_8', + Load(), + lineno=58, + col_offset=15, + end_lineno=58, + end_col_offset=19)], + [], + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=20), + Div(), + Call( + Name( + 'len', + Load(), + lineno=58, + col_offset=23, + end_lineno=58, + end_col_offset=26), + [ + Name( + 'placeholder_8', + Load(), + lineno=58, + col_offset=27, + end_lineno=58, + end_col_offset=31)], + [], + lineno=58, + col_offset=23, + end_lineno=58, + end_col_offset=32), + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=32), + lineno=58, + col_offset=4, + end_lineno=58, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=59, + col_offset=4, + end_lineno=59, + end_col_offset=11)], + Compare( + Name( + 'placeholder_10', + Load(), + lineno=59, + col_offset=14, + end_lineno=59, + end_col_offset=17), + [ + Eq()], + [ + BinOp( + BinOp( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=26), + Constant( + 0, + lineno=59, + col_offset=27, + end_lineno=59, + end_col_offset=28), + Load(), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=29), + Add(), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=59, + col_offset=32, + end_lineno=59, + end_col_offset=36), + UnaryOp( + USub(), + Constant( + 1, + lineno=59, + col_offset=38, + end_lineno=59, + end_col_offset=39), + lineno=59, + col_offset=37, + end_lineno=59, + end_col_offset=39), + Load(), + lineno=59, + col_offset=32, + end_lineno=59, + end_col_offset=40), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=40), + Div(), + Constant( + 2, + lineno=59, + col_offset=44, + end_lineno=59, + end_col_offset=45), + lineno=59, + col_offset=21, + end_lineno=59, + end_col_offset=45)], + lineno=59, + col_offset=14, + end_lineno=59, + end_col_offset=45), + lineno=59, + col_offset=4, + end_lineno=59, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=11)], + Compare( + Name( + 'placeholder_10', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=17), + [ + Eq()], + [ + Call( + Attribute( + Name( + 'statistics', + Load(), + lineno=60, + col_offset=21, + end_lineno=60, + end_col_offset=31), + 'median', + Load(), + lineno=60, + col_offset=21, + end_lineno=60, + end_col_offset=38), + [ + Name( + 'placeholder_8', + Load(), + lineno=60, + col_offset=39, + end_lineno=60, + end_col_offset=43)], + [], + lineno=60, + col_offset=21, + end_lineno=60, + end_col_offset=44)], + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=44), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=44), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_12', + Load(), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=15), + [ + Eq()], + [ + Constant( + True, + lineno=62, + col_offset=19, + end_lineno=62, + end_col_offset=23)], + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=23), + Compare( + Name( + 'placeholder_11', + Load(), + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=34), + [ + Eq()], + [ + Constant( + True, + lineno=62, + col_offset=38, + end_lineno=62, + end_col_offset=42)], + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=42)], + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=42), + [ + Return( + Constant( + True, + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=19), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=19)], + [ + Return( + Constant( + False, + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=20), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=20)], + lineno=62, + col_offset=4, + end_lineno=65, + end_col_offset=20)], + [], + lineno=51, + col_offset=0, + end_lineno=65, + end_col_offset=20), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=67, + col_offset=32, + end_lineno=67, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=13)], + Call( + Name( + 'len', + Load(), + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=19), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=73, + col_offset=20, + end_lineno=73, + end_col_offset=24), + Slice( + Constant( + 0, + lineno=73, + col_offset=25, + end_lineno=73, + end_col_offset=26), + Call( + Name( + 'len', + Load(), + lineno=73, + col_offset=27, + end_lineno=73, + end_col_offset=30), + [ + Name( + 'placeholder_8', + Load(), + lineno=73, + col_offset=31, + end_lineno=73, + end_col_offset=35)], + [], + lineno=73, + col_offset=27, + end_lineno=73, + end_col_offset=36), + Constant( + 2, + lineno=73, + col_offset=37, + end_lineno=73, + end_col_offset=38), + lineno=73, + col_offset=25, + end_lineno=73, + end_col_offset=38), + Load(), + lineno=73, + col_offset=20, + end_lineno=73, + end_col_offset=39)], + [], + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=40), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=74, + col_offset=4, + end_lineno=74, + end_col_offset=11)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=18), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=74, + col_offset=19, + end_lineno=74, + end_col_offset=23), + Slice( + Constant( + 0, + lineno=74, + col_offset=24, + end_lineno=74, + end_col_offset=25), + Call( + Name( + 'len', + Load(), + lineno=74, + col_offset=26, + end_lineno=74, + end_col_offset=29), + [ + Name( + 'placeholder_8', + Load(), + lineno=74, + col_offset=30, + end_lineno=74, + end_col_offset=34)], + [], + lineno=74, + col_offset=26, + end_lineno=74, + end_col_offset=35), + Constant( + 2, + lineno=74, + col_offset=36, + end_lineno=74, + end_col_offset=37), + lineno=74, + col_offset=24, + end_lineno=74, + end_col_offset=37), + Load(), + lineno=74, + col_offset=19, + end_lineno=74, + end_col_offset=38)], + [], + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=39), + Div(), + Name( + 'placeholder_14', + Load(), + lineno=74, + col_offset=43, + end_lineno=74, + end_col_offset=52), + lineno=74, + col_offset=14, + end_lineno=74, + end_col_offset=52), + lineno=74, + col_offset=4, + end_lineno=74, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=14)], + Call( + Name( + 'len', + Load(), + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=20), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=75, + col_offset=22, + end_lineno=75, + end_col_offset=26), + Slice( + Constant( + 1, + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=28), + Call( + Name( + 'len', + Load(), + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=32), + [ + Name( + 'placeholder_8', + Load(), + lineno=75, + col_offset=34, + end_lineno=75, + end_col_offset=38)], + [], + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=40), + Constant( + 2, + lineno=75, + col_offset=41, + end_lineno=75, + end_col_offset=42), + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=42), + Load(), + lineno=75, + col_offset=22, + end_lineno=75, + end_col_offset=43)], + [], + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=45), + lineno=75, + col_offset=4, + end_lineno=75, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=12)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=76, + col_offset=16, + end_lineno=76, + end_col_offset=19), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=76, + col_offset=21, + end_lineno=76, + end_col_offset=25), + Slice( + Constant( + 1, + lineno=76, + col_offset=26, + end_lineno=76, + end_col_offset=27), + Call( + Name( + 'len', + Load(), + lineno=76, + col_offset=28, + end_lineno=76, + end_col_offset=31), + [ + Name( + 'placeholder_8', + Load(), + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=37)], + [], + lineno=76, + col_offset=28, + end_lineno=76, + end_col_offset=39), + Constant( + 2, + lineno=76, + col_offset=40, + end_lineno=76, + end_col_offset=41), + lineno=76, + col_offset=26, + end_lineno=76, + end_col_offset=41), + Load(), + lineno=76, + col_offset=21, + end_lineno=76, + end_col_offset=42)], + [], + lineno=76, + col_offset=16, + end_lineno=76, + end_col_offset=44), + Div(), + Name( + 'placeholder_16', + Load(), + lineno=76, + col_offset=48, + end_lineno=76, + end_col_offset=58), + lineno=76, + col_offset=15, + end_lineno=76, + end_col_offset=58), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=58), + Return( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=78, + col_offset=11, + end_lineno=78, + end_col_offset=18), + [ + Eq()], + [ + Name( + 'placeholder_17', + Load(), + lineno=78, + col_offset=22, + end_lineno=78, + end_col_offset=30)], + lineno=78, + col_offset=11, + end_lineno=78, + end_col_offset=30), + lineno=78, + col_offset=4, + end_lineno=78, + end_col_offset=30)], + [], + lineno=67, + col_offset=0, + end_lineno=78, + end_col_offset=30), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=88, + col_offset=7, + end_lineno=88, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=88, + col_offset=13, + end_lineno=88, + end_col_offset=14), + lineno=88, + col_offset=12, + end_lineno=88, + end_col_offset=14), + Load(), + lineno=88, + col_offset=7, + end_lineno=88, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 11, + lineno=88, + col_offset=19, + end_lineno=88, + end_col_offset=21)], + lineno=88, + col_offset=7, + end_lineno=88, + end_col_offset=21), + [ + Return( + List( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=89, + col_offset=16, + end_lineno=89, + end_col_offset=20), + Constant( + 0, + lineno=89, + col_offset=22, + end_lineno=89, + end_col_offset=23), + Load(), + lineno=89, + col_offset=16, + end_lineno=89, + end_col_offset=24), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=89, + col_offset=26, + end_lineno=89, + end_col_offset=30), + Constant( + 1, + lineno=89, + col_offset=32, + end_lineno=89, + end_col_offset=33), + Load(), + lineno=89, + col_offset=26, + end_lineno=89, + end_col_offset=34), + BinOp( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=89, + col_offset=36, + end_lineno=89, + end_col_offset=40), + UnaryOp( + USub(), + Constant( + 1, + lineno=89, + col_offset=42, + end_lineno=89, + end_col_offset=43), + lineno=89, + col_offset=41, + end_lineno=89, + end_col_offset=43), + Load(), + lineno=89, + col_offset=36, + end_lineno=89, + end_col_offset=44), + Mult(), + Constant( + 2, + lineno=89, + col_offset=47, + end_lineno=89, + end_col_offset=48), + lineno=89, + col_offset=36, + end_lineno=89, + end_col_offset=48)], + Load(), + lineno=89, + col_offset=15, + end_lineno=89, + end_col_offset=49), + lineno=89, + col_offset=8, + end_lineno=89, + end_col_offset=49)], + [ + Return( + Name( + 'placeholder_8', + Load(), + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=19), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=19)], + lineno=88, + col_offset=4, + end_lineno=91, + end_col_offset=19)], + [], + lineno=81, + col_offset=0, + end_lineno=91, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-main-removal/representation.txt b/test/example-main-removal/representation.txt new file mode 100644 index 0000000..158882d --- /dev/null +++ b/test/example-main-removal/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('statistics', lineno=5, col_offset=7, end_lineno=5, end_col_offset=17)], lineno=5, col_offset=0, end_lineno=5, end_col_offset=17), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=7, col_offset=15, end_lineno=7, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(List([Call(Name('int', Load(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=15), [Name('placeholder_1', Load(), lineno=14, col_offset=17, end_lineno=14, end_col_offset=23)], [], lineno=14, col_offset=12, end_lineno=14, end_col_offset=25), BinOp(Call(Name('int', Load(), lineno=14, col_offset=27, end_lineno=14, end_col_offset=30), [Name('placeholder_1', Load(), lineno=14, col_offset=32, end_lineno=14, end_col_offset=38)], [], lineno=14, col_offset=27, end_lineno=14, end_col_offset=40), Add(), Constant(1, lineno=14, col_offset=43, end_lineno=14, end_col_offset=44), lineno=14, col_offset=27, end_lineno=14, end_col_offset=44), BinOp(Call(Name('int', Load(), lineno=14, col_offset=46, end_lineno=14, end_col_offset=49), [Name('placeholder_1', Load(), lineno=14, col_offset=51, end_lineno=14, end_col_offset=57)], [], lineno=14, col_offset=46, end_lineno=14, end_col_offset=59), Add(), Constant(2, lineno=14, col_offset=62, end_lineno=14, end_col_offset=63), lineno=14, col_offset=46, end_lineno=14, end_col_offset=63)], Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=64), lineno=14, col_offset=4, end_lineno=14, end_col_offset=64)], [], lineno=7, col_offset=0, end_lineno=14, end_col_offset=64), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=17, col_offset=23, end_lineno=17, end_col_offset=31), arg('placeholder_4', lineno=17, col_offset=33, end_lineno=17, end_col_offset=41)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_3', Load(), lineno=25, col_offset=11, end_lineno=25, end_col_offset=19), Add(), Name('placeholder_4', Load(), lineno=25, col_offset=22, end_lineno=25, end_col_offset=30), lineno=25, col_offset=11, end_lineno=25, end_col_offset=30), lineno=25, col_offset=4, end_lineno=25, end_col_offset=30)], [], lineno=17, col_offset=0, end_lineno=25, end_col_offset=30), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=28, col_offset=24, end_lineno=28, end_col_offset=30), arg('placeholder_1', lineno=28, col_offset=32, end_lineno=28, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_1', Load(), lineno=36, col_offset=7, end_lineno=36, end_col_offset=13), [In()], [Name('placeholder_6', Load(), lineno=36, col_offset=17, end_lineno=36, end_col_offset=23)], lineno=36, col_offset=7, end_lineno=36, end_col_offset=23), [Return(Constant(True, lineno=37, col_offset=15, end_lineno=37, end_col_offset=19), lineno=37, col_offset=8, end_lineno=37, end_col_offset=19)], [Return(Constant(False, lineno=39, col_offset=15, end_lineno=39, end_col_offset=20), lineno=39, col_offset=8, end_lineno=39, end_col_offset=20)], lineno=36, col_offset=4, end_lineno=39, end_col_offset=20)], [], lineno=28, col_offset=0, end_lineno=39, end_col_offset=20), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=41, col_offset=17, end_lineno=41, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('round', Load(), lineno=48, col_offset=11, end_lineno=48, end_col_offset=16), [BinOp(Call(Name('sum', Load(), lineno=48, col_offset=17, end_lineno=48, end_col_offset=20), [Name('placeholder_8', Load(), lineno=48, col_offset=21, end_lineno=48, end_col_offset=25)], [], lineno=48, col_offset=17, end_lineno=48, end_col_offset=26), Div(), Call(Name('len', Load(), lineno=48, col_offset=27, end_lineno=48, end_col_offset=30), [Name('placeholder_8', Load(), lineno=48, col_offset=31, end_lineno=48, end_col_offset=35)], [], lineno=48, col_offset=27, end_lineno=48, end_col_offset=36), lineno=48, col_offset=17, end_lineno=48, end_col_offset=36), Constant(1, lineno=48, col_offset=38, end_lineno=48, end_col_offset=39)], [], lineno=48, col_offset=11, end_lineno=48, end_col_offset=40), lineno=48, col_offset=4, end_lineno=48, end_col_offset=40)], [], lineno=41, col_offset=0, end_lineno=48, end_col_offset=40), FunctionDef('placeholder_9', arguments([], [arg('placeholder_8', lineno=51, col_offset=30, end_lineno=51, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_10', Store(), lineno=58, col_offset=4, end_lineno=58, end_col_offset=7)], BinOp(Call(Name('sum', Load(), lineno=58, col_offset=11, end_lineno=58, end_col_offset=14), [Name('placeholder_8', Load(), lineno=58, col_offset=15, end_lineno=58, end_col_offset=19)], [], lineno=58, col_offset=11, end_lineno=58, end_col_offset=20), Div(), Call(Name('len', Load(), lineno=58, col_offset=23, end_lineno=58, end_col_offset=26), [Name('placeholder_8', Load(), lineno=58, col_offset=27, end_lineno=58, end_col_offset=31)], [], lineno=58, col_offset=23, end_lineno=58, end_col_offset=32), lineno=58, col_offset=11, end_lineno=58, end_col_offset=32), lineno=58, col_offset=4, end_lineno=58, end_col_offset=33), Assign([Name('placeholder_11', Store(), lineno=59, col_offset=4, end_lineno=59, end_col_offset=11)], Compare(Name('placeholder_10', Load(), lineno=59, col_offset=14, end_lineno=59, end_col_offset=17), [Eq()], [BinOp(BinOp(Subscript(Name('placeholder_8', Load(), lineno=59, col_offset=22, end_lineno=59, end_col_offset=26), Constant(0, lineno=59, col_offset=27, end_lineno=59, end_col_offset=28), Load(), lineno=59, col_offset=22, end_lineno=59, end_col_offset=29), Add(), Subscript(Name('placeholder_8', Load(), lineno=59, col_offset=32, end_lineno=59, end_col_offset=36), UnaryOp(USub(), Constant(1, lineno=59, col_offset=38, end_lineno=59, end_col_offset=39), lineno=59, col_offset=37, end_lineno=59, end_col_offset=39), Load(), lineno=59, col_offset=32, end_lineno=59, end_col_offset=40), lineno=59, col_offset=22, end_lineno=59, end_col_offset=40), Div(), Constant(2, lineno=59, col_offset=44, end_lineno=59, end_col_offset=45), lineno=59, col_offset=21, end_lineno=59, end_col_offset=45)], lineno=59, col_offset=14, end_lineno=59, end_col_offset=45), lineno=59, col_offset=4, end_lineno=59, end_col_offset=45), Assign([Name('placeholder_12', Store(), lineno=60, col_offset=4, end_lineno=60, end_col_offset=11)], Compare(Name('placeholder_10', Load(), lineno=60, col_offset=14, end_lineno=60, end_col_offset=17), [Eq()], [Call(Attribute(Name('statistics', Load(), lineno=60, col_offset=21, end_lineno=60, end_col_offset=31), 'median', Load(), lineno=60, col_offset=21, end_lineno=60, end_col_offset=38), [Name('placeholder_8', Load(), lineno=60, col_offset=39, end_lineno=60, end_col_offset=43)], [], lineno=60, col_offset=21, end_lineno=60, end_col_offset=44)], lineno=60, col_offset=14, end_lineno=60, end_col_offset=44), lineno=60, col_offset=4, end_lineno=60, end_col_offset=44), If(BoolOp(Or(), [Compare(Name('placeholder_12', Load(), lineno=62, col_offset=8, end_lineno=62, end_col_offset=15), [Eq()], [Constant(True, lineno=62, col_offset=19, end_lineno=62, end_col_offset=23)], lineno=62, col_offset=8, end_lineno=62, end_col_offset=23), Compare(Name('placeholder_11', Load(), lineno=62, col_offset=27, end_lineno=62, end_col_offset=34), [Eq()], [Constant(True, lineno=62, col_offset=38, end_lineno=62, end_col_offset=42)], lineno=62, col_offset=27, end_lineno=62, end_col_offset=42)], lineno=62, col_offset=8, end_lineno=62, end_col_offset=42), [Return(Constant(True, lineno=63, col_offset=15, end_lineno=63, end_col_offset=19), lineno=63, col_offset=8, end_lineno=63, end_col_offset=19)], [Return(Constant(False, lineno=65, col_offset=15, end_lineno=65, end_col_offset=20), lineno=65, col_offset=8, end_lineno=65, end_col_offset=20)], lineno=62, col_offset=4, end_lineno=65, end_col_offset=20)], [], lineno=51, col_offset=0, end_lineno=65, end_col_offset=20), FunctionDef('placeholder_13', arguments([], [arg('placeholder_8', lineno=67, col_offset=32, end_lineno=67, end_col_offset=36)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=73, col_offset=4, end_lineno=73, end_col_offset=13)], Call(Name('len', Load(), lineno=73, col_offset=16, end_lineno=73, end_col_offset=19), [Subscript(Name('placeholder_8', Load(), lineno=73, col_offset=20, end_lineno=73, end_col_offset=24), Slice(Constant(0, lineno=73, col_offset=25, end_lineno=73, end_col_offset=26), Call(Name('len', Load(), lineno=73, col_offset=27, end_lineno=73, end_col_offset=30), [Name('placeholder_8', Load(), lineno=73, col_offset=31, end_lineno=73, end_col_offset=35)], [], lineno=73, col_offset=27, end_lineno=73, end_col_offset=36), Constant(2, lineno=73, col_offset=37, end_lineno=73, end_col_offset=38), lineno=73, col_offset=25, end_lineno=73, end_col_offset=38), Load(), lineno=73, col_offset=20, end_lineno=73, end_col_offset=39)], [], lineno=73, col_offset=16, end_lineno=73, end_col_offset=40), lineno=73, col_offset=4, end_lineno=73, end_col_offset=40), Assign([Name('placeholder_15', Store(), lineno=74, col_offset=4, end_lineno=74, end_col_offset=11)], BinOp(Call(Name('sum', Load(), lineno=74, col_offset=15, end_lineno=74, end_col_offset=18), [Subscript(Name('placeholder_8', Load(), lineno=74, col_offset=19, end_lineno=74, end_col_offset=23), Slice(Constant(0, lineno=74, col_offset=24, end_lineno=74, end_col_offset=25), Call(Name('len', Load(), lineno=74, col_offset=26, end_lineno=74, end_col_offset=29), [Name('placeholder_8', Load(), lineno=74, col_offset=30, end_lineno=74, end_col_offset=34)], [], lineno=74, col_offset=26, end_lineno=74, end_col_offset=35), Constant(2, lineno=74, col_offset=36, end_lineno=74, end_col_offset=37), lineno=74, col_offset=24, end_lineno=74, end_col_offset=37), Load(), lineno=74, col_offset=19, end_lineno=74, end_col_offset=38)], [], lineno=74, col_offset=15, end_lineno=74, end_col_offset=39), Div(), Name('placeholder_14', Load(), lineno=74, col_offset=43, end_lineno=74, end_col_offset=52), lineno=74, col_offset=14, end_lineno=74, end_col_offset=52), lineno=74, col_offset=4, end_lineno=74, end_col_offset=52), Assign([Name('placeholder_16', Store(), lineno=75, col_offset=4, end_lineno=75, end_col_offset=14)], Call(Name('len', Load(), lineno=75, col_offset=17, end_lineno=75, end_col_offset=20), [Subscript(Name('placeholder_8', Load(), lineno=75, col_offset=22, end_lineno=75, end_col_offset=26), Slice(Constant(1, lineno=75, col_offset=27, end_lineno=75, end_col_offset=28), Call(Name('len', Load(), lineno=75, col_offset=29, end_lineno=75, end_col_offset=32), [Name('placeholder_8', Load(), lineno=75, col_offset=34, end_lineno=75, end_col_offset=38)], [], lineno=75, col_offset=29, end_lineno=75, end_col_offset=40), Constant(2, lineno=75, col_offset=41, end_lineno=75, end_col_offset=42), lineno=75, col_offset=27, end_lineno=75, end_col_offset=42), Load(), lineno=75, col_offset=22, end_lineno=75, end_col_offset=43)], [], lineno=75, col_offset=17, end_lineno=75, end_col_offset=45), lineno=75, col_offset=4, end_lineno=75, end_col_offset=45), Assign([Name('placeholder_17', Store(), lineno=76, col_offset=4, end_lineno=76, end_col_offset=12)], BinOp(Call(Name('sum', Load(), lineno=76, col_offset=16, end_lineno=76, end_col_offset=19), [Subscript(Name('placeholder_8', Load(), lineno=76, col_offset=21, end_lineno=76, end_col_offset=25), Slice(Constant(1, lineno=76, col_offset=26, end_lineno=76, end_col_offset=27), Call(Name('len', Load(), lineno=76, col_offset=28, end_lineno=76, end_col_offset=31), [Name('placeholder_8', Load(), lineno=76, col_offset=33, end_lineno=76, end_col_offset=37)], [], lineno=76, col_offset=28, end_lineno=76, end_col_offset=39), Constant(2, lineno=76, col_offset=40, end_lineno=76, end_col_offset=41), lineno=76, col_offset=26, end_lineno=76, end_col_offset=41), Load(), lineno=76, col_offset=21, end_lineno=76, end_col_offset=42)], [], lineno=76, col_offset=16, end_lineno=76, end_col_offset=44), Div(), Name('placeholder_16', Load(), lineno=76, col_offset=48, end_lineno=76, end_col_offset=58), lineno=76, col_offset=15, end_lineno=76, end_col_offset=58), lineno=76, col_offset=4, end_lineno=76, end_col_offset=58), Return(Compare(Name('placeholder_15', Load(), lineno=78, col_offset=11, end_lineno=78, end_col_offset=18), [Eq()], [Name('placeholder_17', Load(), lineno=78, col_offset=22, end_lineno=78, end_col_offset=30)], lineno=78, col_offset=11, end_lineno=78, end_col_offset=30), lineno=78, col_offset=4, end_lineno=78, end_col_offset=30)], [], lineno=67, col_offset=0, end_lineno=78, end_col_offset=30), FunctionDef('placeholder_18', arguments([], [arg('placeholder_8', lineno=81, col_offset=22, end_lineno=81, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Subscript(Name('placeholder_8', Load(), lineno=88, col_offset=7, end_lineno=88, end_col_offset=11), UnaryOp(USub(), Constant(1, lineno=88, col_offset=13, end_lineno=88, end_col_offset=14), lineno=88, col_offset=12, end_lineno=88, end_col_offset=14), Load(), lineno=88, col_offset=7, end_lineno=88, end_col_offset=15), [Eq()], [Constant(11, lineno=88, col_offset=19, end_lineno=88, end_col_offset=21)], lineno=88, col_offset=7, end_lineno=88, end_col_offset=21), [Return(List([Subscript(Name('placeholder_8', Load(), lineno=89, col_offset=16, end_lineno=89, end_col_offset=20), Constant(0, lineno=89, col_offset=22, end_lineno=89, end_col_offset=23), Load(), lineno=89, col_offset=16, end_lineno=89, end_col_offset=24), Subscript(Name('placeholder_8', Load(), lineno=89, col_offset=26, end_lineno=89, end_col_offset=30), Constant(1, lineno=89, col_offset=32, end_lineno=89, end_col_offset=33), Load(), lineno=89, col_offset=26, end_lineno=89, end_col_offset=34), BinOp(Subscript(Name('placeholder_8', Load(), lineno=89, col_offset=36, end_lineno=89, end_col_offset=40), UnaryOp(USub(), Constant(1, lineno=89, col_offset=42, end_lineno=89, end_col_offset=43), lineno=89, col_offset=41, end_lineno=89, end_col_offset=43), Load(), lineno=89, col_offset=36, end_lineno=89, end_col_offset=44), Mult(), Constant(2, lineno=89, col_offset=47, end_lineno=89, end_col_offset=48), lineno=89, col_offset=36, end_lineno=89, end_col_offset=48)], Load(), lineno=89, col_offset=15, end_lineno=89, end_col_offset=49), lineno=89, col_offset=8, end_lineno=89, end_col_offset=49)], [Return(Name('placeholder_8', Load(), lineno=91, col_offset=15, end_lineno=91, end_col_offset=19), lineno=91, col_offset=8, end_lineno=91, end_col_offset=19)], lineno=88, col_offset=4, end_lineno=91, end_col_offset=19)], [], lineno=81, col_offset=0, end_lineno=91, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/example-number-normalization/.meta/config.json b/test/example-number-normalization/.meta/config.json new file mode 100644 index 0000000..e790c71 --- /dev/null +++ b/test/example-number-normalization/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_number_normalization.py" + ] + } +} \ No newline at end of file diff --git a/test/example-number-normalization/example_number_normalization.py b/test/example-number-normalization/example_number_normalization.py new file mode 100644 index 0000000..8edfede --- /dev/null +++ b/test/example-number-normalization/example_number_normalization.py @@ -0,0 +1,19 @@ +complex_number = 5+6_5j #5+65j +complex_number_float = 33.4+99.14j #33.4+99.14j +complex_number_sci = 1e6+6.6e-4j #1000000+0.00066j +complex_number_sci_float = 1e2+.23+1e6j #100.23+1000000j + +regular_int = 10000000 #untouched +regular_float = 22040396.55 #untouched + +sci_int = 1e6 #1000000 +sci_float = 1e2+.23 #100.23 +sci_float_underscore = 1e2+1_23e0+4.4e-1 #223.44 +sci_float_underscore2 = 7e6+7e5+5e4+9.98e2+4.45_779e-1 #7750998.445779 +sci_complex_number_float_underscore = (7e6+7e5+5e4+9.98e1+4.457_79e-1)+(1e2+1.23e1+4.444_23e-1)*1j # 7750100.245779+112.744423j + +underscore_int = 66_777_888_433 #66777888433 +underscore_float = 1_999_878_473.66 #1999878473.66 +underscore_float_underscore = 77_555_998_125.445_779 #77555998125.44579 +underscore_complex_number = 44_556+77_998j #44556+77998j +underscore_complex_number_float = 44_573_123.445_312+123_674.889_12j #44573123.445312+123674.88912j diff --git a/test/example-number-normalization/mapping.json b/test/example-number-normalization/mapping.json new file mode 100644 index 0000000..0855100 --- /dev/null +++ b/test/example-number-normalization/mapping.json @@ -0,0 +1,18 @@ +{ + "placeholder_0": "complex_number", + "placeholder_1": "complex_number_float", + "placeholder_2": "complex_number_sci", + "placeholder_3": "complex_number_sci_float", + "placeholder_4": "regular_int", + "placeholder_5": "regular_float", + "placeholder_6": "sci_int", + "placeholder_7": "sci_float", + "placeholder_8": "sci_float_underscore", + "placeholder_9": "sci_float_underscore2", + "placeholder_10": "sci_complex_number_float_underscore", + "placeholder_11": "underscore_int", + "placeholder_12": "underscore_float", + "placeholder_13": "underscore_float_underscore", + "placeholder_14": "underscore_complex_number", + "placeholder_15": "underscore_complex_number_float" +} \ No newline at end of file diff --git a/test/example-number-normalization/representation.json b/test/example-number-normalization/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-number-normalization/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-number-normalization/representation.out b/test/example-number-normalization/representation.out new file mode 100644 index 0000000..5840e0f --- /dev/null +++ b/test/example-number-normalization/representation.out @@ -0,0 +1,1169 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = 5 + 65j +placeholder_1 = 33.4 + 99.14j +placeholder_2 = 1000000.0 + 0.00066j +placeholder_3 = 100.0 + 0.23 + 1000000j +placeholder_4 = 10000000 +placeholder_5 = 22040396.55 +placeholder_6 = 1000000.0 +placeholder_7 = 100.0 + 0.23 +placeholder_8 = 100.0 + 123.0 + 0.44 +placeholder_9 = 7000000.0 + 700000.0 + 50000.0 + 998.0 + 0.445779 +placeholder_10 = ( + 7000000.0 + 700000.0 + 50000.0 + 99.8 + 0.445779 + (100.0 + 12.3 + 0.444423) * 1j +) +placeholder_11 = 66777888433 +placeholder_12 = 1999878473.66 +placeholder_13 = 77555998125.44579 +placeholder_14 = 44556 + 77998j +placeholder_15 = 44573123.445312 + 123674.88912j + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'complex_number', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=14)], + BinOp( + Constant( + 5, + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=18), + Add(), + Constant( + 65j, + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=23), + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=23), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=23), + Assign( + [ + Name( + 'complex_number_float', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=20)], + BinOp( + Constant( + 33.4, + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=27), + Add(), + Constant( + 99.14j, + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=34), + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=34), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=34), + Assign( + [ + Name( + 'complex_number_sci', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=18)], + BinOp( + Constant( + 1000000.0, + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=24), + Add(), + Constant( + 0.00066j, + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=32), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=32), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=32), + Assign( + [ + Name( + 'complex_number_sci_float', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=24)], + BinOp( + BinOp( + Constant( + 100.0, + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=30), + Add(), + Constant( + 0.23, + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=34), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=34), + Add(), + Constant( + 1000000j, + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=39), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=39), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=39), + Assign( + [ + Name( + 'regular_int', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=11)], + Constant( + 10000000, + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=22), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=22), + Assign( + [ + Name( + 'regular_float', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=13)], + Constant( + 22040396.55, + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=27), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=27), + Assign( + [ + Name( + 'sci_int', + Store(), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=7)], + Constant( + 1000000.0, + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=13), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=13), + Assign( + [ + Name( + 'sci_float', + Store(), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=9)], + BinOp( + Constant( + 100.0, + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=15), + Add(), + Constant( + 0.23, + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=19), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=19), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=19), + Assign( + [ + Name( + 'sci_float_underscore', + Store(), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=20)], + BinOp( + BinOp( + Constant( + 100.0, + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=26), + Add(), + Constant( + 123.0, + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=33), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=33), + Add(), + Constant( + 0.44, + lineno=11, + col_offset=34, + end_lineno=11, + end_col_offset=40), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=40), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=40), + Assign( + [ + Name( + 'sci_float_underscore2', + Store(), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=21)], + BinOp( + BinOp( + BinOp( + BinOp( + Constant( + 7000000.0, + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=27), + Add(), + Constant( + 700000.0, + lineno=12, + col_offset=28, + end_lineno=12, + end_col_offset=31), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=31), + Add(), + Constant( + 50000.0, + lineno=12, + col_offset=32, + end_lineno=12, + end_col_offset=35), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=35), + Add(), + Constant( + 998.0, + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=42), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=42), + Add(), + Constant( + 0.445779, + lineno=12, + col_offset=43, + end_lineno=12, + end_col_offset=54), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=54), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=54), + Assign( + [ + Name( + 'sci_complex_number_float_underscore', + Store(), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=35)], + BinOp( + BinOp( + BinOp( + BinOp( + BinOp( + Constant( + 7000000.0, + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=42), + Add(), + Constant( + 700000.0, + lineno=13, + col_offset=43, + end_lineno=13, + end_col_offset=46), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=46), + Add(), + Constant( + 50000.0, + lineno=13, + col_offset=47, + end_lineno=13, + end_col_offset=50), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=50), + Add(), + Constant( + 99.8, + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=57), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=57), + Add(), + Constant( + 0.445779, + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=69), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=69), + Add(), + BinOp( + BinOp( + BinOp( + Constant( + 100.0, + lineno=13, + col_offset=72, + end_lineno=13, + end_col_offset=75), + Add(), + Constant( + 12.3, + lineno=13, + col_offset=76, + end_lineno=13, + end_col_offset=82), + lineno=13, + col_offset=72, + end_lineno=13, + end_col_offset=82), + Add(), + Constant( + 0.444423, + lineno=13, + col_offset=83, + end_lineno=13, + end_col_offset=94), + lineno=13, + col_offset=72, + end_lineno=13, + end_col_offset=94), + Mult(), + Constant( + 1j, + lineno=13, + col_offset=96, + end_lineno=13, + end_col_offset=98), + lineno=13, + col_offset=71, + end_lineno=13, + end_col_offset=98), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=98), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=98), + Assign( + [ + Name( + 'underscore_int', + Store(), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=14)], + Constant( + 66777888433, + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=31), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=31), + Assign( + [ + Name( + 'underscore_float', + Store(), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=16)], + Constant( + 1999878473.66, + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=35), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=35), + Assign( + [ + Name( + 'underscore_float_underscore', + Store(), + lineno=17, + col_offset=0, + end_lineno=17, + end_col_offset=27)], + Constant( + 77555998125.44579, + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=52), + lineno=17, + col_offset=0, + end_lineno=17, + end_col_offset=52), + Assign( + [ + Name( + 'underscore_complex_number', + Store(), + lineno=18, + col_offset=0, + end_lineno=18, + end_col_offset=25)], + BinOp( + Constant( + 44556, + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=34), + Add(), + Constant( + 77998j, + lineno=18, + col_offset=35, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=0, + end_lineno=18, + end_col_offset=42), + Assign( + [ + Name( + 'underscore_complex_number_float', + Store(), + lineno=19, + col_offset=0, + end_lineno=19, + end_col_offset=31)], + BinOp( + Constant( + 44573123.445312, + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=52), + Add(), + Constant( + 123674.88912j, + lineno=19, + col_offset=53, + end_lineno=19, + end_col_offset=68), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=68), + lineno=19, + col_offset=0, + end_lineno=19, + end_col_offset=68)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=14)], + BinOp( + Constant( + 5, + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=18), + Add(), + Constant( + 65j, + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=23), + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=23), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=23), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=20)], + BinOp( + Constant( + 33.4, + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=27), + Add(), + Constant( + 99.14j, + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=34), + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=34), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=34), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=18)], + BinOp( + Constant( + 1000000.0, + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=24), + Add(), + Constant( + 0.00066j, + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=32), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=32), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=24)], + BinOp( + BinOp( + Constant( + 100.0, + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=30), + Add(), + Constant( + 0.23, + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=34), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=34), + Add(), + Constant( + 1000000j, + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=39), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=39), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=11)], + Constant( + 10000000, + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=22), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=22), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=13)], + Constant( + 22040396.55, + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=27), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=7)], + Constant( + 1000000.0, + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=13), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=9)], + BinOp( + Constant( + 100.0, + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=15), + Add(), + Constant( + 0.23, + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=19), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=19), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=19), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=20)], + BinOp( + BinOp( + Constant( + 100.0, + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=26), + Add(), + Constant( + 123.0, + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=33), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=33), + Add(), + Constant( + 0.44, + lineno=11, + col_offset=34, + end_lineno=11, + end_col_offset=40), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=40), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=21)], + BinOp( + BinOp( + BinOp( + BinOp( + Constant( + 7000000.0, + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=27), + Add(), + Constant( + 700000.0, + lineno=12, + col_offset=28, + end_lineno=12, + end_col_offset=31), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=31), + Add(), + Constant( + 50000.0, + lineno=12, + col_offset=32, + end_lineno=12, + end_col_offset=35), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=35), + Add(), + Constant( + 998.0, + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=42), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=42), + Add(), + Constant( + 0.445779, + lineno=12, + col_offset=43, + end_lineno=12, + end_col_offset=54), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=54), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=54), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=35)], + BinOp( + BinOp( + BinOp( + BinOp( + BinOp( + Constant( + 7000000.0, + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=42), + Add(), + Constant( + 700000.0, + lineno=13, + col_offset=43, + end_lineno=13, + end_col_offset=46), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=46), + Add(), + Constant( + 50000.0, + lineno=13, + col_offset=47, + end_lineno=13, + end_col_offset=50), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=50), + Add(), + Constant( + 99.8, + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=57), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=57), + Add(), + Constant( + 0.445779, + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=69), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=69), + Add(), + BinOp( + BinOp( + BinOp( + Constant( + 100.0, + lineno=13, + col_offset=72, + end_lineno=13, + end_col_offset=75), + Add(), + Constant( + 12.3, + lineno=13, + col_offset=76, + end_lineno=13, + end_col_offset=82), + lineno=13, + col_offset=72, + end_lineno=13, + end_col_offset=82), + Add(), + Constant( + 0.444423, + lineno=13, + col_offset=83, + end_lineno=13, + end_col_offset=94), + lineno=13, + col_offset=72, + end_lineno=13, + end_col_offset=94), + Mult(), + Constant( + 1j, + lineno=13, + col_offset=96, + end_lineno=13, + end_col_offset=98), + lineno=13, + col_offset=71, + end_lineno=13, + end_col_offset=98), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=98), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=98), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=14)], + Constant( + 66777888433, + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=31), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=31), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=16)], + Constant( + 1999878473.66, + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=35), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=35), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=17, + col_offset=0, + end_lineno=17, + end_col_offset=27)], + Constant( + 77555998125.44579, + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=52), + lineno=17, + col_offset=0, + end_lineno=17, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=18, + col_offset=0, + end_lineno=18, + end_col_offset=25)], + BinOp( + Constant( + 44556, + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=34), + Add(), + Constant( + 77998j, + lineno=18, + col_offset=35, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=0, + end_lineno=18, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=19, + col_offset=0, + end_lineno=19, + end_col_offset=31)], + BinOp( + Constant( + 44573123.445312, + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=52), + Add(), + Constant( + 123674.88912j, + lineno=19, + col_offset=53, + end_lineno=19, + end_col_offset=68), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=68), + lineno=19, + col_offset=0, + end_lineno=19, + end_col_offset=68)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-number-normalization/representation.txt b/test/example-number-normalization/representation.txt new file mode 100644 index 0000000..38b0653 --- /dev/null +++ b/test/example-number-normalization/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=14)], BinOp(Constant(5, lineno=1, col_offset=17, end_lineno=1, end_col_offset=18), Add(), Constant(65j, lineno=1, col_offset=19, end_lineno=1, end_col_offset=23), lineno=1, col_offset=17, end_lineno=1, end_col_offset=23), lineno=1, col_offset=0, end_lineno=1, end_col_offset=23), Assign([Name('placeholder_1', Store(), lineno=2, col_offset=0, end_lineno=2, end_col_offset=20)], BinOp(Constant(33.4, lineno=2, col_offset=23, end_lineno=2, end_col_offset=27), Add(), Constant(99.14j, lineno=2, col_offset=28, end_lineno=2, end_col_offset=34), lineno=2, col_offset=23, end_lineno=2, end_col_offset=34), lineno=2, col_offset=0, end_lineno=2, end_col_offset=34), Assign([Name('placeholder_2', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=18)], BinOp(Constant(1000000.0, lineno=3, col_offset=21, end_lineno=3, end_col_offset=24), Add(), Constant(0.00066j, lineno=3, col_offset=25, end_lineno=3, end_col_offset=32), lineno=3, col_offset=21, end_lineno=3, end_col_offset=32), lineno=3, col_offset=0, end_lineno=3, end_col_offset=32), Assign([Name('placeholder_3', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=24)], BinOp(BinOp(Constant(100.0, lineno=4, col_offset=27, end_lineno=4, end_col_offset=30), Add(), Constant(0.23, lineno=4, col_offset=31, end_lineno=4, end_col_offset=34), lineno=4, col_offset=27, end_lineno=4, end_col_offset=34), Add(), Constant(1000000j, lineno=4, col_offset=35, end_lineno=4, end_col_offset=39), lineno=4, col_offset=27, end_lineno=4, end_col_offset=39), lineno=4, col_offset=0, end_lineno=4, end_col_offset=39), Assign([Name('placeholder_4', Store(), lineno=6, col_offset=0, end_lineno=6, end_col_offset=11)], Constant(10000000, lineno=6, col_offset=14, end_lineno=6, end_col_offset=22), lineno=6, col_offset=0, end_lineno=6, end_col_offset=22), Assign([Name('placeholder_5', Store(), lineno=7, col_offset=0, end_lineno=7, end_col_offset=13)], Constant(22040396.55, lineno=7, col_offset=16, end_lineno=7, end_col_offset=27), lineno=7, col_offset=0, end_lineno=7, end_col_offset=27), Assign([Name('placeholder_6', Store(), lineno=9, col_offset=0, end_lineno=9, end_col_offset=7)], Constant(1000000.0, lineno=9, col_offset=10, end_lineno=9, end_col_offset=13), lineno=9, col_offset=0, end_lineno=9, end_col_offset=13), Assign([Name('placeholder_7', Store(), lineno=10, col_offset=0, end_lineno=10, end_col_offset=9)], BinOp(Constant(100.0, lineno=10, col_offset=12, end_lineno=10, end_col_offset=15), Add(), Constant(0.23, lineno=10, col_offset=16, end_lineno=10, end_col_offset=19), lineno=10, col_offset=12, end_lineno=10, end_col_offset=19), lineno=10, col_offset=0, end_lineno=10, end_col_offset=19), Assign([Name('placeholder_8', Store(), lineno=11, col_offset=0, end_lineno=11, end_col_offset=20)], BinOp(BinOp(Constant(100.0, lineno=11, col_offset=23, end_lineno=11, end_col_offset=26), Add(), Constant(123.0, lineno=11, col_offset=27, end_lineno=11, end_col_offset=33), lineno=11, col_offset=23, end_lineno=11, end_col_offset=33), Add(), Constant(0.44, lineno=11, col_offset=34, end_lineno=11, end_col_offset=40), lineno=11, col_offset=23, end_lineno=11, end_col_offset=40), lineno=11, col_offset=0, end_lineno=11, end_col_offset=40), Assign([Name('placeholder_9', Store(), lineno=12, col_offset=0, end_lineno=12, end_col_offset=21)], BinOp(BinOp(BinOp(BinOp(Constant(7000000.0, lineno=12, col_offset=24, end_lineno=12, end_col_offset=27), Add(), Constant(700000.0, lineno=12, col_offset=28, end_lineno=12, end_col_offset=31), lineno=12, col_offset=24, end_lineno=12, end_col_offset=31), Add(), Constant(50000.0, lineno=12, col_offset=32, end_lineno=12, end_col_offset=35), lineno=12, col_offset=24, end_lineno=12, end_col_offset=35), Add(), Constant(998.0, lineno=12, col_offset=36, end_lineno=12, end_col_offset=42), lineno=12, col_offset=24, end_lineno=12, end_col_offset=42), Add(), Constant(0.445779, lineno=12, col_offset=43, end_lineno=12, end_col_offset=54), lineno=12, col_offset=24, end_lineno=12, end_col_offset=54), lineno=12, col_offset=0, end_lineno=12, end_col_offset=54), Assign([Name('placeholder_10', Store(), lineno=13, col_offset=0, end_lineno=13, end_col_offset=35)], BinOp(BinOp(BinOp(BinOp(BinOp(Constant(7000000.0, lineno=13, col_offset=39, end_lineno=13, end_col_offset=42), Add(), Constant(700000.0, lineno=13, col_offset=43, end_lineno=13, end_col_offset=46), lineno=13, col_offset=39, end_lineno=13, end_col_offset=46), Add(), Constant(50000.0, lineno=13, col_offset=47, end_lineno=13, end_col_offset=50), lineno=13, col_offset=39, end_lineno=13, end_col_offset=50), Add(), Constant(99.8, lineno=13, col_offset=51, end_lineno=13, end_col_offset=57), lineno=13, col_offset=39, end_lineno=13, end_col_offset=57), Add(), Constant(0.445779, lineno=13, col_offset=58, end_lineno=13, end_col_offset=69), lineno=13, col_offset=39, end_lineno=13, end_col_offset=69), Add(), BinOp(BinOp(BinOp(Constant(100.0, lineno=13, col_offset=72, end_lineno=13, end_col_offset=75), Add(), Constant(12.3, lineno=13, col_offset=76, end_lineno=13, end_col_offset=82), lineno=13, col_offset=72, end_lineno=13, end_col_offset=82), Add(), Constant(0.444423, lineno=13, col_offset=83, end_lineno=13, end_col_offset=94), lineno=13, col_offset=72, end_lineno=13, end_col_offset=94), Mult(), Constant(1j, lineno=13, col_offset=96, end_lineno=13, end_col_offset=98), lineno=13, col_offset=71, end_lineno=13, end_col_offset=98), lineno=13, col_offset=38, end_lineno=13, end_col_offset=98), lineno=13, col_offset=0, end_lineno=13, end_col_offset=98), Assign([Name('placeholder_11', Store(), lineno=15, col_offset=0, end_lineno=15, end_col_offset=14)], Constant(66777888433, lineno=15, col_offset=17, end_lineno=15, end_col_offset=31), lineno=15, col_offset=0, end_lineno=15, end_col_offset=31), Assign([Name('placeholder_12', Store(), lineno=16, col_offset=0, end_lineno=16, end_col_offset=16)], Constant(1999878473.66, lineno=16, col_offset=19, end_lineno=16, end_col_offset=35), lineno=16, col_offset=0, end_lineno=16, end_col_offset=35), Assign([Name('placeholder_13', Store(), lineno=17, col_offset=0, end_lineno=17, end_col_offset=27)], Constant(77555998125.44579, lineno=17, col_offset=30, end_lineno=17, end_col_offset=52), lineno=17, col_offset=0, end_lineno=17, end_col_offset=52), Assign([Name('placeholder_14', Store(), lineno=18, col_offset=0, end_lineno=18, end_col_offset=25)], BinOp(Constant(44556, lineno=18, col_offset=28, end_lineno=18, end_col_offset=34), Add(), Constant(77998j, lineno=18, col_offset=35, end_lineno=18, end_col_offset=42), lineno=18, col_offset=28, end_lineno=18, end_col_offset=42), lineno=18, col_offset=0, end_lineno=18, end_col_offset=42), Assign([Name('placeholder_15', Store(), lineno=19, col_offset=0, end_lineno=19, end_col_offset=31)], BinOp(Constant(44573123.445312, lineno=19, col_offset=34, end_lineno=19, end_col_offset=52), Add(), Constant(123674.88912j, lineno=19, col_offset=53, end_lineno=19, end_col_offset=68), lineno=19, col_offset=34, end_lineno=19, end_col_offset=68), lineno=19, col_offset=0, end_lineno=19, end_col_offset=68)], []) \ No newline at end of file diff --git a/test/example-print-removal/.meta/config.json b/test/example-print-removal/.meta/config.json new file mode 100644 index 0000000..977ec94 --- /dev/null +++ b/test/example-print-removal/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_print_removal.py" + ] + } +} \ No newline at end of file diff --git a/test/example-print-removal/example_print_removal.py b/test/example-print-removal/example_print_removal.py new file mode 100644 index 0000000..f0d85e3 --- /dev/null +++ b/test/example-print-removal/example_print_removal.py @@ -0,0 +1,113 @@ +"""Functions for tracking poker hands and assorted card tasks. + +Python list documentation: https://docs.python.org/3/tutorial/datastructures.html +""" + + +def get_rounds(number): + """ + + :param number: int - current round number. + :return: list - current round and the two that follow. + """ + print([int( number ), int( number ) + 1, int( number ) + 2]) + + return [int( number ), int( number ) + 1, int( number ) + 2] + + +def concatenate_rounds(rounds_1, rounds_2): + """ + + :param rounds_1: list - first rounds played. + :param rounds_2: list - second set of rounds played. + :return: list - all rounds played. + """ + print(rounds_1 + rounds_2) + + return rounds_1 + rounds_2 + + +def list_contains_round(rounds, number): + """ + + :param rounds: list - rounds played. + :param number: int - round number. + :return: bool - was the round played? + """ + + if(number in rounds): + print(number) + return True + else: + print(rounds) + return False + +def card_average(hand): + """ + + :param hand: list - cards in hand. + :return: float - average value of the cards in the hand. + """ + + return round(sum(hand)/len(hand), 1) + + +def approx_average_is_average(hand): + """ + + :param hand: list - cards in hand. + :return: bool - if approximate average equals to the `true average`. + """ + + avg = (sum(hand) / len(hand)) + skrajne = avg == (hand[0] + hand[-1]) / 2 + import statistics + + print((hand[0] + hand[-1]) / 2) + + mediana = avg == statistics.median(hand) + + print(hand[0] + hand[-1]) + + if (mediana == True or skrajne == True): + print(mediana) + return True + else: + return False + +def average_even_is_average_odd(hand): + """ + + :param hand: list - cards in hand. + :return: bool - are even and odd averages equal? + """ + + list_odd = (list(range(1, len(hand), 2))) + list_even = (list( range( 0, len( hand ), 2 ) )) + + print([list_odd,list_even]) + + count_odd = len(hand[0:len(hand):2]) + avg_odd = (sum(hand[0:len(hand):2])) / count_odd + count_even = len( hand[1:len( hand ):2] ) + avg_even = (sum( hand[1:len( hand ):2] )) / count_even + + print(avg_odd, count_odd) + + return avg_odd == avg_even + + +def maybe_double_last(hand): + """ + + :param hand: list - cards in hand. + :return: list - hand with Jacks (if present) value doubled. + """ + + if(hand[-1] == 11): + print(hand) + return [hand [0], hand [1], hand[-1] * 2] + else: + print("Nothing found!", hand) + return hand + diff --git a/test/example-print-removal/mapping.json b/test/example-print-removal/mapping.json new file mode 100644 index 0000000..e2c47c2 --- /dev/null +++ b/test/example-print-removal/mapping.json @@ -0,0 +1,23 @@ +{ + "placeholder_0": "get_rounds", + "placeholder_1": "number", + "placeholder_2": "concatenate_rounds", + "placeholder_3": "rounds_1", + "placeholder_4": "rounds_2", + "placeholder_5": "list_contains_round", + "placeholder_6": "rounds", + "placeholder_7": "card_average", + "placeholder_8": "hand", + "placeholder_9": "approx_average_is_average", + "placeholder_10": "avg", + "placeholder_11": "skrajne", + "placeholder_12": "mediana", + "placeholder_13": "average_even_is_average_odd", + "placeholder_14": "list_odd", + "placeholder_15": "list_even", + "placeholder_16": "count_odd", + "placeholder_17": "avg_odd", + "placeholder_18": "count_even", + "placeholder_19": "avg_even", + "placeholder_20": "maybe_double_last" +} \ No newline at end of file diff --git a/test/example-print-removal/representation.json b/test/example-print-removal/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-print-removal/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-print-removal/representation.out b/test/example-print-removal/representation.out new file mode 100644 index 0000000..d4ca94f --- /dev/null +++ b/test/example-print-removal/representation.out @@ -0,0 +1,3370 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return [int(placeholder_1), int(placeholder_1) + 1, int(placeholder_1) + 2] + + +def placeholder_2(placeholder_3, placeholder_4): + return placeholder_3 + placeholder_4 + + +def placeholder_5(placeholder_6, placeholder_1): + if placeholder_1 in placeholder_6: + return True + else: + return False + + +def placeholder_7(placeholder_8): + return round(sum(placeholder_8) / len(placeholder_8), 1) + + +def placeholder_9(placeholder_8): + placeholder_10 = sum(placeholder_8) / len(placeholder_8) + placeholder_11 = placeholder_10 == (placeholder_8[0] + placeholder_8[-1]) / 2 + import statistics + + placeholder_12 = placeholder_10 == statistics.median(placeholder_8) + if placeholder_12 == True or placeholder_11 == True: + return True + else: + return False + + +def placeholder_13(placeholder_8): + placeholder_14 = list(range(1, len(placeholder_8), 2)) + placeholder_15 = list(range(0, len(placeholder_8), 2)) + placeholder_16 = len(placeholder_8[0 : len(placeholder_8) : 2]) + placeholder_17 = sum(placeholder_8[0 : len(placeholder_8) : 2]) / placeholder_16 + placeholder_18 = len(placeholder_8[1 : len(placeholder_8) : 2]) + placeholder_19 = sum(placeholder_8[1 : len(placeholder_8) : 2]) / placeholder_18 + return placeholder_17 == placeholder_19 + + +def placeholder_20(placeholder_8): + if placeholder_8[-1] == 11: + return [placeholder_8[0], placeholder_8[1], placeholder_8[-1] * 2] + else: + return placeholder_8 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions for tracking poker hands and assorted card tasks.\n\nPython list documentation: https://docs.python.org/3/tutorial/datastructures.html\n', + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + FunctionDef( + 'get_rounds', + arguments( + [], + [ + arg( + 'number', + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param number: int - current round number.\n :return: list - current round and the two that follow.\n ', + lineno=8, + col_offset=4, + end_lineno=12, + end_col_offset=7), + lineno=8, + col_offset=4, + end_lineno=12, + end_col_offset=7), + Expr( + Call( + Name( + 'print', + Load(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=9), + [ + List( + [ + Call( + Name( + 'int', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=14), + [ + Name( + 'number', + Load(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=22)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=24), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=29), + [ + Name( + 'number', + Load(), + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=37)], + [], + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=39), + Add(), + Constant( + 1, + lineno=13, + col_offset=42, + end_lineno=13, + end_col_offset=43), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=43), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=13, + col_offset=45, + end_lineno=13, + end_col_offset=48), + [ + Name( + 'number', + Load(), + lineno=13, + col_offset=50, + end_lineno=13, + end_col_offset=56)], + [], + lineno=13, + col_offset=45, + end_lineno=13, + end_col_offset=58), + Add(), + Constant( + 2, + lineno=13, + col_offset=61, + end_lineno=13, + end_col_offset=62), + lineno=13, + col_offset=45, + end_lineno=13, + end_col_offset=62)], + Load(), + lineno=13, + col_offset=10, + end_lineno=13, + end_col_offset=63)], + [], + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=64), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=64), + Return( + List( + [ + Call( + Name( + 'int', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=15), + [ + Name( + 'number', + Load(), + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=23)], + [], + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=25), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=30), + [ + Name( + 'number', + Load(), + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=38)], + [], + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=15, + col_offset=43, + end_lineno=15, + end_col_offset=44), + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=44), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=15, + col_offset=46, + end_lineno=15, + end_col_offset=49), + [ + Name( + 'number', + Load(), + lineno=15, + col_offset=51, + end_lineno=15, + end_col_offset=57)], + [], + lineno=15, + col_offset=46, + end_lineno=15, + end_col_offset=59), + Add(), + Constant( + 2, + lineno=15, + col_offset=62, + end_lineno=15, + end_col_offset=63), + lineno=15, + col_offset=46, + end_lineno=15, + end_col_offset=63)], + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=64), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=64)], + [], + lineno=7, + col_offset=0, + end_lineno=15, + end_col_offset=64), + FunctionDef( + 'concatenate_rounds', + arguments( + [], + [ + arg( + 'rounds_1', + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=31), + arg( + 'rounds_2', + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param rounds_1: list - first rounds played.\n :param rounds_2: list - second set of rounds played.\n :return: list - all rounds played.\n ', + lineno=19, + col_offset=4, + end_lineno=24, + end_col_offset=7), + lineno=19, + col_offset=4, + end_lineno=24, + end_col_offset=7), + Expr( + Call( + Name( + 'print', + Load(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=9), + [ + BinOp( + Name( + 'rounds_1', + Load(), + lineno=25, + col_offset=10, + end_lineno=25, + end_col_offset=18), + Add(), + Name( + 'rounds_2', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=29), + lineno=25, + col_offset=10, + end_lineno=25, + end_col_offset=29)], + [], + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=30), + Return( + BinOp( + Name( + 'rounds_1', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=19), + Add(), + Name( + 'rounds_2', + Load(), + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=30), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=30), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=30)], + [], + lineno=18, + col_offset=0, + end_lineno=27, + end_col_offset=30), + FunctionDef( + 'list_contains_round', + arguments( + [], + [ + arg( + 'rounds', + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=30), + arg( + 'number', + lineno=30, + col_offset=32, + end_lineno=30, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param rounds: list - rounds played.\n :param number: int - round number.\n :return: bool - was the round played?\n ', + lineno=31, + col_offset=4, + end_lineno=36, + end_col_offset=7), + lineno=31, + col_offset=4, + end_lineno=36, + end_col_offset=7), + If( + Compare( + Name( + 'number', + Load(), + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=13), + [ + In()], + [ + Name( + 'rounds', + Load(), + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=23)], + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=23), + [ + Expr( + Call( + Name( + 'print', + Load(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=13), + [ + Name( + 'number', + Load(), + lineno=39, + col_offset=14, + end_lineno=39, + end_col_offset=20)], + [], + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=21), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=21), + Return( + Constant( + True, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=19), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=19)], + [ + Expr( + Call( + Name( + 'print', + Load(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=13), + [ + Name( + 'rounds', + Load(), + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=20)], + [], + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=21), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=21), + Return( + Constant( + False, + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=20), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=20)], + lineno=38, + col_offset=4, + end_lineno=43, + end_col_offset=20)], + [], + lineno=30, + col_offset=0, + end_lineno=43, + end_col_offset=20), + FunctionDef( + 'card_average', + arguments( + [], + [ + arg( + 'hand', + lineno=45, + col_offset=17, + end_lineno=45, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param hand: list - cards in hand.\n :return: float - average value of the cards in the hand.\n ', + lineno=46, + col_offset=4, + end_lineno=50, + end_col_offset=7), + lineno=46, + col_offset=4, + end_lineno=50, + end_col_offset=7), + Return( + Call( + Name( + 'round', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=16), + [ + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=20), + [ + Name( + 'hand', + Load(), + lineno=52, + col_offset=21, + end_lineno=52, + end_col_offset=25)], + [], + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=26), + Div(), + Call( + Name( + 'len', + Load(), + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=30), + [ + Name( + 'hand', + Load(), + lineno=52, + col_offset=31, + end_lineno=52, + end_col_offset=35)], + [], + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=36), + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=36), + Constant( + 1, + lineno=52, + col_offset=38, + end_lineno=52, + end_col_offset=39)], + [], + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=40), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=40)], + [], + lineno=45, + col_offset=0, + end_lineno=52, + end_col_offset=40), + FunctionDef( + 'approx_average_is_average', + arguments( + [], + [ + arg( + 'hand', + lineno=55, + col_offset=30, + end_lineno=55, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param hand: list - cards in hand.\n :return: bool - if approximate average equals to the `true average`.\n ', + lineno=56, + col_offset=4, + end_lineno=60, + end_col_offset=7), + lineno=56, + col_offset=4, + end_lineno=60, + end_col_offset=7), + Assign( + [ + Name( + 'avg', + Store(), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=7)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=14), + [ + Name( + 'hand', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=19)], + [], + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=20), + Div(), + Call( + Name( + 'len', + Load(), + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=26), + [ + Name( + 'hand', + Load(), + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=31)], + [], + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=32), + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=32), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=33), + Assign( + [ + Name( + 'skrajne', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=11)], + Compare( + Name( + 'avg', + Load(), + lineno=63, + col_offset=14, + end_lineno=63, + end_col_offset=17), + [ + Eq()], + [ + BinOp( + BinOp( + Subscript( + Name( + 'hand', + Load(), + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=26), + Constant( + 0, + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=28), + Load(), + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=29), + Add(), + Subscript( + Name( + 'hand', + Load(), + lineno=63, + col_offset=32, + end_lineno=63, + end_col_offset=36), + UnaryOp( + USub(), + Constant( + 1, + lineno=63, + col_offset=38, + end_lineno=63, + end_col_offset=39), + lineno=63, + col_offset=37, + end_lineno=63, + end_col_offset=39), + Load(), + lineno=63, + col_offset=32, + end_lineno=63, + end_col_offset=40), + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=40), + Div(), + Constant( + 2, + lineno=63, + col_offset=44, + end_lineno=63, + end_col_offset=45), + lineno=63, + col_offset=21, + end_lineno=63, + end_col_offset=45)], + lineno=63, + col_offset=14, + end_lineno=63, + end_col_offset=45), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=45), + Import( + [ + alias( + 'statistics', + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=21)], + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=21), + Expr( + Call( + Name( + 'print', + Load(), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=9), + [ + BinOp( + BinOp( + Subscript( + Name( + 'hand', + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=15), + Constant( + 0, + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=17), + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=18), + Add(), + Subscript( + Name( + 'hand', + Load(), + lineno=66, + col_offset=21, + end_lineno=66, + end_col_offset=25), + UnaryOp( + USub(), + Constant( + 1, + lineno=66, + col_offset=27, + end_lineno=66, + end_col_offset=28), + lineno=66, + col_offset=26, + end_lineno=66, + end_col_offset=28), + Load(), + lineno=66, + col_offset=21, + end_lineno=66, + end_col_offset=29), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=29), + Div(), + Constant( + 2, + lineno=66, + col_offset=33, + end_lineno=66, + end_col_offset=34), + lineno=66, + col_offset=10, + end_lineno=66, + end_col_offset=34)], + [], + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=35), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=35), + Assign( + [ + Name( + 'mediana', + Store(), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=11)], + Compare( + Name( + 'avg', + Load(), + lineno=68, + col_offset=14, + end_lineno=68, + end_col_offset=17), + [ + Eq()], + [ + Call( + Attribute( + Name( + 'statistics', + Load(), + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=31), + 'median', + Load(), + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=38), + [ + Name( + 'hand', + Load(), + lineno=68, + col_offset=39, + end_lineno=68, + end_col_offset=43)], + [], + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=44)], + lineno=68, + col_offset=14, + end_lineno=68, + end_col_offset=44), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=44), + Expr( + Call( + Name( + 'print', + Load(), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=9), + [ + BinOp( + Subscript( + Name( + 'hand', + Load(), + lineno=70, + col_offset=10, + end_lineno=70, + end_col_offset=14), + Constant( + 0, + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=16), + Load(), + lineno=70, + col_offset=10, + end_lineno=70, + end_col_offset=17), + Add(), + Subscript( + Name( + 'hand', + Load(), + lineno=70, + col_offset=20, + end_lineno=70, + end_col_offset=24), + UnaryOp( + USub(), + Constant( + 1, + lineno=70, + col_offset=26, + end_lineno=70, + end_col_offset=27), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=27), + Load(), + lineno=70, + col_offset=20, + end_lineno=70, + end_col_offset=28), + lineno=70, + col_offset=10, + end_lineno=70, + end_col_offset=28)], + [], + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=29), + lineno=70, + col_offset=4, + end_lineno=70, + end_col_offset=29), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'mediana', + Load(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=15), + [ + Eq()], + [ + Constant( + True, + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=23)], + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=23), + Compare( + Name( + 'skrajne', + Load(), + lineno=72, + col_offset=27, + end_lineno=72, + end_col_offset=34), + [ + Eq()], + [ + Constant( + True, + lineno=72, + col_offset=38, + end_lineno=72, + end_col_offset=42)], + lineno=72, + col_offset=27, + end_lineno=72, + end_col_offset=42)], + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=42), + [ + Expr( + Call( + Name( + 'print', + Load(), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=13), + [ + Name( + 'mediana', + Load(), + lineno=73, + col_offset=14, + end_lineno=73, + end_col_offset=21)], + [], + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=22), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=22), + Return( + Constant( + True, + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=19), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=19)], + [ + Return( + Constant( + False, + lineno=76, + col_offset=15, + end_lineno=76, + end_col_offset=20), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=20)], + lineno=72, + col_offset=4, + end_lineno=76, + end_col_offset=20)], + [], + lineno=55, + col_offset=0, + end_lineno=76, + end_col_offset=20), + FunctionDef( + 'average_even_is_average_odd', + arguments( + [], + [ + arg( + 'hand', + lineno=78, + col_offset=32, + end_lineno=78, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param hand: list - cards in hand.\n :return: bool - are even and odd averages equal?\n ', + lineno=79, + col_offset=4, + end_lineno=83, + end_col_offset=7), + lineno=79, + col_offset=4, + end_lineno=83, + end_col_offset=7), + Assign( + [ + Name( + 'list_odd', + Store(), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=12)], + Call( + Name( + 'list', + Load(), + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=20), + [ + Call( + Name( + 'range', + Load(), + lineno=85, + col_offset=21, + end_lineno=85, + end_col_offset=26), + [ + Constant( + 1, + lineno=85, + col_offset=27, + end_lineno=85, + end_col_offset=28), + Call( + Name( + 'len', + Load(), + lineno=85, + col_offset=30, + end_lineno=85, + end_col_offset=33), + [ + Name( + 'hand', + Load(), + lineno=85, + col_offset=34, + end_lineno=85, + end_col_offset=38)], + [], + lineno=85, + col_offset=30, + end_lineno=85, + end_col_offset=39), + Constant( + 2, + lineno=85, + col_offset=41, + end_lineno=85, + end_col_offset=42)], + [], + lineno=85, + col_offset=21, + end_lineno=85, + end_col_offset=43)], + [], + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=44), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=45), + Assign( + [ + Name( + 'list_even', + Store(), + lineno=86, + col_offset=4, + end_lineno=86, + end_col_offset=13)], + Call( + Name( + 'list', + Load(), + lineno=86, + col_offset=17, + end_lineno=86, + end_col_offset=21), + [ + Call( + Name( + 'range', + Load(), + lineno=86, + col_offset=23, + end_lineno=86, + end_col_offset=28), + [ + Constant( + 0, + lineno=86, + col_offset=30, + end_lineno=86, + end_col_offset=31), + Call( + Name( + 'len', + Load(), + lineno=86, + col_offset=33, + end_lineno=86, + end_col_offset=36), + [ + Name( + 'hand', + Load(), + lineno=86, + col_offset=38, + end_lineno=86, + end_col_offset=42)], + [], + lineno=86, + col_offset=33, + end_lineno=86, + end_col_offset=44), + Constant( + 2, + lineno=86, + col_offset=46, + end_lineno=86, + end_col_offset=47)], + [], + lineno=86, + col_offset=23, + end_lineno=86, + end_col_offset=49)], + [], + lineno=86, + col_offset=17, + end_lineno=86, + end_col_offset=51), + lineno=86, + col_offset=4, + end_lineno=86, + end_col_offset=52), + Expr( + Call( + Name( + 'print', + Load(), + lineno=88, + col_offset=4, + end_lineno=88, + end_col_offset=9), + [ + List( + [ + Name( + 'list_odd', + Load(), + lineno=88, + col_offset=11, + end_lineno=88, + end_col_offset=19), + Name( + 'list_even', + Load(), + lineno=88, + col_offset=20, + end_lineno=88, + end_col_offset=29)], + Load(), + lineno=88, + col_offset=10, + end_lineno=88, + end_col_offset=30)], + [], + lineno=88, + col_offset=4, + end_lineno=88, + end_col_offset=31), + lineno=88, + col_offset=4, + end_lineno=88, + end_col_offset=31), + Assign( + [ + Name( + 'count_odd', + Store(), + lineno=90, + col_offset=4, + end_lineno=90, + end_col_offset=13)], + Call( + Name( + 'len', + Load(), + lineno=90, + col_offset=16, + end_lineno=90, + end_col_offset=19), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=90, + col_offset=20, + end_lineno=90, + end_col_offset=24), + Slice( + Constant( + 0, + lineno=90, + col_offset=25, + end_lineno=90, + end_col_offset=26), + Call( + Name( + 'len', + Load(), + lineno=90, + col_offset=27, + end_lineno=90, + end_col_offset=30), + [ + Name( + 'hand', + Load(), + lineno=90, + col_offset=31, + end_lineno=90, + end_col_offset=35)], + [], + lineno=90, + col_offset=27, + end_lineno=90, + end_col_offset=36), + Constant( + 2, + lineno=90, + col_offset=37, + end_lineno=90, + end_col_offset=38), + lineno=90, + col_offset=25, + end_lineno=90, + end_col_offset=38), + Load(), + lineno=90, + col_offset=20, + end_lineno=90, + end_col_offset=39)], + [], + lineno=90, + col_offset=16, + end_lineno=90, + end_col_offset=40), + lineno=90, + col_offset=4, + end_lineno=90, + end_col_offset=40), + Assign( + [ + Name( + 'avg_odd', + Store(), + lineno=91, + col_offset=4, + end_lineno=91, + end_col_offset=11)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=18), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=91, + col_offset=19, + end_lineno=91, + end_col_offset=23), + Slice( + Constant( + 0, + lineno=91, + col_offset=24, + end_lineno=91, + end_col_offset=25), + Call( + Name( + 'len', + Load(), + lineno=91, + col_offset=26, + end_lineno=91, + end_col_offset=29), + [ + Name( + 'hand', + Load(), + lineno=91, + col_offset=30, + end_lineno=91, + end_col_offset=34)], + [], + lineno=91, + col_offset=26, + end_lineno=91, + end_col_offset=35), + Constant( + 2, + lineno=91, + col_offset=36, + end_lineno=91, + end_col_offset=37), + lineno=91, + col_offset=24, + end_lineno=91, + end_col_offset=37), + Load(), + lineno=91, + col_offset=19, + end_lineno=91, + end_col_offset=38)], + [], + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=39), + Div(), + Name( + 'count_odd', + Load(), + lineno=91, + col_offset=43, + end_lineno=91, + end_col_offset=52), + lineno=91, + col_offset=14, + end_lineno=91, + end_col_offset=52), + lineno=91, + col_offset=4, + end_lineno=91, + end_col_offset=52), + Assign( + [ + Name( + 'count_even', + Store(), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=14)], + Call( + Name( + 'len', + Load(), + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=20), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=26), + Slice( + Constant( + 1, + lineno=92, + col_offset=27, + end_lineno=92, + end_col_offset=28), + Call( + Name( + 'len', + Load(), + lineno=92, + col_offset=29, + end_lineno=92, + end_col_offset=32), + [ + Name( + 'hand', + Load(), + lineno=92, + col_offset=34, + end_lineno=92, + end_col_offset=38)], + [], + lineno=92, + col_offset=29, + end_lineno=92, + end_col_offset=40), + Constant( + 2, + lineno=92, + col_offset=41, + end_lineno=92, + end_col_offset=42), + lineno=92, + col_offset=27, + end_lineno=92, + end_col_offset=42), + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=43)], + [], + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=45), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=45), + Assign( + [ + Name( + 'avg_even', + Store(), + lineno=93, + col_offset=4, + end_lineno=93, + end_col_offset=12)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=19), + [ + Subscript( + Name( + 'hand', + Load(), + lineno=93, + col_offset=21, + end_lineno=93, + end_col_offset=25), + Slice( + Constant( + 1, + lineno=93, + col_offset=26, + end_lineno=93, + end_col_offset=27), + Call( + Name( + 'len', + Load(), + lineno=93, + col_offset=28, + end_lineno=93, + end_col_offset=31), + [ + Name( + 'hand', + Load(), + lineno=93, + col_offset=33, + end_lineno=93, + end_col_offset=37)], + [], + lineno=93, + col_offset=28, + end_lineno=93, + end_col_offset=39), + Constant( + 2, + lineno=93, + col_offset=40, + end_lineno=93, + end_col_offset=41), + lineno=93, + col_offset=26, + end_lineno=93, + end_col_offset=41), + Load(), + lineno=93, + col_offset=21, + end_lineno=93, + end_col_offset=42)], + [], + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=44), + Div(), + Name( + 'count_even', + Load(), + lineno=93, + col_offset=48, + end_lineno=93, + end_col_offset=58), + lineno=93, + col_offset=15, + end_lineno=93, + end_col_offset=58), + lineno=93, + col_offset=4, + end_lineno=93, + end_col_offset=58), + Expr( + Call( + Name( + 'print', + Load(), + lineno=95, + col_offset=4, + end_lineno=95, + end_col_offset=9), + [ + Name( + 'avg_odd', + Load(), + lineno=95, + col_offset=10, + end_lineno=95, + end_col_offset=17), + Name( + 'count_odd', + Load(), + lineno=95, + col_offset=19, + end_lineno=95, + end_col_offset=28)], + [], + lineno=95, + col_offset=4, + end_lineno=95, + end_col_offset=29), + lineno=95, + col_offset=4, + end_lineno=95, + end_col_offset=29), + Return( + Compare( + Name( + 'avg_odd', + Load(), + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=18), + [ + Eq()], + [ + Name( + 'avg_even', + Load(), + lineno=97, + col_offset=22, + end_lineno=97, + end_col_offset=30)], + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=30), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=30)], + [], + lineno=78, + col_offset=0, + end_lineno=97, + end_col_offset=30), + FunctionDef( + 'maybe_double_last', + arguments( + [], + [ + arg( + 'hand', + lineno=100, + col_offset=22, + end_lineno=100, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n\n :param hand: list - cards in hand.\n :return: list - hand with Jacks (if present) value doubled.\n ', + lineno=101, + col_offset=4, + end_lineno=105, + end_col_offset=7), + lineno=101, + col_offset=4, + end_lineno=105, + end_col_offset=7), + If( + Compare( + Subscript( + Name( + 'hand', + Load(), + lineno=107, + col_offset=7, + end_lineno=107, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=107, + col_offset=13, + end_lineno=107, + end_col_offset=14), + lineno=107, + col_offset=12, + end_lineno=107, + end_col_offset=14), + Load(), + lineno=107, + col_offset=7, + end_lineno=107, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 11, + lineno=107, + col_offset=19, + end_lineno=107, + end_col_offset=21)], + lineno=107, + col_offset=7, + end_lineno=107, + end_col_offset=21), + [ + Expr( + Call( + Name( + 'print', + Load(), + lineno=108, + col_offset=8, + end_lineno=108, + end_col_offset=13), + [ + Name( + 'hand', + Load(), + lineno=108, + col_offset=14, + end_lineno=108, + end_col_offset=18)], + [], + lineno=108, + col_offset=8, + end_lineno=108, + end_col_offset=19), + lineno=108, + col_offset=8, + end_lineno=108, + end_col_offset=19), + Return( + List( + [ + Subscript( + Name( + 'hand', + Load(), + lineno=109, + col_offset=16, + end_lineno=109, + end_col_offset=20), + Constant( + 0, + lineno=109, + col_offset=22, + end_lineno=109, + end_col_offset=23), + Load(), + lineno=109, + col_offset=16, + end_lineno=109, + end_col_offset=24), + Subscript( + Name( + 'hand', + Load(), + lineno=109, + col_offset=26, + end_lineno=109, + end_col_offset=30), + Constant( + 1, + lineno=109, + col_offset=32, + end_lineno=109, + end_col_offset=33), + Load(), + lineno=109, + col_offset=26, + end_lineno=109, + end_col_offset=34), + BinOp( + Subscript( + Name( + 'hand', + Load(), + lineno=109, + col_offset=36, + end_lineno=109, + end_col_offset=40), + UnaryOp( + USub(), + Constant( + 1, + lineno=109, + col_offset=42, + end_lineno=109, + end_col_offset=43), + lineno=109, + col_offset=41, + end_lineno=109, + end_col_offset=43), + Load(), + lineno=109, + col_offset=36, + end_lineno=109, + end_col_offset=44), + Mult(), + Constant( + 2, + lineno=109, + col_offset=47, + end_lineno=109, + end_col_offset=48), + lineno=109, + col_offset=36, + end_lineno=109, + end_col_offset=48)], + Load(), + lineno=109, + col_offset=15, + end_lineno=109, + end_col_offset=49), + lineno=109, + col_offset=8, + end_lineno=109, + end_col_offset=49)], + [ + Expr( + Call( + Name( + 'print', + Load(), + lineno=111, + col_offset=8, + end_lineno=111, + end_col_offset=13), + [ + Constant( + 'Nothing found!', + lineno=111, + col_offset=14, + end_lineno=111, + end_col_offset=30), + Name( + 'hand', + Load(), + lineno=111, + col_offset=32, + end_lineno=111, + end_col_offset=36)], + [], + lineno=111, + col_offset=8, + end_lineno=111, + end_col_offset=37), + lineno=111, + col_offset=8, + end_lineno=111, + end_col_offset=37), + Return( + Name( + 'hand', + Load(), + lineno=112, + col_offset=15, + end_lineno=112, + end_col_offset=19), + lineno=112, + col_offset=8, + end_lineno=112, + end_col_offset=19)], + lineno=107, + col_offset=4, + end_lineno=112, + end_col_offset=19)], + [], + lineno=100, + col_offset=0, + end_lineno=112, + end_col_offset=19)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + List( + [ + Call( + Name( + 'int', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=15), + [ + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=23)], + [], + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=25), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=30), + [ + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=38)], + [], + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=15, + col_offset=43, + end_lineno=15, + end_col_offset=44), + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=44), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=15, + col_offset=46, + end_lineno=15, + end_col_offset=49), + [ + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=51, + end_lineno=15, + end_col_offset=57)], + [], + lineno=15, + col_offset=46, + end_lineno=15, + end_col_offset=59), + Add(), + Constant( + 2, + lineno=15, + col_offset=62, + end_lineno=15, + end_col_offset=63), + lineno=15, + col_offset=46, + end_lineno=15, + end_col_offset=63)], + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=64), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=64)], + [], + lineno=7, + col_offset=0, + end_lineno=15, + end_col_offset=64), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=31), + arg( + 'placeholder_4', + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=19), + Add(), + Name( + 'placeholder_4', + Load(), + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=30), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=30), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=30)], + [], + lineno=18, + col_offset=0, + end_lineno=27, + end_col_offset=30), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=30), + arg( + 'placeholder_1', + lineno=30, + col_offset=32, + end_lineno=30, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=13), + [ + In()], + [ + Name( + 'placeholder_6', + Load(), + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=23)], + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=23), + [ + Return( + Constant( + True, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=19), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=19)], + [ + Return( + Constant( + False, + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=20), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=20)], + lineno=38, + col_offset=4, + end_lineno=43, + end_col_offset=20)], + [], + lineno=30, + col_offset=0, + end_lineno=43, + end_col_offset=20), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=45, + col_offset=17, + end_lineno=45, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'round', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=16), + [ + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=20), + [ + Name( + 'placeholder_8', + Load(), + lineno=52, + col_offset=21, + end_lineno=52, + end_col_offset=25)], + [], + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=26), + Div(), + Call( + Name( + 'len', + Load(), + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=30), + [ + Name( + 'placeholder_8', + Load(), + lineno=52, + col_offset=31, + end_lineno=52, + end_col_offset=35)], + [], + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=36), + lineno=52, + col_offset=17, + end_lineno=52, + end_col_offset=36), + Constant( + 1, + lineno=52, + col_offset=38, + end_lineno=52, + end_col_offset=39)], + [], + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=40), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=40)], + [], + lineno=45, + col_offset=0, + end_lineno=52, + end_col_offset=40), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=55, + col_offset=30, + end_lineno=55, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=7)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=14), + [ + Name( + 'placeholder_8', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=19)], + [], + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=20), + Div(), + Call( + Name( + 'len', + Load(), + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=26), + [ + Name( + 'placeholder_8', + Load(), + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=31)], + [], + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=32), + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=32), + lineno=62, + col_offset=4, + end_lineno=62, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=11)], + Compare( + Name( + 'placeholder_10', + Load(), + lineno=63, + col_offset=14, + end_lineno=63, + end_col_offset=17), + [ + Eq()], + [ + BinOp( + BinOp( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=26), + Constant( + 0, + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=28), + Load(), + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=29), + Add(), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=63, + col_offset=32, + end_lineno=63, + end_col_offset=36), + UnaryOp( + USub(), + Constant( + 1, + lineno=63, + col_offset=38, + end_lineno=63, + end_col_offset=39), + lineno=63, + col_offset=37, + end_lineno=63, + end_col_offset=39), + Load(), + lineno=63, + col_offset=32, + end_lineno=63, + end_col_offset=40), + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=40), + Div(), + Constant( + 2, + lineno=63, + col_offset=44, + end_lineno=63, + end_col_offset=45), + lineno=63, + col_offset=21, + end_lineno=63, + end_col_offset=45)], + lineno=63, + col_offset=14, + end_lineno=63, + end_col_offset=45), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=45), + Import( + [ + alias( + 'statistics', + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=21)], + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=21), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=11)], + Compare( + Name( + 'placeholder_10', + Load(), + lineno=68, + col_offset=14, + end_lineno=68, + end_col_offset=17), + [ + Eq()], + [ + Call( + Attribute( + Name( + 'statistics', + Load(), + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=31), + 'median', + Load(), + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=38), + [ + Name( + 'placeholder_8', + Load(), + lineno=68, + col_offset=39, + end_lineno=68, + end_col_offset=43)], + [], + lineno=68, + col_offset=21, + end_lineno=68, + end_col_offset=44)], + lineno=68, + col_offset=14, + end_lineno=68, + end_col_offset=44), + lineno=68, + col_offset=4, + end_lineno=68, + end_col_offset=44), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_12', + Load(), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=15), + [ + Eq()], + [ + Constant( + True, + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=23)], + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=23), + Compare( + Name( + 'placeholder_11', + Load(), + lineno=72, + col_offset=27, + end_lineno=72, + end_col_offset=34), + [ + Eq()], + [ + Constant( + True, + lineno=72, + col_offset=38, + end_lineno=72, + end_col_offset=42)], + lineno=72, + col_offset=27, + end_lineno=72, + end_col_offset=42)], + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=42), + [ + Return( + Constant( + True, + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=19), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=19)], + [ + Return( + Constant( + False, + lineno=76, + col_offset=15, + end_lineno=76, + end_col_offset=20), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=20)], + lineno=72, + col_offset=4, + end_lineno=76, + end_col_offset=20)], + [], + lineno=55, + col_offset=0, + end_lineno=76, + end_col_offset=20), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=78, + col_offset=32, + end_lineno=78, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=12)], + Call( + Name( + 'list', + Load(), + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=20), + [ + Call( + Name( + 'range', + Load(), + lineno=85, + col_offset=21, + end_lineno=85, + end_col_offset=26), + [ + Constant( + 1, + lineno=85, + col_offset=27, + end_lineno=85, + end_col_offset=28), + Call( + Name( + 'len', + Load(), + lineno=85, + col_offset=30, + end_lineno=85, + end_col_offset=33), + [ + Name( + 'placeholder_8', + Load(), + lineno=85, + col_offset=34, + end_lineno=85, + end_col_offset=38)], + [], + lineno=85, + col_offset=30, + end_lineno=85, + end_col_offset=39), + Constant( + 2, + lineno=85, + col_offset=41, + end_lineno=85, + end_col_offset=42)], + [], + lineno=85, + col_offset=21, + end_lineno=85, + end_col_offset=43)], + [], + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=44), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=86, + col_offset=4, + end_lineno=86, + end_col_offset=13)], + Call( + Name( + 'list', + Load(), + lineno=86, + col_offset=17, + end_lineno=86, + end_col_offset=21), + [ + Call( + Name( + 'range', + Load(), + lineno=86, + col_offset=23, + end_lineno=86, + end_col_offset=28), + [ + Constant( + 0, + lineno=86, + col_offset=30, + end_lineno=86, + end_col_offset=31), + Call( + Name( + 'len', + Load(), + lineno=86, + col_offset=33, + end_lineno=86, + end_col_offset=36), + [ + Name( + 'placeholder_8', + Load(), + lineno=86, + col_offset=38, + end_lineno=86, + end_col_offset=42)], + [], + lineno=86, + col_offset=33, + end_lineno=86, + end_col_offset=44), + Constant( + 2, + lineno=86, + col_offset=46, + end_lineno=86, + end_col_offset=47)], + [], + lineno=86, + col_offset=23, + end_lineno=86, + end_col_offset=49)], + [], + lineno=86, + col_offset=17, + end_lineno=86, + end_col_offset=51), + lineno=86, + col_offset=4, + end_lineno=86, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=90, + col_offset=4, + end_lineno=90, + end_col_offset=13)], + Call( + Name( + 'len', + Load(), + lineno=90, + col_offset=16, + end_lineno=90, + end_col_offset=19), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=90, + col_offset=20, + end_lineno=90, + end_col_offset=24), + Slice( + Constant( + 0, + lineno=90, + col_offset=25, + end_lineno=90, + end_col_offset=26), + Call( + Name( + 'len', + Load(), + lineno=90, + col_offset=27, + end_lineno=90, + end_col_offset=30), + [ + Name( + 'placeholder_8', + Load(), + lineno=90, + col_offset=31, + end_lineno=90, + end_col_offset=35)], + [], + lineno=90, + col_offset=27, + end_lineno=90, + end_col_offset=36), + Constant( + 2, + lineno=90, + col_offset=37, + end_lineno=90, + end_col_offset=38), + lineno=90, + col_offset=25, + end_lineno=90, + end_col_offset=38), + Load(), + lineno=90, + col_offset=20, + end_lineno=90, + end_col_offset=39)], + [], + lineno=90, + col_offset=16, + end_lineno=90, + end_col_offset=40), + lineno=90, + col_offset=4, + end_lineno=90, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=91, + col_offset=4, + end_lineno=91, + end_col_offset=11)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=18), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=91, + col_offset=19, + end_lineno=91, + end_col_offset=23), + Slice( + Constant( + 0, + lineno=91, + col_offset=24, + end_lineno=91, + end_col_offset=25), + Call( + Name( + 'len', + Load(), + lineno=91, + col_offset=26, + end_lineno=91, + end_col_offset=29), + [ + Name( + 'placeholder_8', + Load(), + lineno=91, + col_offset=30, + end_lineno=91, + end_col_offset=34)], + [], + lineno=91, + col_offset=26, + end_lineno=91, + end_col_offset=35), + Constant( + 2, + lineno=91, + col_offset=36, + end_lineno=91, + end_col_offset=37), + lineno=91, + col_offset=24, + end_lineno=91, + end_col_offset=37), + Load(), + lineno=91, + col_offset=19, + end_lineno=91, + end_col_offset=38)], + [], + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=39), + Div(), + Name( + 'placeholder_16', + Load(), + lineno=91, + col_offset=43, + end_lineno=91, + end_col_offset=52), + lineno=91, + col_offset=14, + end_lineno=91, + end_col_offset=52), + lineno=91, + col_offset=4, + end_lineno=91, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=14)], + Call( + Name( + 'len', + Load(), + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=20), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=26), + Slice( + Constant( + 1, + lineno=92, + col_offset=27, + end_lineno=92, + end_col_offset=28), + Call( + Name( + 'len', + Load(), + lineno=92, + col_offset=29, + end_lineno=92, + end_col_offset=32), + [ + Name( + 'placeholder_8', + Load(), + lineno=92, + col_offset=34, + end_lineno=92, + end_col_offset=38)], + [], + lineno=92, + col_offset=29, + end_lineno=92, + end_col_offset=40), + Constant( + 2, + lineno=92, + col_offset=41, + end_lineno=92, + end_col_offset=42), + lineno=92, + col_offset=27, + end_lineno=92, + end_col_offset=42), + Load(), + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=43)], + [], + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=45), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=93, + col_offset=4, + end_lineno=93, + end_col_offset=12)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=19), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=93, + col_offset=21, + end_lineno=93, + end_col_offset=25), + Slice( + Constant( + 1, + lineno=93, + col_offset=26, + end_lineno=93, + end_col_offset=27), + Call( + Name( + 'len', + Load(), + lineno=93, + col_offset=28, + end_lineno=93, + end_col_offset=31), + [ + Name( + 'placeholder_8', + Load(), + lineno=93, + col_offset=33, + end_lineno=93, + end_col_offset=37)], + [], + lineno=93, + col_offset=28, + end_lineno=93, + end_col_offset=39), + Constant( + 2, + lineno=93, + col_offset=40, + end_lineno=93, + end_col_offset=41), + lineno=93, + col_offset=26, + end_lineno=93, + end_col_offset=41), + Load(), + lineno=93, + col_offset=21, + end_lineno=93, + end_col_offset=42)], + [], + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=44), + Div(), + Name( + 'placeholder_18', + Load(), + lineno=93, + col_offset=48, + end_lineno=93, + end_col_offset=58), + lineno=93, + col_offset=15, + end_lineno=93, + end_col_offset=58), + lineno=93, + col_offset=4, + end_lineno=93, + end_col_offset=58), + Return( + Compare( + Name( + 'placeholder_17', + Load(), + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=18), + [ + Eq()], + [ + Name( + 'placeholder_19', + Load(), + lineno=97, + col_offset=22, + end_lineno=97, + end_col_offset=30)], + lineno=97, + col_offset=11, + end_lineno=97, + end_col_offset=30), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=30)], + [], + lineno=78, + col_offset=0, + end_lineno=97, + end_col_offset=30), + FunctionDef( + 'placeholder_20', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=100, + col_offset=22, + end_lineno=100, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=107, + col_offset=7, + end_lineno=107, + end_col_offset=11), + UnaryOp( + USub(), + Constant( + 1, + lineno=107, + col_offset=13, + end_lineno=107, + end_col_offset=14), + lineno=107, + col_offset=12, + end_lineno=107, + end_col_offset=14), + Load(), + lineno=107, + col_offset=7, + end_lineno=107, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 11, + lineno=107, + col_offset=19, + end_lineno=107, + end_col_offset=21)], + lineno=107, + col_offset=7, + end_lineno=107, + end_col_offset=21), + [ + Return( + List( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=109, + col_offset=16, + end_lineno=109, + end_col_offset=20), + Constant( + 0, + lineno=109, + col_offset=22, + end_lineno=109, + end_col_offset=23), + Load(), + lineno=109, + col_offset=16, + end_lineno=109, + end_col_offset=24), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=109, + col_offset=26, + end_lineno=109, + end_col_offset=30), + Constant( + 1, + lineno=109, + col_offset=32, + end_lineno=109, + end_col_offset=33), + Load(), + lineno=109, + col_offset=26, + end_lineno=109, + end_col_offset=34), + BinOp( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=109, + col_offset=36, + end_lineno=109, + end_col_offset=40), + UnaryOp( + USub(), + Constant( + 1, + lineno=109, + col_offset=42, + end_lineno=109, + end_col_offset=43), + lineno=109, + col_offset=41, + end_lineno=109, + end_col_offset=43), + Load(), + lineno=109, + col_offset=36, + end_lineno=109, + end_col_offset=44), + Mult(), + Constant( + 2, + lineno=109, + col_offset=47, + end_lineno=109, + end_col_offset=48), + lineno=109, + col_offset=36, + end_lineno=109, + end_col_offset=48)], + Load(), + lineno=109, + col_offset=15, + end_lineno=109, + end_col_offset=49), + lineno=109, + col_offset=8, + end_lineno=109, + end_col_offset=49)], + [ + Return( + Name( + 'placeholder_8', + Load(), + lineno=112, + col_offset=15, + end_lineno=112, + end_col_offset=19), + lineno=112, + col_offset=8, + end_lineno=112, + end_col_offset=19)], + lineno=107, + col_offset=4, + end_lineno=112, + end_col_offset=19)], + [], + lineno=100, + col_offset=0, + end_lineno=112, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-print-removal/representation.txt b/test/example-print-removal/representation.txt new file mode 100644 index 0000000..8748671 --- /dev/null +++ b/test/example-print-removal/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=7, col_offset=15, end_lineno=7, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(List([Call(Name('int', Load(), lineno=15, col_offset=12, end_lineno=15, end_col_offset=15), [Name('placeholder_1', Load(), lineno=15, col_offset=17, end_lineno=15, end_col_offset=23)], [], lineno=15, col_offset=12, end_lineno=15, end_col_offset=25), BinOp(Call(Name('int', Load(), lineno=15, col_offset=27, end_lineno=15, end_col_offset=30), [Name('placeholder_1', Load(), lineno=15, col_offset=32, end_lineno=15, end_col_offset=38)], [], lineno=15, col_offset=27, end_lineno=15, end_col_offset=40), Add(), Constant(1, lineno=15, col_offset=43, end_lineno=15, end_col_offset=44), lineno=15, col_offset=27, end_lineno=15, end_col_offset=44), BinOp(Call(Name('int', Load(), lineno=15, col_offset=46, end_lineno=15, end_col_offset=49), [Name('placeholder_1', Load(), lineno=15, col_offset=51, end_lineno=15, end_col_offset=57)], [], lineno=15, col_offset=46, end_lineno=15, end_col_offset=59), Add(), Constant(2, lineno=15, col_offset=62, end_lineno=15, end_col_offset=63), lineno=15, col_offset=46, end_lineno=15, end_col_offset=63)], Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=64), lineno=15, col_offset=4, end_lineno=15, end_col_offset=64)], [], lineno=7, col_offset=0, end_lineno=15, end_col_offset=64), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=18, col_offset=23, end_lineno=18, end_col_offset=31), arg('placeholder_4', lineno=18, col_offset=33, end_lineno=18, end_col_offset=41)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_3', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=19), Add(), Name('placeholder_4', Load(), lineno=27, col_offset=22, end_lineno=27, end_col_offset=30), lineno=27, col_offset=11, end_lineno=27, end_col_offset=30), lineno=27, col_offset=4, end_lineno=27, end_col_offset=30)], [], lineno=18, col_offset=0, end_lineno=27, end_col_offset=30), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=30, col_offset=24, end_lineno=30, end_col_offset=30), arg('placeholder_1', lineno=30, col_offset=32, end_lineno=30, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_1', Load(), lineno=38, col_offset=7, end_lineno=38, end_col_offset=13), [In()], [Name('placeholder_6', Load(), lineno=38, col_offset=17, end_lineno=38, end_col_offset=23)], lineno=38, col_offset=7, end_lineno=38, end_col_offset=23), [Return(Constant(True, lineno=40, col_offset=15, end_lineno=40, end_col_offset=19), lineno=40, col_offset=8, end_lineno=40, end_col_offset=19)], [Return(Constant(False, lineno=43, col_offset=15, end_lineno=43, end_col_offset=20), lineno=43, col_offset=8, end_lineno=43, end_col_offset=20)], lineno=38, col_offset=4, end_lineno=43, end_col_offset=20)], [], lineno=30, col_offset=0, end_lineno=43, end_col_offset=20), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=45, col_offset=17, end_lineno=45, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('round', Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=16), [BinOp(Call(Name('sum', Load(), lineno=52, col_offset=17, end_lineno=52, end_col_offset=20), [Name('placeholder_8', Load(), lineno=52, col_offset=21, end_lineno=52, end_col_offset=25)], [], lineno=52, col_offset=17, end_lineno=52, end_col_offset=26), Div(), Call(Name('len', Load(), lineno=52, col_offset=27, end_lineno=52, end_col_offset=30), [Name('placeholder_8', Load(), lineno=52, col_offset=31, end_lineno=52, end_col_offset=35)], [], lineno=52, col_offset=27, end_lineno=52, end_col_offset=36), lineno=52, col_offset=17, end_lineno=52, end_col_offset=36), Constant(1, lineno=52, col_offset=38, end_lineno=52, end_col_offset=39)], [], lineno=52, col_offset=11, end_lineno=52, end_col_offset=40), lineno=52, col_offset=4, end_lineno=52, end_col_offset=40)], [], lineno=45, col_offset=0, end_lineno=52, end_col_offset=40), FunctionDef('placeholder_9', arguments([], [arg('placeholder_8', lineno=55, col_offset=30, end_lineno=55, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_10', Store(), lineno=62, col_offset=4, end_lineno=62, end_col_offset=7)], BinOp(Call(Name('sum', Load(), lineno=62, col_offset=11, end_lineno=62, end_col_offset=14), [Name('placeholder_8', Load(), lineno=62, col_offset=15, end_lineno=62, end_col_offset=19)], [], lineno=62, col_offset=11, end_lineno=62, end_col_offset=20), Div(), Call(Name('len', Load(), lineno=62, col_offset=23, end_lineno=62, end_col_offset=26), [Name('placeholder_8', Load(), lineno=62, col_offset=27, end_lineno=62, end_col_offset=31)], [], lineno=62, col_offset=23, end_lineno=62, end_col_offset=32), lineno=62, col_offset=11, end_lineno=62, end_col_offset=32), lineno=62, col_offset=4, end_lineno=62, end_col_offset=33), Assign([Name('placeholder_11', Store(), lineno=63, col_offset=4, end_lineno=63, end_col_offset=11)], Compare(Name('placeholder_10', Load(), lineno=63, col_offset=14, end_lineno=63, end_col_offset=17), [Eq()], [BinOp(BinOp(Subscript(Name('placeholder_8', Load(), lineno=63, col_offset=22, end_lineno=63, end_col_offset=26), Constant(0, lineno=63, col_offset=27, end_lineno=63, end_col_offset=28), Load(), lineno=63, col_offset=22, end_lineno=63, end_col_offset=29), Add(), Subscript(Name('placeholder_8', Load(), lineno=63, col_offset=32, end_lineno=63, end_col_offset=36), UnaryOp(USub(), Constant(1, lineno=63, col_offset=38, end_lineno=63, end_col_offset=39), lineno=63, col_offset=37, end_lineno=63, end_col_offset=39), Load(), lineno=63, col_offset=32, end_lineno=63, end_col_offset=40), lineno=63, col_offset=22, end_lineno=63, end_col_offset=40), Div(), Constant(2, lineno=63, col_offset=44, end_lineno=63, end_col_offset=45), lineno=63, col_offset=21, end_lineno=63, end_col_offset=45)], lineno=63, col_offset=14, end_lineno=63, end_col_offset=45), lineno=63, col_offset=4, end_lineno=63, end_col_offset=45), Import([alias('statistics', lineno=64, col_offset=11, end_lineno=64, end_col_offset=21)], lineno=64, col_offset=4, end_lineno=64, end_col_offset=21), Assign([Name('placeholder_12', Store(), lineno=68, col_offset=4, end_lineno=68, end_col_offset=11)], Compare(Name('placeholder_10', Load(), lineno=68, col_offset=14, end_lineno=68, end_col_offset=17), [Eq()], [Call(Attribute(Name('statistics', Load(), lineno=68, col_offset=21, end_lineno=68, end_col_offset=31), 'median', Load(), lineno=68, col_offset=21, end_lineno=68, end_col_offset=38), [Name('placeholder_8', Load(), lineno=68, col_offset=39, end_lineno=68, end_col_offset=43)], [], lineno=68, col_offset=21, end_lineno=68, end_col_offset=44)], lineno=68, col_offset=14, end_lineno=68, end_col_offset=44), lineno=68, col_offset=4, end_lineno=68, end_col_offset=44), If(BoolOp(Or(), [Compare(Name('placeholder_12', Load(), lineno=72, col_offset=8, end_lineno=72, end_col_offset=15), [Eq()], [Constant(True, lineno=72, col_offset=19, end_lineno=72, end_col_offset=23)], lineno=72, col_offset=8, end_lineno=72, end_col_offset=23), Compare(Name('placeholder_11', Load(), lineno=72, col_offset=27, end_lineno=72, end_col_offset=34), [Eq()], [Constant(True, lineno=72, col_offset=38, end_lineno=72, end_col_offset=42)], lineno=72, col_offset=27, end_lineno=72, end_col_offset=42)], lineno=72, col_offset=8, end_lineno=72, end_col_offset=42), [Return(Constant(True, lineno=74, col_offset=15, end_lineno=74, end_col_offset=19), lineno=74, col_offset=8, end_lineno=74, end_col_offset=19)], [Return(Constant(False, lineno=76, col_offset=15, end_lineno=76, end_col_offset=20), lineno=76, col_offset=8, end_lineno=76, end_col_offset=20)], lineno=72, col_offset=4, end_lineno=76, end_col_offset=20)], [], lineno=55, col_offset=0, end_lineno=76, end_col_offset=20), FunctionDef('placeholder_13', arguments([], [arg('placeholder_8', lineno=78, col_offset=32, end_lineno=78, end_col_offset=36)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=85, col_offset=4, end_lineno=85, end_col_offset=12)], Call(Name('list', Load(), lineno=85, col_offset=16, end_lineno=85, end_col_offset=20), [Call(Name('range', Load(), lineno=85, col_offset=21, end_lineno=85, end_col_offset=26), [Constant(1, lineno=85, col_offset=27, end_lineno=85, end_col_offset=28), Call(Name('len', Load(), lineno=85, col_offset=30, end_lineno=85, end_col_offset=33), [Name('placeholder_8', Load(), lineno=85, col_offset=34, end_lineno=85, end_col_offset=38)], [], lineno=85, col_offset=30, end_lineno=85, end_col_offset=39), Constant(2, lineno=85, col_offset=41, end_lineno=85, end_col_offset=42)], [], lineno=85, col_offset=21, end_lineno=85, end_col_offset=43)], [], lineno=85, col_offset=16, end_lineno=85, end_col_offset=44), lineno=85, col_offset=4, end_lineno=85, end_col_offset=45), Assign([Name('placeholder_15', Store(), lineno=86, col_offset=4, end_lineno=86, end_col_offset=13)], Call(Name('list', Load(), lineno=86, col_offset=17, end_lineno=86, end_col_offset=21), [Call(Name('range', Load(), lineno=86, col_offset=23, end_lineno=86, end_col_offset=28), [Constant(0, lineno=86, col_offset=30, end_lineno=86, end_col_offset=31), Call(Name('len', Load(), lineno=86, col_offset=33, end_lineno=86, end_col_offset=36), [Name('placeholder_8', Load(), lineno=86, col_offset=38, end_lineno=86, end_col_offset=42)], [], lineno=86, col_offset=33, end_lineno=86, end_col_offset=44), Constant(2, lineno=86, col_offset=46, end_lineno=86, end_col_offset=47)], [], lineno=86, col_offset=23, end_lineno=86, end_col_offset=49)], [], lineno=86, col_offset=17, end_lineno=86, end_col_offset=51), lineno=86, col_offset=4, end_lineno=86, end_col_offset=52), Assign([Name('placeholder_16', Store(), lineno=90, col_offset=4, end_lineno=90, end_col_offset=13)], Call(Name('len', Load(), lineno=90, col_offset=16, end_lineno=90, end_col_offset=19), [Subscript(Name('placeholder_8', Load(), lineno=90, col_offset=20, end_lineno=90, end_col_offset=24), Slice(Constant(0, lineno=90, col_offset=25, end_lineno=90, end_col_offset=26), Call(Name('len', Load(), lineno=90, col_offset=27, end_lineno=90, end_col_offset=30), [Name('placeholder_8', Load(), lineno=90, col_offset=31, end_lineno=90, end_col_offset=35)], [], lineno=90, col_offset=27, end_lineno=90, end_col_offset=36), Constant(2, lineno=90, col_offset=37, end_lineno=90, end_col_offset=38), lineno=90, col_offset=25, end_lineno=90, end_col_offset=38), Load(), lineno=90, col_offset=20, end_lineno=90, end_col_offset=39)], [], lineno=90, col_offset=16, end_lineno=90, end_col_offset=40), lineno=90, col_offset=4, end_lineno=90, end_col_offset=40), Assign([Name('placeholder_17', Store(), lineno=91, col_offset=4, end_lineno=91, end_col_offset=11)], BinOp(Call(Name('sum', Load(), lineno=91, col_offset=15, end_lineno=91, end_col_offset=18), [Subscript(Name('placeholder_8', Load(), lineno=91, col_offset=19, end_lineno=91, end_col_offset=23), Slice(Constant(0, lineno=91, col_offset=24, end_lineno=91, end_col_offset=25), Call(Name('len', Load(), lineno=91, col_offset=26, end_lineno=91, end_col_offset=29), [Name('placeholder_8', Load(), lineno=91, col_offset=30, end_lineno=91, end_col_offset=34)], [], lineno=91, col_offset=26, end_lineno=91, end_col_offset=35), Constant(2, lineno=91, col_offset=36, end_lineno=91, end_col_offset=37), lineno=91, col_offset=24, end_lineno=91, end_col_offset=37), Load(), lineno=91, col_offset=19, end_lineno=91, end_col_offset=38)], [], lineno=91, col_offset=15, end_lineno=91, end_col_offset=39), Div(), Name('placeholder_16', Load(), lineno=91, col_offset=43, end_lineno=91, end_col_offset=52), lineno=91, col_offset=14, end_lineno=91, end_col_offset=52), lineno=91, col_offset=4, end_lineno=91, end_col_offset=52), Assign([Name('placeholder_18', Store(), lineno=92, col_offset=4, end_lineno=92, end_col_offset=14)], Call(Name('len', Load(), lineno=92, col_offset=17, end_lineno=92, end_col_offset=20), [Subscript(Name('placeholder_8', Load(), lineno=92, col_offset=22, end_lineno=92, end_col_offset=26), Slice(Constant(1, lineno=92, col_offset=27, end_lineno=92, end_col_offset=28), Call(Name('len', Load(), lineno=92, col_offset=29, end_lineno=92, end_col_offset=32), [Name('placeholder_8', Load(), lineno=92, col_offset=34, end_lineno=92, end_col_offset=38)], [], lineno=92, col_offset=29, end_lineno=92, end_col_offset=40), Constant(2, lineno=92, col_offset=41, end_lineno=92, end_col_offset=42), lineno=92, col_offset=27, end_lineno=92, end_col_offset=42), Load(), lineno=92, col_offset=22, end_lineno=92, end_col_offset=43)], [], lineno=92, col_offset=17, end_lineno=92, end_col_offset=45), lineno=92, col_offset=4, end_lineno=92, end_col_offset=45), Assign([Name('placeholder_19', Store(), lineno=93, col_offset=4, end_lineno=93, end_col_offset=12)], BinOp(Call(Name('sum', Load(), lineno=93, col_offset=16, end_lineno=93, end_col_offset=19), [Subscript(Name('placeholder_8', Load(), lineno=93, col_offset=21, end_lineno=93, end_col_offset=25), Slice(Constant(1, lineno=93, col_offset=26, end_lineno=93, end_col_offset=27), Call(Name('len', Load(), lineno=93, col_offset=28, end_lineno=93, end_col_offset=31), [Name('placeholder_8', Load(), lineno=93, col_offset=33, end_lineno=93, end_col_offset=37)], [], lineno=93, col_offset=28, end_lineno=93, end_col_offset=39), Constant(2, lineno=93, col_offset=40, end_lineno=93, end_col_offset=41), lineno=93, col_offset=26, end_lineno=93, end_col_offset=41), Load(), lineno=93, col_offset=21, end_lineno=93, end_col_offset=42)], [], lineno=93, col_offset=16, end_lineno=93, end_col_offset=44), Div(), Name('placeholder_18', Load(), lineno=93, col_offset=48, end_lineno=93, end_col_offset=58), lineno=93, col_offset=15, end_lineno=93, end_col_offset=58), lineno=93, col_offset=4, end_lineno=93, end_col_offset=58), Return(Compare(Name('placeholder_17', Load(), lineno=97, col_offset=11, end_lineno=97, end_col_offset=18), [Eq()], [Name('placeholder_19', Load(), lineno=97, col_offset=22, end_lineno=97, end_col_offset=30)], lineno=97, col_offset=11, end_lineno=97, end_col_offset=30), lineno=97, col_offset=4, end_lineno=97, end_col_offset=30)], [], lineno=78, col_offset=0, end_lineno=97, end_col_offset=30), FunctionDef('placeholder_20', arguments([], [arg('placeholder_8', lineno=100, col_offset=22, end_lineno=100, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Subscript(Name('placeholder_8', Load(), lineno=107, col_offset=7, end_lineno=107, end_col_offset=11), UnaryOp(USub(), Constant(1, lineno=107, col_offset=13, end_lineno=107, end_col_offset=14), lineno=107, col_offset=12, end_lineno=107, end_col_offset=14), Load(), lineno=107, col_offset=7, end_lineno=107, end_col_offset=15), [Eq()], [Constant(11, lineno=107, col_offset=19, end_lineno=107, end_col_offset=21)], lineno=107, col_offset=7, end_lineno=107, end_col_offset=21), [Return(List([Subscript(Name('placeholder_8', Load(), lineno=109, col_offset=16, end_lineno=109, end_col_offset=20), Constant(0, lineno=109, col_offset=22, end_lineno=109, end_col_offset=23), Load(), lineno=109, col_offset=16, end_lineno=109, end_col_offset=24), Subscript(Name('placeholder_8', Load(), lineno=109, col_offset=26, end_lineno=109, end_col_offset=30), Constant(1, lineno=109, col_offset=32, end_lineno=109, end_col_offset=33), Load(), lineno=109, col_offset=26, end_lineno=109, end_col_offset=34), BinOp(Subscript(Name('placeholder_8', Load(), lineno=109, col_offset=36, end_lineno=109, end_col_offset=40), UnaryOp(USub(), Constant(1, lineno=109, col_offset=42, end_lineno=109, end_col_offset=43), lineno=109, col_offset=41, end_lineno=109, end_col_offset=43), Load(), lineno=109, col_offset=36, end_lineno=109, end_col_offset=44), Mult(), Constant(2, lineno=109, col_offset=47, end_lineno=109, end_col_offset=48), lineno=109, col_offset=36, end_lineno=109, end_col_offset=48)], Load(), lineno=109, col_offset=15, end_lineno=109, end_col_offset=49), lineno=109, col_offset=8, end_lineno=109, end_col_offset=49)], [Return(Name('placeholder_8', Load(), lineno=112, col_offset=15, end_lineno=112, end_col_offset=19), lineno=112, col_offset=8, end_lineno=112, end_col_offset=19)], lineno=107, col_offset=4, end_lineno=112, end_col_offset=19)], [], lineno=100, col_offset=0, end_lineno=112, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/example-stringquotes-normalization/.meta/config.json b/test/example-stringquotes-normalization/.meta/config.json new file mode 100644 index 0000000..3439d6d --- /dev/null +++ b/test/example-stringquotes-normalization/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_stringquotes_normalization.py" + ] + } +} \ No newline at end of file diff --git a/test/example-stringquotes-normalization/example_stringquotes_normalization.py b/test/example-stringquotes-normalization/example_stringquotes_normalization.py new file mode 100644 index 0000000..b9cfa7e --- /dev/null +++ b/test/example-stringquotes-normalization/example_stringquotes_normalization.py @@ -0,0 +1,34 @@ + +from itertools import chain, zip_longest, repeat + + +def recite(start, take=1): + """Assemble verse list with separators via zip_longest.""" + + end_at = start - take + separate_by = (start-end_at) - 1 + + verses = chain(make_verse(number) for number in range(start, end_at, -1)) + separators = repeat([''], separate_by) + + song = chain.from_iterable(item for item in + chain(*zip_longest(verses, separators)) + if item) + return list(song) + + +def make_verse(number): + '''Yield verses according to number given.''' + + num_words = {0:"no", 1:'One', 2:"Two", 3:'Three', 4:"Four",5:'Five', + 6:"Six",7:'Seven',8:"Eight",9:'Nine',10:"Ten"} + + number_verse = (f'{num_words[number]} green bottle' + f'{"s" if number > 1 else ""} hanging on the wall,') + + middle_verse = "And if one green bottle should accidentally fall," + + ending_verse = (f"There'll be {num_words[number-1].lower()} green bottle" + f"{'s' if number-1 != 1 else ''} hanging on the wall.") + + return [number_verse, number_verse, middle_verse, ending_verse] \ No newline at end of file diff --git a/test/example-stringquotes-normalization/mapping.json b/test/example-stringquotes-normalization/mapping.json new file mode 100644 index 0000000..ab14c82 --- /dev/null +++ b/test/example-stringquotes-normalization/mapping.json @@ -0,0 +1,17 @@ +{ + "placeholder_0": "recite", + "placeholder_1": "start", + "placeholder_2": "take", + "placeholder_3": "end_at", + "placeholder_4": "separate_by", + "placeholder_5": "verses", + "placeholder_6": "number", + "placeholder_7": "separators", + "placeholder_8": "song", + "placeholder_9": "item", + "placeholder_10": "make_verse", + "placeholder_11": "num_words", + "placeholder_12": "number_verse", + "placeholder_13": "middle_verse", + "placeholder_14": "ending_verse" +} \ No newline at end of file diff --git a/test/example-stringquotes-normalization/representation.json b/test/example-stringquotes-normalization/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-stringquotes-normalization/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-stringquotes-normalization/representation.out b/test/example-stringquotes-normalization/representation.out new file mode 100644 index 0000000..b7186e0 --- /dev/null +++ b/test/example-stringquotes-normalization/representation.out @@ -0,0 +1,1882 @@ +## BEGIN NORMALIZED CODE ## +from itertools import chain, zip_longest, repeat + + +def placeholder_0(placeholder_1, placeholder_2=1): + placeholder_3 = placeholder_1 - placeholder_2 + placeholder_4 = placeholder_1 - placeholder_3 - 1 + placeholder_5 = chain( + ( + make_verse(placeholder_6) + for placeholder_6 in range(placeholder_1, placeholder_3, -1) + ) + ) + placeholder_7 = repeat([""], placeholder_4) + placeholder_8 = chain.from_iterable( + ( + placeholder_9 + for placeholder_9 in chain(*zip_longest(placeholder_5, placeholder_7)) + if placeholder_9 + ) + ) + return list(placeholder_8) + + +def placeholder_10(placeholder_6): + placeholder_11 = { + 0: "no", + 1: "One", + 2: "Two", + 3: "Three", + 4: "Four", + 5: "Five", + 6: "Six", + 7: "Seven", + 8: "Eight", + 9: "Nine", + 10: "Ten", + } + placeholder_12 = f"{placeholder_11[placeholder_6]} green bottle{('s' if placeholder_6 > 1 else '')} hanging on the wall," + placeholder_13 = "And if one green bottle should accidentally fall," + placeholder_14 = f"There'll be {placeholder_11[placeholder_6 - 1].lower()} green bottle{('s' if placeholder_6 - 1 != 1 else '')} hanging on the wall." + return [placeholder_12, placeholder_12, placeholder_13, placeholder_14] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'chain', + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=27), + alias( + 'zip_longest', + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=40), + alias( + 'repeat', + lineno=2, + col_offset=42, + end_lineno=2, + end_col_offset=48)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=48), + FunctionDef( + 'recite', + arguments( + [], + [ + arg( + 'start', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=16), + arg( + 'take', + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 1, + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=24)]), + [ + Expr( + Constant( + 'Assemble verse list with separators via zip_longest.', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=62), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=62), + Assign( + [ + Name( + 'end_at', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10)], + BinOp( + Name( + 'start', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=18), + Sub(), + Name( + 'take', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=25), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=25), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=25), + Assign( + [ + Name( + 'separate_by', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=15)], + BinOp( + BinOp( + Name( + 'start', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=24), + Sub(), + Name( + 'end_at', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=31), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=31), + Sub(), + Constant( + 1, + lineno=9, + col_offset=35, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=36), + Assign( + [ + Name( + 'verses', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=10)], + Call( + Name( + 'chain', + Load(), + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=18), + [ + GeneratorExp( + Call( + Name( + 'make_verse', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=29), + [ + Name( + 'number', + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=36)], + [], + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=37), + [ + comprehension( + Name( + 'number', + Store(), + lineno=11, + col_offset=42, + end_lineno=11, + end_col_offset=48), + Call( + Name( + 'range', + Load(), + lineno=11, + col_offset=52, + end_lineno=11, + end_col_offset=57), + [ + Name( + 'start', + Load(), + lineno=11, + col_offset=58, + end_lineno=11, + end_col_offset=63), + Name( + 'end_at', + Load(), + lineno=11, + col_offset=65, + end_lineno=11, + end_col_offset=71), + UnaryOp( + USub(), + Constant( + 1, + lineno=11, + col_offset=74, + end_lineno=11, + end_col_offset=75), + lineno=11, + col_offset=73, + end_lineno=11, + end_col_offset=75)], + [], + lineno=11, + col_offset=52, + end_lineno=11, + end_col_offset=76), + [], + 0)], + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=77)], + [], + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=77), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=77), + Assign( + [ + Name( + 'separators', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=14)], + Call( + Name( + 'repeat', + Load(), + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=23), + [ + List( + [ + Constant( + '', + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=27)], + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=28), + Name( + 'separate_by', + Load(), + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=41)], + [], + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=42), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=42), + Assign( + [ + Name( + 'song', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=8)], + Call( + Attribute( + Name( + 'chain', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=16), + 'from_iterable', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=30), + [ + GeneratorExp( + Name( + 'item', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=35), + [ + comprehension( + Name( + 'item', + Store(), + lineno=14, + col_offset=40, + end_lineno=14, + end_col_offset=44), + Call( + Name( + 'chain', + Load(), + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=36), + [ + Starred( + Call( + Name( + 'zip_longest', + Load(), + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=49), + [ + Name( + 'verses', + Load(), + lineno=15, + col_offset=50, + end_lineno=15, + end_col_offset=56), + Name( + 'separators', + Load(), + lineno=15, + col_offset=58, + end_lineno=15, + end_col_offset=68)], + [], + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=69), + Load(), + lineno=15, + col_offset=37, + end_lineno=15, + end_col_offset=69)], + [], + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=70), + [ + Name( + 'item', + Load(), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=38)], + 0)], + lineno=14, + col_offset=30, + end_lineno=16, + end_col_offset=39)], + [], + lineno=14, + col_offset=11, + end_lineno=16, + end_col_offset=39), + lineno=14, + col_offset=4, + end_lineno=16, + end_col_offset=39), + Return( + Call( + Name( + 'list', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=16), + [ + Name( + 'song', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + [], + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=22), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=22)], + [], + lineno=5, + col_offset=0, + end_lineno=17, + end_col_offset=22), + FunctionDef( + 'make_verse', + arguments( + [], + [ + arg( + 'number', + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Yield verses according to number given.', + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=49), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=49), + Assign( + [ + Name( + 'num_words', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=13)], + Dict( + [ + Constant( + 0, + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=18), + Constant( + 1, + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=26), + Constant( + 2, + lineno=23, + col_offset=34, + end_lineno=23, + end_col_offset=35), + Constant( + 3, + lineno=23, + col_offset=43, + end_lineno=23, + end_col_offset=44), + Constant( + 4, + lineno=23, + col_offset=54, + end_lineno=23, + end_col_offset=55), + Constant( + 5, + lineno=23, + col_offset=63, + end_lineno=23, + end_col_offset=64), + Constant( + 6, + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=18), + Constant( + 7, + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=26), + Constant( + 8, + lineno=24, + col_offset=35, + end_lineno=24, + end_col_offset=36), + Constant( + 9, + lineno=24, + col_offset=45, + end_lineno=24, + end_col_offset=46), + Constant( + 10, + lineno=24, + col_offset=54, + end_lineno=24, + end_col_offset=56)], + [ + Constant( + 'no', + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=23), + Constant( + 'One', + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=32), + Constant( + 'Two', + lineno=23, + col_offset=36, + end_lineno=23, + end_col_offset=41), + Constant( + 'Three', + lineno=23, + col_offset=45, + end_lineno=23, + end_col_offset=52), + Constant( + 'Four', + lineno=23, + col_offset=56, + end_lineno=23, + end_col_offset=62), + Constant( + 'Five', + lineno=23, + col_offset=65, + end_lineno=23, + end_col_offset=71), + Constant( + 'Six', + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=24), + Constant( + 'Seven', + lineno=24, + col_offset=27, + end_lineno=24, + end_col_offset=34), + Constant( + 'Eight', + lineno=24, + col_offset=37, + end_lineno=24, + end_col_offset=44), + Constant( + 'Nine', + lineno=24, + col_offset=47, + end_lineno=24, + end_col_offset=53), + Constant( + 'Ten', + lineno=24, + col_offset=57, + end_lineno=24, + end_col_offset=62)], + lineno=23, + col_offset=16, + end_lineno=24, + end_col_offset=63), + lineno=23, + col_offset=4, + end_lineno=24, + end_col_offset=63), + Assign( + [ + Name( + 'number_verse', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=16)], + JoinedStr( + [ + FormattedValue( + Subscript( + Name( + 'num_words', + Load(), + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=32), + Name( + 'number', + Load(), + lineno=26, + col_offset=33, + end_lineno=26, + end_col_offset=39), + Load(), + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=40), + -1, + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71), + Constant( + ' green bottle', + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71), + FormattedValue( + IfExp( + Compare( + Name( + 'number', + Load(), + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=36), + [ + Gt()], + [ + Constant( + 1, + lineno=27, + col_offset=39, + end_lineno=27, + end_col_offset=40)], + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=40), + Constant( + 's', + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=26), + Constant( + '', + lineno=27, + col_offset=46, + end_lineno=27, + end_col_offset=48), + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=48), + -1, + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71), + Constant( + ' hanging on the wall,', + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71)], + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71), + lineno=26, + col_offset=4, + end_lineno=27, + end_col_offset=72), + Assign( + [ + Name( + 'middle_verse', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=16)], + Constant( + 'And if one green bottle should accidentally fall,', + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=70), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=70), + Assign( + [ + Name( + 'ending_verse', + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=16)], + JoinedStr( + [ + Constant( + "There'll be ", + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + FormattedValue( + Call( + Attribute( + Subscript( + Name( + 'num_words', + Load(), + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=44), + BinOp( + Name( + 'number', + Load(), + lineno=31, + col_offset=45, + end_lineno=31, + end_col_offset=51), + Sub(), + Constant( + 1, + lineno=31, + col_offset=52, + end_lineno=31, + end_col_offset=53), + lineno=31, + col_offset=45, + end_lineno=31, + end_col_offset=53), + Load(), + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=54), + 'lower', + Load(), + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=60), + [], + [], + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=62), + -1, + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + Constant( + ' green bottle', + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + FormattedValue( + IfExp( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=36), + Sub(), + Constant( + 1, + lineno=32, + col_offset=37, + end_lineno=32, + end_col_offset=38), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=38), + [ + NotEq()], + [ + Constant( + 1, + lineno=32, + col_offset=42, + end_lineno=32, + end_col_offset=43)], + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=43), + Constant( + 's', + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=26), + Constant( + '', + lineno=32, + col_offset=49, + end_lineno=32, + end_col_offset=51), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=51), + -1, + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + Constant( + ' hanging on the wall.', + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74)], + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + lineno=31, + col_offset=4, + end_lineno=32, + end_col_offset=75), + Return( + List( + [ + Name( + 'number_verse', + Load(), + lineno=34, + col_offset=16, + end_lineno=34, + end_col_offset=28), + Name( + 'number_verse', + Load(), + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=42), + Name( + 'middle_verse', + Load(), + lineno=34, + col_offset=44, + end_lineno=34, + end_col_offset=56), + Name( + 'ending_verse', + Load(), + lineno=34, + col_offset=58, + end_lineno=34, + end_col_offset=70)], + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=71), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=71)], + [], + lineno=20, + col_offset=0, + end_lineno=34, + end_col_offset=71)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'chain', + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=27), + alias( + 'zip_longest', + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=40), + alias( + 'repeat', + lineno=2, + col_offset=42, + end_lineno=2, + end_col_offset=48)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=48), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=16), + arg( + 'placeholder_2', + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 1, + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=24)]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10)], + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=18), + Sub(), + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=25), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=25), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=25), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=15)], + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=24), + Sub(), + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=31), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=31), + Sub(), + Constant( + 1, + lineno=9, + col_offset=35, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=36), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=10)], + Call( + Name( + 'chain', + Load(), + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=18), + [ + GeneratorExp( + Call( + Name( + 'make_verse', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=29), + [ + Name( + 'placeholder_6', + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=36)], + [], + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=37), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=11, + col_offset=42, + end_lineno=11, + end_col_offset=48), + Call( + Name( + 'range', + Load(), + lineno=11, + col_offset=52, + end_lineno=11, + end_col_offset=57), + [ + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=58, + end_lineno=11, + end_col_offset=63), + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=65, + end_lineno=11, + end_col_offset=71), + UnaryOp( + USub(), + Constant( + 1, + lineno=11, + col_offset=74, + end_lineno=11, + end_col_offset=75), + lineno=11, + col_offset=73, + end_lineno=11, + end_col_offset=75)], + [], + lineno=11, + col_offset=52, + end_lineno=11, + end_col_offset=76), + [], + 0)], + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=77)], + [], + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=77), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=77), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=14)], + Call( + Name( + 'repeat', + Load(), + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=23), + [ + List( + [ + Constant( + '', + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=27)], + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=28), + Name( + 'placeholder_4', + Load(), + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=41)], + [], + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=42), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=8)], + Call( + Attribute( + Name( + 'chain', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=16), + 'from_iterable', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=30), + [ + GeneratorExp( + Name( + 'placeholder_9', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=35), + [ + comprehension( + Name( + 'placeholder_9', + Store(), + lineno=14, + col_offset=40, + end_lineno=14, + end_col_offset=44), + Call( + Name( + 'chain', + Load(), + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=36), + [ + Starred( + Call( + Name( + 'zip_longest', + Load(), + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=49), + [ + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=50, + end_lineno=15, + end_col_offset=56), + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=58, + end_lineno=15, + end_col_offset=68)], + [], + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=69), + Load(), + lineno=15, + col_offset=37, + end_lineno=15, + end_col_offset=69)], + [], + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=70), + [ + Name( + 'placeholder_9', + Load(), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=38)], + 0)], + lineno=14, + col_offset=30, + end_lineno=16, + end_col_offset=39)], + [], + lineno=14, + col_offset=11, + end_lineno=16, + end_col_offset=39), + lineno=14, + col_offset=4, + end_lineno=16, + end_col_offset=39), + Return( + Call( + Name( + 'list', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=16), + [ + Name( + 'placeholder_8', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + [], + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=22), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=22)], + [], + lineno=5, + col_offset=0, + end_lineno=17, + end_col_offset=22), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=13)], + Dict( + [ + Constant( + 0, + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=18), + Constant( + 1, + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=26), + Constant( + 2, + lineno=23, + col_offset=34, + end_lineno=23, + end_col_offset=35), + Constant( + 3, + lineno=23, + col_offset=43, + end_lineno=23, + end_col_offset=44), + Constant( + 4, + lineno=23, + col_offset=54, + end_lineno=23, + end_col_offset=55), + Constant( + 5, + lineno=23, + col_offset=63, + end_lineno=23, + end_col_offset=64), + Constant( + 6, + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=18), + Constant( + 7, + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=26), + Constant( + 8, + lineno=24, + col_offset=35, + end_lineno=24, + end_col_offset=36), + Constant( + 9, + lineno=24, + col_offset=45, + end_lineno=24, + end_col_offset=46), + Constant( + 10, + lineno=24, + col_offset=54, + end_lineno=24, + end_col_offset=56)], + [ + Constant( + 'no', + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=23), + Constant( + 'One', + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=32), + Constant( + 'Two', + lineno=23, + col_offset=36, + end_lineno=23, + end_col_offset=41), + Constant( + 'Three', + lineno=23, + col_offset=45, + end_lineno=23, + end_col_offset=52), + Constant( + 'Four', + lineno=23, + col_offset=56, + end_lineno=23, + end_col_offset=62), + Constant( + 'Five', + lineno=23, + col_offset=65, + end_lineno=23, + end_col_offset=71), + Constant( + 'Six', + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=24), + Constant( + 'Seven', + lineno=24, + col_offset=27, + end_lineno=24, + end_col_offset=34), + Constant( + 'Eight', + lineno=24, + col_offset=37, + end_lineno=24, + end_col_offset=44), + Constant( + 'Nine', + lineno=24, + col_offset=47, + end_lineno=24, + end_col_offset=53), + Constant( + 'Ten', + lineno=24, + col_offset=57, + end_lineno=24, + end_col_offset=62)], + lineno=23, + col_offset=16, + end_lineno=24, + end_col_offset=63), + lineno=23, + col_offset=4, + end_lineno=24, + end_col_offset=63), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=16)], + JoinedStr( + [ + FormattedValue( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=32), + Name( + 'placeholder_6', + Load(), + lineno=26, + col_offset=33, + end_lineno=26, + end_col_offset=39), + Load(), + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=40), + -1, + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71), + Constant( + ' green bottle', + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71), + FormattedValue( + IfExp( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=36), + [ + Gt()], + [ + Constant( + 1, + lineno=27, + col_offset=39, + end_lineno=27, + end_col_offset=40)], + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=40), + Constant( + 's', + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=26), + Constant( + '', + lineno=27, + col_offset=46, + end_lineno=27, + end_col_offset=48), + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=48), + -1, + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71), + Constant( + ' hanging on the wall,', + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71)], + lineno=26, + col_offset=20, + end_lineno=27, + end_col_offset=71), + lineno=26, + col_offset=4, + end_lineno=27, + end_col_offset=72), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=16)], + Constant( + 'And if one green bottle should accidentally fall,', + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=70), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=70), + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=16)], + JoinedStr( + [ + Constant( + "There'll be ", + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + FormattedValue( + Call( + Attribute( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=44), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=31, + col_offset=45, + end_lineno=31, + end_col_offset=51), + Sub(), + Constant( + 1, + lineno=31, + col_offset=52, + end_lineno=31, + end_col_offset=53), + lineno=31, + col_offset=45, + end_lineno=31, + end_col_offset=53), + Load(), + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=54), + 'lower', + Load(), + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=60), + [], + [], + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=62), + -1, + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + Constant( + ' green bottle', + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + FormattedValue( + IfExp( + Compare( + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=36), + Sub(), + Constant( + 1, + lineno=32, + col_offset=37, + end_lineno=32, + end_col_offset=38), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=38), + [ + NotEq()], + [ + Constant( + 1, + lineno=32, + col_offset=42, + end_lineno=32, + end_col_offset=43)], + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=43), + Constant( + 's', + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=26), + Constant( + '', + lineno=32, + col_offset=49, + end_lineno=32, + end_col_offset=51), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=51), + -1, + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + Constant( + ' hanging on the wall.', + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74)], + lineno=31, + col_offset=20, + end_lineno=32, + end_col_offset=74), + lineno=31, + col_offset=4, + end_lineno=32, + end_col_offset=75), + Return( + List( + [ + Name( + 'placeholder_12', + Load(), + lineno=34, + col_offset=16, + end_lineno=34, + end_col_offset=28), + Name( + 'placeholder_12', + Load(), + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=42), + Name( + 'placeholder_13', + Load(), + lineno=34, + col_offset=44, + end_lineno=34, + end_col_offset=56), + Name( + 'placeholder_14', + Load(), + lineno=34, + col_offset=58, + end_lineno=34, + end_col_offset=70)], + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=71), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=71)], + [], + lineno=20, + col_offset=0, + end_lineno=34, + end_col_offset=71)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-stringquotes-normalization/representation.txt b/test/example-stringquotes-normalization/representation.txt new file mode 100644 index 0000000..cd0fc7a --- /dev/null +++ b/test/example-stringquotes-normalization/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('itertools', [alias('chain', lineno=2, col_offset=22, end_lineno=2, end_col_offset=27), alias('zip_longest', lineno=2, col_offset=29, end_lineno=2, end_col_offset=40), alias('repeat', lineno=2, col_offset=42, end_lineno=2, end_col_offset=48)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=48), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=11, end_lineno=5, end_col_offset=16), arg('placeholder_2', lineno=5, col_offset=18, end_lineno=5, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(1, lineno=5, col_offset=23, end_lineno=5, end_col_offset=24)]), [Assign([Name('placeholder_3', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=10)], BinOp(Name('placeholder_1', Load(), lineno=8, col_offset=13, end_lineno=8, end_col_offset=18), Sub(), Name('placeholder_2', Load(), lineno=8, col_offset=21, end_lineno=8, end_col_offset=25), lineno=8, col_offset=13, end_lineno=8, end_col_offset=25), lineno=8, col_offset=4, end_lineno=8, end_col_offset=25), Assign([Name('placeholder_4', Store(), lineno=9, col_offset=4, end_lineno=9, end_col_offset=15)], BinOp(BinOp(Name('placeholder_1', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=24), Sub(), Name('placeholder_3', Load(), lineno=9, col_offset=25, end_lineno=9, end_col_offset=31), lineno=9, col_offset=19, end_lineno=9, end_col_offset=31), Sub(), Constant(1, lineno=9, col_offset=35, end_lineno=9, end_col_offset=36), lineno=9, col_offset=18, end_lineno=9, end_col_offset=36), lineno=9, col_offset=4, end_lineno=9, end_col_offset=36), Assign([Name('placeholder_5', Store(), lineno=11, col_offset=4, end_lineno=11, end_col_offset=10)], Call(Name('chain', Load(), lineno=11, col_offset=13, end_lineno=11, end_col_offset=18), [GeneratorExp(Call(Name('make_verse', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=29), [Name('placeholder_6', Load(), lineno=11, col_offset=30, end_lineno=11, end_col_offset=36)], [], lineno=11, col_offset=19, end_lineno=11, end_col_offset=37), [comprehension(Name('placeholder_6', Store(), lineno=11, col_offset=42, end_lineno=11, end_col_offset=48), Call(Name('range', Load(), lineno=11, col_offset=52, end_lineno=11, end_col_offset=57), [Name('placeholder_1', Load(), lineno=11, col_offset=58, end_lineno=11, end_col_offset=63), Name('placeholder_3', Load(), lineno=11, col_offset=65, end_lineno=11, end_col_offset=71), UnaryOp(USub(), Constant(1, lineno=11, col_offset=74, end_lineno=11, end_col_offset=75), lineno=11, col_offset=73, end_lineno=11, end_col_offset=75)], [], lineno=11, col_offset=52, end_lineno=11, end_col_offset=76), [], 0)], lineno=11, col_offset=18, end_lineno=11, end_col_offset=77)], [], lineno=11, col_offset=13, end_lineno=11, end_col_offset=77), lineno=11, col_offset=4, end_lineno=11, end_col_offset=77), Assign([Name('placeholder_7', Store(), lineno=12, col_offset=4, end_lineno=12, end_col_offset=14)], Call(Name('repeat', Load(), lineno=12, col_offset=17, end_lineno=12, end_col_offset=23), [List([Constant('', lineno=12, col_offset=25, end_lineno=12, end_col_offset=27)], Load(), lineno=12, col_offset=24, end_lineno=12, end_col_offset=28), Name('placeholder_4', Load(), lineno=12, col_offset=30, end_lineno=12, end_col_offset=41)], [], lineno=12, col_offset=17, end_lineno=12, end_col_offset=42), lineno=12, col_offset=4, end_lineno=12, end_col_offset=42), Assign([Name('placeholder_8', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=8)], Call(Attribute(Name('chain', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=16), 'from_iterable', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=30), [GeneratorExp(Name('placeholder_9', Load(), lineno=14, col_offset=31, end_lineno=14, end_col_offset=35), [comprehension(Name('placeholder_9', Store(), lineno=14, col_offset=40, end_lineno=14, end_col_offset=44), Call(Name('chain', Load(), lineno=15, col_offset=31, end_lineno=15, end_col_offset=36), [Starred(Call(Name('zip_longest', Load(), lineno=15, col_offset=38, end_lineno=15, end_col_offset=49), [Name('placeholder_5', Load(), lineno=15, col_offset=50, end_lineno=15, end_col_offset=56), Name('placeholder_7', Load(), lineno=15, col_offset=58, end_lineno=15, end_col_offset=68)], [], lineno=15, col_offset=38, end_lineno=15, end_col_offset=69), Load(), lineno=15, col_offset=37, end_lineno=15, end_col_offset=69)], [], lineno=15, col_offset=31, end_lineno=15, end_col_offset=70), [Name('placeholder_9', Load(), lineno=16, col_offset=34, end_lineno=16, end_col_offset=38)], 0)], lineno=14, col_offset=30, end_lineno=16, end_col_offset=39)], [], lineno=14, col_offset=11, end_lineno=16, end_col_offset=39), lineno=14, col_offset=4, end_lineno=16, end_col_offset=39), Return(Call(Name('list', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=16), [Name('placeholder_8', Load(), lineno=17, col_offset=17, end_lineno=17, end_col_offset=21)], [], lineno=17, col_offset=12, end_lineno=17, end_col_offset=22), lineno=17, col_offset=4, end_lineno=17, end_col_offset=22)], [], lineno=5, col_offset=0, end_lineno=17, end_col_offset=22), FunctionDef('placeholder_10', arguments([], [arg('placeholder_6', lineno=20, col_offset=15, end_lineno=20, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_11', Store(), lineno=23, col_offset=4, end_lineno=23, end_col_offset=13)], Dict([Constant(0, lineno=23, col_offset=17, end_lineno=23, end_col_offset=18), Constant(1, lineno=23, col_offset=25, end_lineno=23, end_col_offset=26), Constant(2, lineno=23, col_offset=34, end_lineno=23, end_col_offset=35), Constant(3, lineno=23, col_offset=43, end_lineno=23, end_col_offset=44), Constant(4, lineno=23, col_offset=54, end_lineno=23, end_col_offset=55), Constant(5, lineno=23, col_offset=63, end_lineno=23, end_col_offset=64), Constant(6, lineno=24, col_offset=17, end_lineno=24, end_col_offset=18), Constant(7, lineno=24, col_offset=25, end_lineno=24, end_col_offset=26), Constant(8, lineno=24, col_offset=35, end_lineno=24, end_col_offset=36), Constant(9, lineno=24, col_offset=45, end_lineno=24, end_col_offset=46), Constant(10, lineno=24, col_offset=54, end_lineno=24, end_col_offset=56)], [Constant('no', lineno=23, col_offset=19, end_lineno=23, end_col_offset=23), Constant('One', lineno=23, col_offset=27, end_lineno=23, end_col_offset=32), Constant('Two', lineno=23, col_offset=36, end_lineno=23, end_col_offset=41), Constant('Three', lineno=23, col_offset=45, end_lineno=23, end_col_offset=52), Constant('Four', lineno=23, col_offset=56, end_lineno=23, end_col_offset=62), Constant('Five', lineno=23, col_offset=65, end_lineno=23, end_col_offset=71), Constant('Six', lineno=24, col_offset=19, end_lineno=24, end_col_offset=24), Constant('Seven', lineno=24, col_offset=27, end_lineno=24, end_col_offset=34), Constant('Eight', lineno=24, col_offset=37, end_lineno=24, end_col_offset=44), Constant('Nine', lineno=24, col_offset=47, end_lineno=24, end_col_offset=53), Constant('Ten', lineno=24, col_offset=57, end_lineno=24, end_col_offset=62)], lineno=23, col_offset=16, end_lineno=24, end_col_offset=63), lineno=23, col_offset=4, end_lineno=24, end_col_offset=63), Assign([Name('placeholder_12', Store(), lineno=26, col_offset=4, end_lineno=26, end_col_offset=16)], JoinedStr([FormattedValue(Subscript(Name('placeholder_11', Load(), lineno=26, col_offset=23, end_lineno=26, end_col_offset=32), Name('placeholder_6', Load(), lineno=26, col_offset=33, end_lineno=26, end_col_offset=39), Load(), lineno=26, col_offset=23, end_lineno=26, end_col_offset=40), -1, lineno=26, col_offset=20, end_lineno=27, end_col_offset=71), Constant(' green bottle', lineno=26, col_offset=20, end_lineno=27, end_col_offset=71), FormattedValue(IfExp(Compare(Name('placeholder_6', Load(), lineno=27, col_offset=30, end_lineno=27, end_col_offset=36), [Gt()], [Constant(1, lineno=27, col_offset=39, end_lineno=27, end_col_offset=40)], lineno=27, col_offset=30, end_lineno=27, end_col_offset=40), Constant('s', lineno=27, col_offset=23, end_lineno=27, end_col_offset=26), Constant('', lineno=27, col_offset=46, end_lineno=27, end_col_offset=48), lineno=27, col_offset=23, end_lineno=27, end_col_offset=48), -1, lineno=26, col_offset=20, end_lineno=27, end_col_offset=71), Constant(' hanging on the wall,', lineno=26, col_offset=20, end_lineno=27, end_col_offset=71)], lineno=26, col_offset=20, end_lineno=27, end_col_offset=71), lineno=26, col_offset=4, end_lineno=27, end_col_offset=72), Assign([Name('placeholder_13', Store(), lineno=29, col_offset=4, end_lineno=29, end_col_offset=16)], Constant('And if one green bottle should accidentally fall,', lineno=29, col_offset=19, end_lineno=29, end_col_offset=70), lineno=29, col_offset=4, end_lineno=29, end_col_offset=70), Assign([Name('placeholder_14', Store(), lineno=31, col_offset=4, end_lineno=31, end_col_offset=16)], JoinedStr([Constant("There'll be ", lineno=31, col_offset=20, end_lineno=32, end_col_offset=74), FormattedValue(Call(Attribute(Subscript(Name('placeholder_11', Load(), lineno=31, col_offset=35, end_lineno=31, end_col_offset=44), BinOp(Name('placeholder_6', Load(), lineno=31, col_offset=45, end_lineno=31, end_col_offset=51), Sub(), Constant(1, lineno=31, col_offset=52, end_lineno=31, end_col_offset=53), lineno=31, col_offset=45, end_lineno=31, end_col_offset=53), Load(), lineno=31, col_offset=35, end_lineno=31, end_col_offset=54), 'lower', Load(), lineno=31, col_offset=35, end_lineno=31, end_col_offset=60), [], [], lineno=31, col_offset=35, end_lineno=31, end_col_offset=62), -1, lineno=31, col_offset=20, end_lineno=32, end_col_offset=74), Constant(' green bottle', lineno=31, col_offset=20, end_lineno=32, end_col_offset=74), FormattedValue(IfExp(Compare(BinOp(Name('placeholder_6', Load(), lineno=32, col_offset=30, end_lineno=32, end_col_offset=36), Sub(), Constant(1, lineno=32, col_offset=37, end_lineno=32, end_col_offset=38), lineno=32, col_offset=30, end_lineno=32, end_col_offset=38), [NotEq()], [Constant(1, lineno=32, col_offset=42, end_lineno=32, end_col_offset=43)], lineno=32, col_offset=30, end_lineno=32, end_col_offset=43), Constant('s', lineno=32, col_offset=23, end_lineno=32, end_col_offset=26), Constant('', lineno=32, col_offset=49, end_lineno=32, end_col_offset=51), lineno=32, col_offset=23, end_lineno=32, end_col_offset=51), -1, lineno=31, col_offset=20, end_lineno=32, end_col_offset=74), Constant(' hanging on the wall.', lineno=31, col_offset=20, end_lineno=32, end_col_offset=74)], lineno=31, col_offset=20, end_lineno=32, end_col_offset=74), lineno=31, col_offset=4, end_lineno=32, end_col_offset=75), Return(List([Name('placeholder_12', Load(), lineno=34, col_offset=16, end_lineno=34, end_col_offset=28), Name('placeholder_12', Load(), lineno=34, col_offset=30, end_lineno=34, end_col_offset=42), Name('placeholder_13', Load(), lineno=34, col_offset=44, end_lineno=34, end_col_offset=56), Name('placeholder_14', Load(), lineno=34, col_offset=58, end_lineno=34, end_col_offset=70)], Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=71), lineno=34, col_offset=4, end_lineno=34, end_col_offset=71)], [], lineno=20, col_offset=0, end_lineno=34, end_col_offset=71)], []) \ No newline at end of file diff --git a/test/example-structural-pattern-matching/.meta/config.json b/test/example-structural-pattern-matching/.meta/config.json new file mode 100644 index 0000000..7077d0a --- /dev/null +++ b/test/example-structural-pattern-matching/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_structural_pattern_matching.py" + ] + } +} \ No newline at end of file diff --git a/test/example-structural-pattern-matching/example_structural_pattern_matching.py b/test/example-structural-pattern-matching/example_structural_pattern_matching.py new file mode 100644 index 0000000..6019260 --- /dev/null +++ b/test/example-structural-pattern-matching/example_structural_pattern_matching.py @@ -0,0 +1,38 @@ +from math import hypot, ceil + +YACHT = 'yacht' +ONES, TWOS, THREES, FOURS, FIVES, SIXES = 1, 2, 3, 4, 5, 6 +FULL_HOUSE = 'full_house' +FOUR_OF_A_KIND = 'four_of_a_kind' +LITTLE_STRAIGHT = 'little' +BIG_STRAIGHT = 'big' +CHOICE = 'choice' + + +def yacht_score(dice, category): + dice, roll = sorted(dice), sorted(set(dice)) + + match (category, roll): + case ('full_house', _) | ('choice', _): + three_match = any(dice.count(item) == 3 for item in roll) + return sum(dice) if three_match or category == 'choice' else 0 + + case ('big', [2, 3, 4, 5, 6]) | ('little', [1, 2, 3, 4, 5]): + return 30 + + case ('four_of_a_kind', _): + four_match = dice[0] == dice[3] or dice[1] == dice[4] + return 4 * dice[1] if four_match else 0 + + case ('yacht', _) if len(roll) == 1: + return 50 + + case _: + return sum(item for item in dice if item == category) + +def dart_score(x, y): + match ceil(hypot(x, y)): + case 0 | 1: return 10 + case 2 | 3 | 4 | 5: return 5 + case 6 | 7 | 8 | 9 | 10: return 1 + case _: return 0 diff --git a/test/example-structural-pattern-matching/mapping.json b/test/example-structural-pattern-matching/mapping.json new file mode 100644 index 0000000..a5260dd --- /dev/null +++ b/test/example-structural-pattern-matching/mapping.json @@ -0,0 +1,24 @@ +{ + "placeholder_0": "YACHT", + "placeholder_1": "ONES", + "placeholder_2": "TWOS", + "placeholder_3": "THREES", + "placeholder_4": "FOURS", + "placeholder_5": "FIVES", + "placeholder_6": "SIXES", + "placeholder_7": "FULL_HOUSE", + "placeholder_8": "FOUR_OF_A_KIND", + "placeholder_9": "LITTLE_STRAIGHT", + "placeholder_10": "BIG_STRAIGHT", + "placeholder_11": "CHOICE", + "placeholder_12": "yacht_score", + "placeholder_13": "dice", + "placeholder_14": "category", + "placeholder_15": "roll", + "placeholder_16": "three_match", + "placeholder_17": "item", + "placeholder_18": "four_match", + "placeholder_19": "dart_score", + "placeholder_20": "x", + "placeholder_21": "y" +} \ No newline at end of file diff --git a/test/example-structural-pattern-matching/representation.json b/test/example-structural-pattern-matching/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-structural-pattern-matching/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-structural-pattern-matching/representation.out b/test/example-structural-pattern-matching/representation.out new file mode 100644 index 0000000..0dcc1fa --- /dev/null +++ b/test/example-structural-pattern-matching/representation.out @@ -0,0 +1,2829 @@ +## BEGIN NORMALIZED CODE ## +from math import hypot, ceil + +placeholder_0 = "yacht" +( + placeholder_1, + placeholder_2, + placeholder_3, + placeholder_4, + placeholder_5, + placeholder_6, +) = (1, 2, 3, 4, 5, 6) +placeholder_7 = "full_house" +placeholder_8 = "four_of_a_kind" +placeholder_9 = "little" +placeholder_10 = "big" +placeholder_11 = "choice" + + +def placeholder_12(placeholder_13, placeholder_14): + placeholder_13, placeholder_15 = ( + sorted(placeholder_13), + sorted(set(placeholder_13)), + ) + match (placeholder_14, placeholder_15): + case ["full_house", _] | ["choice", _]: + placeholder_16 = any( + ( + placeholder_13.count(placeholder_17) == 3 + for placeholder_17 in placeholder_15 + ) + ) + return ( + sum(placeholder_13) + if placeholder_16 or placeholder_14 == "choice" + else 0 + ) + case ["big", [2, 3, 4, 5, 6]] | ["little", [1, 2, 3, 4, 5]]: + return 30 + case ["four_of_a_kind", _]: + placeholder_18 = ( + placeholder_13[0] == placeholder_13[3] + or placeholder_13[1] == placeholder_13[4] + ) + return 4 * placeholder_13[1] if placeholder_18 else 0 + case ["yacht", _] if len(placeholder_15) == 1: + return 50 + case _: + return sum( + ( + placeholder_17 + for placeholder_17 in placeholder_13 + if placeholder_17 == placeholder_14 + ) + ) + + +def placeholder_19(placeholder_20, placeholder_21): + match ceil(hypot(placeholder_20, placeholder_21)): + case 0 | 1: + return 10 + case 2 | 3 | 4 | 5: + return 5 + case 6 | 7 | 8 | 9 | 10: + return 1 + case _: + return 0 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'hypot', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=22), + alias( + 'ceil', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=28)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=28), + Assign( + [ + Name( + 'YACHT', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=5)], + Constant( + 'yacht', + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=15), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=15), + Assign( + [ + Tuple( + [ + Name( + 'ONES', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=4), + Name( + 'TWOS', + Store(), + lineno=4, + col_offset=6, + end_lineno=4, + end_col_offset=10), + Name( + 'THREES', + Store(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=18), + Name( + 'FOURS', + Store(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=25), + Name( + 'FIVES', + Store(), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=32), + Name( + 'SIXES', + Store(), + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=39)], + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=39)], + Tuple( + [ + Constant( + 1, + lineno=4, + col_offset=42, + end_lineno=4, + end_col_offset=43), + Constant( + 2, + lineno=4, + col_offset=45, + end_lineno=4, + end_col_offset=46), + Constant( + 3, + lineno=4, + col_offset=48, + end_lineno=4, + end_col_offset=49), + Constant( + 4, + lineno=4, + col_offset=51, + end_lineno=4, + end_col_offset=52), + Constant( + 5, + lineno=4, + col_offset=54, + end_lineno=4, + end_col_offset=55), + Constant( + 6, + lineno=4, + col_offset=57, + end_lineno=4, + end_col_offset=58)], + Load(), + lineno=4, + col_offset=42, + end_lineno=4, + end_col_offset=58), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=58), + Assign( + [ + Name( + 'FULL_HOUSE', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=10)], + Constant( + 'full_house', + lineno=5, + col_offset=13, + end_lineno=5, + end_col_offset=25), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=25), + Assign( + [ + Name( + 'FOUR_OF_A_KIND', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=14)], + Constant( + 'four_of_a_kind', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=33), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=33), + Assign( + [ + Name( + 'LITTLE_STRAIGHT', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=15)], + Constant( + 'little', + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=26), + Assign( + [ + Name( + 'BIG_STRAIGHT', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=12)], + Constant( + 'big', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=20), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=20), + Assign( + [ + Name( + 'CHOICE', + Store(), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=6)], + Constant( + 'choice', + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=17), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=17), + FunctionDef( + 'yacht_score', + arguments( + [], + [ + arg( + 'dice', + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=20), + arg( + 'category', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'dice', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=8), + Name( + 'roll', + Store(), + lineno=13, + col_offset=10, + end_lineno=13, + end_col_offset=14)], + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=14)], + Tuple( + [ + Call( + Name( + 'sorted', + Load(), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=23), + [ + Name( + 'dice', + Load(), + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=28)], + [], + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=29), + Call( + Name( + 'sorted', + Load(), + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=37), + [ + Call( + Name( + 'set', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=41), + [ + Name( + 'dice', + Load(), + lineno=13, + col_offset=42, + end_lineno=13, + end_col_offset=46)], + [], + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=47)], + [], + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=48)], + Load(), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=48), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=48), + Match( + Tuple( + [ + Name( + 'category', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=19), + Name( + 'roll', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=25)], + Load(), + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=26), + [ + match_case( + MatchOr( + [ + MatchSequence( + [ + MatchValue( + Constant( + 'full_house', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=26), + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=26), + MatchAs( + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=29)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=30), + MatchSequence( + [ + MatchValue( + Constant( + 'choice', + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=42), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=42), + MatchAs( + lineno=16, + col_offset=44, + end_lineno=16, + end_col_offset=45)], + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=46)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=46), + body=[ + Assign( + [ + Name( + 'three_match', + Store(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=23)], + Call( + Name( + 'any', + Load(), + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=29), + [ + GeneratorExp( + Compare( + Call( + Attribute( + Name( + 'dice', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=34), + 'count', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=40), + [ + Name( + 'item', + Load(), + lineno=17, + col_offset=41, + end_lineno=17, + end_col_offset=45)], + [], + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=46), + [ + Eq()], + [ + Constant( + 3, + lineno=17, + col_offset=50, + end_lineno=17, + end_col_offset=51)], + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=51), + [ + comprehension( + Name( + 'item', + Store(), + lineno=17, + col_offset=56, + end_lineno=17, + end_col_offset=60), + Name( + 'roll', + Load(), + lineno=17, + col_offset=64, + end_lineno=17, + end_col_offset=68), + [], + 0)], + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=69)], + [], + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=69), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=69), + Return( + IfExp( + BoolOp( + Or(), + [ + Name( + 'three_match', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=43), + Compare( + Name( + 'category', + Load(), + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=55), + [ + Eq()], + [ + Constant( + 'choice', + lineno=18, + col_offset=59, + end_lineno=18, + end_col_offset=67)], + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=67)], + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=67), + Call( + Name( + 'sum', + Load(), + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=22), + [ + Name( + 'dice', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=27)], + [], + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=28), + Constant( + 0, + lineno=18, + col_offset=73, + end_lineno=18, + end_col_offset=74), + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=74), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=74)]), + match_case( + MatchOr( + [ + MatchSequence( + [ + MatchValue( + Constant( + 'big', + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=19), + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=19), + MatchSequence( + [ + MatchValue( + Constant( + 2, + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=23), + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=23), + MatchValue( + Constant( + 3, + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=26), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=26), + MatchValue( + Constant( + 4, + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=29), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=29), + MatchValue( + Constant( + 5, + lineno=20, + col_offset=31, + end_lineno=20, + end_col_offset=32), + lineno=20, + col_offset=31, + end_lineno=20, + end_col_offset=32), + MatchValue( + Constant( + 6, + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=35), + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=35)], + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=36)], + lineno=20, + col_offset=13, + end_lineno=20, + end_col_offset=37), + MatchSequence( + [ + MatchValue( + Constant( + 'little', + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=49), + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=49), + MatchSequence( + [ + MatchValue( + Constant( + 1, + lineno=20, + col_offset=52, + end_lineno=20, + end_col_offset=53), + lineno=20, + col_offset=52, + end_lineno=20, + end_col_offset=53), + MatchValue( + Constant( + 2, + lineno=20, + col_offset=55, + end_lineno=20, + end_col_offset=56), + lineno=20, + col_offset=55, + end_lineno=20, + end_col_offset=56), + MatchValue( + Constant( + 3, + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=59), + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=59), + MatchValue( + Constant( + 4, + lineno=20, + col_offset=61, + end_lineno=20, + end_col_offset=62), + lineno=20, + col_offset=61, + end_lineno=20, + end_col_offset=62), + MatchValue( + Constant( + 5, + lineno=20, + col_offset=64, + end_lineno=20, + end_col_offset=65), + lineno=20, + col_offset=64, + end_lineno=20, + end_col_offset=65)], + lineno=20, + col_offset=51, + end_lineno=20, + end_col_offset=66)], + lineno=20, + col_offset=40, + end_lineno=20, + end_col_offset=67)], + lineno=20, + col_offset=13, + end_lineno=20, + end_col_offset=67), + body=[ + Return( + Constant( + 30, + lineno=21, + col_offset=19, + end_lineno=21, + end_col_offset=21), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=21)]), + match_case( + MatchSequence( + [ + MatchValue( + Constant( + 'four_of_a_kind', + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=30), + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=30), + MatchAs( + lineno=23, + col_offset=32, + end_lineno=23, + end_col_offset=33)], + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=34), + body=[ + Assign( + [ + Name( + 'four_match', + Store(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=22)], + BoolOp( + Or(), + [ + Compare( + Subscript( + Name( + 'dice', + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=29), + Constant( + 0, + lineno=24, + col_offset=30, + end_lineno=24, + end_col_offset=31), + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=32), + [ + Eq()], + [ + Subscript( + Name( + 'dice', + Load(), + lineno=24, + col_offset=36, + end_lineno=24, + end_col_offset=40), + Constant( + 3, + lineno=24, + col_offset=41, + end_lineno=24, + end_col_offset=42), + Load(), + lineno=24, + col_offset=36, + end_lineno=24, + end_col_offset=43)], + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=43), + Compare( + Subscript( + Name( + 'dice', + Load(), + lineno=24, + col_offset=47, + end_lineno=24, + end_col_offset=51), + Constant( + 1, + lineno=24, + col_offset=52, + end_lineno=24, + end_col_offset=53), + Load(), + lineno=24, + col_offset=47, + end_lineno=24, + end_col_offset=54), + [ + Eq()], + [ + Subscript( + Name( + 'dice', + Load(), + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=62), + Constant( + 4, + lineno=24, + col_offset=63, + end_lineno=24, + end_col_offset=64), + Load(), + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=65)], + lineno=24, + col_offset=47, + end_lineno=24, + end_col_offset=65)], + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=65), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=65), + Return( + IfExp( + Name( + 'four_match', + Load(), + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=44), + BinOp( + Constant( + 4, + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=20), + Mult(), + Subscript( + Name( + 'dice', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=27), + Constant( + 1, + lineno=25, + col_offset=28, + end_lineno=25, + end_col_offset=29), + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=30), + Constant( + 0, + lineno=25, + col_offset=50, + end_lineno=25, + end_col_offset=51), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=51), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=51)]), + match_case( + MatchSequence( + [ + MatchValue( + Constant( + 'yacht', + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=21), + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=21), + MatchAs( + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=24)], + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=25), + Compare( + Call( + Name( + 'len', + Load(), + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=32), + [ + Name( + 'roll', + Load(), + lineno=27, + col_offset=33, + end_lineno=27, + end_col_offset=37)], + [], + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 1, + lineno=27, + col_offset=42, + end_lineno=27, + end_col_offset=43)], + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=43), + [ + Return( + Constant( + 50, + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=21), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=21)]), + match_case( + MatchAs( + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=14), + body=[ + Return( + Call( + Name( + 'sum', + Load(), + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=22), + [ + GeneratorExp( + Name( + 'item', + Load(), + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=27), + [ + comprehension( + Name( + 'item', + Store(), + lineno=31, + col_offset=32, + end_lineno=31, + end_col_offset=36), + Name( + 'dice', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=44), + [ + Compare( + Name( + 'item', + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=52), + [ + Eq()], + [ + Name( + 'category', + Load(), + lineno=31, + col_offset=56, + end_lineno=31, + end_col_offset=64)], + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=64)], + 0)], + lineno=31, + col_offset=22, + end_lineno=31, + end_col_offset=65)], + [], + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=65), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=65)])], + lineno=15, + col_offset=4, + end_lineno=31, + end_col_offset=65)], + [], + lineno=12, + col_offset=0, + end_lineno=31, + end_col_offset=65), + FunctionDef( + 'dart_score', + arguments( + [], + [ + arg( + 'x', + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=16), + arg( + 'y', + lineno=33, + col_offset=18, + end_lineno=33, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Match( + Call( + Name( + 'ceil', + Load(), + lineno=34, + col_offset=10, + end_lineno=34, + end_col_offset=14), + [ + Call( + Name( + 'hypot', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=20), + [ + Name( + 'x', + Load(), + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=22), + Name( + 'y', + Load(), + lineno=34, + col_offset=24, + end_lineno=34, + end_col_offset=25)], + [], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=26)], + [], + lineno=34, + col_offset=10, + end_lineno=34, + end_col_offset=27), + [ + match_case( + MatchOr( + [ + MatchValue( + Constant( + 0, + lineno=35, + col_offset=13, + end_lineno=35, + end_col_offset=14), + lineno=35, + col_offset=13, + end_lineno=35, + end_col_offset=14), + MatchValue( + Constant( + 1, + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=18), + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=18)], + lineno=35, + col_offset=13, + end_lineno=35, + end_col_offset=18), + body=[ + Return( + Constant( + 10, + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=29), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=29)]), + match_case( + MatchOr( + [ + MatchValue( + Constant( + 2, + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=14), + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=14), + MatchValue( + Constant( + 3, + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=18), + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=18), + MatchValue( + Constant( + 4, + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=22), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=22), + MatchValue( + Constant( + 5, + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=26), + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=26)], + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=26), + body=[ + Return( + Constant( + 5, + lineno=36, + col_offset=35, + end_lineno=36, + end_col_offset=36), + lineno=36, + col_offset=28, + end_lineno=36, + end_col_offset=36)]), + match_case( + MatchOr( + [ + MatchValue( + Constant( + 6, + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=14), + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=14), + MatchValue( + Constant( + 7, + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=18), + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=18), + MatchValue( + Constant( + 8, + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=22), + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=22), + MatchValue( + Constant( + 9, + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=26), + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=26), + MatchValue( + Constant( + 10, + lineno=37, + col_offset=29, + end_lineno=37, + end_col_offset=31), + lineno=37, + col_offset=29, + end_lineno=37, + end_col_offset=31)], + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=31), + body=[ + Return( + Constant( + 1, + lineno=37, + col_offset=40, + end_lineno=37, + end_col_offset=41), + lineno=37, + col_offset=33, + end_lineno=37, + end_col_offset=41)]), + match_case( + MatchAs( + lineno=38, + col_offset=13, + end_lineno=38, + end_col_offset=14), + body=[ + Return( + Constant( + 0, + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=24), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=24)])], + lineno=34, + col_offset=4, + end_lineno=38, + end_col_offset=24)], + [], + lineno=33, + col_offset=0, + end_lineno=38, + end_col_offset=24)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'hypot', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=22), + alias( + 'ceil', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=28)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=5)], + Constant( + 'yacht', + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=15), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=15), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_1', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=4), + Name( + 'placeholder_2', + Store(), + lineno=4, + col_offset=6, + end_lineno=4, + end_col_offset=10), + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=18), + Name( + 'placeholder_4', + Store(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=25), + Name( + 'placeholder_5', + Store(), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=32), + Name( + 'placeholder_6', + Store(), + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=39)], + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=39)], + Tuple( + [ + Constant( + 1, + lineno=4, + col_offset=42, + end_lineno=4, + end_col_offset=43), + Constant( + 2, + lineno=4, + col_offset=45, + end_lineno=4, + end_col_offset=46), + Constant( + 3, + lineno=4, + col_offset=48, + end_lineno=4, + end_col_offset=49), + Constant( + 4, + lineno=4, + col_offset=51, + end_lineno=4, + end_col_offset=52), + Constant( + 5, + lineno=4, + col_offset=54, + end_lineno=4, + end_col_offset=55), + Constant( + 6, + lineno=4, + col_offset=57, + end_lineno=4, + end_col_offset=58)], + Load(), + lineno=4, + col_offset=42, + end_lineno=4, + end_col_offset=58), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=58), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=10)], + Constant( + 'full_house', + lineno=5, + col_offset=13, + end_lineno=5, + end_col_offset=25), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=25), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=14)], + Constant( + 'four_of_a_kind', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=33), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=15)], + Constant( + 'little', + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=26), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=12)], + Constant( + 'big', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=20), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=20), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=6)], + Constant( + 'choice', + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=17), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=17), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=20), + arg( + 'placeholder_14', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_13', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=8), + Name( + 'placeholder_15', + Store(), + lineno=13, + col_offset=10, + end_lineno=13, + end_col_offset=14)], + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=14)], + Tuple( + [ + Call( + Name( + 'sorted', + Load(), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=23), + [ + Name( + 'placeholder_13', + Load(), + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=28)], + [], + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=29), + Call( + Name( + 'sorted', + Load(), + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=37), + [ + Call( + Name( + 'set', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=41), + [ + Name( + 'placeholder_13', + Load(), + lineno=13, + col_offset=42, + end_lineno=13, + end_col_offset=46)], + [], + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=47)], + [], + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=48)], + Load(), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=48), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=48), + Match( + Tuple( + [ + Name( + 'placeholder_14', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=19), + Name( + 'placeholder_15', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=25)], + Load(), + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=26), + [ + match_case( + MatchOr( + [ + MatchSequence( + [ + MatchValue( + Constant( + 'full_house', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=26), + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=26), + MatchAs( + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=29)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=30), + MatchSequence( + [ + MatchValue( + Constant( + 'choice', + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=42), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=42), + MatchAs( + lineno=16, + col_offset=44, + end_lineno=16, + end_col_offset=45)], + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=46)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=46), + body=[ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=23)], + Call( + Name( + 'any', + Load(), + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=29), + [ + GeneratorExp( + Compare( + Call( + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=34), + 'count', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=40), + [ + Name( + 'placeholder_17', + Load(), + lineno=17, + col_offset=41, + end_lineno=17, + end_col_offset=45)], + [], + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=46), + [ + Eq()], + [ + Constant( + 3, + lineno=17, + col_offset=50, + end_lineno=17, + end_col_offset=51)], + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=51), + [ + comprehension( + Name( + 'placeholder_17', + Store(), + lineno=17, + col_offset=56, + end_lineno=17, + end_col_offset=60), + Name( + 'placeholder_15', + Load(), + lineno=17, + col_offset=64, + end_lineno=17, + end_col_offset=68), + [], + 0)], + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=69)], + [], + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=69), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=69), + Return( + IfExp( + BoolOp( + Or(), + [ + Name( + 'placeholder_16', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=43), + Compare( + Name( + 'placeholder_14', + Load(), + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=55), + [ + Eq()], + [ + Constant( + 'choice', + lineno=18, + col_offset=59, + end_lineno=18, + end_col_offset=67)], + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=67)], + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=67), + Call( + Name( + 'sum', + Load(), + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=22), + [ + Name( + 'placeholder_13', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=27)], + [], + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=28), + Constant( + 0, + lineno=18, + col_offset=73, + end_lineno=18, + end_col_offset=74), + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=74), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=74)]), + match_case( + MatchOr( + [ + MatchSequence( + [ + MatchValue( + Constant( + 'big', + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=19), + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=19), + MatchSequence( + [ + MatchValue( + Constant( + 2, + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=23), + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=23), + MatchValue( + Constant( + 3, + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=26), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=26), + MatchValue( + Constant( + 4, + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=29), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=29), + MatchValue( + Constant( + 5, + lineno=20, + col_offset=31, + end_lineno=20, + end_col_offset=32), + lineno=20, + col_offset=31, + end_lineno=20, + end_col_offset=32), + MatchValue( + Constant( + 6, + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=35), + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=35)], + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=36)], + lineno=20, + col_offset=13, + end_lineno=20, + end_col_offset=37), + MatchSequence( + [ + MatchValue( + Constant( + 'little', + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=49), + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=49), + MatchSequence( + [ + MatchValue( + Constant( + 1, + lineno=20, + col_offset=52, + end_lineno=20, + end_col_offset=53), + lineno=20, + col_offset=52, + end_lineno=20, + end_col_offset=53), + MatchValue( + Constant( + 2, + lineno=20, + col_offset=55, + end_lineno=20, + end_col_offset=56), + lineno=20, + col_offset=55, + end_lineno=20, + end_col_offset=56), + MatchValue( + Constant( + 3, + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=59), + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=59), + MatchValue( + Constant( + 4, + lineno=20, + col_offset=61, + end_lineno=20, + end_col_offset=62), + lineno=20, + col_offset=61, + end_lineno=20, + end_col_offset=62), + MatchValue( + Constant( + 5, + lineno=20, + col_offset=64, + end_lineno=20, + end_col_offset=65), + lineno=20, + col_offset=64, + end_lineno=20, + end_col_offset=65)], + lineno=20, + col_offset=51, + end_lineno=20, + end_col_offset=66)], + lineno=20, + col_offset=40, + end_lineno=20, + end_col_offset=67)], + lineno=20, + col_offset=13, + end_lineno=20, + end_col_offset=67), + body=[ + Return( + Constant( + 30, + lineno=21, + col_offset=19, + end_lineno=21, + end_col_offset=21), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=21)]), + match_case( + MatchSequence( + [ + MatchValue( + Constant( + 'four_of_a_kind', + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=30), + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=30), + MatchAs( + lineno=23, + col_offset=32, + end_lineno=23, + end_col_offset=33)], + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=34), + body=[ + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=22)], + BoolOp( + Or(), + [ + Compare( + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=29), + Constant( + 0, + lineno=24, + col_offset=30, + end_lineno=24, + end_col_offset=31), + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=32), + [ + Eq()], + [ + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=24, + col_offset=36, + end_lineno=24, + end_col_offset=40), + Constant( + 3, + lineno=24, + col_offset=41, + end_lineno=24, + end_col_offset=42), + Load(), + lineno=24, + col_offset=36, + end_lineno=24, + end_col_offset=43)], + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=43), + Compare( + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=24, + col_offset=47, + end_lineno=24, + end_col_offset=51), + Constant( + 1, + lineno=24, + col_offset=52, + end_lineno=24, + end_col_offset=53), + Load(), + lineno=24, + col_offset=47, + end_lineno=24, + end_col_offset=54), + [ + Eq()], + [ + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=62), + Constant( + 4, + lineno=24, + col_offset=63, + end_lineno=24, + end_col_offset=64), + Load(), + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=65)], + lineno=24, + col_offset=47, + end_lineno=24, + end_col_offset=65)], + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=65), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=65), + Return( + IfExp( + Name( + 'placeholder_18', + Load(), + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=44), + BinOp( + Constant( + 4, + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=20), + Mult(), + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=27), + Constant( + 1, + lineno=25, + col_offset=28, + end_lineno=25, + end_col_offset=29), + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=30), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=30), + Constant( + 0, + lineno=25, + col_offset=50, + end_lineno=25, + end_col_offset=51), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=51), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=51)]), + match_case( + MatchSequence( + [ + MatchValue( + Constant( + 'yacht', + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=21), + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=21), + MatchAs( + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=24)], + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=25), + Compare( + Call( + Name( + 'len', + Load(), + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=32), + [ + Name( + 'placeholder_15', + Load(), + lineno=27, + col_offset=33, + end_lineno=27, + end_col_offset=37)], + [], + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 1, + lineno=27, + col_offset=42, + end_lineno=27, + end_col_offset=43)], + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=43), + [ + Return( + Constant( + 50, + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=21), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=21)]), + match_case( + MatchAs( + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=14), + body=[ + Return( + Call( + Name( + 'sum', + Load(), + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=22), + [ + GeneratorExp( + Name( + 'placeholder_17', + Load(), + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=27), + [ + comprehension( + Name( + 'placeholder_17', + Store(), + lineno=31, + col_offset=32, + end_lineno=31, + end_col_offset=36), + Name( + 'placeholder_13', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=44), + [ + Compare( + Name( + 'placeholder_17', + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=52), + [ + Eq()], + [ + Name( + 'placeholder_14', + Load(), + lineno=31, + col_offset=56, + end_lineno=31, + end_col_offset=64)], + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=64)], + 0)], + lineno=31, + col_offset=22, + end_lineno=31, + end_col_offset=65)], + [], + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=65), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=65)])], + lineno=15, + col_offset=4, + end_lineno=31, + end_col_offset=65)], + [], + lineno=12, + col_offset=0, + end_lineno=31, + end_col_offset=65), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'placeholder_20', + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=16), + arg( + 'placeholder_21', + lineno=33, + col_offset=18, + end_lineno=33, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Match( + Call( + Name( + 'ceil', + Load(), + lineno=34, + col_offset=10, + end_lineno=34, + end_col_offset=14), + [ + Call( + Name( + 'hypot', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=20), + [ + Name( + 'placeholder_20', + Load(), + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=22), + Name( + 'placeholder_21', + Load(), + lineno=34, + col_offset=24, + end_lineno=34, + end_col_offset=25)], + [], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=26)], + [], + lineno=34, + col_offset=10, + end_lineno=34, + end_col_offset=27), + [ + match_case( + MatchOr( + [ + MatchValue( + Constant( + 0, + lineno=35, + col_offset=13, + end_lineno=35, + end_col_offset=14), + lineno=35, + col_offset=13, + end_lineno=35, + end_col_offset=14), + MatchValue( + Constant( + 1, + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=18), + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=18)], + lineno=35, + col_offset=13, + end_lineno=35, + end_col_offset=18), + body=[ + Return( + Constant( + 10, + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=29), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=29)]), + match_case( + MatchOr( + [ + MatchValue( + Constant( + 2, + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=14), + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=14), + MatchValue( + Constant( + 3, + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=18), + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=18), + MatchValue( + Constant( + 4, + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=22), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=22), + MatchValue( + Constant( + 5, + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=26), + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=26)], + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=26), + body=[ + Return( + Constant( + 5, + lineno=36, + col_offset=35, + end_lineno=36, + end_col_offset=36), + lineno=36, + col_offset=28, + end_lineno=36, + end_col_offset=36)]), + match_case( + MatchOr( + [ + MatchValue( + Constant( + 6, + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=14), + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=14), + MatchValue( + Constant( + 7, + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=18), + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=18), + MatchValue( + Constant( + 8, + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=22), + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=22), + MatchValue( + Constant( + 9, + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=26), + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=26), + MatchValue( + Constant( + 10, + lineno=37, + col_offset=29, + end_lineno=37, + end_col_offset=31), + lineno=37, + col_offset=29, + end_lineno=37, + end_col_offset=31)], + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=31), + body=[ + Return( + Constant( + 1, + lineno=37, + col_offset=40, + end_lineno=37, + end_col_offset=41), + lineno=37, + col_offset=33, + end_lineno=37, + end_col_offset=41)]), + match_case( + MatchAs( + lineno=38, + col_offset=13, + end_lineno=38, + end_col_offset=14), + body=[ + Return( + Constant( + 0, + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=24), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=24)])], + lineno=34, + col_offset=4, + end_lineno=38, + end_col_offset=24)], + [], + lineno=33, + col_offset=0, + end_lineno=38, + end_col_offset=24)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-structural-pattern-matching/representation.txt b/test/example-structural-pattern-matching/representation.txt new file mode 100644 index 0000000..6d8b5e9 --- /dev/null +++ b/test/example-structural-pattern-matching/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('math', [alias('hypot', lineno=1, col_offset=17, end_lineno=1, end_col_offset=22), alias('ceil', lineno=1, col_offset=24, end_lineno=1, end_col_offset=28)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=28), Assign([Name('placeholder_0', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=5)], Constant('yacht', lineno=3, col_offset=8, end_lineno=3, end_col_offset=15), lineno=3, col_offset=0, end_lineno=3, end_col_offset=15), Assign([Tuple([Name('placeholder_1', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=4), Name('placeholder_2', Store(), lineno=4, col_offset=6, end_lineno=4, end_col_offset=10), Name('placeholder_3', Store(), lineno=4, col_offset=12, end_lineno=4, end_col_offset=18), Name('placeholder_4', Store(), lineno=4, col_offset=20, end_lineno=4, end_col_offset=25), Name('placeholder_5', Store(), lineno=4, col_offset=27, end_lineno=4, end_col_offset=32), Name('placeholder_6', Store(), lineno=4, col_offset=34, end_lineno=4, end_col_offset=39)], Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=39)], Tuple([Constant(1, lineno=4, col_offset=42, end_lineno=4, end_col_offset=43), Constant(2, lineno=4, col_offset=45, end_lineno=4, end_col_offset=46), Constant(3, lineno=4, col_offset=48, end_lineno=4, end_col_offset=49), Constant(4, lineno=4, col_offset=51, end_lineno=4, end_col_offset=52), Constant(5, lineno=4, col_offset=54, end_lineno=4, end_col_offset=55), Constant(6, lineno=4, col_offset=57, end_lineno=4, end_col_offset=58)], Load(), lineno=4, col_offset=42, end_lineno=4, end_col_offset=58), lineno=4, col_offset=0, end_lineno=4, end_col_offset=58), Assign([Name('placeholder_7', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=10)], Constant('full_house', lineno=5, col_offset=13, end_lineno=5, end_col_offset=25), lineno=5, col_offset=0, end_lineno=5, end_col_offset=25), Assign([Name('placeholder_8', Store(), lineno=6, col_offset=0, end_lineno=6, end_col_offset=14)], Constant('four_of_a_kind', lineno=6, col_offset=17, end_lineno=6, end_col_offset=33), lineno=6, col_offset=0, end_lineno=6, end_col_offset=33), Assign([Name('placeholder_9', Store(), lineno=7, col_offset=0, end_lineno=7, end_col_offset=15)], Constant('little', lineno=7, col_offset=18, end_lineno=7, end_col_offset=26), lineno=7, col_offset=0, end_lineno=7, end_col_offset=26), Assign([Name('placeholder_10', Store(), lineno=8, col_offset=0, end_lineno=8, end_col_offset=12)], Constant('big', lineno=8, col_offset=15, end_lineno=8, end_col_offset=20), lineno=8, col_offset=0, end_lineno=8, end_col_offset=20), Assign([Name('placeholder_11', Store(), lineno=9, col_offset=0, end_lineno=9, end_col_offset=6)], Constant('choice', lineno=9, col_offset=9, end_lineno=9, end_col_offset=17), lineno=9, col_offset=0, end_lineno=9, end_col_offset=17), FunctionDef('placeholder_12', arguments([], [arg('placeholder_13', lineno=12, col_offset=16, end_lineno=12, end_col_offset=20), arg('placeholder_14', lineno=12, col_offset=22, end_lineno=12, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Tuple([Name('placeholder_13', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=8), Name('placeholder_15', Store(), lineno=13, col_offset=10, end_lineno=13, end_col_offset=14)], Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=14)], Tuple([Call(Name('sorted', Load(), lineno=13, col_offset=17, end_lineno=13, end_col_offset=23), [Name('placeholder_13', Load(), lineno=13, col_offset=24, end_lineno=13, end_col_offset=28)], [], lineno=13, col_offset=17, end_lineno=13, end_col_offset=29), Call(Name('sorted', Load(), lineno=13, col_offset=31, end_lineno=13, end_col_offset=37), [Call(Name('set', Load(), lineno=13, col_offset=38, end_lineno=13, end_col_offset=41), [Name('placeholder_13', Load(), lineno=13, col_offset=42, end_lineno=13, end_col_offset=46)], [], lineno=13, col_offset=38, end_lineno=13, end_col_offset=47)], [], lineno=13, col_offset=31, end_lineno=13, end_col_offset=48)], Load(), lineno=13, col_offset=17, end_lineno=13, end_col_offset=48), lineno=13, col_offset=4, end_lineno=13, end_col_offset=48), Match(Tuple([Name('placeholder_14', Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=19), Name('placeholder_15', Load(), lineno=15, col_offset=21, end_lineno=15, end_col_offset=25)], Load(), lineno=15, col_offset=10, end_lineno=15, end_col_offset=26), [match_case(MatchOr([MatchSequence([MatchValue(Constant('full_house', lineno=16, col_offset=14, end_lineno=16, end_col_offset=26), lineno=16, col_offset=14, end_lineno=16, end_col_offset=26), MatchAs(lineno=16, col_offset=28, end_lineno=16, end_col_offset=29)], lineno=16, col_offset=13, end_lineno=16, end_col_offset=30), MatchSequence([MatchValue(Constant('choice', lineno=16, col_offset=34, end_lineno=16, end_col_offset=42), lineno=16, col_offset=34, end_lineno=16, end_col_offset=42), MatchAs(lineno=16, col_offset=44, end_lineno=16, end_col_offset=45)], lineno=16, col_offset=33, end_lineno=16, end_col_offset=46)], lineno=16, col_offset=13, end_lineno=16, end_col_offset=46), body=[Assign([Name('placeholder_16', Store(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=23)], Call(Name('any', Load(), lineno=17, col_offset=26, end_lineno=17, end_col_offset=29), [GeneratorExp(Compare(Call(Attribute(Name('placeholder_13', Load(), lineno=17, col_offset=30, end_lineno=17, end_col_offset=34), 'count', Load(), lineno=17, col_offset=30, end_lineno=17, end_col_offset=40), [Name('placeholder_17', Load(), lineno=17, col_offset=41, end_lineno=17, end_col_offset=45)], [], lineno=17, col_offset=30, end_lineno=17, end_col_offset=46), [Eq()], [Constant(3, lineno=17, col_offset=50, end_lineno=17, end_col_offset=51)], lineno=17, col_offset=30, end_lineno=17, end_col_offset=51), [comprehension(Name('placeholder_17', Store(), lineno=17, col_offset=56, end_lineno=17, end_col_offset=60), Name('placeholder_15', Load(), lineno=17, col_offset=64, end_lineno=17, end_col_offset=68), [], 0)], lineno=17, col_offset=29, end_lineno=17, end_col_offset=69)], [], lineno=17, col_offset=26, end_lineno=17, end_col_offset=69), lineno=17, col_offset=12, end_lineno=17, end_col_offset=69), Return(IfExp(BoolOp(Or(), [Name('placeholder_16', Load(), lineno=18, col_offset=32, end_lineno=18, end_col_offset=43), Compare(Name('placeholder_14', Load(), lineno=18, col_offset=47, end_lineno=18, end_col_offset=55), [Eq()], [Constant('choice', lineno=18, col_offset=59, end_lineno=18, end_col_offset=67)], lineno=18, col_offset=47, end_lineno=18, end_col_offset=67)], lineno=18, col_offset=32, end_lineno=18, end_col_offset=67), Call(Name('sum', Load(), lineno=18, col_offset=19, end_lineno=18, end_col_offset=22), [Name('placeholder_13', Load(), lineno=18, col_offset=23, end_lineno=18, end_col_offset=27)], [], lineno=18, col_offset=19, end_lineno=18, end_col_offset=28), Constant(0, lineno=18, col_offset=73, end_lineno=18, end_col_offset=74), lineno=18, col_offset=19, end_lineno=18, end_col_offset=74), lineno=18, col_offset=12, end_lineno=18, end_col_offset=74)]), match_case(MatchOr([MatchSequence([MatchValue(Constant('big', lineno=20, col_offset=14, end_lineno=20, end_col_offset=19), lineno=20, col_offset=14, end_lineno=20, end_col_offset=19), MatchSequence([MatchValue(Constant(2, lineno=20, col_offset=22, end_lineno=20, end_col_offset=23), lineno=20, col_offset=22, end_lineno=20, end_col_offset=23), MatchValue(Constant(3, lineno=20, col_offset=25, end_lineno=20, end_col_offset=26), lineno=20, col_offset=25, end_lineno=20, end_col_offset=26), MatchValue(Constant(4, lineno=20, col_offset=28, end_lineno=20, end_col_offset=29), lineno=20, col_offset=28, end_lineno=20, end_col_offset=29), MatchValue(Constant(5, lineno=20, col_offset=31, end_lineno=20, end_col_offset=32), lineno=20, col_offset=31, end_lineno=20, end_col_offset=32), MatchValue(Constant(6, lineno=20, col_offset=34, end_lineno=20, end_col_offset=35), lineno=20, col_offset=34, end_lineno=20, end_col_offset=35)], lineno=20, col_offset=21, end_lineno=20, end_col_offset=36)], lineno=20, col_offset=13, end_lineno=20, end_col_offset=37), MatchSequence([MatchValue(Constant('little', lineno=20, col_offset=41, end_lineno=20, end_col_offset=49), lineno=20, col_offset=41, end_lineno=20, end_col_offset=49), MatchSequence([MatchValue(Constant(1, lineno=20, col_offset=52, end_lineno=20, end_col_offset=53), lineno=20, col_offset=52, end_lineno=20, end_col_offset=53), MatchValue(Constant(2, lineno=20, col_offset=55, end_lineno=20, end_col_offset=56), lineno=20, col_offset=55, end_lineno=20, end_col_offset=56), MatchValue(Constant(3, lineno=20, col_offset=58, end_lineno=20, end_col_offset=59), lineno=20, col_offset=58, end_lineno=20, end_col_offset=59), MatchValue(Constant(4, lineno=20, col_offset=61, end_lineno=20, end_col_offset=62), lineno=20, col_offset=61, end_lineno=20, end_col_offset=62), MatchValue(Constant(5, lineno=20, col_offset=64, end_lineno=20, end_col_offset=65), lineno=20, col_offset=64, end_lineno=20, end_col_offset=65)], lineno=20, col_offset=51, end_lineno=20, end_col_offset=66)], lineno=20, col_offset=40, end_lineno=20, end_col_offset=67)], lineno=20, col_offset=13, end_lineno=20, end_col_offset=67), body=[Return(Constant(30, lineno=21, col_offset=19, end_lineno=21, end_col_offset=21), lineno=21, col_offset=12, end_lineno=21, end_col_offset=21)]), match_case(MatchSequence([MatchValue(Constant('four_of_a_kind', lineno=23, col_offset=14, end_lineno=23, end_col_offset=30), lineno=23, col_offset=14, end_lineno=23, end_col_offset=30), MatchAs(lineno=23, col_offset=32, end_lineno=23, end_col_offset=33)], lineno=23, col_offset=13, end_lineno=23, end_col_offset=34), body=[Assign([Name('placeholder_18', Store(), lineno=24, col_offset=12, end_lineno=24, end_col_offset=22)], BoolOp(Or(), [Compare(Subscript(Name('placeholder_13', Load(), lineno=24, col_offset=25, end_lineno=24, end_col_offset=29), Constant(0, lineno=24, col_offset=30, end_lineno=24, end_col_offset=31), Load(), lineno=24, col_offset=25, end_lineno=24, end_col_offset=32), [Eq()], [Subscript(Name('placeholder_13', Load(), lineno=24, col_offset=36, end_lineno=24, end_col_offset=40), Constant(3, lineno=24, col_offset=41, end_lineno=24, end_col_offset=42), Load(), lineno=24, col_offset=36, end_lineno=24, end_col_offset=43)], lineno=24, col_offset=25, end_lineno=24, end_col_offset=43), Compare(Subscript(Name('placeholder_13', Load(), lineno=24, col_offset=47, end_lineno=24, end_col_offset=51), Constant(1, lineno=24, col_offset=52, end_lineno=24, end_col_offset=53), Load(), lineno=24, col_offset=47, end_lineno=24, end_col_offset=54), [Eq()], [Subscript(Name('placeholder_13', Load(), lineno=24, col_offset=58, end_lineno=24, end_col_offset=62), Constant(4, lineno=24, col_offset=63, end_lineno=24, end_col_offset=64), Load(), lineno=24, col_offset=58, end_lineno=24, end_col_offset=65)], lineno=24, col_offset=47, end_lineno=24, end_col_offset=65)], lineno=24, col_offset=25, end_lineno=24, end_col_offset=65), lineno=24, col_offset=12, end_lineno=24, end_col_offset=65), Return(IfExp(Name('placeholder_18', Load(), lineno=25, col_offset=34, end_lineno=25, end_col_offset=44), BinOp(Constant(4, lineno=25, col_offset=19, end_lineno=25, end_col_offset=20), Mult(), Subscript(Name('placeholder_13', Load(), lineno=25, col_offset=23, end_lineno=25, end_col_offset=27), Constant(1, lineno=25, col_offset=28, end_lineno=25, end_col_offset=29), Load(), lineno=25, col_offset=23, end_lineno=25, end_col_offset=30), lineno=25, col_offset=19, end_lineno=25, end_col_offset=30), Constant(0, lineno=25, col_offset=50, end_lineno=25, end_col_offset=51), lineno=25, col_offset=19, end_lineno=25, end_col_offset=51), lineno=25, col_offset=12, end_lineno=25, end_col_offset=51)]), match_case(MatchSequence([MatchValue(Constant('yacht', lineno=27, col_offset=14, end_lineno=27, end_col_offset=21), lineno=27, col_offset=14, end_lineno=27, end_col_offset=21), MatchAs(lineno=27, col_offset=23, end_lineno=27, end_col_offset=24)], lineno=27, col_offset=13, end_lineno=27, end_col_offset=25), Compare(Call(Name('len', Load(), lineno=27, col_offset=29, end_lineno=27, end_col_offset=32), [Name('placeholder_15', Load(), lineno=27, col_offset=33, end_lineno=27, end_col_offset=37)], [], lineno=27, col_offset=29, end_lineno=27, end_col_offset=38), [Eq()], [Constant(1, lineno=27, col_offset=42, end_lineno=27, end_col_offset=43)], lineno=27, col_offset=29, end_lineno=27, end_col_offset=43), [Return(Constant(50, lineno=28, col_offset=19, end_lineno=28, end_col_offset=21), lineno=28, col_offset=12, end_lineno=28, end_col_offset=21)]), match_case(MatchAs(lineno=30, col_offset=13, end_lineno=30, end_col_offset=14), body=[Return(Call(Name('sum', Load(), lineno=31, col_offset=19, end_lineno=31, end_col_offset=22), [GeneratorExp(Name('placeholder_17', Load(), lineno=31, col_offset=23, end_lineno=31, end_col_offset=27), [comprehension(Name('placeholder_17', Store(), lineno=31, col_offset=32, end_lineno=31, end_col_offset=36), Name('placeholder_13', Load(), lineno=31, col_offset=40, end_lineno=31, end_col_offset=44), [Compare(Name('placeholder_17', Load(), lineno=31, col_offset=48, end_lineno=31, end_col_offset=52), [Eq()], [Name('placeholder_14', Load(), lineno=31, col_offset=56, end_lineno=31, end_col_offset=64)], lineno=31, col_offset=48, end_lineno=31, end_col_offset=64)], 0)], lineno=31, col_offset=22, end_lineno=31, end_col_offset=65)], [], lineno=31, col_offset=19, end_lineno=31, end_col_offset=65), lineno=31, col_offset=12, end_lineno=31, end_col_offset=65)])], lineno=15, col_offset=4, end_lineno=31, end_col_offset=65)], [], lineno=12, col_offset=0, end_lineno=31, end_col_offset=65), FunctionDef('placeholder_19', arguments([], [arg('placeholder_20', lineno=33, col_offset=15, end_lineno=33, end_col_offset=16), arg('placeholder_21', lineno=33, col_offset=18, end_lineno=33, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Match(Call(Name('ceil', Load(), lineno=34, col_offset=10, end_lineno=34, end_col_offset=14), [Call(Name('hypot', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=20), [Name('placeholder_20', Load(), lineno=34, col_offset=21, end_lineno=34, end_col_offset=22), Name('placeholder_21', Load(), lineno=34, col_offset=24, end_lineno=34, end_col_offset=25)], [], lineno=34, col_offset=15, end_lineno=34, end_col_offset=26)], [], lineno=34, col_offset=10, end_lineno=34, end_col_offset=27), [match_case(MatchOr([MatchValue(Constant(0, lineno=35, col_offset=13, end_lineno=35, end_col_offset=14), lineno=35, col_offset=13, end_lineno=35, end_col_offset=14), MatchValue(Constant(1, lineno=35, col_offset=17, end_lineno=35, end_col_offset=18), lineno=35, col_offset=17, end_lineno=35, end_col_offset=18)], lineno=35, col_offset=13, end_lineno=35, end_col_offset=18), body=[Return(Constant(10, lineno=35, col_offset=27, end_lineno=35, end_col_offset=29), lineno=35, col_offset=20, end_lineno=35, end_col_offset=29)]), match_case(MatchOr([MatchValue(Constant(2, lineno=36, col_offset=13, end_lineno=36, end_col_offset=14), lineno=36, col_offset=13, end_lineno=36, end_col_offset=14), MatchValue(Constant(3, lineno=36, col_offset=17, end_lineno=36, end_col_offset=18), lineno=36, col_offset=17, end_lineno=36, end_col_offset=18), MatchValue(Constant(4, lineno=36, col_offset=21, end_lineno=36, end_col_offset=22), lineno=36, col_offset=21, end_lineno=36, end_col_offset=22), MatchValue(Constant(5, lineno=36, col_offset=25, end_lineno=36, end_col_offset=26), lineno=36, col_offset=25, end_lineno=36, end_col_offset=26)], lineno=36, col_offset=13, end_lineno=36, end_col_offset=26), body=[Return(Constant(5, lineno=36, col_offset=35, end_lineno=36, end_col_offset=36), lineno=36, col_offset=28, end_lineno=36, end_col_offset=36)]), match_case(MatchOr([MatchValue(Constant(6, lineno=37, col_offset=13, end_lineno=37, end_col_offset=14), lineno=37, col_offset=13, end_lineno=37, end_col_offset=14), MatchValue(Constant(7, lineno=37, col_offset=17, end_lineno=37, end_col_offset=18), lineno=37, col_offset=17, end_lineno=37, end_col_offset=18), MatchValue(Constant(8, lineno=37, col_offset=21, end_lineno=37, end_col_offset=22), lineno=37, col_offset=21, end_lineno=37, end_col_offset=22), MatchValue(Constant(9, lineno=37, col_offset=25, end_lineno=37, end_col_offset=26), lineno=37, col_offset=25, end_lineno=37, end_col_offset=26), MatchValue(Constant(10, lineno=37, col_offset=29, end_lineno=37, end_col_offset=31), lineno=37, col_offset=29, end_lineno=37, end_col_offset=31)], lineno=37, col_offset=13, end_lineno=37, end_col_offset=31), body=[Return(Constant(1, lineno=37, col_offset=40, end_lineno=37, end_col_offset=41), lineno=37, col_offset=33, end_lineno=37, end_col_offset=41)]), match_case(MatchAs(lineno=38, col_offset=13, end_lineno=38, end_col_offset=14), body=[Return(Constant(0, lineno=38, col_offset=23, end_lineno=38, end_col_offset=24), lineno=38, col_offset=16, end_lineno=38, end_col_offset=24)])], lineno=34, col_offset=4, end_lineno=38, end_col_offset=24)], [], lineno=33, col_offset=0, end_lineno=38, end_col_offset=24)], []) \ No newline at end of file diff --git a/test/example-typehints-removal/.meta/config.json b/test/example-typehints-removal/.meta/config.json new file mode 100644 index 0000000..18300ed --- /dev/null +++ b/test/example-typehints-removal/.meta/config.json @@ -0,0 +1,10 @@ +{ + "authors": [ + "BethanyG" + ], + "files": { + "solution": [ + "example_typehints_removal.py" + ] + } +} \ No newline at end of file diff --git a/test/example-typehints-removal/example_typehints_removal.py b/test/example-typehints-removal/example_typehints_removal.py new file mode 100644 index 0000000..8b94409 --- /dev/null +++ b/test/example-typehints-removal/example_typehints_removal.py @@ -0,0 +1,84 @@ +"""Functions to prevent a nuclear meltdown.""" + + +def is_criticality_balanced( + temperature: int | float, + neutrons_emitted: int | float, +) -> bool: + """Verify criticality is balanced. + + :param temperature: int or float - temperature value in kelvin. + :param neutrons_emitted: int or float - number of neutrons emitted per second. + :return: bool - is criticality balanced? + + A reactor is said to be critical if it satisfies the following conditions: + - The temperature is less than 800 K. + - The number of neutrons emitted per second is greater than 500. + - The product of temperature and neutrons emitted per second is less than 500000. + """ + + return temperature < 800 and neutrons_emitted > 500 and ((temperature * neutrons_emitted) < 500_000) + + +def reactor_efficiency( + voltage: int | float, + current: int | float, + theoretical_max_power: int | float, +) -> str: + """Assess reactor efficiency zone. + + :param voltage: int or float - voltage value. + :param current: int or float - current value. + :param theoretical_max_power: int or float - power that corresponds to a 100% efficiency. + :return: str - one of ('green', 'orange', 'red', or 'black'). + + Efficiency can be grouped into 4 bands: + + 1. green -> efficiency of 80% or more, + 2. orange -> efficiency of less than 80% but at least 60%, + 3. red -> efficiency below 60%, but still 30% or more, + 4. black -> less than 30% efficient. + + The percentage value is calculated as + (generated power/ theoretical max power)*100 + where generated power = voltage * current + """ + + power : int | float = voltage * current + efficiency : float = (power / theoretical_max_power) * 100 + + if efficiency >= 80: + return 'green' + if efficiency >= 60: + return 'orange' + if efficiency >= 30: + print(efficiency) + return 'red' + return 'black' + + +def fail_safe( + temperature: int | float, + neutrons_produced_per_second: int | float, + threshold: int | float, +) -> str: + """Assess and return status code for the reactor. + + :param temperature: int or float - value of the temperature in kelvin. + :param neutrons_produced_per_second: int or float - neutron flux. + :param threshold: int or float - threshold for category. + :return: str - one of ('LOW', 'NORMAL', 'DANGER'). + + 1. 'LOW' -> `temperature * neutrons per second` < 90% of `threshold` + 2. 'NORMAL' -> `temperature * neutrons per second` +/- 10% of `threshold` + 3. 'DANGER' -> `temperature * neutrons per second` is not in the above-stated ranges + """ + criticality : int | float = temperature * neutrons_produced_per_second + + match criticality: + case n if n < threshold * 0.9: + return 'LOW' + case n if n > threshold * 1.1: + return 'DANGER' + case _: + return 'NORMAL' \ No newline at end of file diff --git a/test/example-typehints-removal/mapping.json b/test/example-typehints-removal/mapping.json new file mode 100644 index 0000000..7023e0d --- /dev/null +++ b/test/example-typehints-removal/mapping.json @@ -0,0 +1,15 @@ +{ + "placeholder_0": "is_criticality_balanced", + "placeholder_1": "temperature", + "placeholder_2": "neutrons_emitted", + "placeholder_3": "reactor_efficiency", + "placeholder_4": "voltage", + "placeholder_5": "current", + "placeholder_6": "theoretical_max_power", + "placeholder_7": "power", + "placeholder_8": "efficiency", + "placeholder_9": "fail_safe", + "placeholder_10": "neutrons_produced_per_second", + "placeholder_11": "threshold", + "placeholder_12": "criticality" +} \ No newline at end of file diff --git a/test/example-typehints-removal/representation.json b/test/example-typehints-removal/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/example-typehints-removal/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/example-typehints-removal/representation.out b/test/example-typehints-removal/representation.out new file mode 100644 index 0000000..d0063ad --- /dev/null +++ b/test/example-typehints-removal/representation.out @@ -0,0 +1,1441 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return ( + placeholder_1 < 800 + and placeholder_2 > 500 + and (placeholder_1 * placeholder_2 < 500000) + ) + + +def placeholder_3(placeholder_4, placeholder_5, placeholder_6): + placeholder_7 = placeholder_4 * placeholder_5 + placeholder_8 = placeholder_7 / placeholder_6 * 100 + if placeholder_8 >= 80: + return "green" + if placeholder_8 >= 60: + return "orange" + if placeholder_8 >= 30: + return "red" + return "black" + + +def placeholder_9(placeholder_1, placeholder_10, placeholder_11): + placeholder_12 = placeholder_1 * placeholder_10 + match placeholder_12: + case n if n < placeholder_11 * 0.9: + return "LOW" + case n if n > placeholder_11 * 1.1: + return "DANGER" + case _: + return "NORMAL" + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Functions to prevent a nuclear meltdown.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=46), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=46), + FunctionDef( + 'is_criticality_balanced', + arguments( + [], + [ + arg( + 'temperature', + BinOp( + Name( + 'int', + Load(), + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + BitOr(), + Name( + 'float', + Load(), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=32), + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=32), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=32), + arg( + 'neutrons_emitted', + BinOp( + Name( + 'int', + Load(), + lineno=6, + col_offset=26, + end_lineno=6, + end_col_offset=29), + BitOr(), + Name( + 'float', + Load(), + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=37), + lineno=6, + col_offset=26, + end_lineno=6, + end_col_offset=37), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Verify criticality is balanced.\n\n :param temperature: int or float - temperature value in kelvin.\n :param neutrons_emitted: int or float - number of neutrons emitted per second.\n :return: bool - is criticality balanced?\n\n A reactor is said to be critical if it satisfies the following conditions:\n - The temperature is less than 800 K.\n - The number of neutrons emitted per second is greater than 500.\n - The product of temperature and neutrons emitted per second is less than 500000.\n ', + lineno=8, + col_offset=4, + end_lineno=18, + end_col_offset=7), + lineno=8, + col_offset=4, + end_lineno=18, + end_col_offset=7), + Return( + BoolOp( + And(), + [ + Compare( + Name( + 'temperature', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=22), + [ + Lt()], + [ + Constant( + 800, + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=28)], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=28), + Compare( + Name( + 'neutrons_emitted', + Load(), + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=49), + [ + Gt()], + [ + Constant( + 500, + lineno=20, + col_offset=52, + end_lineno=20, + end_col_offset=55)], + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=55), + Compare( + BinOp( + Name( + 'temperature', + Load(), + lineno=20, + col_offset=62, + end_lineno=20, + end_col_offset=73), + Mult(), + Name( + 'neutrons_emitted', + Load(), + lineno=20, + col_offset=76, + end_lineno=20, + end_col_offset=92), + lineno=20, + col_offset=62, + end_lineno=20, + end_col_offset=92), + [ + Lt()], + [ + Constant( + 500000, + lineno=20, + col_offset=96, + end_lineno=20, + end_col_offset=103)], + lineno=20, + col_offset=61, + end_lineno=20, + end_col_offset=103)], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=104), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=104)], + [], + Name( + 'bool', + Load(), + lineno=7, + col_offset=5, + end_lineno=7, + end_col_offset=9), + lineno=4, + col_offset=0, + end_lineno=20, + end_col_offset=104), + FunctionDef( + 'reactor_efficiency', + arguments( + [], + [ + arg( + 'voltage', + BinOp( + Name( + 'int', + Load(), + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=20), + BitOr(), + Name( + 'float', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=28), + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=28), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=28), + arg( + 'current', + BinOp( + Name( + 'int', + Load(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=20), + BitOr(), + Name( + 'float', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=28), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=28), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=28), + arg( + 'theoretical_max_power', + BinOp( + Name( + 'int', + Load(), + lineno=26, + col_offset=31, + end_lineno=26, + end_col_offset=34), + BitOr(), + Name( + 'float', + Load(), + lineno=26, + col_offset=37, + end_lineno=26, + end_col_offset=42), + lineno=26, + col_offset=31, + end_lineno=26, + end_col_offset=42), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Assess reactor efficiency zone.\n\n :param voltage: int or float - voltage value.\n :param current: int or float - current value.\n :param theoretical_max_power: int or float - power that corresponds to a 100% efficiency.\n :return: str - one of ('green', 'orange', 'red', or 'black').\n\n Efficiency can be grouped into 4 bands:\n\n 1. green -> efficiency of 80% or more,\n 2. orange -> efficiency of less than 80% but at least 60%,\n 3. red -> efficiency below 60%, but still 30% or more,\n 4. black -> less than 30% efficient.\n\n The percentage value is calculated as\n (generated power/ theoretical max power)*100\n where generated power = voltage * current\n ", + lineno=28, + col_offset=4, + end_lineno=45, + end_col_offset=7), + lineno=28, + col_offset=4, + end_lineno=45, + end_col_offset=7), + AnnAssign( + Name( + 'power', + Store(), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=9), + BinOp( + Name( + 'int', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=15), + BitOr(), + Name( + 'float', + Load(), + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=23), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=23), + BinOp( + Name( + 'voltage', + Load(), + lineno=47, + col_offset=26, + end_lineno=47, + end_col_offset=33), + Mult(), + Name( + 'current', + Load(), + lineno=47, + col_offset=36, + end_lineno=47, + end_col_offset=43), + lineno=47, + col_offset=26, + end_lineno=47, + end_col_offset=43), + 1, + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=43), + AnnAssign( + Name( + 'efficiency', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=14), + Name( + 'float', + Load(), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=22), + BinOp( + BinOp( + Name( + 'power', + Load(), + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=31), + Div(), + Name( + 'theoretical_max_power', + Load(), + lineno=48, + col_offset=34, + end_lineno=48, + end_col_offset=55), + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=55), + Mult(), + Constant( + 100, + lineno=48, + col_offset=59, + end_lineno=48, + end_col_offset=62), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=62), + 1, + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=62), + If( + Compare( + Name( + 'efficiency', + Load(), + lineno=50, + col_offset=7, + end_lineno=50, + end_col_offset=17), + [ + GtE()], + [ + Constant( + 80, + lineno=50, + col_offset=21, + end_lineno=50, + end_col_offset=23)], + lineno=50, + col_offset=7, + end_lineno=50, + end_col_offset=23), + [ + Return( + Constant( + 'green', + lineno=51, + col_offset=15, + end_lineno=51, + end_col_offset=22), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=22)], + [], + lineno=50, + col_offset=4, + end_lineno=51, + end_col_offset=22), + If( + Compare( + Name( + 'efficiency', + Load(), + lineno=52, + col_offset=7, + end_lineno=52, + end_col_offset=17), + [ + GtE()], + [ + Constant( + 60, + lineno=52, + col_offset=21, + end_lineno=52, + end_col_offset=23)], + lineno=52, + col_offset=7, + end_lineno=52, + end_col_offset=23), + [ + Return( + Constant( + 'orange', + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=23), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=23)], + [], + lineno=52, + col_offset=4, + end_lineno=53, + end_col_offset=23), + If( + Compare( + Name( + 'efficiency', + Load(), + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=17), + [ + GtE()], + [ + Constant( + 30, + lineno=54, + col_offset=21, + end_lineno=54, + end_col_offset=23)], + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=23), + [ + Expr( + Call( + Name( + 'print', + Load(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=13), + [ + Name( + 'efficiency', + Load(), + lineno=55, + col_offset=14, + end_lineno=55, + end_col_offset=24)], + [], + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=25), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=25), + Return( + Constant( + 'red', + lineno=56, + col_offset=15, + end_lineno=56, + end_col_offset=20), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=20)], + [], + lineno=54, + col_offset=4, + end_lineno=56, + end_col_offset=20), + Return( + Constant( + 'black', + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=18), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=18)], + [], + Name( + 'str', + Load(), + lineno=27, + col_offset=5, + end_lineno=27, + end_col_offset=8), + lineno=23, + col_offset=0, + end_lineno=57, + end_col_offset=18), + FunctionDef( + 'fail_safe', + arguments( + [], + [ + arg( + 'temperature', + BinOp( + Name( + 'int', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=24), + BitOr(), + Name( + 'float', + Load(), + lineno=61, + col_offset=27, + end_lineno=61, + end_col_offset=32), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=32), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=32), + arg( + 'neutrons_produced_per_second', + BinOp( + Name( + 'int', + Load(), + lineno=62, + col_offset=38, + end_lineno=62, + end_col_offset=41), + BitOr(), + Name( + 'float', + Load(), + lineno=62, + col_offset=44, + end_lineno=62, + end_col_offset=49), + lineno=62, + col_offset=38, + end_lineno=62, + end_col_offset=49), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=49), + arg( + 'threshold', + BinOp( + Name( + 'int', + Load(), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=22), + BitOr(), + Name( + 'float', + Load(), + lineno=63, + col_offset=25, + end_lineno=63, + end_col_offset=30), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=30), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Assess and return status code for the reactor.\n\n :param temperature: int or float - value of the temperature in kelvin.\n :param neutrons_produced_per_second: int or float - neutron flux.\n :param threshold: int or float - threshold for category.\n :return: str - one of ('LOW', 'NORMAL', 'DANGER').\n\n 1. 'LOW' -> `temperature * neutrons per second` < 90% of `threshold`\n 2. 'NORMAL' -> `temperature * neutrons per second` +/- 10% of `threshold`\n 3. 'DANGER' -> `temperature * neutrons per second` is not in the above-stated ranges\n ", + lineno=65, + col_offset=4, + end_lineno=75, + end_col_offset=7), + lineno=65, + col_offset=4, + end_lineno=75, + end_col_offset=7), + AnnAssign( + Name( + 'criticality', + Store(), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=15), + BinOp( + Name( + 'int', + Load(), + lineno=76, + col_offset=18, + end_lineno=76, + end_col_offset=21), + BitOr(), + Name( + 'float', + Load(), + lineno=76, + col_offset=24, + end_lineno=76, + end_col_offset=29), + lineno=76, + col_offset=18, + end_lineno=76, + end_col_offset=29), + BinOp( + Name( + 'temperature', + Load(), + lineno=76, + col_offset=32, + end_lineno=76, + end_col_offset=43), + Mult(), + Name( + 'neutrons_produced_per_second', + Load(), + lineno=76, + col_offset=46, + end_lineno=76, + end_col_offset=74), + lineno=76, + col_offset=32, + end_lineno=76, + end_col_offset=74), + 1, + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=74), + Match( + Name( + 'criticality', + Load(), + lineno=78, + col_offset=10, + end_lineno=78, + end_col_offset=21), + [ + match_case( + MatchAs( + name='n', + lineno=79, + col_offset=13, + end_lineno=79, + end_col_offset=14), + Compare( + Name( + 'n', + Load(), + lineno=79, + col_offset=18, + end_lineno=79, + end_col_offset=19), + [ + Lt()], + [ + BinOp( + Name( + 'threshold', + Load(), + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=31), + Mult(), + Constant( + 0.9, + lineno=79, + col_offset=34, + end_lineno=79, + end_col_offset=37), + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=37)], + lineno=79, + col_offset=18, + end_lineno=79, + end_col_offset=37), + [ + Return( + Constant( + 'LOW', + lineno=80, + col_offset=19, + end_lineno=80, + end_col_offset=24), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=24)]), + match_case( + MatchAs( + name='n', + lineno=81, + col_offset=13, + end_lineno=81, + end_col_offset=14), + Compare( + Name( + 'n', + Load(), + lineno=81, + col_offset=18, + end_lineno=81, + end_col_offset=19), + [ + Gt()], + [ + BinOp( + Name( + 'threshold', + Load(), + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=31), + Mult(), + Constant( + 1.1, + lineno=81, + col_offset=34, + end_lineno=81, + end_col_offset=37), + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=37)], + lineno=81, + col_offset=18, + end_lineno=81, + end_col_offset=37), + [ + Return( + Constant( + 'DANGER', + lineno=82, + col_offset=19, + end_lineno=82, + end_col_offset=27), + lineno=82, + col_offset=12, + end_lineno=82, + end_col_offset=27)]), + match_case( + MatchAs( + lineno=83, + col_offset=13, + end_lineno=83, + end_col_offset=14), + body=[ + Return( + Constant( + 'NORMAL', + lineno=84, + col_offset=19, + end_lineno=84, + end_col_offset=27), + lineno=84, + col_offset=12, + end_lineno=84, + end_col_offset=27)])], + lineno=78, + col_offset=4, + end_lineno=84, + end_col_offset=27)], + [], + Name( + 'str', + Load(), + lineno=64, + col_offset=5, + end_lineno=64, + end_col_offset=8), + lineno=60, + col_offset=0, + end_lineno=84, + end_col_offset=27)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=32), + arg( + 'placeholder_2', + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Name( + 'placeholder_1', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=22), + [ + Lt()], + [ + Constant( + 800, + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=28)], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=28), + Compare( + Name( + 'placeholder_2', + Load(), + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=49), + [ + Gt()], + [ + Constant( + 500, + lineno=20, + col_offset=52, + end_lineno=20, + end_col_offset=55)], + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=55), + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=20, + col_offset=62, + end_lineno=20, + end_col_offset=73), + Mult(), + Name( + 'placeholder_2', + Load(), + lineno=20, + col_offset=76, + end_lineno=20, + end_col_offset=92), + lineno=20, + col_offset=62, + end_lineno=20, + end_col_offset=92), + [ + Lt()], + [ + Constant( + 500000, + lineno=20, + col_offset=96, + end_lineno=20, + end_col_offset=103)], + lineno=20, + col_offset=61, + end_lineno=20, + end_col_offset=103)], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=104), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=104)], + [], + lineno=4, + col_offset=0, + end_lineno=20, + end_col_offset=104), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=28), + arg( + 'placeholder_5', + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=28), + arg( + 'placeholder_6', + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=9)], + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=47, + col_offset=26, + end_lineno=47, + end_col_offset=33), + Mult(), + Name( + 'placeholder_5', + Load(), + lineno=47, + col_offset=36, + end_lineno=47, + end_col_offset=43), + lineno=47, + col_offset=26, + end_lineno=47, + end_col_offset=43), + lineno=47), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=14)], + BinOp( + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=31), + Div(), + Name( + 'placeholder_6', + Load(), + lineno=48, + col_offset=34, + end_lineno=48, + end_col_offset=55), + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=55), + Mult(), + Constant( + 100, + lineno=48, + col_offset=59, + end_lineno=48, + end_col_offset=62), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=62), + lineno=48), + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=50, + col_offset=7, + end_lineno=50, + end_col_offset=17), + [ + GtE()], + [ + Constant( + 80, + lineno=50, + col_offset=21, + end_lineno=50, + end_col_offset=23)], + lineno=50, + col_offset=7, + end_lineno=50, + end_col_offset=23), + [ + Return( + Constant( + 'green', + lineno=51, + col_offset=15, + end_lineno=51, + end_col_offset=22), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=22)], + [], + lineno=50, + col_offset=4, + end_lineno=51, + end_col_offset=22), + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=52, + col_offset=7, + end_lineno=52, + end_col_offset=17), + [ + GtE()], + [ + Constant( + 60, + lineno=52, + col_offset=21, + end_lineno=52, + end_col_offset=23)], + lineno=52, + col_offset=7, + end_lineno=52, + end_col_offset=23), + [ + Return( + Constant( + 'orange', + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=23), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=23)], + [], + lineno=52, + col_offset=4, + end_lineno=53, + end_col_offset=23), + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=17), + [ + GtE()], + [ + Constant( + 30, + lineno=54, + col_offset=21, + end_lineno=54, + end_col_offset=23)], + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=23), + [ + Return( + Constant( + 'red', + lineno=56, + col_offset=15, + end_lineno=56, + end_col_offset=20), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=20)], + [], + lineno=54, + col_offset=4, + end_lineno=56, + end_col_offset=20), + Return( + Constant( + 'black', + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=18), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=18)], + [], + lineno=23, + col_offset=0, + end_lineno=57, + end_col_offset=18), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=32), + arg( + 'placeholder_10', + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=49), + arg( + 'placeholder_11', + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=76, + col_offset=4, + end_lineno=76, + end_col_offset=15)], + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=76, + col_offset=32, + end_lineno=76, + end_col_offset=43), + Mult(), + Name( + 'placeholder_10', + Load(), + lineno=76, + col_offset=46, + end_lineno=76, + end_col_offset=74), + lineno=76, + col_offset=32, + end_lineno=76, + end_col_offset=74), + lineno=76), + Match( + Name( + 'placeholder_12', + Load(), + lineno=78, + col_offset=10, + end_lineno=78, + end_col_offset=21), + [ + match_case( + MatchAs( + name='n', + lineno=79, + col_offset=13, + end_lineno=79, + end_col_offset=14), + Compare( + Name( + 'n', + Load(), + lineno=79, + col_offset=18, + end_lineno=79, + end_col_offset=19), + [ + Lt()], + [ + BinOp( + Name( + 'placeholder_11', + Load(), + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=31), + Mult(), + Constant( + 0.9, + lineno=79, + col_offset=34, + end_lineno=79, + end_col_offset=37), + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=37)], + lineno=79, + col_offset=18, + end_lineno=79, + end_col_offset=37), + [ + Return( + Constant( + 'LOW', + lineno=80, + col_offset=19, + end_lineno=80, + end_col_offset=24), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=24)]), + match_case( + MatchAs( + name='n', + lineno=81, + col_offset=13, + end_lineno=81, + end_col_offset=14), + Compare( + Name( + 'n', + Load(), + lineno=81, + col_offset=18, + end_lineno=81, + end_col_offset=19), + [ + Gt()], + [ + BinOp( + Name( + 'placeholder_11', + Load(), + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=31), + Mult(), + Constant( + 1.1, + lineno=81, + col_offset=34, + end_lineno=81, + end_col_offset=37), + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=37)], + lineno=81, + col_offset=18, + end_lineno=81, + end_col_offset=37), + [ + Return( + Constant( + 'DANGER', + lineno=82, + col_offset=19, + end_lineno=82, + end_col_offset=27), + lineno=82, + col_offset=12, + end_lineno=82, + end_col_offset=27)]), + match_case( + MatchAs( + lineno=83, + col_offset=13, + end_lineno=83, + end_col_offset=14), + body=[ + Return( + Constant( + 'NORMAL', + lineno=84, + col_offset=19, + end_lineno=84, + end_col_offset=27), + lineno=84, + col_offset=12, + end_lineno=84, + end_col_offset=27)])], + lineno=78, + col_offset=4, + end_lineno=84, + end_col_offset=27)], + [], + lineno=60, + col_offset=0, + end_lineno=84, + end_col_offset=27)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/example-typehints-removal/representation.txt b/test/example-typehints-removal/representation.txt new file mode 100644 index 0000000..c2a3c7f --- /dev/null +++ b/test/example-typehints-removal/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=8, end_lineno=5, end_col_offset=32), arg('placeholder_2', lineno=6, col_offset=8, end_lineno=6, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Name('placeholder_1', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=22), [Lt()], [Constant(800, lineno=20, col_offset=25, end_lineno=20, end_col_offset=28)], lineno=20, col_offset=11, end_lineno=20, end_col_offset=28), Compare(Name('placeholder_2', Load(), lineno=20, col_offset=33, end_lineno=20, end_col_offset=49), [Gt()], [Constant(500, lineno=20, col_offset=52, end_lineno=20, end_col_offset=55)], lineno=20, col_offset=33, end_lineno=20, end_col_offset=55), Compare(BinOp(Name('placeholder_1', Load(), lineno=20, col_offset=62, end_lineno=20, end_col_offset=73), Mult(), Name('placeholder_2', Load(), lineno=20, col_offset=76, end_lineno=20, end_col_offset=92), lineno=20, col_offset=62, end_lineno=20, end_col_offset=92), [Lt()], [Constant(500000, lineno=20, col_offset=96, end_lineno=20, end_col_offset=103)], lineno=20, col_offset=61, end_lineno=20, end_col_offset=103)], lineno=20, col_offset=11, end_lineno=20, end_col_offset=104), lineno=20, col_offset=4, end_lineno=20, end_col_offset=104)], [], lineno=4, col_offset=0, end_lineno=20, end_col_offset=104), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=24, col_offset=8, end_lineno=24, end_col_offset=28), arg('placeholder_5', lineno=25, col_offset=8, end_lineno=25, end_col_offset=28), arg('placeholder_6', lineno=26, col_offset=8, end_lineno=26, end_col_offset=42)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=47, col_offset=4, end_lineno=47, end_col_offset=9)], BinOp(Name('placeholder_4', Load(), lineno=47, col_offset=26, end_lineno=47, end_col_offset=33), Mult(), Name('placeholder_5', Load(), lineno=47, col_offset=36, end_lineno=47, end_col_offset=43), lineno=47, col_offset=26, end_lineno=47, end_col_offset=43), lineno=47), Assign([Name('placeholder_8', Store(), lineno=48, col_offset=4, end_lineno=48, end_col_offset=14)], BinOp(BinOp(Name('placeholder_7', Load(), lineno=48, col_offset=26, end_lineno=48, end_col_offset=31), Div(), Name('placeholder_6', Load(), lineno=48, col_offset=34, end_lineno=48, end_col_offset=55), lineno=48, col_offset=26, end_lineno=48, end_col_offset=55), Mult(), Constant(100, lineno=48, col_offset=59, end_lineno=48, end_col_offset=62), lineno=48, col_offset=25, end_lineno=48, end_col_offset=62), lineno=48), If(Compare(Name('placeholder_8', Load(), lineno=50, col_offset=7, end_lineno=50, end_col_offset=17), [GtE()], [Constant(80, lineno=50, col_offset=21, end_lineno=50, end_col_offset=23)], lineno=50, col_offset=7, end_lineno=50, end_col_offset=23), [Return(Constant('green', lineno=51, col_offset=15, end_lineno=51, end_col_offset=22), lineno=51, col_offset=8, end_lineno=51, end_col_offset=22)], [], lineno=50, col_offset=4, end_lineno=51, end_col_offset=22), If(Compare(Name('placeholder_8', Load(), lineno=52, col_offset=7, end_lineno=52, end_col_offset=17), [GtE()], [Constant(60, lineno=52, col_offset=21, end_lineno=52, end_col_offset=23)], lineno=52, col_offset=7, end_lineno=52, end_col_offset=23), [Return(Constant('orange', lineno=53, col_offset=15, end_lineno=53, end_col_offset=23), lineno=53, col_offset=8, end_lineno=53, end_col_offset=23)], [], lineno=52, col_offset=4, end_lineno=53, end_col_offset=23), If(Compare(Name('placeholder_8', Load(), lineno=54, col_offset=7, end_lineno=54, end_col_offset=17), [GtE()], [Constant(30, lineno=54, col_offset=21, end_lineno=54, end_col_offset=23)], lineno=54, col_offset=7, end_lineno=54, end_col_offset=23), [Return(Constant('red', lineno=56, col_offset=15, end_lineno=56, end_col_offset=20), lineno=56, col_offset=8, end_lineno=56, end_col_offset=20)], [], lineno=54, col_offset=4, end_lineno=56, end_col_offset=20), Return(Constant('black', lineno=57, col_offset=11, end_lineno=57, end_col_offset=18), lineno=57, col_offset=4, end_lineno=57, end_col_offset=18)], [], lineno=23, col_offset=0, end_lineno=57, end_col_offset=18), FunctionDef('placeholder_9', arguments([], [arg('placeholder_1', lineno=61, col_offset=8, end_lineno=61, end_col_offset=32), arg('placeholder_10', lineno=62, col_offset=8, end_lineno=62, end_col_offset=49), arg('placeholder_11', lineno=63, col_offset=8, end_lineno=63, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_12', Store(), lineno=76, col_offset=4, end_lineno=76, end_col_offset=15)], BinOp(Name('placeholder_1', Load(), lineno=76, col_offset=32, end_lineno=76, end_col_offset=43), Mult(), Name('placeholder_10', Load(), lineno=76, col_offset=46, end_lineno=76, end_col_offset=74), lineno=76, col_offset=32, end_lineno=76, end_col_offset=74), lineno=76), Match(Name('placeholder_12', Load(), lineno=78, col_offset=10, end_lineno=78, end_col_offset=21), [match_case(MatchAs(name='n', lineno=79, col_offset=13, end_lineno=79, end_col_offset=14), Compare(Name('n', Load(), lineno=79, col_offset=18, end_lineno=79, end_col_offset=19), [Lt()], [BinOp(Name('placeholder_11', Load(), lineno=79, col_offset=22, end_lineno=79, end_col_offset=31), Mult(), Constant(0.9, lineno=79, col_offset=34, end_lineno=79, end_col_offset=37), lineno=79, col_offset=22, end_lineno=79, end_col_offset=37)], lineno=79, col_offset=18, end_lineno=79, end_col_offset=37), [Return(Constant('LOW', lineno=80, col_offset=19, end_lineno=80, end_col_offset=24), lineno=80, col_offset=12, end_lineno=80, end_col_offset=24)]), match_case(MatchAs(name='n', lineno=81, col_offset=13, end_lineno=81, end_col_offset=14), Compare(Name('n', Load(), lineno=81, col_offset=18, end_lineno=81, end_col_offset=19), [Gt()], [BinOp(Name('placeholder_11', Load(), lineno=81, col_offset=22, end_lineno=81, end_col_offset=31), Mult(), Constant(1.1, lineno=81, col_offset=34, end_lineno=81, end_col_offset=37), lineno=81, col_offset=22, end_lineno=81, end_col_offset=37)], lineno=81, col_offset=18, end_lineno=81, end_col_offset=37), [Return(Constant('DANGER', lineno=82, col_offset=19, end_lineno=82, end_col_offset=27), lineno=82, col_offset=12, end_lineno=82, end_col_offset=27)]), match_case(MatchAs(lineno=83, col_offset=13, end_lineno=83, end_col_offset=14), body=[Return(Constant('NORMAL', lineno=84, col_offset=19, end_lineno=84, end_col_offset=27), lineno=84, col_offset=12, end_lineno=84, end_col_offset=27)])], lineno=78, col_offset=4, end_lineno=84, end_col_offset=27)], [], lineno=60, col_offset=0, end_lineno=84, end_col_offset=27)], []) \ No newline at end of file diff --git a/test/practice-accumulate/.meta/config.json b/test/practice-accumulate/.meta/config.json new file mode 100644 index 0000000..35da9ae --- /dev/null +++ b/test/practice-accumulate/.meta/config.json @@ -0,0 +1,30 @@ +{ + "blurb": "Implement the `accumulate` operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection.", + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "iandexter", + "ikhadykin", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "accumulate.py" + ], + "test": [ + "accumulate_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "Conversation with James Edward Gray II", + "source_url": "https://twitter.com/jeg2" +} diff --git a/test/practice-accumulate/accumulate.py b/test/practice-accumulate/accumulate.py new file mode 100644 index 0000000..15fd44f --- /dev/null +++ b/test/practice-accumulate/accumulate.py @@ -0,0 +1,8 @@ +# [collection(x) for x in collection] would be nice but trivial + + +def accumulate(collection, operation): + response = [] + for element in collection: + response.append(operation(element)) + return response diff --git a/test/practice-accumulate/mapping.json b/test/practice-accumulate/mapping.json new file mode 100644 index 0000000..5aa6cf1 --- /dev/null +++ b/test/practice-accumulate/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "accumulate", + "placeholder_1": "collection", + "placeholder_2": "operation", + "placeholder_3": "response", + "placeholder_4": "element" +} \ No newline at end of file diff --git a/test/practice-accumulate/representation.json b/test/practice-accumulate/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-accumulate/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-accumulate/representation.out b/test/practice-accumulate/representation.out new file mode 100644 index 0000000..f09c9aa --- /dev/null +++ b/test/practice-accumulate/representation.out @@ -0,0 +1,272 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + placeholder_3 = [] + for placeholder_4 in placeholder_1: + placeholder_3.append(placeholder_2(placeholder_4)) + return placeholder_3 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'accumulate', + arguments( + [], + [ + arg( + 'collection', + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=25), + arg( + 'operation', + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'response', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12)], + List( + [], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=17), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=17), + For( + Name( + 'element', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=15), + Name( + 'collection', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'response', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=16), + 'append', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=23), + [ + Call( + Name( + 'operation', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=33), + [ + Name( + 'element', + Load(), + lineno=7, + col_offset=34, + end_lineno=7, + end_col_offset=41)], + [], + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=42)], + [], + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=43), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=43)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=43), + Return( + Name( + 'response', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=19), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=19)], + [], + lineno=4, + col_offset=0, + end_lineno=8, + end_col_offset=19)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=25), + arg( + 'placeholder_2', + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12)], + List( + [], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=17), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=17), + For( + Name( + 'placeholder_4', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=15), + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=16), + 'append', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=23), + [ + Call( + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=33), + [ + Name( + 'placeholder_4', + Load(), + lineno=7, + col_offset=34, + end_lineno=7, + end_col_offset=41)], + [], + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=42)], + [], + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=43), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=43)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=43), + Return( + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=19), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=19)], + [], + lineno=4, + col_offset=0, + end_lineno=8, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-accumulate/representation.txt b/test/practice-accumulate/representation.txt new file mode 100644 index 0000000..e223521 --- /dev/null +++ b/test/practice-accumulate/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=15, end_lineno=4, end_col_offset=25), arg('placeholder_2', lineno=4, col_offset=27, end_lineno=4, end_col_offset=36)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=12)], List([], Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=17), lineno=5, col_offset=4, end_lineno=5, end_col_offset=17), For(Name('placeholder_4', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=15), Name('placeholder_1', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=29), [Expr(Call(Attribute(Name('placeholder_3', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=16), 'append', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=23), [Call(Name('placeholder_2', Load(), lineno=7, col_offset=24, end_lineno=7, end_col_offset=33), [Name('placeholder_4', Load(), lineno=7, col_offset=34, end_lineno=7, end_col_offset=41)], [], lineno=7, col_offset=24, end_lineno=7, end_col_offset=42)], [], lineno=7, col_offset=8, end_lineno=7, end_col_offset=43), lineno=7, col_offset=8, end_lineno=7, end_col_offset=43)], [], lineno=6, col_offset=4, end_lineno=7, end_col_offset=43), Return(Name('placeholder_3', Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=19), lineno=8, col_offset=4, end_lineno=8, end_col_offset=19)], [], lineno=4, col_offset=0, end_lineno=8, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/practice-acronym/.meta/config.json b/test/practice-acronym/.meta/config.json new file mode 100644 index 0000000..e29fff6 --- /dev/null +++ b/test/practice-acronym/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [ + "rootulp" + ], + "contributors": [ + "AnAccountForReportingBugs", + "behrtam", + "cmccandless", + "Dog", + "GascaK", + "ikhadykin", + "N-Parsons", + "omer-g", + "pheanex", + "sjwarner-bp", + "thomasjpfan", + "tqa236" + ], + "files": { + "solution": [ + "acronym.py" + ], + "test": [ + "acronym_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Convert a long phrase to its acronym.", + "source": "Julien Vanier", + "source_url": "https://github.com/monkbroc" +} diff --git a/test/practice-acronym/acronym.py b/test/practice-acronym/acronym.py new file mode 100644 index 0000000..e7cf298 --- /dev/null +++ b/test/practice-acronym/acronym.py @@ -0,0 +1,6 @@ +import re + + +def abbreviate(words): + regex = "[A-Z]+['a-z]*|['a-z]+" + return ''.join(word[0].upper() for word in re.findall(regex, words)) diff --git a/test/practice-acronym/mapping.json b/test/practice-acronym/mapping.json new file mode 100644 index 0000000..98bd0e8 --- /dev/null +++ b/test/practice-acronym/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "abbreviate", + "placeholder_1": "words", + "placeholder_2": "regex", + "placeholder_3": "word" +} \ No newline at end of file diff --git a/test/practice-acronym/representation.json b/test/practice-acronym/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-acronym/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-acronym/representation.out b/test/practice-acronym/representation.out new file mode 100644 index 0000000..77428a8 --- /dev/null +++ b/test/practice-acronym/representation.out @@ -0,0 +1,346 @@ +## BEGIN NORMALIZED CODE ## +import re + + +def placeholder_0(placeholder_1): + placeholder_2 = "[A-Z]+['a-z]*|['a-z]+" + return "".join( + ( + placeholder_3[0].upper() + for placeholder_3 in re.findall(placeholder_2, placeholder_1) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + FunctionDef( + 'abbreviate', + arguments( + [], + [ + arg( + 'words', + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'regex', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=9)], + Constant( + "[A-Z]+['a-z]*|['a-z]+", + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=35), + Return( + Call( + Attribute( + Constant( + '', + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=13), + 'join', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=18), + [ + GeneratorExp( + Call( + Attribute( + Subscript( + Name( + 'word', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=23), + Constant( + 0, + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=25), + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=26), + 'upper', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=32), + [], + [], + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=34), + [ + comprehension( + Name( + 'word', + Store(), + lineno=6, + col_offset=39, + end_lineno=6, + end_col_offset=43), + Call( + Attribute( + Name( + 're', + Load(), + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=49), + 'findall', + Load(), + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=57), + [ + Name( + 'regex', + Load(), + lineno=6, + col_offset=58, + end_lineno=6, + end_col_offset=63), + Name( + 'words', + Load(), + lineno=6, + col_offset=65, + end_lineno=6, + end_col_offset=70)], + [], + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=71), + [], + 0)], + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=72)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=72), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=72)], + [], + lineno=4, + col_offset=0, + end_lineno=6, + end_col_offset=72)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=9)], + Constant( + "[A-Z]+['a-z]*|['a-z]+", + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=35), + Return( + Call( + Attribute( + Constant( + '', + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=13), + 'join', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=18), + [ + GeneratorExp( + Call( + Attribute( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=23), + Constant( + 0, + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=25), + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=26), + 'upper', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=32), + [], + [], + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=34), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=6, + col_offset=39, + end_lineno=6, + end_col_offset=43), + Call( + Attribute( + Name( + 're', + Load(), + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=49), + 'findall', + Load(), + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=57), + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=58, + end_lineno=6, + end_col_offset=63), + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=65, + end_lineno=6, + end_col_offset=70)], + [], + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=71), + [], + 0)], + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=72)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=72), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=72)], + [], + lineno=4, + col_offset=0, + end_lineno=6, + end_col_offset=72)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-acronym/representation.txt b/test/practice-acronym/representation.txt new file mode 100644 index 0000000..bfd1b7d --- /dev/null +++ b/test/practice-acronym/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('re', lineno=1, col_offset=7, end_lineno=1, end_col_offset=9)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=9), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=15, end_lineno=4, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=9)], Constant("[A-Z]+['a-z]*|['a-z]+", lineno=5, col_offset=12, end_lineno=5, end_col_offset=35), lineno=5, col_offset=4, end_lineno=5, end_col_offset=35), Return(Call(Attribute(Constant('', lineno=6, col_offset=11, end_lineno=6, end_col_offset=13), 'join', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=18), [GeneratorExp(Call(Attribute(Subscript(Name('placeholder_3', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=23), Constant(0, lineno=6, col_offset=24, end_lineno=6, end_col_offset=25), Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=26), 'upper', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=32), [], [], lineno=6, col_offset=19, end_lineno=6, end_col_offset=34), [comprehension(Name('placeholder_3', Store(), lineno=6, col_offset=39, end_lineno=6, end_col_offset=43), Call(Attribute(Name('re', Load(), lineno=6, col_offset=47, end_lineno=6, end_col_offset=49), 'findall', Load(), lineno=6, col_offset=47, end_lineno=6, end_col_offset=57), [Name('placeholder_2', Load(), lineno=6, col_offset=58, end_lineno=6, end_col_offset=63), Name('placeholder_1', Load(), lineno=6, col_offset=65, end_lineno=6, end_col_offset=70)], [], lineno=6, col_offset=47, end_lineno=6, end_col_offset=71), [], 0)], lineno=6, col_offset=18, end_lineno=6, end_col_offset=72)], [], lineno=6, col_offset=11, end_lineno=6, end_col_offset=72), lineno=6, col_offset=4, end_lineno=6, end_col_offset=72)], [], lineno=4, col_offset=0, end_lineno=6, end_col_offset=72)], []) \ No newline at end of file diff --git a/test/practice-affine-cipher/.meta/config.json b/test/practice-affine-cipher/.meta/config.json new file mode 100644 index 0000000..3d23cca --- /dev/null +++ b/test/practice-affine-cipher/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "jackattack24" + ], + "contributors": [ + "cmccandless", + "crsmi", + "Dog", + "tqa236" + ], + "files": { + "solution": [ + "affine_cipher.py" + ], + "test": [ + "affine_cipher_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Create an implementation of the Affine cipher, an ancient encryption algorithm from the Middle East.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Affine_cipher" +} diff --git a/test/practice-affine-cipher/affine_cipher.py b/test/practice-affine-cipher/affine_cipher.py new file mode 100644 index 0000000..8418108 --- /dev/null +++ b/test/practice-affine-cipher/affine_cipher.py @@ -0,0 +1,43 @@ +"""Why won't this damn thing work?!!""" + +BLOCK_SIZE = 5 +ALPHABET = 26 + + +def mod_inverse(a_key, alphabet): + a_key = a_key % alphabet + for idx in range(1, alphabet): + if (a_key * idx) % alphabet == 1: + return idx + return 1 + + +def translate(text, a_key, b_key, mode): + inverse = mod_inverse(a_key, ALPHABET) + if inverse == 1: + raise ValueError('a and m must be coprime.') + + chars = [] + for character in text: + if character.isalnum(): + origin = ord(character.lower()) - 97 + if origin < 0: + chars.append(character) + continue + if mode == 0: + new = (a_key * origin + b_key) % ALPHABET + elif mode == 1: + new = (inverse * (origin - b_key)) % ALPHABET + chars.append(chr(new + 97)) + + return ''.join(chars) + + +def encode(plain, a, b): + cipher = translate(plain, a, b, 0) + return ' '.join([cipher[idx:idx + BLOCK_SIZE] + for idx in range(0, len(cipher), BLOCK_SIZE)]) + + +def decode(ciphered, a, b): + return translate(ciphered, a, b, 1) \ No newline at end of file diff --git a/test/practice-affine-cipher/mapping.json b/test/practice-affine-cipher/mapping.json new file mode 100644 index 0000000..e55782d --- /dev/null +++ b/test/practice-affine-cipher/mapping.json @@ -0,0 +1,24 @@ +{ + "placeholder_0": "BLOCK_SIZE", + "placeholder_1": "ALPHABET", + "placeholder_2": "mod_inverse", + "placeholder_3": "a_key", + "placeholder_4": "alphabet", + "placeholder_5": "idx", + "placeholder_6": "translate", + "placeholder_7": "text", + "placeholder_8": "b_key", + "placeholder_9": "mode", + "placeholder_10": "inverse", + "placeholder_11": "chars", + "placeholder_12": "character", + "placeholder_13": "origin", + "placeholder_14": "new", + "placeholder_15": "encode", + "placeholder_16": "plain", + "placeholder_17": "a", + "placeholder_18": "b", + "placeholder_19": "cipher", + "placeholder_20": "decode", + "placeholder_21": "ciphered" +} \ No newline at end of file diff --git a/test/practice-affine-cipher/representation.json b/test/practice-affine-cipher/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-affine-cipher/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-affine-cipher/representation.out b/test/practice-affine-cipher/representation.out new file mode 100644 index 0000000..883eaae --- /dev/null +++ b/test/practice-affine-cipher/representation.out @@ -0,0 +1,2283 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = 5 +placeholder_1 = 26 + + +def placeholder_2(placeholder_3, placeholder_4): + placeholder_3 = placeholder_3 % placeholder_4 + for placeholder_5 in range(1, placeholder_4): + if placeholder_3 * placeholder_5 % placeholder_4 == 1: + return placeholder_5 + return 1 + + +def placeholder_6(placeholder_7, placeholder_3, placeholder_8, placeholder_9): + placeholder_10 = placeholder_2(placeholder_3, placeholder_1) + if placeholder_10 == 1: + raise ValueError("a and m must be coprime.") + placeholder_11 = [] + for placeholder_12 in placeholder_7: + if placeholder_12.isalnum(): + placeholder_13 = ord(placeholder_12.lower()) - 97 + if placeholder_13 < 0: + placeholder_11.append(placeholder_12) + continue + if placeholder_9 == 0: + placeholder_14 = ( + placeholder_3 * placeholder_13 + placeholder_8 + ) % placeholder_1 + elif placeholder_9 == 1: + placeholder_14 = ( + placeholder_10 * (placeholder_13 - placeholder_8) % placeholder_1 + ) + placeholder_11.append(chr(placeholder_14 + 97)) + return "".join(placeholder_11) + + +def placeholder_15(placeholder_16, placeholder_17, placeholder_18): + placeholder_19 = placeholder_6(placeholder_16, placeholder_17, placeholder_18, 0) + return " ".join( + [ + placeholder_19[placeholder_5 : placeholder_5 + placeholder_0] + for placeholder_5 in range(0, len(placeholder_19), placeholder_0) + ] + ) + + +def placeholder_20(placeholder_21, placeholder_17, placeholder_18): + return placeholder_6(placeholder_21, placeholder_17, placeholder_18, 1) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + "Why won't this damn thing work?!!", + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=39), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=39), + Assign( + [ + Name( + 'BLOCK_SIZE', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=10)], + Constant( + 5, + lineno=3, + col_offset=13, + end_lineno=3, + end_col_offset=14), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=14), + Assign( + [ + Name( + 'ALPHABET', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=8)], + Constant( + 26, + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=13), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=13), + FunctionDef( + 'mod_inverse', + arguments( + [], + [ + arg( + 'a_key', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=21), + arg( + 'alphabet', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'a_key', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=9)], + BinOp( + Name( + 'a_key', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=17), + Mod(), + Name( + 'alphabet', + Load(), + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=28), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=28), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=28), + For( + Name( + 'idx', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=20), + [ + Constant( + 1, + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=22), + Name( + 'alphabet', + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=32)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=33), + [ + If( + Compare( + BinOp( + BinOp( + Name( + 'a_key', + Load(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=17), + Mult(), + Name( + 'idx', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=23), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=23), + Mod(), + Name( + 'alphabet', + Load(), + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=35), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=35), + [ + Eq()], + [ + Constant( + 1, + lineno=10, + col_offset=39, + end_lineno=10, + end_col_offset=40)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=40), + [ + Return( + Name( + 'idx', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=22)], + [], + lineno=10, + col_offset=8, + end_lineno=11, + end_col_offset=22)], + [], + lineno=9, + col_offset=4, + end_lineno=11, + end_col_offset=22), + Return( + Constant( + 1, + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=12), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=12)], + [], + lineno=7, + col_offset=0, + end_lineno=12, + end_col_offset=12), + FunctionDef( + 'translate', + arguments( + [], + [ + arg( + 'text', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=18), + arg( + 'a_key', + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=25), + arg( + 'b_key', + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=32), + arg( + 'mode', + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'inverse', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=11)], + Call( + Name( + 'mod_inverse', + Load(), + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=25), + [ + Name( + 'a_key', + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=31), + Name( + 'ALPHABET', + Load(), + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=41)], + [], + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=42), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=42), + If( + Compare( + Name( + 'inverse', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=14), + [ + Eq()], + [ + Constant( + 1, + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=19)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=19), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + Constant( + 'a and m must be coprime.', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=51)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=52), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=52)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=52), + Assign( + [ + Name( + 'chars', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=9)], + List( + [], + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=14), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=14), + For( + Name( + 'character', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=17), + Name( + 'text', + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=25), + [ + If( + Call( + Attribute( + Name( + 'character', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=20), + 'isalnum', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=28), + [], + [], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=30), + [ + Assign( + [ + Name( + 'origin', + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=18)], + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=24), + [ + Call( + Attribute( + Name( + 'character', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=34), + 'lower', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=40), + [], + [], + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=42)], + [], + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=43), + Sub(), + Constant( + 97, + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=48), + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=48), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=48), + If( + Compare( + Name( + 'origin', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=21), + [ + Lt()], + [ + Constant( + 0, + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=25)], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=25), + [ + Expr( + Call( + Attribute( + Name( + 'chars', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=21), + 'append', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=28), + [ + Name( + 'character', + Load(), + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=38)], + [], + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=39), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=39), + Continue( + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=24)], + [], + lineno=24, + col_offset=12, + end_lineno=26, + end_col_offset=24), + If( + Compare( + Name( + 'mode', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=19), + [ + Eq()], + [ + Constant( + 0, + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=24)], + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=24), + [ + Assign( + [ + Name( + 'new', + Store(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=19)], + BinOp( + BinOp( + BinOp( + Name( + 'a_key', + Load(), + lineno=28, + col_offset=23, + end_lineno=28, + end_col_offset=28), + Mult(), + Name( + 'origin', + Load(), + lineno=28, + col_offset=31, + end_lineno=28, + end_col_offset=37), + lineno=28, + col_offset=23, + end_lineno=28, + end_col_offset=37), + Add(), + Name( + 'b_key', + Load(), + lineno=28, + col_offset=40, + end_lineno=28, + end_col_offset=45), + lineno=28, + col_offset=23, + end_lineno=28, + end_col_offset=45), + Mod(), + Name( + 'ALPHABET', + Load(), + lineno=28, + col_offset=49, + end_lineno=28, + end_col_offset=57), + lineno=28, + col_offset=22, + end_lineno=28, + end_col_offset=57), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=57)], + [ + If( + Compare( + Name( + 'mode', + Load(), + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 1, + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=26)], + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=26), + [ + Assign( + [ + Name( + 'new', + Store(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=19)], + BinOp( + BinOp( + Name( + 'inverse', + Load(), + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=30), + Mult(), + BinOp( + Name( + 'origin', + Load(), + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=40), + Sub(), + Name( + 'b_key', + Load(), + lineno=30, + col_offset=43, + end_lineno=30, + end_col_offset=48), + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=48), + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=49), + Mod(), + Name( + 'ALPHABET', + Load(), + lineno=30, + col_offset=53, + end_lineno=30, + end_col_offset=61), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=61), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=61)], + [], + lineno=29, + col_offset=12, + end_lineno=30, + end_col_offset=61)], + lineno=27, + col_offset=12, + end_lineno=30, + end_col_offset=61), + Expr( + Call( + Attribute( + Name( + 'chars', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=17), + 'append', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=24), + [ + Call( + Name( + 'chr', + Load(), + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=28), + [ + BinOp( + Name( + 'new', + Load(), + lineno=31, + col_offset=29, + end_lineno=31, + end_col_offset=32), + Add(), + Constant( + 97, + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=37), + lineno=31, + col_offset=29, + end_lineno=31, + end_col_offset=37)], + [], + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=38)], + [], + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=39), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=39)], + [], + lineno=22, + col_offset=8, + end_lineno=31, + end_col_offset=39)], + [], + lineno=21, + col_offset=4, + end_lineno=31, + end_col_offset=39), + Return( + Call( + Attribute( + Constant( + '', + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=13), + 'join', + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=18), + [ + Name( + 'chars', + Load(), + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=24)], + [], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=25), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=25)], + [], + lineno=15, + col_offset=0, + end_lineno=33, + end_col_offset=25), + FunctionDef( + 'encode', + arguments( + [], + [ + arg( + 'plain', + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=16), + arg( + 'a', + lineno=36, + col_offset=18, + end_lineno=36, + end_col_offset=19), + arg( + 'b', + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'cipher', + Store(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=10)], + Call( + Name( + 'translate', + Load(), + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=22), + [ + Name( + 'plain', + Load(), + lineno=37, + col_offset=23, + end_lineno=37, + end_col_offset=28), + Name( + 'a', + Load(), + lineno=37, + col_offset=30, + end_lineno=37, + end_col_offset=31), + Name( + 'b', + Load(), + lineno=37, + col_offset=33, + end_lineno=37, + end_col_offset=34), + Constant( + 0, + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=37)], + [], + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=38), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=38), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=14), + 'join', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=19), + [ + ListComp( + Subscript( + Name( + 'cipher', + Load(), + lineno=38, + col_offset=21, + end_lineno=38, + end_col_offset=27), + Slice( + Name( + 'idx', + Load(), + lineno=38, + col_offset=28, + end_lineno=38, + end_col_offset=31), + BinOp( + Name( + 'idx', + Load(), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=35), + Add(), + Name( + 'BLOCK_SIZE', + Load(), + lineno=38, + col_offset=38, + end_lineno=38, + end_col_offset=48), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=48), + lineno=38, + col_offset=28, + end_lineno=38, + end_col_offset=48), + Load(), + lineno=38, + col_offset=21, + end_lineno=38, + end_col_offset=49), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=39, + col_offset=25, + end_lineno=39, + end_col_offset=28), + Call( + Name( + 'range', + Load(), + lineno=39, + col_offset=32, + end_lineno=39, + end_col_offset=37), + [ + Constant( + 0, + lineno=39, + col_offset=38, + end_lineno=39, + end_col_offset=39), + Call( + Name( + 'len', + Load(), + lineno=39, + col_offset=41, + end_lineno=39, + end_col_offset=44), + [ + Name( + 'cipher', + Load(), + lineno=39, + col_offset=45, + end_lineno=39, + end_col_offset=51)], + [], + lineno=39, + col_offset=41, + end_lineno=39, + end_col_offset=52), + Name( + 'BLOCK_SIZE', + Load(), + lineno=39, + col_offset=54, + end_lineno=39, + end_col_offset=64)], + [], + lineno=39, + col_offset=32, + end_lineno=39, + end_col_offset=65), + [], + 0)], + lineno=38, + col_offset=20, + end_lineno=39, + end_col_offset=66)], + [], + lineno=38, + col_offset=11, + end_lineno=39, + end_col_offset=67), + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=67)], + [], + lineno=36, + col_offset=0, + end_lineno=39, + end_col_offset=67), + FunctionDef( + 'decode', + arguments( + [], + [ + arg( + 'ciphered', + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=19), + arg( + 'a', + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=22), + arg( + 'b', + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'translate', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=20), + [ + Name( + 'ciphered', + Load(), + lineno=43, + col_offset=21, + end_lineno=43, + end_col_offset=29), + Name( + 'a', + Load(), + lineno=43, + col_offset=31, + end_lineno=43, + end_col_offset=32), + Name( + 'b', + Load(), + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=35), + Constant( + 1, + lineno=43, + col_offset=37, + end_lineno=43, + end_col_offset=38)], + [], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=39), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=39)], + [], + lineno=42, + col_offset=0, + end_lineno=43, + end_col_offset=39)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=10)], + Constant( + 5, + lineno=3, + col_offset=13, + end_lineno=3, + end_col_offset=14), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=8)], + Constant( + 26, + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=13), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=13), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=21), + arg( + 'placeholder_4', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=9)], + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=17), + Mod(), + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=28), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=28), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=28), + For( + Name( + 'placeholder_5', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=20), + [ + Constant( + 1, + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=22), + Name( + 'placeholder_4', + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=32)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=33), + [ + If( + Compare( + BinOp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=17), + Mult(), + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=23), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=23), + Mod(), + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=35), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=35), + [ + Eq()], + [ + Constant( + 1, + lineno=10, + col_offset=39, + end_lineno=10, + end_col_offset=40)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=40), + [ + Return( + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=22)], + [], + lineno=10, + col_offset=8, + end_lineno=11, + end_col_offset=22)], + [], + lineno=9, + col_offset=4, + end_lineno=11, + end_col_offset=22), + Return( + Constant( + 1, + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=12), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=12)], + [], + lineno=7, + col_offset=0, + end_lineno=12, + end_col_offset=12), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=18), + arg( + 'placeholder_3', + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=25), + arg( + 'placeholder_8', + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=32), + arg( + 'placeholder_9', + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=11)], + Call( + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=25), + [ + Name( + 'placeholder_3', + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=31), + Name( + 'placeholder_1', + Load(), + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=41)], + [], + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=42), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=42), + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=14), + [ + Eq()], + [ + Constant( + 1, + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=19)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=19), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + Constant( + 'a and m must be coprime.', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=51)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=52), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=52)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=9)], + List( + [], + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=14), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=14), + For( + Name( + 'placeholder_12', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=17), + Name( + 'placeholder_7', + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=25), + [ + If( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=20), + 'isalnum', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=28), + [], + [], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=30), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=18)], + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=24), + [ + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=34), + 'lower', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=40), + [], + [], + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=42)], + [], + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=43), + Sub(), + Constant( + 97, + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=48), + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=48), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=48), + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=21), + [ + Lt()], + [ + Constant( + 0, + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=25)], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=25), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=21), + 'append', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=28), + [ + Name( + 'placeholder_12', + Load(), + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=38)], + [], + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=39), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=39), + Continue( + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=24)], + [], + lineno=24, + col_offset=12, + end_lineno=26, + end_col_offset=24), + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=19), + [ + Eq()], + [ + Constant( + 0, + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=24)], + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=24), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=19)], + BinOp( + BinOp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=28, + col_offset=23, + end_lineno=28, + end_col_offset=28), + Mult(), + Name( + 'placeholder_13', + Load(), + lineno=28, + col_offset=31, + end_lineno=28, + end_col_offset=37), + lineno=28, + col_offset=23, + end_lineno=28, + end_col_offset=37), + Add(), + Name( + 'placeholder_8', + Load(), + lineno=28, + col_offset=40, + end_lineno=28, + end_col_offset=45), + lineno=28, + col_offset=23, + end_lineno=28, + end_col_offset=45), + Mod(), + Name( + 'placeholder_1', + Load(), + lineno=28, + col_offset=49, + end_lineno=28, + end_col_offset=57), + lineno=28, + col_offset=22, + end_lineno=28, + end_col_offset=57), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=57)], + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 1, + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=26)], + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=26), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=19)], + BinOp( + BinOp( + Name( + 'placeholder_10', + Load(), + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=30), + Mult(), + BinOp( + Name( + 'placeholder_13', + Load(), + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=40), + Sub(), + Name( + 'placeholder_8', + Load(), + lineno=30, + col_offset=43, + end_lineno=30, + end_col_offset=48), + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=48), + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=49), + Mod(), + Name( + 'placeholder_1', + Load(), + lineno=30, + col_offset=53, + end_lineno=30, + end_col_offset=61), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=61), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=61)], + [], + lineno=29, + col_offset=12, + end_lineno=30, + end_col_offset=61)], + lineno=27, + col_offset=12, + end_lineno=30, + end_col_offset=61), + Expr( + Call( + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=17), + 'append', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=24), + [ + Call( + Name( + 'chr', + Load(), + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=28), + [ + BinOp( + Name( + 'placeholder_14', + Load(), + lineno=31, + col_offset=29, + end_lineno=31, + end_col_offset=32), + Add(), + Constant( + 97, + lineno=31, + col_offset=35, + end_lineno=31, + end_col_offset=37), + lineno=31, + col_offset=29, + end_lineno=31, + end_col_offset=37)], + [], + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=38)], + [], + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=39), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=39)], + [], + lineno=22, + col_offset=8, + end_lineno=31, + end_col_offset=39)], + [], + lineno=21, + col_offset=4, + end_lineno=31, + end_col_offset=39), + Return( + Call( + Attribute( + Constant( + '', + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=13), + 'join', + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=18), + [ + Name( + 'placeholder_11', + Load(), + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=24)], + [], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=25), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=25)], + [], + lineno=15, + col_offset=0, + end_lineno=33, + end_col_offset=25), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'placeholder_16', + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=16), + arg( + 'placeholder_17', + lineno=36, + col_offset=18, + end_lineno=36, + end_col_offset=19), + arg( + 'placeholder_18', + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=10)], + Call( + Name( + 'placeholder_6', + Load(), + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=22), + [ + Name( + 'placeholder_16', + Load(), + lineno=37, + col_offset=23, + end_lineno=37, + end_col_offset=28), + Name( + 'placeholder_17', + Load(), + lineno=37, + col_offset=30, + end_lineno=37, + end_col_offset=31), + Name( + 'placeholder_18', + Load(), + lineno=37, + col_offset=33, + end_lineno=37, + end_col_offset=34), + Constant( + 0, + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=37)], + [], + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=38), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=38), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=14), + 'join', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=19), + [ + ListComp( + Subscript( + Name( + 'placeholder_19', + Load(), + lineno=38, + col_offset=21, + end_lineno=38, + end_col_offset=27), + Slice( + Name( + 'placeholder_5', + Load(), + lineno=38, + col_offset=28, + end_lineno=38, + end_col_offset=31), + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=35), + Add(), + Name( + 'placeholder_0', + Load(), + lineno=38, + col_offset=38, + end_lineno=38, + end_col_offset=48), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=48), + lineno=38, + col_offset=28, + end_lineno=38, + end_col_offset=48), + Load(), + lineno=38, + col_offset=21, + end_lineno=38, + end_col_offset=49), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=39, + col_offset=25, + end_lineno=39, + end_col_offset=28), + Call( + Name( + 'range', + Load(), + lineno=39, + col_offset=32, + end_lineno=39, + end_col_offset=37), + [ + Constant( + 0, + lineno=39, + col_offset=38, + end_lineno=39, + end_col_offset=39), + Call( + Name( + 'len', + Load(), + lineno=39, + col_offset=41, + end_lineno=39, + end_col_offset=44), + [ + Name( + 'placeholder_19', + Load(), + lineno=39, + col_offset=45, + end_lineno=39, + end_col_offset=51)], + [], + lineno=39, + col_offset=41, + end_lineno=39, + end_col_offset=52), + Name( + 'placeholder_0', + Load(), + lineno=39, + col_offset=54, + end_lineno=39, + end_col_offset=64)], + [], + lineno=39, + col_offset=32, + end_lineno=39, + end_col_offset=65), + [], + 0)], + lineno=38, + col_offset=20, + end_lineno=39, + end_col_offset=66)], + [], + lineno=38, + col_offset=11, + end_lineno=39, + end_col_offset=67), + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=67)], + [], + lineno=36, + col_offset=0, + end_lineno=39, + end_col_offset=67), + FunctionDef( + 'placeholder_20', + arguments( + [], + [ + arg( + 'placeholder_21', + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=19), + arg( + 'placeholder_17', + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=22), + arg( + 'placeholder_18', + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_6', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=20), + [ + Name( + 'placeholder_21', + Load(), + lineno=43, + col_offset=21, + end_lineno=43, + end_col_offset=29), + Name( + 'placeholder_17', + Load(), + lineno=43, + col_offset=31, + end_lineno=43, + end_col_offset=32), + Name( + 'placeholder_18', + Load(), + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=35), + Constant( + 1, + lineno=43, + col_offset=37, + end_lineno=43, + end_col_offset=38)], + [], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=39), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=39)], + [], + lineno=42, + col_offset=0, + end_lineno=43, + end_col_offset=39)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-affine-cipher/representation.txt b/test/practice-affine-cipher/representation.txt new file mode 100644 index 0000000..011b4c1 --- /dev/null +++ b/test/practice-affine-cipher/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=10)], Constant(5, lineno=3, col_offset=13, end_lineno=3, end_col_offset=14), lineno=3, col_offset=0, end_lineno=3, end_col_offset=14), Assign([Name('placeholder_1', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=8)], Constant(26, lineno=4, col_offset=11, end_lineno=4, end_col_offset=13), lineno=4, col_offset=0, end_lineno=4, end_col_offset=13), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=7, col_offset=16, end_lineno=7, end_col_offset=21), arg('placeholder_4', lineno=7, col_offset=23, end_lineno=7, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=9)], BinOp(Name('placeholder_3', Load(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=17), Mod(), Name('placeholder_4', Load(), lineno=8, col_offset=20, end_lineno=8, end_col_offset=28), lineno=8, col_offset=12, end_lineno=8, end_col_offset=28), lineno=8, col_offset=4, end_lineno=8, end_col_offset=28), For(Name('placeholder_5', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=11), Call(Name('range', Load(), lineno=9, col_offset=15, end_lineno=9, end_col_offset=20), [Constant(1, lineno=9, col_offset=21, end_lineno=9, end_col_offset=22), Name('placeholder_4', Load(), lineno=9, col_offset=24, end_lineno=9, end_col_offset=32)], [], lineno=9, col_offset=15, end_lineno=9, end_col_offset=33), [If(Compare(BinOp(BinOp(Name('placeholder_3', Load(), lineno=10, col_offset=12, end_lineno=10, end_col_offset=17), Mult(), Name('placeholder_5', Load(), lineno=10, col_offset=20, end_lineno=10, end_col_offset=23), lineno=10, col_offset=12, end_lineno=10, end_col_offset=23), Mod(), Name('placeholder_4', Load(), lineno=10, col_offset=27, end_lineno=10, end_col_offset=35), lineno=10, col_offset=11, end_lineno=10, end_col_offset=35), [Eq()], [Constant(1, lineno=10, col_offset=39, end_lineno=10, end_col_offset=40)], lineno=10, col_offset=11, end_lineno=10, end_col_offset=40), [Return(Name('placeholder_5', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=22), lineno=11, col_offset=12, end_lineno=11, end_col_offset=22)], [], lineno=10, col_offset=8, end_lineno=11, end_col_offset=22)], [], lineno=9, col_offset=4, end_lineno=11, end_col_offset=22), Return(Constant(1, lineno=12, col_offset=11, end_lineno=12, end_col_offset=12), lineno=12, col_offset=4, end_lineno=12, end_col_offset=12)], [], lineno=7, col_offset=0, end_lineno=12, end_col_offset=12), FunctionDef('placeholder_6', arguments([], [arg('placeholder_7', lineno=15, col_offset=14, end_lineno=15, end_col_offset=18), arg('placeholder_3', lineno=15, col_offset=20, end_lineno=15, end_col_offset=25), arg('placeholder_8', lineno=15, col_offset=27, end_lineno=15, end_col_offset=32), arg('placeholder_9', lineno=15, col_offset=34, end_lineno=15, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_10', Store(), lineno=16, col_offset=4, end_lineno=16, end_col_offset=11)], Call(Name('placeholder_2', Load(), lineno=16, col_offset=14, end_lineno=16, end_col_offset=25), [Name('placeholder_3', Load(), lineno=16, col_offset=26, end_lineno=16, end_col_offset=31), Name('placeholder_1', Load(), lineno=16, col_offset=33, end_lineno=16, end_col_offset=41)], [], lineno=16, col_offset=14, end_lineno=16, end_col_offset=42), lineno=16, col_offset=4, end_lineno=16, end_col_offset=42), If(Compare(Name('placeholder_10', Load(), lineno=17, col_offset=7, end_lineno=17, end_col_offset=14), [Eq()], [Constant(1, lineno=17, col_offset=18, end_lineno=17, end_col_offset=19)], lineno=17, col_offset=7, end_lineno=17, end_col_offset=19), [Raise(Call(Name('ValueError', Load(), lineno=18, col_offset=14, end_lineno=18, end_col_offset=24), [Constant('a and m must be coprime.', lineno=18, col_offset=25, end_lineno=18, end_col_offset=51)], [], lineno=18, col_offset=14, end_lineno=18, end_col_offset=52), lineno=18, col_offset=8, end_lineno=18, end_col_offset=52)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=52), Assign([Name('placeholder_11', Store(), lineno=20, col_offset=4, end_lineno=20, end_col_offset=9)], List([], Load(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=14), lineno=20, col_offset=4, end_lineno=20, end_col_offset=14), For(Name('placeholder_12', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=17), Name('placeholder_7', Load(), lineno=21, col_offset=21, end_lineno=21, end_col_offset=25), [If(Call(Attribute(Name('placeholder_12', Load(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=20), 'isalnum', Load(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=28), [], [], lineno=22, col_offset=11, end_lineno=22, end_col_offset=30), [Assign([Name('placeholder_13', Store(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=18)], BinOp(Call(Name('ord', Load(), lineno=23, col_offset=21, end_lineno=23, end_col_offset=24), [Call(Attribute(Name('placeholder_12', Load(), lineno=23, col_offset=25, end_lineno=23, end_col_offset=34), 'lower', Load(), lineno=23, col_offset=25, end_lineno=23, end_col_offset=40), [], [], lineno=23, col_offset=25, end_lineno=23, end_col_offset=42)], [], lineno=23, col_offset=21, end_lineno=23, end_col_offset=43), Sub(), Constant(97, lineno=23, col_offset=46, end_lineno=23, end_col_offset=48), lineno=23, col_offset=21, end_lineno=23, end_col_offset=48), lineno=23, col_offset=12, end_lineno=23, end_col_offset=48), If(Compare(Name('placeholder_13', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=21), [Lt()], [Constant(0, lineno=24, col_offset=24, end_lineno=24, end_col_offset=25)], lineno=24, col_offset=15, end_lineno=24, end_col_offset=25), [Expr(Call(Attribute(Name('placeholder_11', Load(), lineno=25, col_offset=16, end_lineno=25, end_col_offset=21), 'append', Load(), lineno=25, col_offset=16, end_lineno=25, end_col_offset=28), [Name('placeholder_12', Load(), lineno=25, col_offset=29, end_lineno=25, end_col_offset=38)], [], lineno=25, col_offset=16, end_lineno=25, end_col_offset=39), lineno=25, col_offset=16, end_lineno=25, end_col_offset=39), Continue(lineno=26, col_offset=16, end_lineno=26, end_col_offset=24)], [], lineno=24, col_offset=12, end_lineno=26, end_col_offset=24), If(Compare(Name('placeholder_9', Load(), lineno=27, col_offset=15, end_lineno=27, end_col_offset=19), [Eq()], [Constant(0, lineno=27, col_offset=23, end_lineno=27, end_col_offset=24)], lineno=27, col_offset=15, end_lineno=27, end_col_offset=24), [Assign([Name('placeholder_14', Store(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=19)], BinOp(BinOp(BinOp(Name('placeholder_3', Load(), lineno=28, col_offset=23, end_lineno=28, end_col_offset=28), Mult(), Name('placeholder_13', Load(), lineno=28, col_offset=31, end_lineno=28, end_col_offset=37), lineno=28, col_offset=23, end_lineno=28, end_col_offset=37), Add(), Name('placeholder_8', Load(), lineno=28, col_offset=40, end_lineno=28, end_col_offset=45), lineno=28, col_offset=23, end_lineno=28, end_col_offset=45), Mod(), Name('placeholder_1', Load(), lineno=28, col_offset=49, end_lineno=28, end_col_offset=57), lineno=28, col_offset=22, end_lineno=28, end_col_offset=57), lineno=28, col_offset=16, end_lineno=28, end_col_offset=57)], [If(Compare(Name('placeholder_9', Load(), lineno=29, col_offset=17, end_lineno=29, end_col_offset=21), [Eq()], [Constant(1, lineno=29, col_offset=25, end_lineno=29, end_col_offset=26)], lineno=29, col_offset=17, end_lineno=29, end_col_offset=26), [Assign([Name('placeholder_14', Store(), lineno=30, col_offset=16, end_lineno=30, end_col_offset=19)], BinOp(BinOp(Name('placeholder_10', Load(), lineno=30, col_offset=23, end_lineno=30, end_col_offset=30), Mult(), BinOp(Name('placeholder_13', Load(), lineno=30, col_offset=34, end_lineno=30, end_col_offset=40), Sub(), Name('placeholder_8', Load(), lineno=30, col_offset=43, end_lineno=30, end_col_offset=48), lineno=30, col_offset=34, end_lineno=30, end_col_offset=48), lineno=30, col_offset=23, end_lineno=30, end_col_offset=49), Mod(), Name('placeholder_1', Load(), lineno=30, col_offset=53, end_lineno=30, end_col_offset=61), lineno=30, col_offset=22, end_lineno=30, end_col_offset=61), lineno=30, col_offset=16, end_lineno=30, end_col_offset=61)], [], lineno=29, col_offset=12, end_lineno=30, end_col_offset=61)], lineno=27, col_offset=12, end_lineno=30, end_col_offset=61), Expr(Call(Attribute(Name('placeholder_11', Load(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=17), 'append', Load(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=24), [Call(Name('chr', Load(), lineno=31, col_offset=25, end_lineno=31, end_col_offset=28), [BinOp(Name('placeholder_14', Load(), lineno=31, col_offset=29, end_lineno=31, end_col_offset=32), Add(), Constant(97, lineno=31, col_offset=35, end_lineno=31, end_col_offset=37), lineno=31, col_offset=29, end_lineno=31, end_col_offset=37)], [], lineno=31, col_offset=25, end_lineno=31, end_col_offset=38)], [], lineno=31, col_offset=12, end_lineno=31, end_col_offset=39), lineno=31, col_offset=12, end_lineno=31, end_col_offset=39)], [], lineno=22, col_offset=8, end_lineno=31, end_col_offset=39)], [], lineno=21, col_offset=4, end_lineno=31, end_col_offset=39), Return(Call(Attribute(Constant('', lineno=33, col_offset=11, end_lineno=33, end_col_offset=13), 'join', Load(), lineno=33, col_offset=11, end_lineno=33, end_col_offset=18), [Name('placeholder_11', Load(), lineno=33, col_offset=19, end_lineno=33, end_col_offset=24)], [], lineno=33, col_offset=11, end_lineno=33, end_col_offset=25), lineno=33, col_offset=4, end_lineno=33, end_col_offset=25)], [], lineno=15, col_offset=0, end_lineno=33, end_col_offset=25), FunctionDef('placeholder_15', arguments([], [arg('placeholder_16', lineno=36, col_offset=11, end_lineno=36, end_col_offset=16), arg('placeholder_17', lineno=36, col_offset=18, end_lineno=36, end_col_offset=19), arg('placeholder_18', lineno=36, col_offset=21, end_lineno=36, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_19', Store(), lineno=37, col_offset=4, end_lineno=37, end_col_offset=10)], Call(Name('placeholder_6', Load(), lineno=37, col_offset=13, end_lineno=37, end_col_offset=22), [Name('placeholder_16', Load(), lineno=37, col_offset=23, end_lineno=37, end_col_offset=28), Name('placeholder_17', Load(), lineno=37, col_offset=30, end_lineno=37, end_col_offset=31), Name('placeholder_18', Load(), lineno=37, col_offset=33, end_lineno=37, end_col_offset=34), Constant(0, lineno=37, col_offset=36, end_lineno=37, end_col_offset=37)], [], lineno=37, col_offset=13, end_lineno=37, end_col_offset=38), lineno=37, col_offset=4, end_lineno=37, end_col_offset=38), Return(Call(Attribute(Constant(' ', lineno=38, col_offset=11, end_lineno=38, end_col_offset=14), 'join', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=19), [ListComp(Subscript(Name('placeholder_19', Load(), lineno=38, col_offset=21, end_lineno=38, end_col_offset=27), Slice(Name('placeholder_5', Load(), lineno=38, col_offset=28, end_lineno=38, end_col_offset=31), BinOp(Name('placeholder_5', Load(), lineno=38, col_offset=32, end_lineno=38, end_col_offset=35), Add(), Name('placeholder_0', Load(), lineno=38, col_offset=38, end_lineno=38, end_col_offset=48), lineno=38, col_offset=32, end_lineno=38, end_col_offset=48), lineno=38, col_offset=28, end_lineno=38, end_col_offset=48), Load(), lineno=38, col_offset=21, end_lineno=38, end_col_offset=49), [comprehension(Name('placeholder_5', Store(), lineno=39, col_offset=25, end_lineno=39, end_col_offset=28), Call(Name('range', Load(), lineno=39, col_offset=32, end_lineno=39, end_col_offset=37), [Constant(0, lineno=39, col_offset=38, end_lineno=39, end_col_offset=39), Call(Name('len', Load(), lineno=39, col_offset=41, end_lineno=39, end_col_offset=44), [Name('placeholder_19', Load(), lineno=39, col_offset=45, end_lineno=39, end_col_offset=51)], [], lineno=39, col_offset=41, end_lineno=39, end_col_offset=52), Name('placeholder_0', Load(), lineno=39, col_offset=54, end_lineno=39, end_col_offset=64)], [], lineno=39, col_offset=32, end_lineno=39, end_col_offset=65), [], 0)], lineno=38, col_offset=20, end_lineno=39, end_col_offset=66)], [], lineno=38, col_offset=11, end_lineno=39, end_col_offset=67), lineno=38, col_offset=4, end_lineno=39, end_col_offset=67)], [], lineno=36, col_offset=0, end_lineno=39, end_col_offset=67), FunctionDef('placeholder_20', arguments([], [arg('placeholder_21', lineno=42, col_offset=11, end_lineno=42, end_col_offset=19), arg('placeholder_17', lineno=42, col_offset=21, end_lineno=42, end_col_offset=22), arg('placeholder_18', lineno=42, col_offset=24, end_lineno=42, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_6', Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=20), [Name('placeholder_21', Load(), lineno=43, col_offset=21, end_lineno=43, end_col_offset=29), Name('placeholder_17', Load(), lineno=43, col_offset=31, end_lineno=43, end_col_offset=32), Name('placeholder_18', Load(), lineno=43, col_offset=34, end_lineno=43, end_col_offset=35), Constant(1, lineno=43, col_offset=37, end_lineno=43, end_col_offset=38)], [], lineno=43, col_offset=11, end_lineno=43, end_col_offset=39), lineno=43, col_offset=4, end_lineno=43, end_col_offset=39)], [], lineno=42, col_offset=0, end_lineno=43, end_col_offset=39)], []) \ No newline at end of file diff --git a/test/practice-all-your-base/.meta/config.json b/test/practice-all-your-base/.meta/config.json new file mode 100644 index 0000000..57499d1 --- /dev/null +++ b/test/practice-all-your-base/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "cmccandless", + "Dog", + "ikhadykin", + "N-Parsons", + "pywkm", + "smt923", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "all_your_base.py" + ], + "test": [ + "all_your_base_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Convert a number, represented as a sequence of digits in one base, to any other base." +} diff --git a/test/practice-all-your-base/all_your_base.py b/test/practice-all-your-base/all_your_base.py new file mode 100644 index 0000000..e493a50 --- /dev/null +++ b/test/practice-all-your-base/all_your_base.py @@ -0,0 +1,25 @@ +def from_digits(digits, base): + return sum(number * base ** idx for idx, number in enumerate(reversed(digits))) + + +def to_digits(number, base_to): + result = [] + while number > 0: + result.append(number % base_to) + number //= base_to + if result: + return result[::-1] # list(reversed(result)) + return [0] + + +def rebase(from_base, digits, to_base): + if from_base < 2: + raise ValueError("input base must be >= 2") + + if to_base < 2: + raise ValueError("output base must be >= 2") + + if any(True for idx in digits if idx < 0 or idx >= from_base): + raise ValueError("all digits must satisfy 0 <= d < input base") + + return to_digits(from_digits(digits, from_base), to_base) diff --git a/test/practice-all-your-base/mapping.json b/test/practice-all-your-base/mapping.json new file mode 100644 index 0000000..0172acf --- /dev/null +++ b/test/practice-all-your-base/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "from_digits", + "placeholder_1": "digits", + "placeholder_2": "base", + "placeholder_3": "idx", + "placeholder_4": "number", + "placeholder_5": "to_digits", + "placeholder_6": "base_to", + "placeholder_7": "result", + "placeholder_8": "rebase", + "placeholder_9": "from_base", + "placeholder_10": "to_base" +} \ No newline at end of file diff --git a/test/practice-all-your-base/representation.json b/test/practice-all-your-base/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-all-your-base/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-all-your-base/representation.out b/test/practice-all-your-base/representation.out new file mode 100644 index 0000000..7b4a506 --- /dev/null +++ b/test/practice-all-your-base/representation.out @@ -0,0 +1,1382 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return sum( + ( + placeholder_4 * placeholder_2**placeholder_3 + for placeholder_3, placeholder_4 in enumerate(reversed(placeholder_1)) + ) + ) + + +def placeholder_5(placeholder_4, placeholder_6): + placeholder_7 = [] + while placeholder_4 > 0: + placeholder_7.append(placeholder_4 % placeholder_6) + placeholder_4 //= placeholder_6 + if placeholder_7: + return placeholder_7[::-1] + return [0] + + +def placeholder_8(placeholder_9, placeholder_1, placeholder_10): + if placeholder_9 < 2: + raise ValueError("input base must be >= 2") + if placeholder_10 < 2: + raise ValueError("output base must be >= 2") + if any( + ( + True + for placeholder_3 in placeholder_1 + if placeholder_3 < 0 or placeholder_3 >= placeholder_9 + ) + ): + raise ValueError("all digits must satisfy 0 <= d < input base") + return placeholder_5(placeholder_0(placeholder_1, placeholder_9), placeholder_10) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'from_digits', + arguments( + [], + [ + arg( + 'digits', + lineno=1, + col_offset=16, + end_lineno=1, + end_col_offset=22), + arg( + 'base', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + GeneratorExp( + BinOp( + Name( + 'number', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=21), + Mult(), + BinOp( + Name( + 'base', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=28), + Pow(), + Name( + 'idx', + Load(), + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=35), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=35), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=35), + [ + comprehension( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=43), + Name( + 'number', + Store(), + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=51)], + Store(), + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=51), + Call( + Name( + 'enumerate', + Load(), + lineno=2, + col_offset=55, + end_lineno=2, + end_col_offset=64), + [ + Call( + Name( + 'reversed', + Load(), + lineno=2, + col_offset=65, + end_lineno=2, + end_col_offset=73), + [ + Name( + 'digits', + Load(), + lineno=2, + col_offset=74, + end_lineno=2, + end_col_offset=80)], + [], + lineno=2, + col_offset=65, + end_lineno=2, + end_col_offset=81)], + [], + lineno=2, + col_offset=55, + end_lineno=2, + end_col_offset=82), + [], + 0)], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=83)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=83), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=83)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=83), + FunctionDef( + 'to_digits', + arguments( + [], + [ + arg( + 'number', + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=20), + arg( + 'base_to', + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=10)], + List( + [], + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=15), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15), + While( + Compare( + Name( + 'number', + Load(), + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 0, + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=20)], + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=20), + [ + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=14), + 'append', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=21), + [ + BinOp( + Name( + 'number', + Load(), + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=28), + Mod(), + Name( + 'base_to', + Load(), + lineno=8, + col_offset=31, + end_lineno=8, + end_col_offset=38), + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=38)], + [], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=39), + AugAssign( + Name( + 'number', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=14), + FloorDiv(), + Name( + 'base_to', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=26), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=26)], + [], + lineno=7, + col_offset=4, + end_lineno=9, + end_col_offset=26), + If( + Name( + 'result', + Load(), + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=13), + [ + Return( + Subscript( + Name( + 'result', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=21), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=26), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=26), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=26), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=27), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=27)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=27), + Return( + List( + [ + Constant( + 0, + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=13)], + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=14), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=14)], + [], + lineno=5, + col_offset=0, + end_lineno=12, + end_col_offset=14), + FunctionDef( + 'rebase', + arguments( + [], + [ + arg( + 'from_base', + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=20), + arg( + 'digits', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=28), + arg( + 'to_base', + lineno=15, + col_offset=30, + end_lineno=15, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'from_base', + Load(), + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=16), + [ + Lt()], + [ + Constant( + 2, + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=20)], + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=17, + col_offset=14, + end_lineno=17, + end_col_offset=24), + [ + Constant( + 'input base must be >= 2', + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=50)], + [], + lineno=17, + col_offset=14, + end_lineno=17, + end_col_offset=51), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=51)], + [], + lineno=16, + col_offset=4, + end_lineno=17, + end_col_offset=51), + If( + Compare( + Name( + 'to_base', + Load(), + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=14), + [ + Lt()], + [ + Constant( + 2, + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=18)], + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=24), + [ + Constant( + 'output base must be >= 2', + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=51)], + [], + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=52), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=52)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=52), + If( + Call( + Name( + 'any', + Load(), + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=10), + [ + GeneratorExp( + Constant( + True, + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=15), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=23), + Name( + 'digits', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=33), + [ + BoolOp( + Or(), + [ + Compare( + Name( + 'idx', + Load(), + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=40), + [ + Lt()], + [ + Constant( + 0, + lineno=22, + col_offset=43, + end_lineno=22, + end_col_offset=44)], + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=44), + Compare( + Name( + 'idx', + Load(), + lineno=22, + col_offset=48, + end_lineno=22, + end_col_offset=51), + [ + GtE()], + [ + Name( + 'from_base', + Load(), + lineno=22, + col_offset=55, + end_lineno=22, + end_col_offset=64)], + lineno=22, + col_offset=48, + end_lineno=22, + end_col_offset=64)], + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=64)], + 0)], + lineno=22, + col_offset=10, + end_lineno=22, + end_col_offset=65)], + [], + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=65), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=24), + [ + Constant( + 'all digits must satisfy 0 <= d < input base', + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=70)], + [], + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=71), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=71)], + [], + lineno=22, + col_offset=4, + end_lineno=23, + end_col_offset=71), + Return( + Call( + Name( + 'to_digits', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=20), + [ + Call( + Name( + 'from_digits', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=32), + [ + Name( + 'digits', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=39), + Name( + 'from_base', + Load(), + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=50)], + [], + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=51), + Name( + 'to_base', + Load(), + lineno=25, + col_offset=53, + end_lineno=25, + end_col_offset=60)], + [], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=61), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=61)], + [], + lineno=15, + col_offset=0, + end_lineno=25, + end_col_offset=61)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=16, + end_lineno=1, + end_col_offset=22), + arg( + 'placeholder_2', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + GeneratorExp( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=21), + Mult(), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=28), + Pow(), + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=35), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=35), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=35), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=43), + Name( + 'placeholder_4', + Store(), + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=51)], + Store(), + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=51), + Call( + Name( + 'enumerate', + Load(), + lineno=2, + col_offset=55, + end_lineno=2, + end_col_offset=64), + [ + Call( + Name( + 'reversed', + Load(), + lineno=2, + col_offset=65, + end_lineno=2, + end_col_offset=73), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=74, + end_lineno=2, + end_col_offset=80)], + [], + lineno=2, + col_offset=65, + end_lineno=2, + end_col_offset=81)], + [], + lineno=2, + col_offset=55, + end_lineno=2, + end_col_offset=82), + [], + 0)], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=83)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=83), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=83)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=83), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=20), + arg( + 'placeholder_6', + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=10)], + List( + [], + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=15), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15), + While( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 0, + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=20)], + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=20), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=14), + 'append', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=21), + [ + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=28), + Mod(), + Name( + 'placeholder_6', + Load(), + lineno=8, + col_offset=31, + end_lineno=8, + end_col_offset=38), + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=38)], + [], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=39), + AugAssign( + Name( + 'placeholder_4', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=14), + FloorDiv(), + Name( + 'placeholder_6', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=26), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=26)], + [], + lineno=7, + col_offset=4, + end_lineno=9, + end_col_offset=26), + If( + Name( + 'placeholder_7', + Load(), + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=13), + [ + Return( + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=21), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=26), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=26), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=26), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=27), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=27)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=27), + Return( + List( + [ + Constant( + 0, + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=13)], + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=14), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=14)], + [], + lineno=5, + col_offset=0, + end_lineno=12, + end_col_offset=14), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'placeholder_9', + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=20), + arg( + 'placeholder_1', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=28), + arg( + 'placeholder_10', + lineno=15, + col_offset=30, + end_lineno=15, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=16), + [ + Lt()], + [ + Constant( + 2, + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=20)], + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=17, + col_offset=14, + end_lineno=17, + end_col_offset=24), + [ + Constant( + 'input base must be >= 2', + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=50)], + [], + lineno=17, + col_offset=14, + end_lineno=17, + end_col_offset=51), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=51)], + [], + lineno=16, + col_offset=4, + end_lineno=17, + end_col_offset=51), + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=14), + [ + Lt()], + [ + Constant( + 2, + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=18)], + lineno=19, + col_offset=7, + end_lineno=19, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=24), + [ + Constant( + 'output base must be >= 2', + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=51)], + [], + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=52), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=52)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=52), + If( + Call( + Name( + 'any', + Load(), + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=10), + [ + GeneratorExp( + Constant( + True, + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=15), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=23), + Name( + 'placeholder_1', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=33), + [ + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_3', + Load(), + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=40), + [ + Lt()], + [ + Constant( + 0, + lineno=22, + col_offset=43, + end_lineno=22, + end_col_offset=44)], + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=44), + Compare( + Name( + 'placeholder_3', + Load(), + lineno=22, + col_offset=48, + end_lineno=22, + end_col_offset=51), + [ + GtE()], + [ + Name( + 'placeholder_9', + Load(), + lineno=22, + col_offset=55, + end_lineno=22, + end_col_offset=64)], + lineno=22, + col_offset=48, + end_lineno=22, + end_col_offset=64)], + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=64)], + 0)], + lineno=22, + col_offset=10, + end_lineno=22, + end_col_offset=65)], + [], + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=65), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=24), + [ + Constant( + 'all digits must satisfy 0 <= d < input base', + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=70)], + [], + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=71), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=71)], + [], + lineno=22, + col_offset=4, + end_lineno=23, + end_col_offset=71), + Return( + Call( + Name( + 'placeholder_5', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=20), + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=32), + [ + Name( + 'placeholder_1', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=39), + Name( + 'placeholder_9', + Load(), + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=50)], + [], + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=51), + Name( + 'placeholder_10', + Load(), + lineno=25, + col_offset=53, + end_lineno=25, + end_col_offset=60)], + [], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=61), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=61)], + [], + lineno=15, + col_offset=0, + end_lineno=25, + end_col_offset=61)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-all-your-base/representation.txt b/test/practice-all-your-base/representation.txt new file mode 100644 index 0000000..315135e --- /dev/null +++ b/test/practice-all-your-base/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=16, end_lineno=1, end_col_offset=22), arg('placeholder_2', lineno=1, col_offset=24, end_lineno=1, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sum', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=14), [GeneratorExp(BinOp(Name('placeholder_4', Load(), lineno=2, col_offset=15, end_lineno=2, end_col_offset=21), Mult(), BinOp(Name('placeholder_2', Load(), lineno=2, col_offset=24, end_lineno=2, end_col_offset=28), Pow(), Name('placeholder_3', Load(), lineno=2, col_offset=32, end_lineno=2, end_col_offset=35), lineno=2, col_offset=24, end_lineno=2, end_col_offset=35), lineno=2, col_offset=15, end_lineno=2, end_col_offset=35), [comprehension(Tuple([Name('placeholder_3', Store(), lineno=2, col_offset=40, end_lineno=2, end_col_offset=43), Name('placeholder_4', Store(), lineno=2, col_offset=45, end_lineno=2, end_col_offset=51)], Store(), lineno=2, col_offset=40, end_lineno=2, end_col_offset=51), Call(Name('enumerate', Load(), lineno=2, col_offset=55, end_lineno=2, end_col_offset=64), [Call(Name('reversed', Load(), lineno=2, col_offset=65, end_lineno=2, end_col_offset=73), [Name('placeholder_1', Load(), lineno=2, col_offset=74, end_lineno=2, end_col_offset=80)], [], lineno=2, col_offset=65, end_lineno=2, end_col_offset=81)], [], lineno=2, col_offset=55, end_lineno=2, end_col_offset=82), [], 0)], lineno=2, col_offset=14, end_lineno=2, end_col_offset=83)], [], lineno=2, col_offset=11, end_lineno=2, end_col_offset=83), lineno=2, col_offset=4, end_lineno=2, end_col_offset=83)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=83), FunctionDef('placeholder_5', arguments([], [arg('placeholder_4', lineno=5, col_offset=14, end_lineno=5, end_col_offset=20), arg('placeholder_6', lineno=5, col_offset=22, end_lineno=5, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=10)], List([], Load(), lineno=6, col_offset=13, end_lineno=6, end_col_offset=15), lineno=6, col_offset=4, end_lineno=6, end_col_offset=15), While(Compare(Name('placeholder_4', Load(), lineno=7, col_offset=10, end_lineno=7, end_col_offset=16), [Gt()], [Constant(0, lineno=7, col_offset=19, end_lineno=7, end_col_offset=20)], lineno=7, col_offset=10, end_lineno=7, end_col_offset=20), [Expr(Call(Attribute(Name('placeholder_7', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=14), 'append', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=21), [BinOp(Name('placeholder_4', Load(), lineno=8, col_offset=22, end_lineno=8, end_col_offset=28), Mod(), Name('placeholder_6', Load(), lineno=8, col_offset=31, end_lineno=8, end_col_offset=38), lineno=8, col_offset=22, end_lineno=8, end_col_offset=38)], [], lineno=8, col_offset=8, end_lineno=8, end_col_offset=39), lineno=8, col_offset=8, end_lineno=8, end_col_offset=39), AugAssign(Name('placeholder_4', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=14), FloorDiv(), Name('placeholder_6', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=26), lineno=9, col_offset=8, end_lineno=9, end_col_offset=26)], [], lineno=7, col_offset=4, end_lineno=9, end_col_offset=26), If(Name('placeholder_7', Load(), lineno=10, col_offset=7, end_lineno=10, end_col_offset=13), [Return(Subscript(Name('placeholder_7', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=21), Slice(step=UnaryOp(USub(), Constant(1, lineno=11, col_offset=25, end_lineno=11, end_col_offset=26), lineno=11, col_offset=24, end_lineno=11, end_col_offset=26), lineno=11, col_offset=22, end_lineno=11, end_col_offset=26), Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=27), lineno=11, col_offset=8, end_lineno=11, end_col_offset=27)], [], lineno=10, col_offset=4, end_lineno=11, end_col_offset=27), Return(List([Constant(0, lineno=12, col_offset=12, end_lineno=12, end_col_offset=13)], Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=14), lineno=12, col_offset=4, end_lineno=12, end_col_offset=14)], [], lineno=5, col_offset=0, end_lineno=12, end_col_offset=14), FunctionDef('placeholder_8', arguments([], [arg('placeholder_9', lineno=15, col_offset=11, end_lineno=15, end_col_offset=20), arg('placeholder_1', lineno=15, col_offset=22, end_lineno=15, end_col_offset=28), arg('placeholder_10', lineno=15, col_offset=30, end_lineno=15, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_9', Load(), lineno=16, col_offset=7, end_lineno=16, end_col_offset=16), [Lt()], [Constant(2, lineno=16, col_offset=19, end_lineno=16, end_col_offset=20)], lineno=16, col_offset=7, end_lineno=16, end_col_offset=20), [Raise(Call(Name('ValueError', Load(), lineno=17, col_offset=14, end_lineno=17, end_col_offset=24), [Constant('input base must be >= 2', lineno=17, col_offset=25, end_lineno=17, end_col_offset=50)], [], lineno=17, col_offset=14, end_lineno=17, end_col_offset=51), lineno=17, col_offset=8, end_lineno=17, end_col_offset=51)], [], lineno=16, col_offset=4, end_lineno=17, end_col_offset=51), If(Compare(Name('placeholder_10', Load(), lineno=19, col_offset=7, end_lineno=19, end_col_offset=14), [Lt()], [Constant(2, lineno=19, col_offset=17, end_lineno=19, end_col_offset=18)], lineno=19, col_offset=7, end_lineno=19, end_col_offset=18), [Raise(Call(Name('ValueError', Load(), lineno=20, col_offset=14, end_lineno=20, end_col_offset=24), [Constant('output base must be >= 2', lineno=20, col_offset=25, end_lineno=20, end_col_offset=51)], [], lineno=20, col_offset=14, end_lineno=20, end_col_offset=52), lineno=20, col_offset=8, end_lineno=20, end_col_offset=52)], [], lineno=19, col_offset=4, end_lineno=20, end_col_offset=52), If(Call(Name('any', Load(), lineno=22, col_offset=7, end_lineno=22, end_col_offset=10), [GeneratorExp(Constant(True, lineno=22, col_offset=11, end_lineno=22, end_col_offset=15), [comprehension(Name('placeholder_3', Store(), lineno=22, col_offset=20, end_lineno=22, end_col_offset=23), Name('placeholder_1', Load(), lineno=22, col_offset=27, end_lineno=22, end_col_offset=33), [BoolOp(Or(), [Compare(Name('placeholder_3', Load(), lineno=22, col_offset=37, end_lineno=22, end_col_offset=40), [Lt()], [Constant(0, lineno=22, col_offset=43, end_lineno=22, end_col_offset=44)], lineno=22, col_offset=37, end_lineno=22, end_col_offset=44), Compare(Name('placeholder_3', Load(), lineno=22, col_offset=48, end_lineno=22, end_col_offset=51), [GtE()], [Name('placeholder_9', Load(), lineno=22, col_offset=55, end_lineno=22, end_col_offset=64)], lineno=22, col_offset=48, end_lineno=22, end_col_offset=64)], lineno=22, col_offset=37, end_lineno=22, end_col_offset=64)], 0)], lineno=22, col_offset=10, end_lineno=22, end_col_offset=65)], [], lineno=22, col_offset=7, end_lineno=22, end_col_offset=65), [Raise(Call(Name('ValueError', Load(), lineno=23, col_offset=14, end_lineno=23, end_col_offset=24), [Constant('all digits must satisfy 0 <= d < input base', lineno=23, col_offset=25, end_lineno=23, end_col_offset=70)], [], lineno=23, col_offset=14, end_lineno=23, end_col_offset=71), lineno=23, col_offset=8, end_lineno=23, end_col_offset=71)], [], lineno=22, col_offset=4, end_lineno=23, end_col_offset=71), Return(Call(Name('placeholder_5', Load(), lineno=25, col_offset=11, end_lineno=25, end_col_offset=20), [Call(Name('placeholder_0', Load(), lineno=25, col_offset=21, end_lineno=25, end_col_offset=32), [Name('placeholder_1', Load(), lineno=25, col_offset=33, end_lineno=25, end_col_offset=39), Name('placeholder_9', Load(), lineno=25, col_offset=41, end_lineno=25, end_col_offset=50)], [], lineno=25, col_offset=21, end_lineno=25, end_col_offset=51), Name('placeholder_10', Load(), lineno=25, col_offset=53, end_lineno=25, end_col_offset=60)], [], lineno=25, col_offset=11, end_lineno=25, end_col_offset=61), lineno=25, col_offset=4, end_lineno=25, end_col_offset=61)], [], lineno=15, col_offset=0, end_lineno=25, end_col_offset=61)], []) \ No newline at end of file diff --git a/test/practice-allergies/.meta/config.json b/test/practice-allergies/.meta/config.json new file mode 100644 index 0000000..b918bdb --- /dev/null +++ b/test/practice-allergies/.meta/config.json @@ -0,0 +1,35 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "iandexter", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "olufotebig", + "pheanex", + "spencer51324312", + "thomasjpfan", + "tqa236", + "ZacharyRSmith" + ], + "files": { + "solution": [ + "allergies.py" + ], + "test": [ + "allergies_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.", + "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", + "source_url": "https://turing.edu" +} diff --git a/test/practice-allergies/allergies.py b/test/practice-allergies/allergies.py new file mode 100644 index 0000000..44298c9 --- /dev/null +++ b/test/practice-allergies/allergies.py @@ -0,0 +1,23 @@ +class Allergies: + + _allergies = [ + "eggs", + "peanuts", + "shellfish", + "strawberries", + "tomatoes", + "chocolate", + "pollen", + "cats" + ] + + def __init__(self, score): + self.score = score + + def allergic_to(self, item): + return bool(self.score & 1 << self._allergies.index(item)) + + @property + def lst(self): + return [allergy for allergy in self._allergies + if self.allergic_to(allergy)] diff --git a/test/practice-allergies/mapping.json b/test/practice-allergies/mapping.json new file mode 100644 index 0000000..4650b1c --- /dev/null +++ b/test/practice-allergies/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "Allergies", + "placeholder_1": "_allergies", + "placeholder_2": "__init__", + "placeholder_3": "score", + "placeholder_4": "allergic_to", + "placeholder_5": "item", + "placeholder_6": "lst", + "placeholder_7": "allergy" +} \ No newline at end of file diff --git a/test/practice-allergies/representation.json b/test/practice-allergies/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-allergies/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-allergies/representation.out b/test/practice-allergies/representation.out new file mode 100644 index 0000000..ad08680 --- /dev/null +++ b/test/practice-allergies/representation.out @@ -0,0 +1,720 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + placeholder_1 = [ + "eggs", + "peanuts", + "shellfish", + "strawberries", + "tomatoes", + "chocolate", + "pollen", + "cats", + ] + + def placeholder_2(self, placeholder_3): + self.placeholder_3 = placeholder_3 + + def placeholder_4(self, placeholder_5): + return bool(self.placeholder_3 & 1 << self.placeholder_1.index(placeholder_5)) + + @property + def placeholder_6(self): + return [ + placeholder_7 + for placeholder_7 in self.placeholder_1 + if self.placeholder_4(placeholder_7) + ] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Allergies', + [], + [], + [ + Assign( + [ + Name( + '_allergies', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=14)], + List( + [ + Constant( + 'eggs', + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=14), + Constant( + 'peanuts', + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17), + Constant( + 'shellfish', + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=19), + Constant( + 'strawberries', + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=22), + Constant( + 'tomatoes', + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=18), + Constant( + 'chocolate', + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=19), + Constant( + 'pollen', + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=16), + Constant( + 'cats', + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=14)], + Load(), + lineno=3, + col_offset=17, + end_lineno=12, + end_col_offset=5), + lineno=3, + col_offset=4, + end_lineno=12, + end_col_offset=5), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'score', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + 'score', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=18)], + Name( + 'score', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=26), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=26)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=26), + FunctionDef( + 'allergic_to', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=20, + end_lineno=17, + end_col_offset=24), + arg( + 'item', + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'bool', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=24), + 'score', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=30), + BitAnd(), + BinOp( + Constant( + 1, + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=34), + LShift(), + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=42), + '_allergies', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=53), + 'index', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=59), + [ + Name( + 'item', + Load(), + lineno=18, + col_offset=60, + end_lineno=18, + end_col_offset=64)], + [], + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=65), + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=65), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=65)], + [], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=66), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=66)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=66), + FunctionDef( + 'lst', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'allergy', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=23), + [ + comprehension( + Name( + 'allergy', + Store(), + lineno=22, + col_offset=28, + end_lineno=22, + end_col_offset=35), + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=43), + '_allergies', + Load(), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=54), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=23), + 'allergic_to', + Load(), + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=35), + [ + Name( + 'allergy', + Load(), + lineno=23, + col_offset=36, + end_lineno=23, + end_col_offset=43)], + [], + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=44)], + 0)], + lineno=22, + col_offset=15, + end_lineno=23, + end_col_offset=45), + lineno=22, + col_offset=8, + end_lineno=23, + end_col_offset=45)], + [ + Name( + 'property', + Load(), + lineno=20, + col_offset=5, + end_lineno=20, + end_col_offset=13)], + lineno=21, + col_offset=4, + end_lineno=23, + end_col_offset=45)], + [], + lineno=1, + col_offset=0, + end_lineno=23, + end_col_offset=45)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=14)], + List( + [ + Constant( + 'eggs', + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=14), + Constant( + 'peanuts', + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17), + Constant( + 'shellfish', + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=19), + Constant( + 'strawberries', + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=22), + Constant( + 'tomatoes', + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=18), + Constant( + 'chocolate', + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=19), + Constant( + 'pollen', + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=16), + Constant( + 'cats', + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=14)], + Load(), + lineno=3, + col_offset=17, + end_lineno=12, + end_col_offset=5), + lineno=3, + col_offset=4, + end_lineno=12, + end_col_offset=5), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'placeholder_3', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=18)], + Name( + 'placeholder_3', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=26), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=26)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=26), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=20, + end_lineno=17, + end_col_offset=24), + arg( + 'placeholder_5', + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'bool', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=24), + 'placeholder_3', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=30), + BitAnd(), + BinOp( + Constant( + 1, + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=34), + LShift(), + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=42), + 'placeholder_1', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=53), + 'index', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=59), + [ + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=60, + end_lineno=18, + end_col_offset=64)], + [], + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=65), + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=65), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=65)], + [], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=66), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=66)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=66), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'placeholder_7', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=23), + [ + comprehension( + Name( + 'placeholder_7', + Store(), + lineno=22, + col_offset=28, + end_lineno=22, + end_col_offset=35), + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=43), + 'placeholder_1', + Load(), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=54), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=23), + 'placeholder_4', + Load(), + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=35), + [ + Name( + 'placeholder_7', + Load(), + lineno=23, + col_offset=36, + end_lineno=23, + end_col_offset=43)], + [], + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=44)], + 0)], + lineno=22, + col_offset=15, + end_lineno=23, + end_col_offset=45), + lineno=22, + col_offset=8, + end_lineno=23, + end_col_offset=45)], + [ + Name( + 'property', + Load(), + lineno=20, + col_offset=5, + end_lineno=20, + end_col_offset=13)], + lineno=21, + col_offset=4, + end_lineno=23, + end_col_offset=45)], + [], + lineno=1, + col_offset=0, + end_lineno=23, + end_col_offset=45)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-allergies/representation.txt b/test/practice-allergies/representation.txt new file mode 100644 index 0000000..870620e --- /dev/null +++ b/test/practice-allergies/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [Assign([Name('placeholder_1', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=14)], List([Constant('eggs', lineno=4, col_offset=8, end_lineno=4, end_col_offset=14), Constant('peanuts', lineno=5, col_offset=8, end_lineno=5, end_col_offset=17), Constant('shellfish', lineno=6, col_offset=8, end_lineno=6, end_col_offset=19), Constant('strawberries', lineno=7, col_offset=8, end_lineno=7, end_col_offset=22), Constant('tomatoes', lineno=8, col_offset=8, end_lineno=8, end_col_offset=18), Constant('chocolate', lineno=9, col_offset=8, end_lineno=9, end_col_offset=19), Constant('pollen', lineno=10, col_offset=8, end_lineno=10, end_col_offset=16), Constant('cats', lineno=11, col_offset=8, end_lineno=11, end_col_offset=14)], Load(), lineno=3, col_offset=17, end_lineno=12, end_col_offset=5), lineno=3, col_offset=4, end_lineno=12, end_col_offset=5), FunctionDef('placeholder_2', arguments([], [arg('self', lineno=14, col_offset=17, end_lineno=14, end_col_offset=21), arg('placeholder_3', lineno=14, col_offset=23, end_lineno=14, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=12), 'placeholder_3', Store(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=18)], Name('placeholder_3', Load(), lineno=15, col_offset=21, end_lineno=15, end_col_offset=26), lineno=15, col_offset=8, end_lineno=15, end_col_offset=26)], [], lineno=14, col_offset=4, end_lineno=15, end_col_offset=26), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=17, col_offset=20, end_lineno=17, end_col_offset=24), arg('placeholder_5', lineno=17, col_offset=26, end_lineno=17, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('bool', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=19), [BinOp(Attribute(Name('self', Load(), lineno=18, col_offset=20, end_lineno=18, end_col_offset=24), 'placeholder_3', Load(), lineno=18, col_offset=20, end_lineno=18, end_col_offset=30), BitAnd(), BinOp(Constant(1, lineno=18, col_offset=33, end_lineno=18, end_col_offset=34), LShift(), Call(Attribute(Attribute(Name('self', Load(), lineno=18, col_offset=38, end_lineno=18, end_col_offset=42), 'placeholder_1', Load(), lineno=18, col_offset=38, end_lineno=18, end_col_offset=53), 'index', Load(), lineno=18, col_offset=38, end_lineno=18, end_col_offset=59), [Name('placeholder_5', Load(), lineno=18, col_offset=60, end_lineno=18, end_col_offset=64)], [], lineno=18, col_offset=38, end_lineno=18, end_col_offset=65), lineno=18, col_offset=33, end_lineno=18, end_col_offset=65), lineno=18, col_offset=20, end_lineno=18, end_col_offset=65)], [], lineno=18, col_offset=15, end_lineno=18, end_col_offset=66), lineno=18, col_offset=8, end_lineno=18, end_col_offset=66)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=66), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=21, col_offset=12, end_lineno=21, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Name('placeholder_7', Load(), lineno=22, col_offset=16, end_lineno=22, end_col_offset=23), [comprehension(Name('placeholder_7', Store(), lineno=22, col_offset=28, end_lineno=22, end_col_offset=35), Attribute(Name('self', Load(), lineno=22, col_offset=39, end_lineno=22, end_col_offset=43), 'placeholder_1', Load(), lineno=22, col_offset=39, end_lineno=22, end_col_offset=54), [Call(Attribute(Name('self', Load(), lineno=23, col_offset=19, end_lineno=23, end_col_offset=23), 'placeholder_4', Load(), lineno=23, col_offset=19, end_lineno=23, end_col_offset=35), [Name('placeholder_7', Load(), lineno=23, col_offset=36, end_lineno=23, end_col_offset=43)], [], lineno=23, col_offset=19, end_lineno=23, end_col_offset=44)], 0)], lineno=22, col_offset=15, end_lineno=23, end_col_offset=45), lineno=22, col_offset=8, end_lineno=23, end_col_offset=45)], [Name('property', Load(), lineno=20, col_offset=5, end_lineno=20, end_col_offset=13)], lineno=21, col_offset=4, end_lineno=23, end_col_offset=45)], [], lineno=1, col_offset=0, end_lineno=23, end_col_offset=45)], []) \ No newline at end of file diff --git a/test/practice-alphametics/.meta/config.json b/test/practice-alphametics/.meta/config.json new file mode 100644 index 0000000..38bc5e3 --- /dev/null +++ b/test/practice-alphametics/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "iandexter", + "ikhadykin", + "N-Parsons", + "nikamirrr", + "rfuentescruz", + "sukovanej", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "alphametics.py" + ], + "test": [ + "alphametics_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "test_runner": false, + "blurb": "Write a function to solve alphametics puzzles." +} diff --git a/test/practice-alphametics/alphametics.py b/test/practice-alphametics/alphametics.py new file mode 100644 index 0000000..3faf17a --- /dev/null +++ b/test/practice-alphametics/alphametics.py @@ -0,0 +1,177 @@ +""" +This solution will first parse the alphametic expression +grouping and counting letters buy digit ranks +then trace recursively all possible permutations starting from +the lowest rank and genrating additional permutations for new digits +at higer ranks as necessary. +This will allow to avoid unnecessarily large permutations to scan. +Also leading letters in words will be treated as non-zero digits only +to reduce the number of permutations +""" + +from itertools import permutations, chain, product + + +def dig_perms(digit_set, non_zero_chars, ok_zero_chars): + """This function creates permutations given the set of digits, + letters not alllowed to be 0, and letters allowed to be 0 + """ + non_zero_count = len(non_zero_chars) # How many letters are non-0 + ok_zero_count = len(ok_zero_chars) # How many letters are allowed 0 + total_count = non_zero_count + ok_zero_count # Total number of letters + if total_count < 1: # if total numbers of letters is 0 + return [()] # return a singe empty permutation + non_zero_digit_set = digit_set - set((0,)) # generate a non-zero digit set + available_zero_digit_count = len(non_zero_digit_set) # how many non-zero digits are available + ok_zero_digit_count = len(digit_set) # how many ok zero digits are available + # if either fewer digits than letters at all or fewer non-0 digits + # than letters that need to be non-zero + if ok_zero_digit_count < total_count or available_zero_digit_count < non_zero_count: + return [] # Return no permutations possible + # Simple case when zeros are allowed everwhere + # or no zero is containted within the given digits + elif non_zero_count == 0 or ok_zero_digit_count == available_zero_digit_count: + return permutations(digit_set, total_count) + # Another simple case all letters are non-0 + elif ok_zero_count == 0: + return permutations(non_zero_digit_set, total_count) + else: + # General case + # Generate a list of possible 0 positions + positions_list = list(range(non_zero_count, total_count)) + # Chain two iterators + # first iterator with all non-0 permutations + # second iterator with all permulations without 1 letter + # insert 0 in all possible positions of that permutation + return chain(permutations(non_zero_digit_set, total_count), + map(lambda iters: iters[0][:iters[1]] + (0,) + iters[0][iters[1]:], + product(permutations(non_zero_digit_set, total_count - 1), + positions_list))) + + +def check_rec(eqparams, trace_combo=({}, 0, set(range(10))), power=0): + """This function recursively traces a parsed expression from lowest + digits to highest, generating additional digits when necessary + checking the digit sum is divisible by 10, carrying the multiple of 10 + up to the next level + """ + # Basic parameters of the equation, + # maximal digit rank + # characters with multipliers by rank + # unique non-zero characters by rank + # unique zero-allowed characters by rank + # all unique characters by rank + max_digit_rank, multipliers_chars, non_zero_chars, zero_chars, unique_chars = eqparams + # recursion cumulative parameters + # established characters with digits + # carry-over from the previous level + # remaining unassigned digits + prev_digits, carry_over, remaining_digits = trace_combo + # the maximal 10-power (beyond the maximal rank) + # is reached + if power == max_digit_rank: + # Carry-over is zero, meaning solution is found + if carry_over == 0: + return prev_digits + else: + # Otherwise the solution in this branch is not found + # return empty + return {} + digit_letters = unique_chars[power] # all new unique letters from the current level + part_sum = carry_over # Carry over from lower level + remaining_exp = [] # TBD letters + # Break down the current level letter into what can be + # calculated in the partial sum and remaining TBD letter-digits + for caesar, van_gogh in multipliers_chars[power]: + if caesar in prev_digits: + part_sum += van_gogh * prev_digits[caesar] + else: + remaining_exp.append((caesar, van_gogh)) + # Generate permutations for the remaining digits and currecnt level + # non-zero letters and zero-allowed letters + for newdigs in dig_perms(remaining_digits, non_zero_chars[power], zero_chars[power]): + # build the dictionary for the new letters and this level + new_dict = dict(zip(digit_letters, newdigs)) + # complete the partial sum into test sum using the current permutation + testsum = part_sum + sum([new_dict[caesar] * van_gogh + for caesar, van_gogh in remaining_exp]) + # check if the sum is divisible by 10 + dali, rembrandt = divmod(testsum, 10) + if rembrandt == 0: + # if divisible, update the dictionary to all established + new_dict.update(prev_digits) + # proceed to the next level of recursion with + # the same eqparams, but updated digit dictionary, + # new carry over and remaining digits to assign + recurring_test = check_rec(eqparams, + (new_dict, dali, remaining_digits - set(newdigs)), + power + 1) + # if the recursive call returned a non-empty dictionary + # this means the recursion has found a solution + # otherwise, proceed to the new permutation + if recurring_test and len(recurring_test) > 0: + return recurring_test + # if no permutations are avaialble or no + # permutation gave the result return None + return None + + +def solve(puzzle): + """A function to solve the alphametics problem + """ + # First, split the expresion into left and right parts by == + # split each part into words by + + # strip spaces fro, each word, reverse each work to + # enumerate the digit rank from lower to higer + full_exp = [list(map(lambda idx: list(reversed(idx.strip())), sigmund.split('+'))) + for sigmund in puzzle.strip().upper().split('==')] + # Find the maximal lenght of the work, maximal possive digit rank or + # the power of 10, should the < maxp + max_digit_rank = max([len(warhol) for sigmund in full_exp for warhol in sigmund]) + # Extract the leading letters for each (reversed) word + # those cannot be zeros as the number cannot start with 0 + nzchars = {warhol[-1] for sigmund in full_exp for warhol in sigmund} + # initialize the lists for digit ranks + non_zero_chars = [] # non-zero letters unique at level + zero_chars = [] # zero-allowed letters unique at level + unique_chars = [] # all letters unique at level + multipliers_chars = [] # all letter with multipliers per level + for _ in range(max_digit_rank): + multipliers_chars.append({}) + non_zero_chars.append(set()) + zero_chars.append(set()) + # Now lets scan the expression and accumulate the letter counts + for idx, sigmund in enumerate(full_exp): + bob = 1 - (idx << 1) # left side (0) is +1, right right (1) is -1 + for warhol in sigmund: # for each word in the side (already reversed) + for picasso, escher in enumerate(warhol): # enumerate with ranks + if escher not in multipliers_chars[picasso]: # check if the letter was alread there + multipliers_chars[picasso][escher] = 0 + multipliers_chars[picasso][escher] += bob # append to the rank dictionary + + total_chars = set() # Keep track of letters already seen at lower ranks + # go through the accumulated rank dictionaries + for picasso, chardict in enumerate(multipliers_chars): + for caesar, cnt in tuple(chardict.items()): + if cnt == 0: # if the cumulative is 0 + del chardict[caesar] # remove the letter from check dictionry + # it does not impact the sum with 0-multiplier + # if the letter contributes to the sum + # and was not yet seen at lower ranks + elif caesar not in total_chars: + # add the letter to either non-zero set + # or allowed-zero set + if caesar in nzchars: + non_zero_chars[picasso].add(caesar) + else: + zero_chars[picasso].add(caesar) + # add to the list as seen letter to ignore at the next + # ranks + total_chars.add(caesar) + # pre-build the combo list of letters for the rank + # non-zero first, followed by zero-allowed + unique_chars.append(tuple(non_zero_chars[picasso]) + tuple(zero_chars[picasso])) + # pre-convert check dictionaries to tuples + multipliers_chars[picasso] = tuple(chardict.items()) + # go for the recursion + return check_rec([max_digit_rank, multipliers_chars, non_zero_chars, zero_chars, unique_chars]) diff --git a/test/practice-alphametics/mapping.json b/test/practice-alphametics/mapping.json new file mode 100644 index 0000000..c352368 --- /dev/null +++ b/test/practice-alphametics/mapping.json @@ -0,0 +1,51 @@ +{ + "placeholder_0": "dig_perms", + "placeholder_1": "digit_set", + "placeholder_2": "non_zero_chars", + "placeholder_3": "ok_zero_chars", + "placeholder_4": "non_zero_count", + "placeholder_5": "ok_zero_count", + "placeholder_6": "total_count", + "placeholder_7": "non_zero_digit_set", + "placeholder_8": "available_zero_digit_count", + "placeholder_9": "ok_zero_digit_count", + "placeholder_10": "positions_list", + "placeholder_11": "iters", + "placeholder_12": "check_rec", + "placeholder_13": "eqparams", + "placeholder_14": "trace_combo", + "placeholder_15": "power", + "placeholder_16": "max_digit_rank", + "placeholder_17": "multipliers_chars", + "placeholder_18": "zero_chars", + "placeholder_19": "unique_chars", + "placeholder_20": "prev_digits", + "placeholder_21": "carry_over", + "placeholder_22": "remaining_digits", + "placeholder_23": "digit_letters", + "placeholder_24": "part_sum", + "placeholder_25": "remaining_exp", + "placeholder_26": "caesar", + "placeholder_27": "van_gogh", + "placeholder_28": "newdigs", + "placeholder_29": "new_dict", + "placeholder_30": "testsum", + "placeholder_31": "dali", + "placeholder_32": "rembrandt", + "placeholder_33": "recurring_test", + "placeholder_34": "solve", + "placeholder_35": "puzzle", + "placeholder_36": "full_exp", + "placeholder_37": "idx", + "placeholder_38": "sigmund", + "placeholder_39": "placeholder_37", + "placeholder_40": "warhol", + "placeholder_41": "nzchars", + "placeholder_42": "_", + "placeholder_43": "bob", + "placeholder_44": "picasso", + "placeholder_45": "escher", + "placeholder_46": "total_chars", + "placeholder_47": "chardict", + "placeholder_48": "cnt" +} \ No newline at end of file diff --git a/test/practice-alphametics/representation.json b/test/practice-alphametics/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-alphametics/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-alphametics/representation.out b/test/practice-alphametics/representation.out new file mode 100644 index 0000000..e990515 --- /dev/null +++ b/test/practice-alphametics/representation.out @@ -0,0 +1,7056 @@ +## BEGIN NORMALIZED CODE ## +from itertools import permutations, chain, product + + +def placeholder_0(placeholder_1, placeholder_2, placeholder_3): + placeholder_4 = len(placeholder_2) + placeholder_5 = len(placeholder_3) + placeholder_6 = placeholder_4 + placeholder_5 + if placeholder_6 < 1: + return [()] + placeholder_7 = placeholder_1 - set((0,)) + placeholder_8 = len(placeholder_7) + placeholder_9 = len(placeholder_1) + if placeholder_9 < placeholder_6 or placeholder_8 < placeholder_4: + return [] + elif placeholder_4 == 0 or placeholder_9 == placeholder_8: + return permutations(placeholder_1, placeholder_6) + elif placeholder_5 == 0: + return permutations(placeholder_7, placeholder_6) + else: + placeholder_10 = list(range(placeholder_4, placeholder_6)) + return chain( + permutations(placeholder_7, placeholder_6), + map( + lambda placeholder_11: placeholder_11[0][: placeholder_11[1]] + + (0,) + + placeholder_11[0][placeholder_11[1] :], + product(permutations(placeholder_7, placeholder_6 - 1), placeholder_10), + ), + ) + + +def placeholder_12( + placeholder_13, placeholder_14=({}, 0, set(range(10))), placeholder_15=0 +): + ( + placeholder_16, + placeholder_17, + placeholder_2, + placeholder_18, + placeholder_19, + ) = placeholder_13 + placeholder_20, placeholder_21, placeholder_22 = placeholder_14 + if placeholder_15 == placeholder_16: + if placeholder_21 == 0: + return placeholder_20 + else: + return {} + placeholder_23 = placeholder_19[placeholder_15] + placeholder_24 = placeholder_21 + placeholder_25 = [] + for placeholder_26, placeholder_27 in placeholder_17[placeholder_15]: + if placeholder_26 in placeholder_20: + placeholder_24 += placeholder_27 * placeholder_20[placeholder_26] + else: + placeholder_25.append((placeholder_26, placeholder_27)) + for placeholder_28 in placeholder_0( + placeholder_22, placeholder_2[placeholder_15], placeholder_18[placeholder_15] + ): + placeholder_29 = dict(zip(placeholder_23, placeholder_28)) + placeholder_30 = placeholder_24 + sum( + [ + placeholder_29[placeholder_26] * placeholder_27 + for placeholder_26, placeholder_27 in placeholder_25 + ] + ) + placeholder_31, placeholder_32 = divmod(placeholder_30, 10) + if placeholder_32 == 0: + placeholder_29.update(placeholder_20) + placeholder_33 = placeholder_12( + placeholder_13, + (placeholder_29, placeholder_31, placeholder_22 - set(placeholder_28)), + placeholder_15 + 1, + ) + if placeholder_33 and len(placeholder_33) > 0: + return placeholder_33 + return None + + +def placeholder_34(placeholder_35): + placeholder_36 = [ + list( + map( + lambda placeholder_39: list(reversed(placeholder_39.strip())), + placeholder_38.split("+"), + ) + ) + for placeholder_38 in placeholder_35.strip().upper().split("==") + ] + placeholder_16 = max( + [ + len(placeholder_40) + for placeholder_38 in placeholder_36 + for placeholder_40 in placeholder_38 + ] + ) + placeholder_41 = { + placeholder_40[-1] + for placeholder_38 in placeholder_36 + for placeholder_40 in placeholder_38 + } + placeholder_2 = [] + placeholder_18 = [] + placeholder_19 = [] + placeholder_17 = [] + for placeholder_42 in range(placeholder_16): + placeholder_17.append({}) + placeholder_2.append(set()) + placeholder_18.append(set()) + for placeholder_37, placeholder_38 in enumerate(placeholder_36): + placeholder_43 = 1 - (placeholder_37 << 1) + for placeholder_40 in placeholder_38: + for placeholder_44, placeholder_45 in enumerate(placeholder_40): + if placeholder_45 not in placeholder_17[placeholder_44]: + placeholder_17[placeholder_44][placeholder_45] = 0 + placeholder_17[placeholder_44][placeholder_45] += placeholder_43 + placeholder_46 = set() + for placeholder_44, placeholder_47 in enumerate(placeholder_17): + for placeholder_26, placeholder_48 in tuple(placeholder_47.items()): + if placeholder_48 == 0: + del placeholder_47[placeholder_26] + elif placeholder_26 not in placeholder_46: + if placeholder_26 in placeholder_41: + placeholder_2[placeholder_44].add(placeholder_26) + else: + placeholder_18[placeholder_44].add(placeholder_26) + placeholder_46.add(placeholder_26) + placeholder_19.append( + tuple(placeholder_2[placeholder_44]) + tuple(placeholder_18[placeholder_44]) + ) + placeholder_17[placeholder_44] = tuple(placeholder_47.items()) + return placeholder_12( + [placeholder_16, placeholder_17, placeholder_2, placeholder_18, placeholder_19] + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + '\nThis solution will first parse the alphametic expression\ngrouping and counting letters buy digit ranks\nthen trace recursively all possible permutations starting from\nthe lowest rank and genrating additional permutations for new digits\nat higer ranks as necessary.\nThis will allow to avoid unnecessarily large permutations to scan.\nAlso leading letters in words will be treated as non-zero digits only\nto reduce the number of permutations\n', + lineno=1, + col_offset=0, + end_lineno=10, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=10, + end_col_offset=3), + ImportFrom( + 'itertools', + [ + alias( + 'permutations', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=34), + alias( + 'chain', + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=41), + alias( + 'product', + lineno=12, + col_offset=43, + end_lineno=12, + end_col_offset=50)], + 0, + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=50), + FunctionDef( + 'dig_perms', + arguments( + [], + [ + arg( + 'digit_set', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=23), + arg( + 'non_zero_chars', + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=39), + arg( + 'ok_zero_chars', + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=54)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'This function creates permutations given the set of digits,\n letters not alllowed to be 0, and letters allowed to be 0\n ', + lineno=16, + col_offset=4, + end_lineno=18, + end_col_offset=7), + lineno=16, + col_offset=4, + end_lineno=18, + end_col_offset=7), + Assign( + [ + Name( + 'non_zero_count', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=18)], + Call( + Name( + 'len', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=24), + [ + Name( + 'non_zero_chars', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=39)], + [], + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=40), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=40), + Assign( + [ + Name( + 'ok_zero_count', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=17)], + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=23), + [ + Name( + 'ok_zero_chars', + Load(), + lineno=20, + col_offset=24, + end_lineno=20, + end_col_offset=37)], + [], + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=38), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=38), + Assign( + [ + Name( + 'total_count', + Store(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=15)], + BinOp( + Name( + 'non_zero_count', + Load(), + lineno=21, + col_offset=18, + end_lineno=21, + end_col_offset=32), + Add(), + Name( + 'ok_zero_count', + Load(), + lineno=21, + col_offset=35, + end_lineno=21, + end_col_offset=48), + lineno=21, + col_offset=18, + end_lineno=21, + end_col_offset=48), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=48), + If( + Compare( + Name( + 'total_count', + Load(), + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=18), + [ + Lt()], + [ + Constant( + 1, + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=22)], + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=22), + [ + Return( + List( + [ + Tuple( + [], + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=18)], + Load(), + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=19), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=19)], + [], + lineno=22, + col_offset=4, + end_lineno=23, + end_col_offset=19), + Assign( + [ + Name( + 'non_zero_digit_set', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=22)], + BinOp( + Name( + 'digit_set', + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=34), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=24, + col_offset=37, + end_lineno=24, + end_col_offset=40), + [ + Tuple( + [ + Constant( + 0, + lineno=24, + col_offset=42, + end_lineno=24, + end_col_offset=43)], + Load(), + lineno=24, + col_offset=41, + end_lineno=24, + end_col_offset=45)], + [], + lineno=24, + col_offset=37, + end_lineno=24, + end_col_offset=46), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=46), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=46), + Assign( + [ + Name( + 'available_zero_digit_count', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=30)], + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=36), + [ + Name( + 'non_zero_digit_set', + Load(), + lineno=25, + col_offset=37, + end_lineno=25, + end_col_offset=55)], + [], + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=56), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=56), + Assign( + [ + Name( + 'ok_zero_digit_count', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=23)], + Call( + Name( + 'len', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=29), + [ + Name( + 'digit_set', + Load(), + lineno=26, + col_offset=30, + end_lineno=26, + end_col_offset=39)], + [], + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=40), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=40), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'ok_zero_digit_count', + Load(), + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=26), + [ + Lt()], + [ + Name( + 'total_count', + Load(), + lineno=29, + col_offset=29, + end_lineno=29, + end_col_offset=40)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=40), + Compare( + Name( + 'available_zero_digit_count', + Load(), + lineno=29, + col_offset=44, + end_lineno=29, + end_col_offset=70), + [ + Lt()], + [ + Name( + 'non_zero_count', + Load(), + lineno=29, + col_offset=73, + end_lineno=29, + end_col_offset=87)], + lineno=29, + col_offset=44, + end_lineno=29, + end_col_offset=87)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=87), + [ + Return( + List( + [], + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=17), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=17)], + [ + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'non_zero_count', + Load(), + lineno=33, + col_offset=9, + end_lineno=33, + end_col_offset=23), + [ + Eq()], + [ + Constant( + 0, + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=28)], + lineno=33, + col_offset=9, + end_lineno=33, + end_col_offset=28), + Compare( + Name( + 'ok_zero_digit_count', + Load(), + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=51), + [ + Eq()], + [ + Name( + 'available_zero_digit_count', + Load(), + lineno=33, + col_offset=55, + end_lineno=33, + end_col_offset=81)], + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=81)], + lineno=33, + col_offset=9, + end_lineno=33, + end_col_offset=81), + [ + Return( + Call( + Name( + 'permutations', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=27), + [ + Name( + 'digit_set', + Load(), + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=37), + Name( + 'total_count', + Load(), + lineno=34, + col_offset=39, + end_lineno=34, + end_col_offset=50)], + [], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=51), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=51)], + [ + If( + Compare( + Name( + 'ok_zero_count', + Load(), + lineno=36, + col_offset=9, + end_lineno=36, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=36, + col_offset=26, + end_lineno=36, + end_col_offset=27)], + lineno=36, + col_offset=9, + end_lineno=36, + end_col_offset=27), + [ + Return( + Call( + Name( + 'permutations', + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=27), + [ + Name( + 'non_zero_digit_set', + Load(), + lineno=37, + col_offset=28, + end_lineno=37, + end_col_offset=46), + Name( + 'total_count', + Load(), + lineno=37, + col_offset=48, + end_lineno=37, + end_col_offset=59)], + [], + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=60), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=60)], + [ + Assign( + [ + Name( + 'positions_list', + Store(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=22)], + Call( + Name( + 'list', + Load(), + lineno=41, + col_offset=25, + end_lineno=41, + end_col_offset=29), + [ + Call( + Name( + 'range', + Load(), + lineno=41, + col_offset=30, + end_lineno=41, + end_col_offset=35), + [ + Name( + 'non_zero_count', + Load(), + lineno=41, + col_offset=36, + end_lineno=41, + end_col_offset=50), + Name( + 'total_count', + Load(), + lineno=41, + col_offset=52, + end_lineno=41, + end_col_offset=63)], + [], + lineno=41, + col_offset=30, + end_lineno=41, + end_col_offset=64)], + [], + lineno=41, + col_offset=25, + end_lineno=41, + end_col_offset=65), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=65), + Return( + Call( + Name( + 'chain', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=20), + [ + Call( + Name( + 'permutations', + Load(), + lineno=46, + col_offset=21, + end_lineno=46, + end_col_offset=33), + [ + Name( + 'non_zero_digit_set', + Load(), + lineno=46, + col_offset=34, + end_lineno=46, + end_col_offset=52), + Name( + 'total_count', + Load(), + lineno=46, + col_offset=54, + end_lineno=46, + end_col_offset=65)], + [], + lineno=46, + col_offset=21, + end_lineno=46, + end_col_offset=66), + Call( + Name( + 'map', + Load(), + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=24), + [ + Lambda( + arguments( + [], + [ + arg( + 'iters', + lineno=47, + col_offset=32, + end_lineno=47, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + BinOp( + BinOp( + Subscript( + Subscript( + Name( + 'iters', + Load(), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=44), + Constant( + 0, + lineno=47, + col_offset=45, + end_lineno=47, + end_col_offset=46), + Load(), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=47), + Slice( + upper=Subscript( + Name( + 'iters', + Load(), + lineno=47, + col_offset=49, + end_lineno=47, + end_col_offset=54), + Constant( + 1, + lineno=47, + col_offset=55, + end_lineno=47, + end_col_offset=56), + Load(), + lineno=47, + col_offset=49, + end_lineno=47, + end_col_offset=57), + lineno=47, + col_offset=48, + end_lineno=47, + end_col_offset=57), + Load(), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=58), + Add(), + Tuple( + [ + Constant( + 0, + lineno=47, + col_offset=62, + end_lineno=47, + end_col_offset=63)], + Load(), + lineno=47, + col_offset=61, + end_lineno=47, + end_col_offset=65), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=65), + Add(), + Subscript( + Subscript( + Name( + 'iters', + Load(), + lineno=47, + col_offset=68, + end_lineno=47, + end_col_offset=73), + Constant( + 0, + lineno=47, + col_offset=74, + end_lineno=47, + end_col_offset=75), + Load(), + lineno=47, + col_offset=68, + end_lineno=47, + end_col_offset=76), + Slice( + Subscript( + Name( + 'iters', + Load(), + lineno=47, + col_offset=77, + end_lineno=47, + end_col_offset=82), + Constant( + 1, + lineno=47, + col_offset=83, + end_lineno=47, + end_col_offset=84), + Load(), + lineno=47, + col_offset=77, + end_lineno=47, + end_col_offset=85), + lineno=47, + col_offset=77, + end_lineno=47, + end_col_offset=86), + Load(), + lineno=47, + col_offset=68, + end_lineno=47, + end_col_offset=87), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=87), + lineno=47, + col_offset=25, + end_lineno=47, + end_col_offset=87), + Call( + Name( + 'product', + Load(), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=32), + [ + Call( + Name( + 'permutations', + Load(), + lineno=48, + col_offset=33, + end_lineno=48, + end_col_offset=45), + [ + Name( + 'non_zero_digit_set', + Load(), + lineno=48, + col_offset=46, + end_lineno=48, + end_col_offset=64), + BinOp( + Name( + 'total_count', + Load(), + lineno=48, + col_offset=66, + end_lineno=48, + end_col_offset=77), + Sub(), + Constant( + 1, + lineno=48, + col_offset=80, + end_lineno=48, + end_col_offset=81), + lineno=48, + col_offset=66, + end_lineno=48, + end_col_offset=81)], + [], + lineno=48, + col_offset=33, + end_lineno=48, + end_col_offset=82), + Name( + 'positions_list', + Load(), + lineno=49, + col_offset=33, + end_lineno=49, + end_col_offset=47)], + [], + lineno=48, + col_offset=25, + end_lineno=49, + end_col_offset=48)], + [], + lineno=47, + col_offset=21, + end_lineno=49, + end_col_offset=49)], + [], + lineno=46, + col_offset=15, + end_lineno=49, + end_col_offset=50), + lineno=46, + col_offset=8, + end_lineno=49, + end_col_offset=50)], + lineno=36, + col_offset=4, + end_lineno=49, + end_col_offset=50)], + lineno=33, + col_offset=4, + end_lineno=49, + end_col_offset=50)], + lineno=29, + col_offset=4, + end_lineno=49, + end_col_offset=50)], + [], + lineno=15, + col_offset=0, + end_lineno=49, + end_col_offset=50), + FunctionDef( + 'check_rec', + arguments( + [], + [ + arg( + 'eqparams', + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=22), + arg( + 'trace_combo', + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=35), + arg( + 'power', + lineno=52, + col_offset=61, + end_lineno=52, + end_col_offset=66)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Tuple( + [ + Dict( + [], + [], + lineno=52, + col_offset=37, + end_lineno=52, + end_col_offset=39), + Constant( + 0, + lineno=52, + col_offset=41, + end_lineno=52, + end_col_offset=42), + Call( + Name( + 'set', + Load(), + lineno=52, + col_offset=44, + end_lineno=52, + end_col_offset=47), + [ + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=48, + end_lineno=52, + end_col_offset=53), + [ + Constant( + 10, + lineno=52, + col_offset=54, + end_lineno=52, + end_col_offset=56)], + [], + lineno=52, + col_offset=48, + end_lineno=52, + end_col_offset=57)], + [], + lineno=52, + col_offset=44, + end_lineno=52, + end_col_offset=58)], + Load(), + lineno=52, + col_offset=36, + end_lineno=52, + end_col_offset=59), + Constant( + 0, + lineno=52, + col_offset=67, + end_lineno=52, + end_col_offset=68)]), + [ + Expr( + Constant( + 'This function recursively traces a parsed expression from lowest\n digits to highest, generating additional digits when necessary\n checking the digit sum is divisible by 10, carrying the multiple of 10\n up to the next level\n ', + lineno=53, + col_offset=4, + end_lineno=57, + end_col_offset=7), + lineno=53, + col_offset=4, + end_lineno=57, + end_col_offset=7), + Assign( + [ + Tuple( + [ + Name( + 'max_digit_rank', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=18), + Name( + 'multipliers_chars', + Store(), + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=37), + Name( + 'non_zero_chars', + Store(), + lineno=64, + col_offset=39, + end_lineno=64, + end_col_offset=53), + Name( + 'zero_chars', + Store(), + lineno=64, + col_offset=55, + end_lineno=64, + end_col_offset=65), + Name( + 'unique_chars', + Store(), + lineno=64, + col_offset=67, + end_lineno=64, + end_col_offset=79)], + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=79)], + Name( + 'eqparams', + Load(), + lineno=64, + col_offset=82, + end_lineno=64, + end_col_offset=90), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=90), + Assign( + [ + Tuple( + [ + Name( + 'prev_digits', + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=15), + Name( + 'carry_over', + Store(), + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=27), + Name( + 'remaining_digits', + Store(), + lineno=69, + col_offset=29, + end_lineno=69, + end_col_offset=45)], + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=45)], + Name( + 'trace_combo', + Load(), + lineno=69, + col_offset=48, + end_lineno=69, + end_col_offset=59), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=59), + If( + Compare( + Name( + 'power', + Load(), + lineno=72, + col_offset=7, + end_lineno=72, + end_col_offset=12), + [ + Eq()], + [ + Name( + 'max_digit_rank', + Load(), + lineno=72, + col_offset=16, + end_lineno=72, + end_col_offset=30)], + lineno=72, + col_offset=7, + end_lineno=72, + end_col_offset=30), + [ + If( + Compare( + Name( + 'carry_over', + Load(), + lineno=74, + col_offset=11, + end_lineno=74, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 0, + lineno=74, + col_offset=25, + end_lineno=74, + end_col_offset=26)], + lineno=74, + col_offset=11, + end_lineno=74, + end_col_offset=26), + [ + Return( + Name( + 'prev_digits', + Load(), + lineno=75, + col_offset=19, + end_lineno=75, + end_col_offset=30), + lineno=75, + col_offset=12, + end_lineno=75, + end_col_offset=30)], + [ + Return( + Dict( + [], + [], + lineno=79, + col_offset=19, + end_lineno=79, + end_col_offset=21), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=21)], + lineno=74, + col_offset=8, + end_lineno=79, + end_col_offset=21)], + [], + lineno=72, + col_offset=4, + end_lineno=79, + end_col_offset=21), + Assign( + [ + Name( + 'digit_letters', + Store(), + lineno=80, + col_offset=4, + end_lineno=80, + end_col_offset=17)], + Subscript( + Name( + 'unique_chars', + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=32), + Name( + 'power', + Load(), + lineno=80, + col_offset=33, + end_lineno=80, + end_col_offset=38), + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=39), + lineno=80, + col_offset=4, + end_lineno=80, + end_col_offset=39), + Assign( + [ + Name( + 'part_sum', + Store(), + lineno=81, + col_offset=4, + end_lineno=81, + end_col_offset=12)], + Name( + 'carry_over', + Load(), + lineno=81, + col_offset=15, + end_lineno=81, + end_col_offset=25), + lineno=81, + col_offset=4, + end_lineno=81, + end_col_offset=25), + Assign( + [ + Name( + 'remaining_exp', + Store(), + lineno=82, + col_offset=4, + end_lineno=82, + end_col_offset=17)], + List( + [], + Load(), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=22), + lineno=82, + col_offset=4, + end_lineno=82, + end_col_offset=22), + For( + Tuple( + [ + Name( + 'caesar', + Store(), + lineno=85, + col_offset=8, + end_lineno=85, + end_col_offset=14), + Name( + 'van_gogh', + Store(), + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=24)], + Store(), + lineno=85, + col_offset=8, + end_lineno=85, + end_col_offset=24), + Subscript( + Name( + 'multipliers_chars', + Load(), + lineno=85, + col_offset=28, + end_lineno=85, + end_col_offset=45), + Name( + 'power', + Load(), + lineno=85, + col_offset=46, + end_lineno=85, + end_col_offset=51), + Load(), + lineno=85, + col_offset=28, + end_lineno=85, + end_col_offset=52), + [ + If( + Compare( + Name( + 'caesar', + Load(), + lineno=86, + col_offset=11, + end_lineno=86, + end_col_offset=17), + [ + In()], + [ + Name( + 'prev_digits', + Load(), + lineno=86, + col_offset=21, + end_lineno=86, + end_col_offset=32)], + lineno=86, + col_offset=11, + end_lineno=86, + end_col_offset=32), + [ + AugAssign( + Name( + 'part_sum', + Store(), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=20), + Add(), + BinOp( + Name( + 'van_gogh', + Load(), + lineno=87, + col_offset=24, + end_lineno=87, + end_col_offset=32), + Mult(), + Subscript( + Name( + 'prev_digits', + Load(), + lineno=87, + col_offset=35, + end_lineno=87, + end_col_offset=46), + Name( + 'caesar', + Load(), + lineno=87, + col_offset=47, + end_lineno=87, + end_col_offset=53), + Load(), + lineno=87, + col_offset=35, + end_lineno=87, + end_col_offset=54), + lineno=87, + col_offset=24, + end_lineno=87, + end_col_offset=54), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=54)], + [ + Expr( + Call( + Attribute( + Name( + 'remaining_exp', + Load(), + lineno=89, + col_offset=12, + end_lineno=89, + end_col_offset=25), + 'append', + Load(), + lineno=89, + col_offset=12, + end_lineno=89, + end_col_offset=32), + [ + Tuple( + [ + Name( + 'caesar', + Load(), + lineno=89, + col_offset=34, + end_lineno=89, + end_col_offset=40), + Name( + 'van_gogh', + Load(), + lineno=89, + col_offset=42, + end_lineno=89, + end_col_offset=50)], + Load(), + lineno=89, + col_offset=33, + end_lineno=89, + end_col_offset=51)], + [], + lineno=89, + col_offset=12, + end_lineno=89, + end_col_offset=52), + lineno=89, + col_offset=12, + end_lineno=89, + end_col_offset=52)], + lineno=86, + col_offset=8, + end_lineno=89, + end_col_offset=52)], + [], + lineno=85, + col_offset=4, + end_lineno=89, + end_col_offset=52), + For( + Name( + 'newdigs', + Store(), + lineno=92, + col_offset=8, + end_lineno=92, + end_col_offset=15), + Call( + Name( + 'dig_perms', + Load(), + lineno=92, + col_offset=19, + end_lineno=92, + end_col_offset=28), + [ + Name( + 'remaining_digits', + Load(), + lineno=92, + col_offset=29, + end_lineno=92, + end_col_offset=45), + Subscript( + Name( + 'non_zero_chars', + Load(), + lineno=92, + col_offset=47, + end_lineno=92, + end_col_offset=61), + Name( + 'power', + Load(), + lineno=92, + col_offset=62, + end_lineno=92, + end_col_offset=67), + Load(), + lineno=92, + col_offset=47, + end_lineno=92, + end_col_offset=68), + Subscript( + Name( + 'zero_chars', + Load(), + lineno=92, + col_offset=70, + end_lineno=92, + end_col_offset=80), + Name( + 'power', + Load(), + lineno=92, + col_offset=81, + end_lineno=92, + end_col_offset=86), + Load(), + lineno=92, + col_offset=70, + end_lineno=92, + end_col_offset=87)], + [], + lineno=92, + col_offset=19, + end_lineno=92, + end_col_offset=88), + [ + Assign( + [ + Name( + 'new_dict', + Store(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=16)], + Call( + Name( + 'dict', + Load(), + lineno=94, + col_offset=19, + end_lineno=94, + end_col_offset=23), + [ + Call( + Name( + 'zip', + Load(), + lineno=94, + col_offset=24, + end_lineno=94, + end_col_offset=27), + [ + Name( + 'digit_letters', + Load(), + lineno=94, + col_offset=28, + end_lineno=94, + end_col_offset=41), + Name( + 'newdigs', + Load(), + lineno=94, + col_offset=43, + end_lineno=94, + end_col_offset=50)], + [], + lineno=94, + col_offset=24, + end_lineno=94, + end_col_offset=51)], + [], + lineno=94, + col_offset=19, + end_lineno=94, + end_col_offset=52), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=52), + Assign( + [ + Name( + 'testsum', + Store(), + lineno=96, + col_offset=8, + end_lineno=96, + end_col_offset=15)], + BinOp( + Name( + 'part_sum', + Load(), + lineno=96, + col_offset=18, + end_lineno=96, + end_col_offset=26), + Add(), + Call( + Name( + 'sum', + Load(), + lineno=96, + col_offset=29, + end_lineno=96, + end_col_offset=32), + [ + ListComp( + BinOp( + Subscript( + Name( + 'new_dict', + Load(), + lineno=96, + col_offset=34, + end_lineno=96, + end_col_offset=42), + Name( + 'caesar', + Load(), + lineno=96, + col_offset=43, + end_lineno=96, + end_col_offset=49), + Load(), + lineno=96, + col_offset=34, + end_lineno=96, + end_col_offset=50), + Mult(), + Name( + 'van_gogh', + Load(), + lineno=96, + col_offset=53, + end_lineno=96, + end_col_offset=61), + lineno=96, + col_offset=34, + end_lineno=96, + end_col_offset=61), + [ + comprehension( + Tuple( + [ + Name( + 'caesar', + Store(), + lineno=97, + col_offset=37, + end_lineno=97, + end_col_offset=43), + Name( + 'van_gogh', + Store(), + lineno=97, + col_offset=45, + end_lineno=97, + end_col_offset=53)], + Store(), + lineno=97, + col_offset=37, + end_lineno=97, + end_col_offset=53), + Name( + 'remaining_exp', + Load(), + lineno=97, + col_offset=57, + end_lineno=97, + end_col_offset=70), + [], + 0)], + lineno=96, + col_offset=33, + end_lineno=97, + end_col_offset=71)], + [], + lineno=96, + col_offset=29, + end_lineno=97, + end_col_offset=72), + lineno=96, + col_offset=18, + end_lineno=97, + end_col_offset=72), + lineno=96, + col_offset=8, + end_lineno=97, + end_col_offset=72), + Assign( + [ + Tuple( + [ + Name( + 'dali', + Store(), + lineno=99, + col_offset=8, + end_lineno=99, + end_col_offset=12), + Name( + 'rembrandt', + Store(), + lineno=99, + col_offset=14, + end_lineno=99, + end_col_offset=23)], + Store(), + lineno=99, + col_offset=8, + end_lineno=99, + end_col_offset=23)], + Call( + Name( + 'divmod', + Load(), + lineno=99, + col_offset=26, + end_lineno=99, + end_col_offset=32), + [ + Name( + 'testsum', + Load(), + lineno=99, + col_offset=33, + end_lineno=99, + end_col_offset=40), + Constant( + 10, + lineno=99, + col_offset=42, + end_lineno=99, + end_col_offset=44)], + [], + lineno=99, + col_offset=26, + end_lineno=99, + end_col_offset=45), + lineno=99, + col_offset=8, + end_lineno=99, + end_col_offset=45), + If( + Compare( + Name( + 'rembrandt', + Load(), + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 0, + lineno=100, + col_offset=24, + end_lineno=100, + end_col_offset=25)], + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=25), + [ + Expr( + Call( + Attribute( + Name( + 'new_dict', + Load(), + lineno=102, + col_offset=12, + end_lineno=102, + end_col_offset=20), + 'update', + Load(), + lineno=102, + col_offset=12, + end_lineno=102, + end_col_offset=27), + [ + Name( + 'prev_digits', + Load(), + lineno=102, + col_offset=28, + end_lineno=102, + end_col_offset=39)], + [], + lineno=102, + col_offset=12, + end_lineno=102, + end_col_offset=40), + lineno=102, + col_offset=12, + end_lineno=102, + end_col_offset=40), + Assign( + [ + Name( + 'recurring_test', + Store(), + lineno=106, + col_offset=12, + end_lineno=106, + end_col_offset=26)], + Call( + Name( + 'check_rec', + Load(), + lineno=106, + col_offset=29, + end_lineno=106, + end_col_offset=38), + [ + Name( + 'eqparams', + Load(), + lineno=106, + col_offset=39, + end_lineno=106, + end_col_offset=47), + Tuple( + [ + Name( + 'new_dict', + Load(), + lineno=107, + col_offset=33, + end_lineno=107, + end_col_offset=41), + Name( + 'dali', + Load(), + lineno=107, + col_offset=43, + end_lineno=107, + end_col_offset=47), + BinOp( + Name( + 'remaining_digits', + Load(), + lineno=107, + col_offset=49, + end_lineno=107, + end_col_offset=65), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=107, + col_offset=68, + end_lineno=107, + end_col_offset=71), + [ + Name( + 'newdigs', + Load(), + lineno=107, + col_offset=72, + end_lineno=107, + end_col_offset=79)], + [], + lineno=107, + col_offset=68, + end_lineno=107, + end_col_offset=80), + lineno=107, + col_offset=49, + end_lineno=107, + end_col_offset=80)], + Load(), + lineno=107, + col_offset=32, + end_lineno=107, + end_col_offset=81), + BinOp( + Name( + 'power', + Load(), + lineno=108, + col_offset=32, + end_lineno=108, + end_col_offset=37), + Add(), + Constant( + 1, + lineno=108, + col_offset=40, + end_lineno=108, + end_col_offset=41), + lineno=108, + col_offset=32, + end_lineno=108, + end_col_offset=41)], + [], + lineno=106, + col_offset=29, + end_lineno=108, + end_col_offset=42), + lineno=106, + col_offset=12, + end_lineno=108, + end_col_offset=42), + If( + BoolOp( + And(), + [ + Name( + 'recurring_test', + Load(), + lineno=112, + col_offset=15, + end_lineno=112, + end_col_offset=29), + Compare( + Call( + Name( + 'len', + Load(), + lineno=112, + col_offset=34, + end_lineno=112, + end_col_offset=37), + [ + Name( + 'recurring_test', + Load(), + lineno=112, + col_offset=38, + end_lineno=112, + end_col_offset=52)], + [], + lineno=112, + col_offset=34, + end_lineno=112, + end_col_offset=53), + [ + Gt()], + [ + Constant( + 0, + lineno=112, + col_offset=56, + end_lineno=112, + end_col_offset=57)], + lineno=112, + col_offset=34, + end_lineno=112, + end_col_offset=57)], + lineno=112, + col_offset=15, + end_lineno=112, + end_col_offset=57), + [ + Return( + Name( + 'recurring_test', + Load(), + lineno=113, + col_offset=23, + end_lineno=113, + end_col_offset=37), + lineno=113, + col_offset=16, + end_lineno=113, + end_col_offset=37)], + [], + lineno=112, + col_offset=12, + end_lineno=113, + end_col_offset=37)], + [], + lineno=100, + col_offset=8, + end_lineno=113, + end_col_offset=37)], + [], + lineno=92, + col_offset=4, + end_lineno=113, + end_col_offset=37), + Return( + Constant( + None, + lineno=116, + col_offset=11, + end_lineno=116, + end_col_offset=15), + lineno=116, + col_offset=4, + end_lineno=116, + end_col_offset=15)], + [], + lineno=52, + col_offset=0, + end_lineno=116, + end_col_offset=15), + FunctionDef( + 'solve', + arguments( + [], + [ + arg( + 'puzzle', + lineno=119, + col_offset=10, + end_lineno=119, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'A function to solve the alphametics problem\n ', + lineno=120, + col_offset=4, + end_lineno=121, + end_col_offset=7), + lineno=120, + col_offset=4, + end_lineno=121, + end_col_offset=7), + Assign( + [ + Name( + 'full_exp', + Store(), + lineno=126, + col_offset=4, + end_lineno=126, + end_col_offset=12)], + ListComp( + Call( + Name( + 'list', + Load(), + lineno=126, + col_offset=16, + end_lineno=126, + end_col_offset=20), + [ + Call( + Name( + 'map', + Load(), + lineno=126, + col_offset=21, + end_lineno=126, + end_col_offset=24), + [ + Lambda( + arguments( + [], + [ + arg( + 'idx', + lineno=126, + col_offset=32, + end_lineno=126, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'list', + Load(), + lineno=126, + col_offset=37, + end_lineno=126, + end_col_offset=41), + [ + Call( + Name( + 'reversed', + Load(), + lineno=126, + col_offset=42, + end_lineno=126, + end_col_offset=50), + [ + Call( + Attribute( + Name( + 'idx', + Load(), + lineno=126, + col_offset=51, + end_lineno=126, + end_col_offset=54), + 'strip', + Load(), + lineno=126, + col_offset=51, + end_lineno=126, + end_col_offset=60), + [], + [], + lineno=126, + col_offset=51, + end_lineno=126, + end_col_offset=62)], + [], + lineno=126, + col_offset=42, + end_lineno=126, + end_col_offset=63)], + [], + lineno=126, + col_offset=37, + end_lineno=126, + end_col_offset=64), + lineno=126, + col_offset=25, + end_lineno=126, + end_col_offset=64), + Call( + Attribute( + Name( + 'sigmund', + Load(), + lineno=126, + col_offset=66, + end_lineno=126, + end_col_offset=73), + 'split', + Load(), + lineno=126, + col_offset=66, + end_lineno=126, + end_col_offset=79), + [ + Constant( + '+', + lineno=126, + col_offset=80, + end_lineno=126, + end_col_offset=83)], + [], + lineno=126, + col_offset=66, + end_lineno=126, + end_col_offset=84)], + [], + lineno=126, + col_offset=21, + end_lineno=126, + end_col_offset=85)], + [], + lineno=126, + col_offset=16, + end_lineno=126, + end_col_offset=86), + [ + comprehension( + Name( + 'sigmund', + Store(), + lineno=127, + col_offset=19, + end_lineno=127, + end_col_offset=26), + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Name( + 'puzzle', + Load(), + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=36), + 'strip', + Load(), + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=42), + [], + [], + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=44), + 'upper', + Load(), + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=50), + [], + [], + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=52), + 'split', + Load(), + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=58), + [ + Constant( + '==', + lineno=127, + col_offset=59, + end_lineno=127, + end_col_offset=63)], + [], + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=64), + [], + 0)], + lineno=126, + col_offset=15, + end_lineno=127, + end_col_offset=65), + lineno=126, + col_offset=4, + end_lineno=127, + end_col_offset=65), + Assign( + [ + Name( + 'max_digit_rank', + Store(), + lineno=130, + col_offset=4, + end_lineno=130, + end_col_offset=18)], + Call( + Name( + 'max', + Load(), + lineno=130, + col_offset=21, + end_lineno=130, + end_col_offset=24), + [ + ListComp( + Call( + Name( + 'len', + Load(), + lineno=130, + col_offset=26, + end_lineno=130, + end_col_offset=29), + [ + Name( + 'warhol', + Load(), + lineno=130, + col_offset=30, + end_lineno=130, + end_col_offset=36)], + [], + lineno=130, + col_offset=26, + end_lineno=130, + end_col_offset=37), + [ + comprehension( + Name( + 'sigmund', + Store(), + lineno=130, + col_offset=42, + end_lineno=130, + end_col_offset=49), + Name( + 'full_exp', + Load(), + lineno=130, + col_offset=53, + end_lineno=130, + end_col_offset=61), + [], + 0), + comprehension( + Name( + 'warhol', + Store(), + lineno=130, + col_offset=66, + end_lineno=130, + end_col_offset=72), + Name( + 'sigmund', + Load(), + lineno=130, + col_offset=76, + end_lineno=130, + end_col_offset=83), + [], + 0)], + lineno=130, + col_offset=25, + end_lineno=130, + end_col_offset=84)], + [], + lineno=130, + col_offset=21, + end_lineno=130, + end_col_offset=85), + lineno=130, + col_offset=4, + end_lineno=130, + end_col_offset=85), + Assign( + [ + Name( + 'nzchars', + Store(), + lineno=133, + col_offset=4, + end_lineno=133, + end_col_offset=11)], + SetComp( + Subscript( + Name( + 'warhol', + Load(), + lineno=133, + col_offset=15, + end_lineno=133, + end_col_offset=21), + UnaryOp( + USub(), + Constant( + 1, + lineno=133, + col_offset=23, + end_lineno=133, + end_col_offset=24), + lineno=133, + col_offset=22, + end_lineno=133, + end_col_offset=24), + Load(), + lineno=133, + col_offset=15, + end_lineno=133, + end_col_offset=25), + [ + comprehension( + Name( + 'sigmund', + Store(), + lineno=133, + col_offset=30, + end_lineno=133, + end_col_offset=37), + Name( + 'full_exp', + Load(), + lineno=133, + col_offset=41, + end_lineno=133, + end_col_offset=49), + [], + 0), + comprehension( + Name( + 'warhol', + Store(), + lineno=133, + col_offset=54, + end_lineno=133, + end_col_offset=60), + Name( + 'sigmund', + Load(), + lineno=133, + col_offset=64, + end_lineno=133, + end_col_offset=71), + [], + 0)], + lineno=133, + col_offset=14, + end_lineno=133, + end_col_offset=72), + lineno=133, + col_offset=4, + end_lineno=133, + end_col_offset=72), + Assign( + [ + Name( + 'non_zero_chars', + Store(), + lineno=135, + col_offset=4, + end_lineno=135, + end_col_offset=18)], + List( + [], + Load(), + lineno=135, + col_offset=21, + end_lineno=135, + end_col_offset=23), + lineno=135, + col_offset=4, + end_lineno=135, + end_col_offset=23), + Assign( + [ + Name( + 'zero_chars', + Store(), + lineno=136, + col_offset=4, + end_lineno=136, + end_col_offset=14)], + List( + [], + Load(), + lineno=136, + col_offset=17, + end_lineno=136, + end_col_offset=19), + lineno=136, + col_offset=4, + end_lineno=136, + end_col_offset=19), + Assign( + [ + Name( + 'unique_chars', + Store(), + lineno=137, + col_offset=4, + end_lineno=137, + end_col_offset=16)], + List( + [], + Load(), + lineno=137, + col_offset=19, + end_lineno=137, + end_col_offset=21), + lineno=137, + col_offset=4, + end_lineno=137, + end_col_offset=21), + Assign( + [ + Name( + 'multipliers_chars', + Store(), + lineno=138, + col_offset=4, + end_lineno=138, + end_col_offset=21)], + List( + [], + Load(), + lineno=138, + col_offset=24, + end_lineno=138, + end_col_offset=26), + lineno=138, + col_offset=4, + end_lineno=138, + end_col_offset=26), + For( + Name( + '_', + Store(), + lineno=139, + col_offset=8, + end_lineno=139, + end_col_offset=9), + Call( + Name( + 'range', + Load(), + lineno=139, + col_offset=13, + end_lineno=139, + end_col_offset=18), + [ + Name( + 'max_digit_rank', + Load(), + lineno=139, + col_offset=19, + end_lineno=139, + end_col_offset=33)], + [], + lineno=139, + col_offset=13, + end_lineno=139, + end_col_offset=34), + [ + Expr( + Call( + Attribute( + Name( + 'multipliers_chars', + Load(), + lineno=140, + col_offset=8, + end_lineno=140, + end_col_offset=25), + 'append', + Load(), + lineno=140, + col_offset=8, + end_lineno=140, + end_col_offset=32), + [ + Dict( + [], + [], + lineno=140, + col_offset=33, + end_lineno=140, + end_col_offset=35)], + [], + lineno=140, + col_offset=8, + end_lineno=140, + end_col_offset=36), + lineno=140, + col_offset=8, + end_lineno=140, + end_col_offset=36), + Expr( + Call( + Attribute( + Name( + 'non_zero_chars', + Load(), + lineno=141, + col_offset=8, + end_lineno=141, + end_col_offset=22), + 'append', + Load(), + lineno=141, + col_offset=8, + end_lineno=141, + end_col_offset=29), + [ + Call( + Name( + 'set', + Load(), + lineno=141, + col_offset=30, + end_lineno=141, + end_col_offset=33), + [], + [], + lineno=141, + col_offset=30, + end_lineno=141, + end_col_offset=35)], + [], + lineno=141, + col_offset=8, + end_lineno=141, + end_col_offset=36), + lineno=141, + col_offset=8, + end_lineno=141, + end_col_offset=36), + Expr( + Call( + Attribute( + Name( + 'zero_chars', + Load(), + lineno=142, + col_offset=8, + end_lineno=142, + end_col_offset=18), + 'append', + Load(), + lineno=142, + col_offset=8, + end_lineno=142, + end_col_offset=25), + [ + Call( + Name( + 'set', + Load(), + lineno=142, + col_offset=26, + end_lineno=142, + end_col_offset=29), + [], + [], + lineno=142, + col_offset=26, + end_lineno=142, + end_col_offset=31)], + [], + lineno=142, + col_offset=8, + end_lineno=142, + end_col_offset=32), + lineno=142, + col_offset=8, + end_lineno=142, + end_col_offset=32)], + [], + lineno=139, + col_offset=4, + end_lineno=142, + end_col_offset=32), + For( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=144, + col_offset=8, + end_lineno=144, + end_col_offset=11), + Name( + 'sigmund', + Store(), + lineno=144, + col_offset=13, + end_lineno=144, + end_col_offset=20)], + Store(), + lineno=144, + col_offset=8, + end_lineno=144, + end_col_offset=20), + Call( + Name( + 'enumerate', + Load(), + lineno=144, + col_offset=24, + end_lineno=144, + end_col_offset=33), + [ + Name( + 'full_exp', + Load(), + lineno=144, + col_offset=34, + end_lineno=144, + end_col_offset=42)], + [], + lineno=144, + col_offset=24, + end_lineno=144, + end_col_offset=43), + [ + Assign( + [ + Name( + 'bob', + Store(), + lineno=145, + col_offset=8, + end_lineno=145, + end_col_offset=11)], + BinOp( + Constant( + 1, + lineno=145, + col_offset=14, + end_lineno=145, + end_col_offset=15), + Sub(), + BinOp( + Name( + 'idx', + Load(), + lineno=145, + col_offset=19, + end_lineno=145, + end_col_offset=22), + LShift(), + Constant( + 1, + lineno=145, + col_offset=26, + end_lineno=145, + end_col_offset=27), + lineno=145, + col_offset=19, + end_lineno=145, + end_col_offset=27), + lineno=145, + col_offset=14, + end_lineno=145, + end_col_offset=28), + lineno=145, + col_offset=8, + end_lineno=145, + end_col_offset=28), + For( + Name( + 'warhol', + Store(), + lineno=146, + col_offset=12, + end_lineno=146, + end_col_offset=18), + Name( + 'sigmund', + Load(), + lineno=146, + col_offset=22, + end_lineno=146, + end_col_offset=29), + [ + For( + Tuple( + [ + Name( + 'picasso', + Store(), + lineno=147, + col_offset=16, + end_lineno=147, + end_col_offset=23), + Name( + 'escher', + Store(), + lineno=147, + col_offset=25, + end_lineno=147, + end_col_offset=31)], + Store(), + lineno=147, + col_offset=16, + end_lineno=147, + end_col_offset=31), + Call( + Name( + 'enumerate', + Load(), + lineno=147, + col_offset=35, + end_lineno=147, + end_col_offset=44), + [ + Name( + 'warhol', + Load(), + lineno=147, + col_offset=45, + end_lineno=147, + end_col_offset=51)], + [], + lineno=147, + col_offset=35, + end_lineno=147, + end_col_offset=52), + [ + If( + Compare( + Name( + 'escher', + Load(), + lineno=148, + col_offset=19, + end_lineno=148, + end_col_offset=25), + [ + NotIn()], + [ + Subscript( + Name( + 'multipliers_chars', + Load(), + lineno=148, + col_offset=33, + end_lineno=148, + end_col_offset=50), + Name( + 'picasso', + Load(), + lineno=148, + col_offset=51, + end_lineno=148, + end_col_offset=58), + Load(), + lineno=148, + col_offset=33, + end_lineno=148, + end_col_offset=59)], + lineno=148, + col_offset=19, + end_lineno=148, + end_col_offset=59), + [ + Assign( + [ + Subscript( + Subscript( + Name( + 'multipliers_chars', + Load(), + lineno=149, + col_offset=20, + end_lineno=149, + end_col_offset=37), + Name( + 'picasso', + Load(), + lineno=149, + col_offset=38, + end_lineno=149, + end_col_offset=45), + Load(), + lineno=149, + col_offset=20, + end_lineno=149, + end_col_offset=46), + Name( + 'escher', + Load(), + lineno=149, + col_offset=47, + end_lineno=149, + end_col_offset=53), + Store(), + lineno=149, + col_offset=20, + end_lineno=149, + end_col_offset=54)], + Constant( + 0, + lineno=149, + col_offset=57, + end_lineno=149, + end_col_offset=58), + lineno=149, + col_offset=20, + end_lineno=149, + end_col_offset=58)], + [], + lineno=148, + col_offset=16, + end_lineno=149, + end_col_offset=58), + AugAssign( + Subscript( + Subscript( + Name( + 'multipliers_chars', + Load(), + lineno=150, + col_offset=16, + end_lineno=150, + end_col_offset=33), + Name( + 'picasso', + Load(), + lineno=150, + col_offset=34, + end_lineno=150, + end_col_offset=41), + Load(), + lineno=150, + col_offset=16, + end_lineno=150, + end_col_offset=42), + Name( + 'escher', + Load(), + lineno=150, + col_offset=43, + end_lineno=150, + end_col_offset=49), + Store(), + lineno=150, + col_offset=16, + end_lineno=150, + end_col_offset=50), + Add(), + Name( + 'bob', + Load(), + lineno=150, + col_offset=54, + end_lineno=150, + end_col_offset=57), + lineno=150, + col_offset=16, + end_lineno=150, + end_col_offset=57)], + [], + lineno=147, + col_offset=12, + end_lineno=150, + end_col_offset=57)], + [], + lineno=146, + col_offset=8, + end_lineno=150, + end_col_offset=57)], + [], + lineno=144, + col_offset=4, + end_lineno=150, + end_col_offset=57), + Assign( + [ + Name( + 'total_chars', + Store(), + lineno=152, + col_offset=4, + end_lineno=152, + end_col_offset=15)], + Call( + Name( + 'set', + Load(), + lineno=152, + col_offset=18, + end_lineno=152, + end_col_offset=21), + [], + [], + lineno=152, + col_offset=18, + end_lineno=152, + end_col_offset=23), + lineno=152, + col_offset=4, + end_lineno=152, + end_col_offset=23), + For( + Tuple( + [ + Name( + 'picasso', + Store(), + lineno=154, + col_offset=8, + end_lineno=154, + end_col_offset=15), + Name( + 'chardict', + Store(), + lineno=154, + col_offset=17, + end_lineno=154, + end_col_offset=25)], + Store(), + lineno=154, + col_offset=8, + end_lineno=154, + end_col_offset=25), + Call( + Name( + 'enumerate', + Load(), + lineno=154, + col_offset=29, + end_lineno=154, + end_col_offset=38), + [ + Name( + 'multipliers_chars', + Load(), + lineno=154, + col_offset=39, + end_lineno=154, + end_col_offset=56)], + [], + lineno=154, + col_offset=29, + end_lineno=154, + end_col_offset=57), + [ + For( + Tuple( + [ + Name( + 'caesar', + Store(), + lineno=155, + col_offset=12, + end_lineno=155, + end_col_offset=18), + Name( + 'cnt', + Store(), + lineno=155, + col_offset=20, + end_lineno=155, + end_col_offset=23)], + Store(), + lineno=155, + col_offset=12, + end_lineno=155, + end_col_offset=23), + Call( + Name( + 'tuple', + Load(), + lineno=155, + col_offset=27, + end_lineno=155, + end_col_offset=32), + [ + Call( + Attribute( + Name( + 'chardict', + Load(), + lineno=155, + col_offset=33, + end_lineno=155, + end_col_offset=41), + 'items', + Load(), + lineno=155, + col_offset=33, + end_lineno=155, + end_col_offset=47), + [], + [], + lineno=155, + col_offset=33, + end_lineno=155, + end_col_offset=49)], + [], + lineno=155, + col_offset=27, + end_lineno=155, + end_col_offset=50), + [ + If( + Compare( + Name( + 'cnt', + Load(), + lineno=156, + col_offset=15, + end_lineno=156, + end_col_offset=18), + [ + Eq()], + [ + Constant( + 0, + lineno=156, + col_offset=22, + end_lineno=156, + end_col_offset=23)], + lineno=156, + col_offset=15, + end_lineno=156, + end_col_offset=23), + [ + Delete( + [ + Subscript( + Name( + 'chardict', + Load(), + lineno=157, + col_offset=20, + end_lineno=157, + end_col_offset=28), + Name( + 'caesar', + Load(), + lineno=157, + col_offset=29, + end_lineno=157, + end_col_offset=35), + Del(), + lineno=157, + col_offset=20, + end_lineno=157, + end_col_offset=36)], + lineno=157, + col_offset=16, + end_lineno=157, + end_col_offset=36)], + [ + If( + Compare( + Name( + 'caesar', + Load(), + lineno=161, + col_offset=17, + end_lineno=161, + end_col_offset=23), + [ + NotIn()], + [ + Name( + 'total_chars', + Load(), + lineno=161, + col_offset=31, + end_lineno=161, + end_col_offset=42)], + lineno=161, + col_offset=17, + end_lineno=161, + end_col_offset=42), + [ + If( + Compare( + Name( + 'caesar', + Load(), + lineno=164, + col_offset=19, + end_lineno=164, + end_col_offset=25), + [ + In()], + [ + Name( + 'nzchars', + Load(), + lineno=164, + col_offset=29, + end_lineno=164, + end_col_offset=36)], + lineno=164, + col_offset=19, + end_lineno=164, + end_col_offset=36), + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'non_zero_chars', + Load(), + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=34), + Name( + 'picasso', + Load(), + lineno=165, + col_offset=35, + end_lineno=165, + end_col_offset=42), + Load(), + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=43), + 'add', + Load(), + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=47), + [ + Name( + 'caesar', + Load(), + lineno=165, + col_offset=48, + end_lineno=165, + end_col_offset=54)], + [], + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=55), + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=55)], + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'zero_chars', + Load(), + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=30), + Name( + 'picasso', + Load(), + lineno=167, + col_offset=31, + end_lineno=167, + end_col_offset=38), + Load(), + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=39), + 'add', + Load(), + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=43), + [ + Name( + 'caesar', + Load(), + lineno=167, + col_offset=44, + end_lineno=167, + end_col_offset=50)], + [], + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=51), + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=51)], + lineno=164, + col_offset=16, + end_lineno=167, + end_col_offset=51), + Expr( + Call( + Attribute( + Name( + 'total_chars', + Load(), + lineno=170, + col_offset=16, + end_lineno=170, + end_col_offset=27), + 'add', + Load(), + lineno=170, + col_offset=16, + end_lineno=170, + end_col_offset=31), + [ + Name( + 'caesar', + Load(), + lineno=170, + col_offset=32, + end_lineno=170, + end_col_offset=38)], + [], + lineno=170, + col_offset=16, + end_lineno=170, + end_col_offset=39), + lineno=170, + col_offset=16, + end_lineno=170, + end_col_offset=39)], + [], + lineno=161, + col_offset=12, + end_lineno=170, + end_col_offset=39)], + lineno=156, + col_offset=12, + end_lineno=170, + end_col_offset=39)], + [], + lineno=155, + col_offset=8, + end_lineno=170, + end_col_offset=39), + Expr( + Call( + Attribute( + Name( + 'unique_chars', + Load(), + lineno=173, + col_offset=8, + end_lineno=173, + end_col_offset=20), + 'append', + Load(), + lineno=173, + col_offset=8, + end_lineno=173, + end_col_offset=27), + [ + BinOp( + Call( + Name( + 'tuple', + Load(), + lineno=173, + col_offset=28, + end_lineno=173, + end_col_offset=33), + [ + Subscript( + Name( + 'non_zero_chars', + Load(), + lineno=173, + col_offset=34, + end_lineno=173, + end_col_offset=48), + Name( + 'picasso', + Load(), + lineno=173, + col_offset=49, + end_lineno=173, + end_col_offset=56), + Load(), + lineno=173, + col_offset=34, + end_lineno=173, + end_col_offset=57)], + [], + lineno=173, + col_offset=28, + end_lineno=173, + end_col_offset=58), + Add(), + Call( + Name( + 'tuple', + Load(), + lineno=173, + col_offset=61, + end_lineno=173, + end_col_offset=66), + [ + Subscript( + Name( + 'zero_chars', + Load(), + lineno=173, + col_offset=67, + end_lineno=173, + end_col_offset=77), + Name( + 'picasso', + Load(), + lineno=173, + col_offset=78, + end_lineno=173, + end_col_offset=85), + Load(), + lineno=173, + col_offset=67, + end_lineno=173, + end_col_offset=86)], + [], + lineno=173, + col_offset=61, + end_lineno=173, + end_col_offset=87), + lineno=173, + col_offset=28, + end_lineno=173, + end_col_offset=87)], + [], + lineno=173, + col_offset=8, + end_lineno=173, + end_col_offset=88), + lineno=173, + col_offset=8, + end_lineno=173, + end_col_offset=88), + Assign( + [ + Subscript( + Name( + 'multipliers_chars', + Load(), + lineno=175, + col_offset=8, + end_lineno=175, + end_col_offset=25), + Name( + 'picasso', + Load(), + lineno=175, + col_offset=26, + end_lineno=175, + end_col_offset=33), + Store(), + lineno=175, + col_offset=8, + end_lineno=175, + end_col_offset=34)], + Call( + Name( + 'tuple', + Load(), + lineno=175, + col_offset=37, + end_lineno=175, + end_col_offset=42), + [ + Call( + Attribute( + Name( + 'chardict', + Load(), + lineno=175, + col_offset=43, + end_lineno=175, + end_col_offset=51), + 'items', + Load(), + lineno=175, + col_offset=43, + end_lineno=175, + end_col_offset=57), + [], + [], + lineno=175, + col_offset=43, + end_lineno=175, + end_col_offset=59)], + [], + lineno=175, + col_offset=37, + end_lineno=175, + end_col_offset=60), + lineno=175, + col_offset=8, + end_lineno=175, + end_col_offset=60)], + [], + lineno=154, + col_offset=4, + end_lineno=175, + end_col_offset=60), + Return( + Call( + Name( + 'check_rec', + Load(), + lineno=177, + col_offset=11, + end_lineno=177, + end_col_offset=20), + [ + List( + [ + Name( + 'max_digit_rank', + Load(), + lineno=177, + col_offset=22, + end_lineno=177, + end_col_offset=36), + Name( + 'multipliers_chars', + Load(), + lineno=177, + col_offset=38, + end_lineno=177, + end_col_offset=55), + Name( + 'non_zero_chars', + Load(), + lineno=177, + col_offset=57, + end_lineno=177, + end_col_offset=71), + Name( + 'zero_chars', + Load(), + lineno=177, + col_offset=73, + end_lineno=177, + end_col_offset=83), + Name( + 'unique_chars', + Load(), + lineno=177, + col_offset=85, + end_lineno=177, + end_col_offset=97)], + Load(), + lineno=177, + col_offset=21, + end_lineno=177, + end_col_offset=98)], + [], + lineno=177, + col_offset=11, + end_lineno=177, + end_col_offset=99), + lineno=177, + col_offset=4, + end_lineno=177, + end_col_offset=99)], + [], + lineno=119, + col_offset=0, + end_lineno=177, + end_col_offset=99)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'permutations', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=34), + alias( + 'chain', + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=41), + alias( + 'product', + lineno=12, + col_offset=43, + end_lineno=12, + end_col_offset=50)], + 0, + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=50), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=23), + arg( + 'placeholder_2', + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=39), + arg( + 'placeholder_3', + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=54)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=18)], + Call( + Name( + 'len', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=24), + [ + Name( + 'placeholder_2', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=39)], + [], + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=40), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=17)], + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=23), + [ + Name( + 'placeholder_3', + Load(), + lineno=20, + col_offset=24, + end_lineno=20, + end_col_offset=37)], + [], + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=38), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=38), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=15)], + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=21, + col_offset=18, + end_lineno=21, + end_col_offset=32), + Add(), + Name( + 'placeholder_5', + Load(), + lineno=21, + col_offset=35, + end_lineno=21, + end_col_offset=48), + lineno=21, + col_offset=18, + end_lineno=21, + end_col_offset=48), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=48), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=18), + [ + Lt()], + [ + Constant( + 1, + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=22)], + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=22), + [ + Return( + List( + [ + Tuple( + [], + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=18)], + Load(), + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=19), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=19)], + [], + lineno=22, + col_offset=4, + end_lineno=23, + end_col_offset=19), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=22)], + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=34), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=24, + col_offset=37, + end_lineno=24, + end_col_offset=40), + [ + Tuple( + [ + Constant( + 0, + lineno=24, + col_offset=42, + end_lineno=24, + end_col_offset=43)], + Load(), + lineno=24, + col_offset=41, + end_lineno=24, + end_col_offset=45)], + [], + lineno=24, + col_offset=37, + end_lineno=24, + end_col_offset=46), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=46), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=30)], + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=36), + [ + Name( + 'placeholder_7', + Load(), + lineno=25, + col_offset=37, + end_lineno=25, + end_col_offset=55)], + [], + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=56), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=56), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=23)], + Call( + Name( + 'len', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=29), + [ + Name( + 'placeholder_1', + Load(), + lineno=26, + col_offset=30, + end_lineno=26, + end_col_offset=39)], + [], + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=40), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=40), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_9', + Load(), + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=26), + [ + Lt()], + [ + Name( + 'placeholder_6', + Load(), + lineno=29, + col_offset=29, + end_lineno=29, + end_col_offset=40)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=40), + Compare( + Name( + 'placeholder_8', + Load(), + lineno=29, + col_offset=44, + end_lineno=29, + end_col_offset=70), + [ + Lt()], + [ + Name( + 'placeholder_4', + Load(), + lineno=29, + col_offset=73, + end_lineno=29, + end_col_offset=87)], + lineno=29, + col_offset=44, + end_lineno=29, + end_col_offset=87)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=87), + [ + Return( + List( + [], + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=17), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=17)], + [ + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_4', + Load(), + lineno=33, + col_offset=9, + end_lineno=33, + end_col_offset=23), + [ + Eq()], + [ + Constant( + 0, + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=28)], + lineno=33, + col_offset=9, + end_lineno=33, + end_col_offset=28), + Compare( + Name( + 'placeholder_9', + Load(), + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=51), + [ + Eq()], + [ + Name( + 'placeholder_8', + Load(), + lineno=33, + col_offset=55, + end_lineno=33, + end_col_offset=81)], + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=81)], + lineno=33, + col_offset=9, + end_lineno=33, + end_col_offset=81), + [ + Return( + Call( + Name( + 'permutations', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=27), + [ + Name( + 'placeholder_1', + Load(), + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=37), + Name( + 'placeholder_6', + Load(), + lineno=34, + col_offset=39, + end_lineno=34, + end_col_offset=50)], + [], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=51), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=51)], + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=36, + col_offset=9, + end_lineno=36, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=36, + col_offset=26, + end_lineno=36, + end_col_offset=27)], + lineno=36, + col_offset=9, + end_lineno=36, + end_col_offset=27), + [ + Return( + Call( + Name( + 'permutations', + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=27), + [ + Name( + 'placeholder_7', + Load(), + lineno=37, + col_offset=28, + end_lineno=37, + end_col_offset=46), + Name( + 'placeholder_6', + Load(), + lineno=37, + col_offset=48, + end_lineno=37, + end_col_offset=59)], + [], + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=60), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=60)], + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=22)], + Call( + Name( + 'list', + Load(), + lineno=41, + col_offset=25, + end_lineno=41, + end_col_offset=29), + [ + Call( + Name( + 'range', + Load(), + lineno=41, + col_offset=30, + end_lineno=41, + end_col_offset=35), + [ + Name( + 'placeholder_4', + Load(), + lineno=41, + col_offset=36, + end_lineno=41, + end_col_offset=50), + Name( + 'placeholder_6', + Load(), + lineno=41, + col_offset=52, + end_lineno=41, + end_col_offset=63)], + [], + lineno=41, + col_offset=30, + end_lineno=41, + end_col_offset=64)], + [], + lineno=41, + col_offset=25, + end_lineno=41, + end_col_offset=65), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=65), + Return( + Call( + Name( + 'chain', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=20), + [ + Call( + Name( + 'permutations', + Load(), + lineno=46, + col_offset=21, + end_lineno=46, + end_col_offset=33), + [ + Name( + 'placeholder_7', + Load(), + lineno=46, + col_offset=34, + end_lineno=46, + end_col_offset=52), + Name( + 'placeholder_6', + Load(), + lineno=46, + col_offset=54, + end_lineno=46, + end_col_offset=65)], + [], + lineno=46, + col_offset=21, + end_lineno=46, + end_col_offset=66), + Call( + Name( + 'map', + Load(), + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=24), + [ + Lambda( + arguments( + [], + [ + arg( + 'placeholder_11', + lineno=47, + col_offset=32, + end_lineno=47, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + BinOp( + BinOp( + Subscript( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=44), + Constant( + 0, + lineno=47, + col_offset=45, + end_lineno=47, + end_col_offset=46), + Load(), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=47), + Slice( + upper=Subscript( + Name( + 'placeholder_11', + Load(), + lineno=47, + col_offset=49, + end_lineno=47, + end_col_offset=54), + Constant( + 1, + lineno=47, + col_offset=55, + end_lineno=47, + end_col_offset=56), + Load(), + lineno=47, + col_offset=49, + end_lineno=47, + end_col_offset=57), + lineno=47, + col_offset=48, + end_lineno=47, + end_col_offset=57), + Load(), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=58), + Add(), + Tuple( + [ + Constant( + 0, + lineno=47, + col_offset=62, + end_lineno=47, + end_col_offset=63)], + Load(), + lineno=47, + col_offset=61, + end_lineno=47, + end_col_offset=65), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=65), + Add(), + Subscript( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=47, + col_offset=68, + end_lineno=47, + end_col_offset=73), + Constant( + 0, + lineno=47, + col_offset=74, + end_lineno=47, + end_col_offset=75), + Load(), + lineno=47, + col_offset=68, + end_lineno=47, + end_col_offset=76), + Slice( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=47, + col_offset=77, + end_lineno=47, + end_col_offset=82), + Constant( + 1, + lineno=47, + col_offset=83, + end_lineno=47, + end_col_offset=84), + Load(), + lineno=47, + col_offset=77, + end_lineno=47, + end_col_offset=85), + lineno=47, + col_offset=77, + end_lineno=47, + end_col_offset=86), + Load(), + lineno=47, + col_offset=68, + end_lineno=47, + end_col_offset=87), + lineno=47, + col_offset=39, + end_lineno=47, + end_col_offset=87), + lineno=47, + col_offset=25, + end_lineno=47, + end_col_offset=87), + Call( + Name( + 'product', + Load(), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=32), + [ + Call( + Name( + 'permutations', + Load(), + lineno=48, + col_offset=33, + end_lineno=48, + end_col_offset=45), + [ + Name( + 'placeholder_7', + Load(), + lineno=48, + col_offset=46, + end_lineno=48, + end_col_offset=64), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=48, + col_offset=66, + end_lineno=48, + end_col_offset=77), + Sub(), + Constant( + 1, + lineno=48, + col_offset=80, + end_lineno=48, + end_col_offset=81), + lineno=48, + col_offset=66, + end_lineno=48, + end_col_offset=81)], + [], + lineno=48, + col_offset=33, + end_lineno=48, + end_col_offset=82), + Name( + 'placeholder_10', + Load(), + lineno=49, + col_offset=33, + end_lineno=49, + end_col_offset=47)], + [], + lineno=48, + col_offset=25, + end_lineno=49, + end_col_offset=48)], + [], + lineno=47, + col_offset=21, + end_lineno=49, + end_col_offset=49)], + [], + lineno=46, + col_offset=15, + end_lineno=49, + end_col_offset=50), + lineno=46, + col_offset=8, + end_lineno=49, + end_col_offset=50)], + lineno=36, + col_offset=4, + end_lineno=49, + end_col_offset=50)], + lineno=33, + col_offset=4, + end_lineno=49, + end_col_offset=50)], + lineno=29, + col_offset=4, + end_lineno=49, + end_col_offset=50)], + [], + lineno=15, + col_offset=0, + end_lineno=49, + end_col_offset=50), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=22), + arg( + 'placeholder_14', + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=35), + arg( + 'placeholder_15', + lineno=52, + col_offset=61, + end_lineno=52, + end_col_offset=66)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Tuple( + [ + Dict( + [], + [], + lineno=52, + col_offset=37, + end_lineno=52, + end_col_offset=39), + Constant( + 0, + lineno=52, + col_offset=41, + end_lineno=52, + end_col_offset=42), + Call( + Name( + 'set', + Load(), + lineno=52, + col_offset=44, + end_lineno=52, + end_col_offset=47), + [ + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=48, + end_lineno=52, + end_col_offset=53), + [ + Constant( + 10, + lineno=52, + col_offset=54, + end_lineno=52, + end_col_offset=56)], + [], + lineno=52, + col_offset=48, + end_lineno=52, + end_col_offset=57)], + [], + lineno=52, + col_offset=44, + end_lineno=52, + end_col_offset=58)], + Load(), + lineno=52, + col_offset=36, + end_lineno=52, + end_col_offset=59), + Constant( + 0, + lineno=52, + col_offset=67, + end_lineno=52, + end_col_offset=68)]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_16', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=18), + Name( + 'placeholder_17', + Store(), + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=37), + Name( + 'placeholder_2', + Store(), + lineno=64, + col_offset=39, + end_lineno=64, + end_col_offset=53), + Name( + 'placeholder_18', + Store(), + lineno=64, + col_offset=55, + end_lineno=64, + end_col_offset=65), + Name( + 'placeholder_19', + Store(), + lineno=64, + col_offset=67, + end_lineno=64, + end_col_offset=79)], + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=79)], + Name( + 'placeholder_13', + Load(), + lineno=64, + col_offset=82, + end_lineno=64, + end_col_offset=90), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=90), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_20', + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=15), + Name( + 'placeholder_21', + Store(), + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=27), + Name( + 'placeholder_22', + Store(), + lineno=69, + col_offset=29, + end_lineno=69, + end_col_offset=45)], + Store(), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=45)], + Name( + 'placeholder_14', + Load(), + lineno=69, + col_offset=48, + end_lineno=69, + end_col_offset=59), + lineno=69, + col_offset=4, + end_lineno=69, + end_col_offset=59), + If( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=72, + col_offset=7, + end_lineno=72, + end_col_offset=12), + [ + Eq()], + [ + Name( + 'placeholder_16', + Load(), + lineno=72, + col_offset=16, + end_lineno=72, + end_col_offset=30)], + lineno=72, + col_offset=7, + end_lineno=72, + end_col_offset=30), + [ + If( + Compare( + Name( + 'placeholder_21', + Load(), + lineno=74, + col_offset=11, + end_lineno=74, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 0, + lineno=74, + col_offset=25, + end_lineno=74, + end_col_offset=26)], + lineno=74, + col_offset=11, + end_lineno=74, + end_col_offset=26), + [ + Return( + Name( + 'placeholder_20', + Load(), + lineno=75, + col_offset=19, + end_lineno=75, + end_col_offset=30), + lineno=75, + col_offset=12, + end_lineno=75, + end_col_offset=30)], + [ + Return( + Dict( + [], + [], + lineno=79, + col_offset=19, + end_lineno=79, + end_col_offset=21), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=21)], + lineno=74, + col_offset=8, + end_lineno=79, + end_col_offset=21)], + [], + lineno=72, + col_offset=4, + end_lineno=79, + end_col_offset=21), + Assign( + [ + Name( + 'placeholder_23', + Store(), + lineno=80, + col_offset=4, + end_lineno=80, + end_col_offset=17)], + Subscript( + Name( + 'placeholder_19', + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=32), + Name( + 'placeholder_15', + Load(), + lineno=80, + col_offset=33, + end_lineno=80, + end_col_offset=38), + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=39), + lineno=80, + col_offset=4, + end_lineno=80, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_24', + Store(), + lineno=81, + col_offset=4, + end_lineno=81, + end_col_offset=12)], + Name( + 'placeholder_21', + Load(), + lineno=81, + col_offset=15, + end_lineno=81, + end_col_offset=25), + lineno=81, + col_offset=4, + end_lineno=81, + end_col_offset=25), + Assign( + [ + Name( + 'placeholder_25', + Store(), + lineno=82, + col_offset=4, + end_lineno=82, + end_col_offset=17)], + List( + [], + Load(), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=22), + lineno=82, + col_offset=4, + end_lineno=82, + end_col_offset=22), + For( + Tuple( + [ + Name( + 'placeholder_26', + Store(), + lineno=85, + col_offset=8, + end_lineno=85, + end_col_offset=14), + Name( + 'placeholder_27', + Store(), + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=24)], + Store(), + lineno=85, + col_offset=8, + end_lineno=85, + end_col_offset=24), + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=85, + col_offset=28, + end_lineno=85, + end_col_offset=45), + Name( + 'placeholder_15', + Load(), + lineno=85, + col_offset=46, + end_lineno=85, + end_col_offset=51), + Load(), + lineno=85, + col_offset=28, + end_lineno=85, + end_col_offset=52), + [ + If( + Compare( + Name( + 'placeholder_26', + Load(), + lineno=86, + col_offset=11, + end_lineno=86, + end_col_offset=17), + [ + In()], + [ + Name( + 'placeholder_20', + Load(), + lineno=86, + col_offset=21, + end_lineno=86, + end_col_offset=32)], + lineno=86, + col_offset=11, + end_lineno=86, + end_col_offset=32), + [ + AugAssign( + Name( + 'placeholder_24', + Store(), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=20), + Add(), + BinOp( + Name( + 'placeholder_27', + Load(), + lineno=87, + col_offset=24, + end_lineno=87, + end_col_offset=32), + Mult(), + Subscript( + Name( + 'placeholder_20', + Load(), + lineno=87, + col_offset=35, + end_lineno=87, + end_col_offset=46), + Name( + 'placeholder_26', + Load(), + lineno=87, + col_offset=47, + end_lineno=87, + end_col_offset=53), + Load(), + lineno=87, + col_offset=35, + end_lineno=87, + end_col_offset=54), + lineno=87, + col_offset=24, + end_lineno=87, + end_col_offset=54), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=54)], + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_25', + Load(), + lineno=89, + col_offset=12, + end_lineno=89, + end_col_offset=25), + 'append', + Load(), + lineno=89, + col_offset=12, + end_lineno=89, + end_col_offset=32), + [ + Tuple( + [ + Name( + 'placeholder_26', + Load(), + lineno=89, + col_offset=34, + end_lineno=89, + end_col_offset=40), + Name( + 'placeholder_27', + Load(), + lineno=89, + col_offset=42, + end_lineno=89, + end_col_offset=50)], + Load(), + lineno=89, + col_offset=33, + end_lineno=89, + end_col_offset=51)], + [], + lineno=89, + col_offset=12, + end_lineno=89, + end_col_offset=52), + lineno=89, + col_offset=12, + end_lineno=89, + end_col_offset=52)], + lineno=86, + col_offset=8, + end_lineno=89, + end_col_offset=52)], + [], + lineno=85, + col_offset=4, + end_lineno=89, + end_col_offset=52), + For( + Name( + 'placeholder_28', + Store(), + lineno=92, + col_offset=8, + end_lineno=92, + end_col_offset=15), + Call( + Name( + 'placeholder_0', + Load(), + lineno=92, + col_offset=19, + end_lineno=92, + end_col_offset=28), + [ + Name( + 'placeholder_22', + Load(), + lineno=92, + col_offset=29, + end_lineno=92, + end_col_offset=45), + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=92, + col_offset=47, + end_lineno=92, + end_col_offset=61), + Name( + 'placeholder_15', + Load(), + lineno=92, + col_offset=62, + end_lineno=92, + end_col_offset=67), + Load(), + lineno=92, + col_offset=47, + end_lineno=92, + end_col_offset=68), + Subscript( + Name( + 'placeholder_18', + Load(), + lineno=92, + col_offset=70, + end_lineno=92, + end_col_offset=80), + Name( + 'placeholder_15', + Load(), + lineno=92, + col_offset=81, + end_lineno=92, + end_col_offset=86), + Load(), + lineno=92, + col_offset=70, + end_lineno=92, + end_col_offset=87)], + [], + lineno=92, + col_offset=19, + end_lineno=92, + end_col_offset=88), + [ + Assign( + [ + Name( + 'placeholder_29', + Store(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=16)], + Call( + Name( + 'dict', + Load(), + lineno=94, + col_offset=19, + end_lineno=94, + end_col_offset=23), + [ + Call( + Name( + 'zip', + Load(), + lineno=94, + col_offset=24, + end_lineno=94, + end_col_offset=27), + [ + Name( + 'placeholder_23', + Load(), + lineno=94, + col_offset=28, + end_lineno=94, + end_col_offset=41), + Name( + 'placeholder_28', + Load(), + lineno=94, + col_offset=43, + end_lineno=94, + end_col_offset=50)], + [], + lineno=94, + col_offset=24, + end_lineno=94, + end_col_offset=51)], + [], + lineno=94, + col_offset=19, + end_lineno=94, + end_col_offset=52), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_30', + Store(), + lineno=96, + col_offset=8, + end_lineno=96, + end_col_offset=15)], + BinOp( + Name( + 'placeholder_24', + Load(), + lineno=96, + col_offset=18, + end_lineno=96, + end_col_offset=26), + Add(), + Call( + Name( + 'sum', + Load(), + lineno=96, + col_offset=29, + end_lineno=96, + end_col_offset=32), + [ + ListComp( + BinOp( + Subscript( + Name( + 'placeholder_29', + Load(), + lineno=96, + col_offset=34, + end_lineno=96, + end_col_offset=42), + Name( + 'placeholder_26', + Load(), + lineno=96, + col_offset=43, + end_lineno=96, + end_col_offset=49), + Load(), + lineno=96, + col_offset=34, + end_lineno=96, + end_col_offset=50), + Mult(), + Name( + 'placeholder_27', + Load(), + lineno=96, + col_offset=53, + end_lineno=96, + end_col_offset=61), + lineno=96, + col_offset=34, + end_lineno=96, + end_col_offset=61), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_26', + Store(), + lineno=97, + col_offset=37, + end_lineno=97, + end_col_offset=43), + Name( + 'placeholder_27', + Store(), + lineno=97, + col_offset=45, + end_lineno=97, + end_col_offset=53)], + Store(), + lineno=97, + col_offset=37, + end_lineno=97, + end_col_offset=53), + Name( + 'placeholder_25', + Load(), + lineno=97, + col_offset=57, + end_lineno=97, + end_col_offset=70), + [], + 0)], + lineno=96, + col_offset=33, + end_lineno=97, + end_col_offset=71)], + [], + lineno=96, + col_offset=29, + end_lineno=97, + end_col_offset=72), + lineno=96, + col_offset=18, + end_lineno=97, + end_col_offset=72), + lineno=96, + col_offset=8, + end_lineno=97, + end_col_offset=72), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_31', + Store(), + lineno=99, + col_offset=8, + end_lineno=99, + end_col_offset=12), + Name( + 'placeholder_32', + Store(), + lineno=99, + col_offset=14, + end_lineno=99, + end_col_offset=23)], + Store(), + lineno=99, + col_offset=8, + end_lineno=99, + end_col_offset=23)], + Call( + Name( + 'divmod', + Load(), + lineno=99, + col_offset=26, + end_lineno=99, + end_col_offset=32), + [ + Name( + 'placeholder_30', + Load(), + lineno=99, + col_offset=33, + end_lineno=99, + end_col_offset=40), + Constant( + 10, + lineno=99, + col_offset=42, + end_lineno=99, + end_col_offset=44)], + [], + lineno=99, + col_offset=26, + end_lineno=99, + end_col_offset=45), + lineno=99, + col_offset=8, + end_lineno=99, + end_col_offset=45), + If( + Compare( + Name( + 'placeholder_32', + Load(), + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 0, + lineno=100, + col_offset=24, + end_lineno=100, + end_col_offset=25)], + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=25), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_29', + Load(), + lineno=102, + col_offset=12, + end_lineno=102, + end_col_offset=20), + 'update', + Load(), + lineno=102, + col_offset=12, + end_lineno=102, + end_col_offset=27), + [ + Name( + 'placeholder_20', + Load(), + lineno=102, + col_offset=28, + end_lineno=102, + end_col_offset=39)], + [], + lineno=102, + col_offset=12, + end_lineno=102, + end_col_offset=40), + lineno=102, + col_offset=12, + end_lineno=102, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_33', + Store(), + lineno=106, + col_offset=12, + end_lineno=106, + end_col_offset=26)], + Call( + Name( + 'placeholder_12', + Load(), + lineno=106, + col_offset=29, + end_lineno=106, + end_col_offset=38), + [ + Name( + 'placeholder_13', + Load(), + lineno=106, + col_offset=39, + end_lineno=106, + end_col_offset=47), + Tuple( + [ + Name( + 'placeholder_29', + Load(), + lineno=107, + col_offset=33, + end_lineno=107, + end_col_offset=41), + Name( + 'placeholder_31', + Load(), + lineno=107, + col_offset=43, + end_lineno=107, + end_col_offset=47), + BinOp( + Name( + 'placeholder_22', + Load(), + lineno=107, + col_offset=49, + end_lineno=107, + end_col_offset=65), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=107, + col_offset=68, + end_lineno=107, + end_col_offset=71), + [ + Name( + 'placeholder_28', + Load(), + lineno=107, + col_offset=72, + end_lineno=107, + end_col_offset=79)], + [], + lineno=107, + col_offset=68, + end_lineno=107, + end_col_offset=80), + lineno=107, + col_offset=49, + end_lineno=107, + end_col_offset=80)], + Load(), + lineno=107, + col_offset=32, + end_lineno=107, + end_col_offset=81), + BinOp( + Name( + 'placeholder_15', + Load(), + lineno=108, + col_offset=32, + end_lineno=108, + end_col_offset=37), + Add(), + Constant( + 1, + lineno=108, + col_offset=40, + end_lineno=108, + end_col_offset=41), + lineno=108, + col_offset=32, + end_lineno=108, + end_col_offset=41)], + [], + lineno=106, + col_offset=29, + end_lineno=108, + end_col_offset=42), + lineno=106, + col_offset=12, + end_lineno=108, + end_col_offset=42), + If( + BoolOp( + And(), + [ + Name( + 'placeholder_33', + Load(), + lineno=112, + col_offset=15, + end_lineno=112, + end_col_offset=29), + Compare( + Call( + Name( + 'len', + Load(), + lineno=112, + col_offset=34, + end_lineno=112, + end_col_offset=37), + [ + Name( + 'placeholder_33', + Load(), + lineno=112, + col_offset=38, + end_lineno=112, + end_col_offset=52)], + [], + lineno=112, + col_offset=34, + end_lineno=112, + end_col_offset=53), + [ + Gt()], + [ + Constant( + 0, + lineno=112, + col_offset=56, + end_lineno=112, + end_col_offset=57)], + lineno=112, + col_offset=34, + end_lineno=112, + end_col_offset=57)], + lineno=112, + col_offset=15, + end_lineno=112, + end_col_offset=57), + [ + Return( + Name( + 'placeholder_33', + Load(), + lineno=113, + col_offset=23, + end_lineno=113, + end_col_offset=37), + lineno=113, + col_offset=16, + end_lineno=113, + end_col_offset=37)], + [], + lineno=112, + col_offset=12, + end_lineno=113, + end_col_offset=37)], + [], + lineno=100, + col_offset=8, + end_lineno=113, + end_col_offset=37)], + [], + lineno=92, + col_offset=4, + end_lineno=113, + end_col_offset=37), + Return( + Constant( + None, + lineno=116, + col_offset=11, + end_lineno=116, + end_col_offset=15), + lineno=116, + col_offset=4, + end_lineno=116, + end_col_offset=15)], + [], + lineno=52, + col_offset=0, + end_lineno=116, + end_col_offset=15), + FunctionDef( + 'placeholder_34', + arguments( + [], + [ + arg( + 'placeholder_35', + lineno=119, + col_offset=10, + end_lineno=119, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_36', + Store(), + lineno=126, + col_offset=4, + end_lineno=126, + end_col_offset=12)], + ListComp( + Call( + Name( + 'list', + Load(), + lineno=126, + col_offset=16, + end_lineno=126, + end_col_offset=20), + [ + Call( + Name( + 'map', + Load(), + lineno=126, + col_offset=21, + end_lineno=126, + end_col_offset=24), + [ + Lambda( + arguments( + [], + [ + arg( + 'placeholder_39', + lineno=126, + col_offset=32, + end_lineno=126, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'list', + Load(), + lineno=126, + col_offset=37, + end_lineno=126, + end_col_offset=41), + [ + Call( + Name( + 'reversed', + Load(), + lineno=126, + col_offset=42, + end_lineno=126, + end_col_offset=50), + [ + Call( + Attribute( + Name( + 'placeholder_39', + Load(), + lineno=126, + col_offset=51, + end_lineno=126, + end_col_offset=54), + 'strip', + Load(), + lineno=126, + col_offset=51, + end_lineno=126, + end_col_offset=60), + [], + [], + lineno=126, + col_offset=51, + end_lineno=126, + end_col_offset=62)], + [], + lineno=126, + col_offset=42, + end_lineno=126, + end_col_offset=63)], + [], + lineno=126, + col_offset=37, + end_lineno=126, + end_col_offset=64), + lineno=126, + col_offset=25, + end_lineno=126, + end_col_offset=64), + Call( + Attribute( + Name( + 'placeholder_38', + Load(), + lineno=126, + col_offset=66, + end_lineno=126, + end_col_offset=73), + 'split', + Load(), + lineno=126, + col_offset=66, + end_lineno=126, + end_col_offset=79), + [ + Constant( + '+', + lineno=126, + col_offset=80, + end_lineno=126, + end_col_offset=83)], + [], + lineno=126, + col_offset=66, + end_lineno=126, + end_col_offset=84)], + [], + lineno=126, + col_offset=21, + end_lineno=126, + end_col_offset=85)], + [], + lineno=126, + col_offset=16, + end_lineno=126, + end_col_offset=86), + [ + comprehension( + Name( + 'placeholder_38', + Store(), + lineno=127, + col_offset=19, + end_lineno=127, + end_col_offset=26), + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_35', + Load(), + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=36), + 'strip', + Load(), + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=42), + [], + [], + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=44), + 'upper', + Load(), + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=50), + [], + [], + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=52), + 'split', + Load(), + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=58), + [ + Constant( + '==', + lineno=127, + col_offset=59, + end_lineno=127, + end_col_offset=63)], + [], + lineno=127, + col_offset=30, + end_lineno=127, + end_col_offset=64), + [], + 0)], + lineno=126, + col_offset=15, + end_lineno=127, + end_col_offset=65), + lineno=126, + col_offset=4, + end_lineno=127, + end_col_offset=65), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=130, + col_offset=4, + end_lineno=130, + end_col_offset=18)], + Call( + Name( + 'max', + Load(), + lineno=130, + col_offset=21, + end_lineno=130, + end_col_offset=24), + [ + ListComp( + Call( + Name( + 'len', + Load(), + lineno=130, + col_offset=26, + end_lineno=130, + end_col_offset=29), + [ + Name( + 'placeholder_40', + Load(), + lineno=130, + col_offset=30, + end_lineno=130, + end_col_offset=36)], + [], + lineno=130, + col_offset=26, + end_lineno=130, + end_col_offset=37), + [ + comprehension( + Name( + 'placeholder_38', + Store(), + lineno=130, + col_offset=42, + end_lineno=130, + end_col_offset=49), + Name( + 'placeholder_36', + Load(), + lineno=130, + col_offset=53, + end_lineno=130, + end_col_offset=61), + [], + 0), + comprehension( + Name( + 'placeholder_40', + Store(), + lineno=130, + col_offset=66, + end_lineno=130, + end_col_offset=72), + Name( + 'placeholder_38', + Load(), + lineno=130, + col_offset=76, + end_lineno=130, + end_col_offset=83), + [], + 0)], + lineno=130, + col_offset=25, + end_lineno=130, + end_col_offset=84)], + [], + lineno=130, + col_offset=21, + end_lineno=130, + end_col_offset=85), + lineno=130, + col_offset=4, + end_lineno=130, + end_col_offset=85), + Assign( + [ + Name( + 'placeholder_41', + Store(), + lineno=133, + col_offset=4, + end_lineno=133, + end_col_offset=11)], + SetComp( + Subscript( + Name( + 'placeholder_40', + Load(), + lineno=133, + col_offset=15, + end_lineno=133, + end_col_offset=21), + UnaryOp( + USub(), + Constant( + 1, + lineno=133, + col_offset=23, + end_lineno=133, + end_col_offset=24), + lineno=133, + col_offset=22, + end_lineno=133, + end_col_offset=24), + Load(), + lineno=133, + col_offset=15, + end_lineno=133, + end_col_offset=25), + [ + comprehension( + Name( + 'placeholder_38', + Store(), + lineno=133, + col_offset=30, + end_lineno=133, + end_col_offset=37), + Name( + 'placeholder_36', + Load(), + lineno=133, + col_offset=41, + end_lineno=133, + end_col_offset=49), + [], + 0), + comprehension( + Name( + 'placeholder_40', + Store(), + lineno=133, + col_offset=54, + end_lineno=133, + end_col_offset=60), + Name( + 'placeholder_38', + Load(), + lineno=133, + col_offset=64, + end_lineno=133, + end_col_offset=71), + [], + 0)], + lineno=133, + col_offset=14, + end_lineno=133, + end_col_offset=72), + lineno=133, + col_offset=4, + end_lineno=133, + end_col_offset=72), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=135, + col_offset=4, + end_lineno=135, + end_col_offset=18)], + List( + [], + Load(), + lineno=135, + col_offset=21, + end_lineno=135, + end_col_offset=23), + lineno=135, + col_offset=4, + end_lineno=135, + end_col_offset=23), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=136, + col_offset=4, + end_lineno=136, + end_col_offset=14)], + List( + [], + Load(), + lineno=136, + col_offset=17, + end_lineno=136, + end_col_offset=19), + lineno=136, + col_offset=4, + end_lineno=136, + end_col_offset=19), + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=137, + col_offset=4, + end_lineno=137, + end_col_offset=16)], + List( + [], + Load(), + lineno=137, + col_offset=19, + end_lineno=137, + end_col_offset=21), + lineno=137, + col_offset=4, + end_lineno=137, + end_col_offset=21), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=138, + col_offset=4, + end_lineno=138, + end_col_offset=21)], + List( + [], + Load(), + lineno=138, + col_offset=24, + end_lineno=138, + end_col_offset=26), + lineno=138, + col_offset=4, + end_lineno=138, + end_col_offset=26), + For( + Name( + 'placeholder_42', + Store(), + lineno=139, + col_offset=8, + end_lineno=139, + end_col_offset=9), + Call( + Name( + 'range', + Load(), + lineno=139, + col_offset=13, + end_lineno=139, + end_col_offset=18), + [ + Name( + 'placeholder_16', + Load(), + lineno=139, + col_offset=19, + end_lineno=139, + end_col_offset=33)], + [], + lineno=139, + col_offset=13, + end_lineno=139, + end_col_offset=34), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=140, + col_offset=8, + end_lineno=140, + end_col_offset=25), + 'append', + Load(), + lineno=140, + col_offset=8, + end_lineno=140, + end_col_offset=32), + [ + Dict( + [], + [], + lineno=140, + col_offset=33, + end_lineno=140, + end_col_offset=35)], + [], + lineno=140, + col_offset=8, + end_lineno=140, + end_col_offset=36), + lineno=140, + col_offset=8, + end_lineno=140, + end_col_offset=36), + Expr( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=141, + col_offset=8, + end_lineno=141, + end_col_offset=22), + 'append', + Load(), + lineno=141, + col_offset=8, + end_lineno=141, + end_col_offset=29), + [ + Call( + Name( + 'set', + Load(), + lineno=141, + col_offset=30, + end_lineno=141, + end_col_offset=33), + [], + [], + lineno=141, + col_offset=30, + end_lineno=141, + end_col_offset=35)], + [], + lineno=141, + col_offset=8, + end_lineno=141, + end_col_offset=36), + lineno=141, + col_offset=8, + end_lineno=141, + end_col_offset=36), + Expr( + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=142, + col_offset=8, + end_lineno=142, + end_col_offset=18), + 'append', + Load(), + lineno=142, + col_offset=8, + end_lineno=142, + end_col_offset=25), + [ + Call( + Name( + 'set', + Load(), + lineno=142, + col_offset=26, + end_lineno=142, + end_col_offset=29), + [], + [], + lineno=142, + col_offset=26, + end_lineno=142, + end_col_offset=31)], + [], + lineno=142, + col_offset=8, + end_lineno=142, + end_col_offset=32), + lineno=142, + col_offset=8, + end_lineno=142, + end_col_offset=32)], + [], + lineno=139, + col_offset=4, + end_lineno=142, + end_col_offset=32), + For( + Tuple( + [ + Name( + 'placeholder_37', + Store(), + lineno=144, + col_offset=8, + end_lineno=144, + end_col_offset=11), + Name( + 'placeholder_38', + Store(), + lineno=144, + col_offset=13, + end_lineno=144, + end_col_offset=20)], + Store(), + lineno=144, + col_offset=8, + end_lineno=144, + end_col_offset=20), + Call( + Name( + 'enumerate', + Load(), + lineno=144, + col_offset=24, + end_lineno=144, + end_col_offset=33), + [ + Name( + 'placeholder_36', + Load(), + lineno=144, + col_offset=34, + end_lineno=144, + end_col_offset=42)], + [], + lineno=144, + col_offset=24, + end_lineno=144, + end_col_offset=43), + [ + Assign( + [ + Name( + 'placeholder_43', + Store(), + lineno=145, + col_offset=8, + end_lineno=145, + end_col_offset=11)], + BinOp( + Constant( + 1, + lineno=145, + col_offset=14, + end_lineno=145, + end_col_offset=15), + Sub(), + BinOp( + Name( + 'placeholder_37', + Load(), + lineno=145, + col_offset=19, + end_lineno=145, + end_col_offset=22), + LShift(), + Constant( + 1, + lineno=145, + col_offset=26, + end_lineno=145, + end_col_offset=27), + lineno=145, + col_offset=19, + end_lineno=145, + end_col_offset=27), + lineno=145, + col_offset=14, + end_lineno=145, + end_col_offset=28), + lineno=145, + col_offset=8, + end_lineno=145, + end_col_offset=28), + For( + Name( + 'placeholder_40', + Store(), + lineno=146, + col_offset=12, + end_lineno=146, + end_col_offset=18), + Name( + 'placeholder_38', + Load(), + lineno=146, + col_offset=22, + end_lineno=146, + end_col_offset=29), + [ + For( + Tuple( + [ + Name( + 'placeholder_44', + Store(), + lineno=147, + col_offset=16, + end_lineno=147, + end_col_offset=23), + Name( + 'placeholder_45', + Store(), + lineno=147, + col_offset=25, + end_lineno=147, + end_col_offset=31)], + Store(), + lineno=147, + col_offset=16, + end_lineno=147, + end_col_offset=31), + Call( + Name( + 'enumerate', + Load(), + lineno=147, + col_offset=35, + end_lineno=147, + end_col_offset=44), + [ + Name( + 'placeholder_40', + Load(), + lineno=147, + col_offset=45, + end_lineno=147, + end_col_offset=51)], + [], + lineno=147, + col_offset=35, + end_lineno=147, + end_col_offset=52), + [ + If( + Compare( + Name( + 'placeholder_45', + Load(), + lineno=148, + col_offset=19, + end_lineno=148, + end_col_offset=25), + [ + NotIn()], + [ + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=148, + col_offset=33, + end_lineno=148, + end_col_offset=50), + Name( + 'placeholder_44', + Load(), + lineno=148, + col_offset=51, + end_lineno=148, + end_col_offset=58), + Load(), + lineno=148, + col_offset=33, + end_lineno=148, + end_col_offset=59)], + lineno=148, + col_offset=19, + end_lineno=148, + end_col_offset=59), + [ + Assign( + [ + Subscript( + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=149, + col_offset=20, + end_lineno=149, + end_col_offset=37), + Name( + 'placeholder_44', + Load(), + lineno=149, + col_offset=38, + end_lineno=149, + end_col_offset=45), + Load(), + lineno=149, + col_offset=20, + end_lineno=149, + end_col_offset=46), + Name( + 'placeholder_45', + Load(), + lineno=149, + col_offset=47, + end_lineno=149, + end_col_offset=53), + Store(), + lineno=149, + col_offset=20, + end_lineno=149, + end_col_offset=54)], + Constant( + 0, + lineno=149, + col_offset=57, + end_lineno=149, + end_col_offset=58), + lineno=149, + col_offset=20, + end_lineno=149, + end_col_offset=58)], + [], + lineno=148, + col_offset=16, + end_lineno=149, + end_col_offset=58), + AugAssign( + Subscript( + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=150, + col_offset=16, + end_lineno=150, + end_col_offset=33), + Name( + 'placeholder_44', + Load(), + lineno=150, + col_offset=34, + end_lineno=150, + end_col_offset=41), + Load(), + lineno=150, + col_offset=16, + end_lineno=150, + end_col_offset=42), + Name( + 'placeholder_45', + Load(), + lineno=150, + col_offset=43, + end_lineno=150, + end_col_offset=49), + Store(), + lineno=150, + col_offset=16, + end_lineno=150, + end_col_offset=50), + Add(), + Name( + 'placeholder_43', + Load(), + lineno=150, + col_offset=54, + end_lineno=150, + end_col_offset=57), + lineno=150, + col_offset=16, + end_lineno=150, + end_col_offset=57)], + [], + lineno=147, + col_offset=12, + end_lineno=150, + end_col_offset=57)], + [], + lineno=146, + col_offset=8, + end_lineno=150, + end_col_offset=57)], + [], + lineno=144, + col_offset=4, + end_lineno=150, + end_col_offset=57), + Assign( + [ + Name( + 'placeholder_46', + Store(), + lineno=152, + col_offset=4, + end_lineno=152, + end_col_offset=15)], + Call( + Name( + 'set', + Load(), + lineno=152, + col_offset=18, + end_lineno=152, + end_col_offset=21), + [], + [], + lineno=152, + col_offset=18, + end_lineno=152, + end_col_offset=23), + lineno=152, + col_offset=4, + end_lineno=152, + end_col_offset=23), + For( + Tuple( + [ + Name( + 'placeholder_44', + Store(), + lineno=154, + col_offset=8, + end_lineno=154, + end_col_offset=15), + Name( + 'placeholder_47', + Store(), + lineno=154, + col_offset=17, + end_lineno=154, + end_col_offset=25)], + Store(), + lineno=154, + col_offset=8, + end_lineno=154, + end_col_offset=25), + Call( + Name( + 'enumerate', + Load(), + lineno=154, + col_offset=29, + end_lineno=154, + end_col_offset=38), + [ + Name( + 'placeholder_17', + Load(), + lineno=154, + col_offset=39, + end_lineno=154, + end_col_offset=56)], + [], + lineno=154, + col_offset=29, + end_lineno=154, + end_col_offset=57), + [ + For( + Tuple( + [ + Name( + 'placeholder_26', + Store(), + lineno=155, + col_offset=12, + end_lineno=155, + end_col_offset=18), + Name( + 'placeholder_48', + Store(), + lineno=155, + col_offset=20, + end_lineno=155, + end_col_offset=23)], + Store(), + lineno=155, + col_offset=12, + end_lineno=155, + end_col_offset=23), + Call( + Name( + 'tuple', + Load(), + lineno=155, + col_offset=27, + end_lineno=155, + end_col_offset=32), + [ + Call( + Attribute( + Name( + 'placeholder_47', + Load(), + lineno=155, + col_offset=33, + end_lineno=155, + end_col_offset=41), + 'items', + Load(), + lineno=155, + col_offset=33, + end_lineno=155, + end_col_offset=47), + [], + [], + lineno=155, + col_offset=33, + end_lineno=155, + end_col_offset=49)], + [], + lineno=155, + col_offset=27, + end_lineno=155, + end_col_offset=50), + [ + If( + Compare( + Name( + 'placeholder_48', + Load(), + lineno=156, + col_offset=15, + end_lineno=156, + end_col_offset=18), + [ + Eq()], + [ + Constant( + 0, + lineno=156, + col_offset=22, + end_lineno=156, + end_col_offset=23)], + lineno=156, + col_offset=15, + end_lineno=156, + end_col_offset=23), + [ + Delete( + [ + Subscript( + Name( + 'placeholder_47', + Load(), + lineno=157, + col_offset=20, + end_lineno=157, + end_col_offset=28), + Name( + 'placeholder_26', + Load(), + lineno=157, + col_offset=29, + end_lineno=157, + end_col_offset=35), + Del(), + lineno=157, + col_offset=20, + end_lineno=157, + end_col_offset=36)], + lineno=157, + col_offset=16, + end_lineno=157, + end_col_offset=36)], + [ + If( + Compare( + Name( + 'placeholder_26', + Load(), + lineno=161, + col_offset=17, + end_lineno=161, + end_col_offset=23), + [ + NotIn()], + [ + Name( + 'placeholder_46', + Load(), + lineno=161, + col_offset=31, + end_lineno=161, + end_col_offset=42)], + lineno=161, + col_offset=17, + end_lineno=161, + end_col_offset=42), + [ + If( + Compare( + Name( + 'placeholder_26', + Load(), + lineno=164, + col_offset=19, + end_lineno=164, + end_col_offset=25), + [ + In()], + [ + Name( + 'placeholder_41', + Load(), + lineno=164, + col_offset=29, + end_lineno=164, + end_col_offset=36)], + lineno=164, + col_offset=19, + end_lineno=164, + end_col_offset=36), + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=34), + Name( + 'placeholder_44', + Load(), + lineno=165, + col_offset=35, + end_lineno=165, + end_col_offset=42), + Load(), + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=43), + 'add', + Load(), + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=47), + [ + Name( + 'placeholder_26', + Load(), + lineno=165, + col_offset=48, + end_lineno=165, + end_col_offset=54)], + [], + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=55), + lineno=165, + col_offset=20, + end_lineno=165, + end_col_offset=55)], + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_18', + Load(), + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=30), + Name( + 'placeholder_44', + Load(), + lineno=167, + col_offset=31, + end_lineno=167, + end_col_offset=38), + Load(), + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=39), + 'add', + Load(), + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=43), + [ + Name( + 'placeholder_26', + Load(), + lineno=167, + col_offset=44, + end_lineno=167, + end_col_offset=50)], + [], + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=51), + lineno=167, + col_offset=20, + end_lineno=167, + end_col_offset=51)], + lineno=164, + col_offset=16, + end_lineno=167, + end_col_offset=51), + Expr( + Call( + Attribute( + Name( + 'placeholder_46', + Load(), + lineno=170, + col_offset=16, + end_lineno=170, + end_col_offset=27), + 'add', + Load(), + lineno=170, + col_offset=16, + end_lineno=170, + end_col_offset=31), + [ + Name( + 'placeholder_26', + Load(), + lineno=170, + col_offset=32, + end_lineno=170, + end_col_offset=38)], + [], + lineno=170, + col_offset=16, + end_lineno=170, + end_col_offset=39), + lineno=170, + col_offset=16, + end_lineno=170, + end_col_offset=39)], + [], + lineno=161, + col_offset=12, + end_lineno=170, + end_col_offset=39)], + lineno=156, + col_offset=12, + end_lineno=170, + end_col_offset=39)], + [], + lineno=155, + col_offset=8, + end_lineno=170, + end_col_offset=39), + Expr( + Call( + Attribute( + Name( + 'placeholder_19', + Load(), + lineno=173, + col_offset=8, + end_lineno=173, + end_col_offset=20), + 'append', + Load(), + lineno=173, + col_offset=8, + end_lineno=173, + end_col_offset=27), + [ + BinOp( + Call( + Name( + 'tuple', + Load(), + lineno=173, + col_offset=28, + end_lineno=173, + end_col_offset=33), + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=173, + col_offset=34, + end_lineno=173, + end_col_offset=48), + Name( + 'placeholder_44', + Load(), + lineno=173, + col_offset=49, + end_lineno=173, + end_col_offset=56), + Load(), + lineno=173, + col_offset=34, + end_lineno=173, + end_col_offset=57)], + [], + lineno=173, + col_offset=28, + end_lineno=173, + end_col_offset=58), + Add(), + Call( + Name( + 'tuple', + Load(), + lineno=173, + col_offset=61, + end_lineno=173, + end_col_offset=66), + [ + Subscript( + Name( + 'placeholder_18', + Load(), + lineno=173, + col_offset=67, + end_lineno=173, + end_col_offset=77), + Name( + 'placeholder_44', + Load(), + lineno=173, + col_offset=78, + end_lineno=173, + end_col_offset=85), + Load(), + lineno=173, + col_offset=67, + end_lineno=173, + end_col_offset=86)], + [], + lineno=173, + col_offset=61, + end_lineno=173, + end_col_offset=87), + lineno=173, + col_offset=28, + end_lineno=173, + end_col_offset=87)], + [], + lineno=173, + col_offset=8, + end_lineno=173, + end_col_offset=88), + lineno=173, + col_offset=8, + end_lineno=173, + end_col_offset=88), + Assign( + [ + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=175, + col_offset=8, + end_lineno=175, + end_col_offset=25), + Name( + 'placeholder_44', + Load(), + lineno=175, + col_offset=26, + end_lineno=175, + end_col_offset=33), + Store(), + lineno=175, + col_offset=8, + end_lineno=175, + end_col_offset=34)], + Call( + Name( + 'tuple', + Load(), + lineno=175, + col_offset=37, + end_lineno=175, + end_col_offset=42), + [ + Call( + Attribute( + Name( + 'placeholder_47', + Load(), + lineno=175, + col_offset=43, + end_lineno=175, + end_col_offset=51), + 'items', + Load(), + lineno=175, + col_offset=43, + end_lineno=175, + end_col_offset=57), + [], + [], + lineno=175, + col_offset=43, + end_lineno=175, + end_col_offset=59)], + [], + lineno=175, + col_offset=37, + end_lineno=175, + end_col_offset=60), + lineno=175, + col_offset=8, + end_lineno=175, + end_col_offset=60)], + [], + lineno=154, + col_offset=4, + end_lineno=175, + end_col_offset=60), + Return( + Call( + Name( + 'placeholder_12', + Load(), + lineno=177, + col_offset=11, + end_lineno=177, + end_col_offset=20), + [ + List( + [ + Name( + 'placeholder_16', + Load(), + lineno=177, + col_offset=22, + end_lineno=177, + end_col_offset=36), + Name( + 'placeholder_17', + Load(), + lineno=177, + col_offset=38, + end_lineno=177, + end_col_offset=55), + Name( + 'placeholder_2', + Load(), + lineno=177, + col_offset=57, + end_lineno=177, + end_col_offset=71), + Name( + 'placeholder_18', + Load(), + lineno=177, + col_offset=73, + end_lineno=177, + end_col_offset=83), + Name( + 'placeholder_19', + Load(), + lineno=177, + col_offset=85, + end_lineno=177, + end_col_offset=97)], + Load(), + lineno=177, + col_offset=21, + end_lineno=177, + end_col_offset=98)], + [], + lineno=177, + col_offset=11, + end_lineno=177, + end_col_offset=99), + lineno=177, + col_offset=4, + end_lineno=177, + end_col_offset=99)], + [], + lineno=119, + col_offset=0, + end_lineno=177, + end_col_offset=99)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-alphametics/representation.txt b/test/practice-alphametics/representation.txt new file mode 100644 index 0000000..1fb9251 --- /dev/null +++ b/test/practice-alphametics/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('itertools', [alias('permutations', lineno=12, col_offset=22, end_lineno=12, end_col_offset=34), alias('chain', lineno=12, col_offset=36, end_lineno=12, end_col_offset=41), alias('product', lineno=12, col_offset=43, end_lineno=12, end_col_offset=50)], 0, lineno=12, col_offset=0, end_lineno=12, end_col_offset=50), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=15, col_offset=14, end_lineno=15, end_col_offset=23), arg('placeholder_2', lineno=15, col_offset=25, end_lineno=15, end_col_offset=39), arg('placeholder_3', lineno=15, col_offset=41, end_lineno=15, end_col_offset=54)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=19, col_offset=4, end_lineno=19, end_col_offset=18)], Call(Name('len', Load(), lineno=19, col_offset=21, end_lineno=19, end_col_offset=24), [Name('placeholder_2', Load(), lineno=19, col_offset=25, end_lineno=19, end_col_offset=39)], [], lineno=19, col_offset=21, end_lineno=19, end_col_offset=40), lineno=19, col_offset=4, end_lineno=19, end_col_offset=40), Assign([Name('placeholder_5', Store(), lineno=20, col_offset=4, end_lineno=20, end_col_offset=17)], Call(Name('len', Load(), lineno=20, col_offset=20, end_lineno=20, end_col_offset=23), [Name('placeholder_3', Load(), lineno=20, col_offset=24, end_lineno=20, end_col_offset=37)], [], lineno=20, col_offset=20, end_lineno=20, end_col_offset=38), lineno=20, col_offset=4, end_lineno=20, end_col_offset=38), Assign([Name('placeholder_6', Store(), lineno=21, col_offset=4, end_lineno=21, end_col_offset=15)], BinOp(Name('placeholder_4', Load(), lineno=21, col_offset=18, end_lineno=21, end_col_offset=32), Add(), Name('placeholder_5', Load(), lineno=21, col_offset=35, end_lineno=21, end_col_offset=48), lineno=21, col_offset=18, end_lineno=21, end_col_offset=48), lineno=21, col_offset=4, end_lineno=21, end_col_offset=48), If(Compare(Name('placeholder_6', Load(), lineno=22, col_offset=7, end_lineno=22, end_col_offset=18), [Lt()], [Constant(1, lineno=22, col_offset=21, end_lineno=22, end_col_offset=22)], lineno=22, col_offset=7, end_lineno=22, end_col_offset=22), [Return(List([Tuple([], Load(), lineno=23, col_offset=16, end_lineno=23, end_col_offset=18)], Load(), lineno=23, col_offset=15, end_lineno=23, end_col_offset=19), lineno=23, col_offset=8, end_lineno=23, end_col_offset=19)], [], lineno=22, col_offset=4, end_lineno=23, end_col_offset=19), Assign([Name('placeholder_7', Store(), lineno=24, col_offset=4, end_lineno=24, end_col_offset=22)], BinOp(Name('placeholder_1', Load(), lineno=24, col_offset=25, end_lineno=24, end_col_offset=34), Sub(), Call(Name('set', Load(), lineno=24, col_offset=37, end_lineno=24, end_col_offset=40), [Tuple([Constant(0, lineno=24, col_offset=42, end_lineno=24, end_col_offset=43)], Load(), lineno=24, col_offset=41, end_lineno=24, end_col_offset=45)], [], lineno=24, col_offset=37, end_lineno=24, end_col_offset=46), lineno=24, col_offset=25, end_lineno=24, end_col_offset=46), lineno=24, col_offset=4, end_lineno=24, end_col_offset=46), Assign([Name('placeholder_8', Store(), lineno=25, col_offset=4, end_lineno=25, end_col_offset=30)], Call(Name('len', Load(), lineno=25, col_offset=33, end_lineno=25, end_col_offset=36), [Name('placeholder_7', Load(), lineno=25, col_offset=37, end_lineno=25, end_col_offset=55)], [], lineno=25, col_offset=33, end_lineno=25, end_col_offset=56), lineno=25, col_offset=4, end_lineno=25, end_col_offset=56), Assign([Name('placeholder_9', Store(), lineno=26, col_offset=4, end_lineno=26, end_col_offset=23)], Call(Name('len', Load(), lineno=26, col_offset=26, end_lineno=26, end_col_offset=29), [Name('placeholder_1', Load(), lineno=26, col_offset=30, end_lineno=26, end_col_offset=39)], [], lineno=26, col_offset=26, end_lineno=26, end_col_offset=40), lineno=26, col_offset=4, end_lineno=26, end_col_offset=40), If(BoolOp(Or(), [Compare(Name('placeholder_9', Load(), lineno=29, col_offset=7, end_lineno=29, end_col_offset=26), [Lt()], [Name('placeholder_6', Load(), lineno=29, col_offset=29, end_lineno=29, end_col_offset=40)], lineno=29, col_offset=7, end_lineno=29, end_col_offset=40), Compare(Name('placeholder_8', Load(), lineno=29, col_offset=44, end_lineno=29, end_col_offset=70), [Lt()], [Name('placeholder_4', Load(), lineno=29, col_offset=73, end_lineno=29, end_col_offset=87)], lineno=29, col_offset=44, end_lineno=29, end_col_offset=87)], lineno=29, col_offset=7, end_lineno=29, end_col_offset=87), [Return(List([], Load(), lineno=30, col_offset=15, end_lineno=30, end_col_offset=17), lineno=30, col_offset=8, end_lineno=30, end_col_offset=17)], [If(BoolOp(Or(), [Compare(Name('placeholder_4', Load(), lineno=33, col_offset=9, end_lineno=33, end_col_offset=23), [Eq()], [Constant(0, lineno=33, col_offset=27, end_lineno=33, end_col_offset=28)], lineno=33, col_offset=9, end_lineno=33, end_col_offset=28), Compare(Name('placeholder_9', Load(), lineno=33, col_offset=32, end_lineno=33, end_col_offset=51), [Eq()], [Name('placeholder_8', Load(), lineno=33, col_offset=55, end_lineno=33, end_col_offset=81)], lineno=33, col_offset=32, end_lineno=33, end_col_offset=81)], lineno=33, col_offset=9, end_lineno=33, end_col_offset=81), [Return(Call(Name('permutations', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=27), [Name('placeholder_1', Load(), lineno=34, col_offset=28, end_lineno=34, end_col_offset=37), Name('placeholder_6', Load(), lineno=34, col_offset=39, end_lineno=34, end_col_offset=50)], [], lineno=34, col_offset=15, end_lineno=34, end_col_offset=51), lineno=34, col_offset=8, end_lineno=34, end_col_offset=51)], [If(Compare(Name('placeholder_5', Load(), lineno=36, col_offset=9, end_lineno=36, end_col_offset=22), [Eq()], [Constant(0, lineno=36, col_offset=26, end_lineno=36, end_col_offset=27)], lineno=36, col_offset=9, end_lineno=36, end_col_offset=27), [Return(Call(Name('permutations', Load(), lineno=37, col_offset=15, end_lineno=37, end_col_offset=27), [Name('placeholder_7', Load(), lineno=37, col_offset=28, end_lineno=37, end_col_offset=46), Name('placeholder_6', Load(), lineno=37, col_offset=48, end_lineno=37, end_col_offset=59)], [], lineno=37, col_offset=15, end_lineno=37, end_col_offset=60), lineno=37, col_offset=8, end_lineno=37, end_col_offset=60)], [Assign([Name('placeholder_10', Store(), lineno=41, col_offset=8, end_lineno=41, end_col_offset=22)], Call(Name('list', Load(), lineno=41, col_offset=25, end_lineno=41, end_col_offset=29), [Call(Name('range', Load(), lineno=41, col_offset=30, end_lineno=41, end_col_offset=35), [Name('placeholder_4', Load(), lineno=41, col_offset=36, end_lineno=41, end_col_offset=50), Name('placeholder_6', Load(), lineno=41, col_offset=52, end_lineno=41, end_col_offset=63)], [], lineno=41, col_offset=30, end_lineno=41, end_col_offset=64)], [], lineno=41, col_offset=25, end_lineno=41, end_col_offset=65), lineno=41, col_offset=8, end_lineno=41, end_col_offset=65), Return(Call(Name('chain', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=20), [Call(Name('permutations', Load(), lineno=46, col_offset=21, end_lineno=46, end_col_offset=33), [Name('placeholder_7', Load(), lineno=46, col_offset=34, end_lineno=46, end_col_offset=52), Name('placeholder_6', Load(), lineno=46, col_offset=54, end_lineno=46, end_col_offset=65)], [], lineno=46, col_offset=21, end_lineno=46, end_col_offset=66), Call(Name('map', Load(), lineno=47, col_offset=21, end_lineno=47, end_col_offset=24), [Lambda(arguments([], [arg('placeholder_11', lineno=47, col_offset=32, end_lineno=47, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), BinOp(BinOp(Subscript(Subscript(Name('placeholder_11', Load(), lineno=47, col_offset=39, end_lineno=47, end_col_offset=44), Constant(0, lineno=47, col_offset=45, end_lineno=47, end_col_offset=46), Load(), lineno=47, col_offset=39, end_lineno=47, end_col_offset=47), Slice(upper=Subscript(Name('placeholder_11', Load(), lineno=47, col_offset=49, end_lineno=47, end_col_offset=54), Constant(1, lineno=47, col_offset=55, end_lineno=47, end_col_offset=56), Load(), lineno=47, col_offset=49, end_lineno=47, end_col_offset=57), lineno=47, col_offset=48, end_lineno=47, end_col_offset=57), Load(), lineno=47, col_offset=39, end_lineno=47, end_col_offset=58), Add(), Tuple([Constant(0, lineno=47, col_offset=62, end_lineno=47, end_col_offset=63)], Load(), lineno=47, col_offset=61, end_lineno=47, end_col_offset=65), lineno=47, col_offset=39, end_lineno=47, end_col_offset=65), Add(), Subscript(Subscript(Name('placeholder_11', Load(), lineno=47, col_offset=68, end_lineno=47, end_col_offset=73), Constant(0, lineno=47, col_offset=74, end_lineno=47, end_col_offset=75), Load(), lineno=47, col_offset=68, end_lineno=47, end_col_offset=76), Slice(Subscript(Name('placeholder_11', Load(), lineno=47, col_offset=77, end_lineno=47, end_col_offset=82), Constant(1, lineno=47, col_offset=83, end_lineno=47, end_col_offset=84), Load(), lineno=47, col_offset=77, end_lineno=47, end_col_offset=85), lineno=47, col_offset=77, end_lineno=47, end_col_offset=86), Load(), lineno=47, col_offset=68, end_lineno=47, end_col_offset=87), lineno=47, col_offset=39, end_lineno=47, end_col_offset=87), lineno=47, col_offset=25, end_lineno=47, end_col_offset=87), Call(Name('product', Load(), lineno=48, col_offset=25, end_lineno=48, end_col_offset=32), [Call(Name('permutations', Load(), lineno=48, col_offset=33, end_lineno=48, end_col_offset=45), [Name('placeholder_7', Load(), lineno=48, col_offset=46, end_lineno=48, end_col_offset=64), BinOp(Name('placeholder_6', Load(), lineno=48, col_offset=66, end_lineno=48, end_col_offset=77), Sub(), Constant(1, lineno=48, col_offset=80, end_lineno=48, end_col_offset=81), lineno=48, col_offset=66, end_lineno=48, end_col_offset=81)], [], lineno=48, col_offset=33, end_lineno=48, end_col_offset=82), Name('placeholder_10', Load(), lineno=49, col_offset=33, end_lineno=49, end_col_offset=47)], [], lineno=48, col_offset=25, end_lineno=49, end_col_offset=48)], [], lineno=47, col_offset=21, end_lineno=49, end_col_offset=49)], [], lineno=46, col_offset=15, end_lineno=49, end_col_offset=50), lineno=46, col_offset=8, end_lineno=49, end_col_offset=50)], lineno=36, col_offset=4, end_lineno=49, end_col_offset=50)], lineno=33, col_offset=4, end_lineno=49, end_col_offset=50)], lineno=29, col_offset=4, end_lineno=49, end_col_offset=50)], [], lineno=15, col_offset=0, end_lineno=49, end_col_offset=50), FunctionDef('placeholder_12', arguments([], [arg('placeholder_13', lineno=52, col_offset=14, end_lineno=52, end_col_offset=22), arg('placeholder_14', lineno=52, col_offset=24, end_lineno=52, end_col_offset=35), arg('placeholder_15', lineno=52, col_offset=61, end_lineno=52, end_col_offset=66)], kwonlyargs=[], kw_defaults=[], defaults=[Tuple([Dict([], [], lineno=52, col_offset=37, end_lineno=52, end_col_offset=39), Constant(0, lineno=52, col_offset=41, end_lineno=52, end_col_offset=42), Call(Name('set', Load(), lineno=52, col_offset=44, end_lineno=52, end_col_offset=47), [Call(Name('range', Load(), lineno=52, col_offset=48, end_lineno=52, end_col_offset=53), [Constant(10, lineno=52, col_offset=54, end_lineno=52, end_col_offset=56)], [], lineno=52, col_offset=48, end_lineno=52, end_col_offset=57)], [], lineno=52, col_offset=44, end_lineno=52, end_col_offset=58)], Load(), lineno=52, col_offset=36, end_lineno=52, end_col_offset=59), Constant(0, lineno=52, col_offset=67, end_lineno=52, end_col_offset=68)]), [Assign([Tuple([Name('placeholder_16', Store(), lineno=64, col_offset=4, end_lineno=64, end_col_offset=18), Name('placeholder_17', Store(), lineno=64, col_offset=20, end_lineno=64, end_col_offset=37), Name('placeholder_2', Store(), lineno=64, col_offset=39, end_lineno=64, end_col_offset=53), Name('placeholder_18', Store(), lineno=64, col_offset=55, end_lineno=64, end_col_offset=65), Name('placeholder_19', Store(), lineno=64, col_offset=67, end_lineno=64, end_col_offset=79)], Store(), lineno=64, col_offset=4, end_lineno=64, end_col_offset=79)], Name('placeholder_13', Load(), lineno=64, col_offset=82, end_lineno=64, end_col_offset=90), lineno=64, col_offset=4, end_lineno=64, end_col_offset=90), Assign([Tuple([Name('placeholder_20', Store(), lineno=69, col_offset=4, end_lineno=69, end_col_offset=15), Name('placeholder_21', Store(), lineno=69, col_offset=17, end_lineno=69, end_col_offset=27), Name('placeholder_22', Store(), lineno=69, col_offset=29, end_lineno=69, end_col_offset=45)], Store(), lineno=69, col_offset=4, end_lineno=69, end_col_offset=45)], Name('placeholder_14', Load(), lineno=69, col_offset=48, end_lineno=69, end_col_offset=59), lineno=69, col_offset=4, end_lineno=69, end_col_offset=59), If(Compare(Name('placeholder_15', Load(), lineno=72, col_offset=7, end_lineno=72, end_col_offset=12), [Eq()], [Name('placeholder_16', Load(), lineno=72, col_offset=16, end_lineno=72, end_col_offset=30)], lineno=72, col_offset=7, end_lineno=72, end_col_offset=30), [If(Compare(Name('placeholder_21', Load(), lineno=74, col_offset=11, end_lineno=74, end_col_offset=21), [Eq()], [Constant(0, lineno=74, col_offset=25, end_lineno=74, end_col_offset=26)], lineno=74, col_offset=11, end_lineno=74, end_col_offset=26), [Return(Name('placeholder_20', Load(), lineno=75, col_offset=19, end_lineno=75, end_col_offset=30), lineno=75, col_offset=12, end_lineno=75, end_col_offset=30)], [Return(Dict([], [], lineno=79, col_offset=19, end_lineno=79, end_col_offset=21), lineno=79, col_offset=12, end_lineno=79, end_col_offset=21)], lineno=74, col_offset=8, end_lineno=79, end_col_offset=21)], [], lineno=72, col_offset=4, end_lineno=79, end_col_offset=21), Assign([Name('placeholder_23', Store(), lineno=80, col_offset=4, end_lineno=80, end_col_offset=17)], Subscript(Name('placeholder_19', Load(), lineno=80, col_offset=20, end_lineno=80, end_col_offset=32), Name('placeholder_15', Load(), lineno=80, col_offset=33, end_lineno=80, end_col_offset=38), Load(), lineno=80, col_offset=20, end_lineno=80, end_col_offset=39), lineno=80, col_offset=4, end_lineno=80, end_col_offset=39), Assign([Name('placeholder_24', Store(), lineno=81, col_offset=4, end_lineno=81, end_col_offset=12)], Name('placeholder_21', Load(), lineno=81, col_offset=15, end_lineno=81, end_col_offset=25), lineno=81, col_offset=4, end_lineno=81, end_col_offset=25), Assign([Name('placeholder_25', Store(), lineno=82, col_offset=4, end_lineno=82, end_col_offset=17)], List([], Load(), lineno=82, col_offset=20, end_lineno=82, end_col_offset=22), lineno=82, col_offset=4, end_lineno=82, end_col_offset=22), For(Tuple([Name('placeholder_26', Store(), lineno=85, col_offset=8, end_lineno=85, end_col_offset=14), Name('placeholder_27', Store(), lineno=85, col_offset=16, end_lineno=85, end_col_offset=24)], Store(), lineno=85, col_offset=8, end_lineno=85, end_col_offset=24), Subscript(Name('placeholder_17', Load(), lineno=85, col_offset=28, end_lineno=85, end_col_offset=45), Name('placeholder_15', Load(), lineno=85, col_offset=46, end_lineno=85, end_col_offset=51), Load(), lineno=85, col_offset=28, end_lineno=85, end_col_offset=52), [If(Compare(Name('placeholder_26', Load(), lineno=86, col_offset=11, end_lineno=86, end_col_offset=17), [In()], [Name('placeholder_20', Load(), lineno=86, col_offset=21, end_lineno=86, end_col_offset=32)], lineno=86, col_offset=11, end_lineno=86, end_col_offset=32), [AugAssign(Name('placeholder_24', Store(), lineno=87, col_offset=12, end_lineno=87, end_col_offset=20), Add(), BinOp(Name('placeholder_27', Load(), lineno=87, col_offset=24, end_lineno=87, end_col_offset=32), Mult(), Subscript(Name('placeholder_20', Load(), lineno=87, col_offset=35, end_lineno=87, end_col_offset=46), Name('placeholder_26', Load(), lineno=87, col_offset=47, end_lineno=87, end_col_offset=53), Load(), lineno=87, col_offset=35, end_lineno=87, end_col_offset=54), lineno=87, col_offset=24, end_lineno=87, end_col_offset=54), lineno=87, col_offset=12, end_lineno=87, end_col_offset=54)], [Expr(Call(Attribute(Name('placeholder_25', Load(), lineno=89, col_offset=12, end_lineno=89, end_col_offset=25), 'append', Load(), lineno=89, col_offset=12, end_lineno=89, end_col_offset=32), [Tuple([Name('placeholder_26', Load(), lineno=89, col_offset=34, end_lineno=89, end_col_offset=40), Name('placeholder_27', Load(), lineno=89, col_offset=42, end_lineno=89, end_col_offset=50)], Load(), lineno=89, col_offset=33, end_lineno=89, end_col_offset=51)], [], lineno=89, col_offset=12, end_lineno=89, end_col_offset=52), lineno=89, col_offset=12, end_lineno=89, end_col_offset=52)], lineno=86, col_offset=8, end_lineno=89, end_col_offset=52)], [], lineno=85, col_offset=4, end_lineno=89, end_col_offset=52), For(Name('placeholder_28', Store(), lineno=92, col_offset=8, end_lineno=92, end_col_offset=15), Call(Name('placeholder_0', Load(), lineno=92, col_offset=19, end_lineno=92, end_col_offset=28), [Name('placeholder_22', Load(), lineno=92, col_offset=29, end_lineno=92, end_col_offset=45), Subscript(Name('placeholder_2', Load(), lineno=92, col_offset=47, end_lineno=92, end_col_offset=61), Name('placeholder_15', Load(), lineno=92, col_offset=62, end_lineno=92, end_col_offset=67), Load(), lineno=92, col_offset=47, end_lineno=92, end_col_offset=68), Subscript(Name('placeholder_18', Load(), lineno=92, col_offset=70, end_lineno=92, end_col_offset=80), Name('placeholder_15', Load(), lineno=92, col_offset=81, end_lineno=92, end_col_offset=86), Load(), lineno=92, col_offset=70, end_lineno=92, end_col_offset=87)], [], lineno=92, col_offset=19, end_lineno=92, end_col_offset=88), [Assign([Name('placeholder_29', Store(), lineno=94, col_offset=8, end_lineno=94, end_col_offset=16)], Call(Name('dict', Load(), lineno=94, col_offset=19, end_lineno=94, end_col_offset=23), [Call(Name('zip', Load(), lineno=94, col_offset=24, end_lineno=94, end_col_offset=27), [Name('placeholder_23', Load(), lineno=94, col_offset=28, end_lineno=94, end_col_offset=41), Name('placeholder_28', Load(), lineno=94, col_offset=43, end_lineno=94, end_col_offset=50)], [], lineno=94, col_offset=24, end_lineno=94, end_col_offset=51)], [], lineno=94, col_offset=19, end_lineno=94, end_col_offset=52), lineno=94, col_offset=8, end_lineno=94, end_col_offset=52), Assign([Name('placeholder_30', Store(), lineno=96, col_offset=8, end_lineno=96, end_col_offset=15)], BinOp(Name('placeholder_24', Load(), lineno=96, col_offset=18, end_lineno=96, end_col_offset=26), Add(), Call(Name('sum', Load(), lineno=96, col_offset=29, end_lineno=96, end_col_offset=32), [ListComp(BinOp(Subscript(Name('placeholder_29', Load(), lineno=96, col_offset=34, end_lineno=96, end_col_offset=42), Name('placeholder_26', Load(), lineno=96, col_offset=43, end_lineno=96, end_col_offset=49), Load(), lineno=96, col_offset=34, end_lineno=96, end_col_offset=50), Mult(), Name('placeholder_27', Load(), lineno=96, col_offset=53, end_lineno=96, end_col_offset=61), lineno=96, col_offset=34, end_lineno=96, end_col_offset=61), [comprehension(Tuple([Name('placeholder_26', Store(), lineno=97, col_offset=37, end_lineno=97, end_col_offset=43), Name('placeholder_27', Store(), lineno=97, col_offset=45, end_lineno=97, end_col_offset=53)], Store(), lineno=97, col_offset=37, end_lineno=97, end_col_offset=53), Name('placeholder_25', Load(), lineno=97, col_offset=57, end_lineno=97, end_col_offset=70), [], 0)], lineno=96, col_offset=33, end_lineno=97, end_col_offset=71)], [], lineno=96, col_offset=29, end_lineno=97, end_col_offset=72), lineno=96, col_offset=18, end_lineno=97, end_col_offset=72), lineno=96, col_offset=8, end_lineno=97, end_col_offset=72), Assign([Tuple([Name('placeholder_31', Store(), lineno=99, col_offset=8, end_lineno=99, end_col_offset=12), Name('placeholder_32', Store(), lineno=99, col_offset=14, end_lineno=99, end_col_offset=23)], Store(), lineno=99, col_offset=8, end_lineno=99, end_col_offset=23)], Call(Name('divmod', Load(), lineno=99, col_offset=26, end_lineno=99, end_col_offset=32), [Name('placeholder_30', Load(), lineno=99, col_offset=33, end_lineno=99, end_col_offset=40), Constant(10, lineno=99, col_offset=42, end_lineno=99, end_col_offset=44)], [], lineno=99, col_offset=26, end_lineno=99, end_col_offset=45), lineno=99, col_offset=8, end_lineno=99, end_col_offset=45), If(Compare(Name('placeholder_32', Load(), lineno=100, col_offset=11, end_lineno=100, end_col_offset=20), [Eq()], [Constant(0, lineno=100, col_offset=24, end_lineno=100, end_col_offset=25)], lineno=100, col_offset=11, end_lineno=100, end_col_offset=25), [Expr(Call(Attribute(Name('placeholder_29', Load(), lineno=102, col_offset=12, end_lineno=102, end_col_offset=20), 'update', Load(), lineno=102, col_offset=12, end_lineno=102, end_col_offset=27), [Name('placeholder_20', Load(), lineno=102, col_offset=28, end_lineno=102, end_col_offset=39)], [], lineno=102, col_offset=12, end_lineno=102, end_col_offset=40), lineno=102, col_offset=12, end_lineno=102, end_col_offset=40), Assign([Name('placeholder_33', Store(), lineno=106, col_offset=12, end_lineno=106, end_col_offset=26)], Call(Name('placeholder_12', Load(), lineno=106, col_offset=29, end_lineno=106, end_col_offset=38), [Name('placeholder_13', Load(), lineno=106, col_offset=39, end_lineno=106, end_col_offset=47), Tuple([Name('placeholder_29', Load(), lineno=107, col_offset=33, end_lineno=107, end_col_offset=41), Name('placeholder_31', Load(), lineno=107, col_offset=43, end_lineno=107, end_col_offset=47), BinOp(Name('placeholder_22', Load(), lineno=107, col_offset=49, end_lineno=107, end_col_offset=65), Sub(), Call(Name('set', Load(), lineno=107, col_offset=68, end_lineno=107, end_col_offset=71), [Name('placeholder_28', Load(), lineno=107, col_offset=72, end_lineno=107, end_col_offset=79)], [], lineno=107, col_offset=68, end_lineno=107, end_col_offset=80), lineno=107, col_offset=49, end_lineno=107, end_col_offset=80)], Load(), lineno=107, col_offset=32, end_lineno=107, end_col_offset=81), BinOp(Name('placeholder_15', Load(), lineno=108, col_offset=32, end_lineno=108, end_col_offset=37), Add(), Constant(1, lineno=108, col_offset=40, end_lineno=108, end_col_offset=41), lineno=108, col_offset=32, end_lineno=108, end_col_offset=41)], [], lineno=106, col_offset=29, end_lineno=108, end_col_offset=42), lineno=106, col_offset=12, end_lineno=108, end_col_offset=42), If(BoolOp(And(), [Name('placeholder_33', Load(), lineno=112, col_offset=15, end_lineno=112, end_col_offset=29), Compare(Call(Name('len', Load(), lineno=112, col_offset=34, end_lineno=112, end_col_offset=37), [Name('placeholder_33', Load(), lineno=112, col_offset=38, end_lineno=112, end_col_offset=52)], [], lineno=112, col_offset=34, end_lineno=112, end_col_offset=53), [Gt()], [Constant(0, lineno=112, col_offset=56, end_lineno=112, end_col_offset=57)], lineno=112, col_offset=34, end_lineno=112, end_col_offset=57)], lineno=112, col_offset=15, end_lineno=112, end_col_offset=57), [Return(Name('placeholder_33', Load(), lineno=113, col_offset=23, end_lineno=113, end_col_offset=37), lineno=113, col_offset=16, end_lineno=113, end_col_offset=37)], [], lineno=112, col_offset=12, end_lineno=113, end_col_offset=37)], [], lineno=100, col_offset=8, end_lineno=113, end_col_offset=37)], [], lineno=92, col_offset=4, end_lineno=113, end_col_offset=37), Return(Constant(None, lineno=116, col_offset=11, end_lineno=116, end_col_offset=15), lineno=116, col_offset=4, end_lineno=116, end_col_offset=15)], [], lineno=52, col_offset=0, end_lineno=116, end_col_offset=15), FunctionDef('placeholder_34', arguments([], [arg('placeholder_35', lineno=119, col_offset=10, end_lineno=119, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_36', Store(), lineno=126, col_offset=4, end_lineno=126, end_col_offset=12)], ListComp(Call(Name('list', Load(), lineno=126, col_offset=16, end_lineno=126, end_col_offset=20), [Call(Name('map', Load(), lineno=126, col_offset=21, end_lineno=126, end_col_offset=24), [Lambda(arguments([], [arg('placeholder_39', lineno=126, col_offset=32, end_lineno=126, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('list', Load(), lineno=126, col_offset=37, end_lineno=126, end_col_offset=41), [Call(Name('reversed', Load(), lineno=126, col_offset=42, end_lineno=126, end_col_offset=50), [Call(Attribute(Name('placeholder_39', Load(), lineno=126, col_offset=51, end_lineno=126, end_col_offset=54), 'strip', Load(), lineno=126, col_offset=51, end_lineno=126, end_col_offset=60), [], [], lineno=126, col_offset=51, end_lineno=126, end_col_offset=62)], [], lineno=126, col_offset=42, end_lineno=126, end_col_offset=63)], [], lineno=126, col_offset=37, end_lineno=126, end_col_offset=64), lineno=126, col_offset=25, end_lineno=126, end_col_offset=64), Call(Attribute(Name('placeholder_38', Load(), lineno=126, col_offset=66, end_lineno=126, end_col_offset=73), 'split', Load(), lineno=126, col_offset=66, end_lineno=126, end_col_offset=79), [Constant('+', lineno=126, col_offset=80, end_lineno=126, end_col_offset=83)], [], lineno=126, col_offset=66, end_lineno=126, end_col_offset=84)], [], lineno=126, col_offset=21, end_lineno=126, end_col_offset=85)], [], lineno=126, col_offset=16, end_lineno=126, end_col_offset=86), [comprehension(Name('placeholder_38', Store(), lineno=127, col_offset=19, end_lineno=127, end_col_offset=26), Call(Attribute(Call(Attribute(Call(Attribute(Name('placeholder_35', Load(), lineno=127, col_offset=30, end_lineno=127, end_col_offset=36), 'strip', Load(), lineno=127, col_offset=30, end_lineno=127, end_col_offset=42), [], [], lineno=127, col_offset=30, end_lineno=127, end_col_offset=44), 'upper', Load(), lineno=127, col_offset=30, end_lineno=127, end_col_offset=50), [], [], lineno=127, col_offset=30, end_lineno=127, end_col_offset=52), 'split', Load(), lineno=127, col_offset=30, end_lineno=127, end_col_offset=58), [Constant('==', lineno=127, col_offset=59, end_lineno=127, end_col_offset=63)], [], lineno=127, col_offset=30, end_lineno=127, end_col_offset=64), [], 0)], lineno=126, col_offset=15, end_lineno=127, end_col_offset=65), lineno=126, col_offset=4, end_lineno=127, end_col_offset=65), Assign([Name('placeholder_16', Store(), lineno=130, col_offset=4, end_lineno=130, end_col_offset=18)], Call(Name('max', Load(), lineno=130, col_offset=21, end_lineno=130, end_col_offset=24), [ListComp(Call(Name('len', Load(), lineno=130, col_offset=26, end_lineno=130, end_col_offset=29), [Name('placeholder_40', Load(), lineno=130, col_offset=30, end_lineno=130, end_col_offset=36)], [], lineno=130, col_offset=26, end_lineno=130, end_col_offset=37), [comprehension(Name('placeholder_38', Store(), lineno=130, col_offset=42, end_lineno=130, end_col_offset=49), Name('placeholder_36', Load(), lineno=130, col_offset=53, end_lineno=130, end_col_offset=61), [], 0), comprehension(Name('placeholder_40', Store(), lineno=130, col_offset=66, end_lineno=130, end_col_offset=72), Name('placeholder_38', Load(), lineno=130, col_offset=76, end_lineno=130, end_col_offset=83), [], 0)], lineno=130, col_offset=25, end_lineno=130, end_col_offset=84)], [], lineno=130, col_offset=21, end_lineno=130, end_col_offset=85), lineno=130, col_offset=4, end_lineno=130, end_col_offset=85), Assign([Name('placeholder_41', Store(), lineno=133, col_offset=4, end_lineno=133, end_col_offset=11)], SetComp(Subscript(Name('placeholder_40', Load(), lineno=133, col_offset=15, end_lineno=133, end_col_offset=21), UnaryOp(USub(), Constant(1, lineno=133, col_offset=23, end_lineno=133, end_col_offset=24), lineno=133, col_offset=22, end_lineno=133, end_col_offset=24), Load(), lineno=133, col_offset=15, end_lineno=133, end_col_offset=25), [comprehension(Name('placeholder_38', Store(), lineno=133, col_offset=30, end_lineno=133, end_col_offset=37), Name('placeholder_36', Load(), lineno=133, col_offset=41, end_lineno=133, end_col_offset=49), [], 0), comprehension(Name('placeholder_40', Store(), lineno=133, col_offset=54, end_lineno=133, end_col_offset=60), Name('placeholder_38', Load(), lineno=133, col_offset=64, end_lineno=133, end_col_offset=71), [], 0)], lineno=133, col_offset=14, end_lineno=133, end_col_offset=72), lineno=133, col_offset=4, end_lineno=133, end_col_offset=72), Assign([Name('placeholder_2', Store(), lineno=135, col_offset=4, end_lineno=135, end_col_offset=18)], List([], Load(), lineno=135, col_offset=21, end_lineno=135, end_col_offset=23), lineno=135, col_offset=4, end_lineno=135, end_col_offset=23), Assign([Name('placeholder_18', Store(), lineno=136, col_offset=4, end_lineno=136, end_col_offset=14)], List([], Load(), lineno=136, col_offset=17, end_lineno=136, end_col_offset=19), lineno=136, col_offset=4, end_lineno=136, end_col_offset=19), Assign([Name('placeholder_19', Store(), lineno=137, col_offset=4, end_lineno=137, end_col_offset=16)], List([], Load(), lineno=137, col_offset=19, end_lineno=137, end_col_offset=21), lineno=137, col_offset=4, end_lineno=137, end_col_offset=21), Assign([Name('placeholder_17', Store(), lineno=138, col_offset=4, end_lineno=138, end_col_offset=21)], List([], Load(), lineno=138, col_offset=24, end_lineno=138, end_col_offset=26), lineno=138, col_offset=4, end_lineno=138, end_col_offset=26), For(Name('placeholder_42', Store(), lineno=139, col_offset=8, end_lineno=139, end_col_offset=9), Call(Name('range', Load(), lineno=139, col_offset=13, end_lineno=139, end_col_offset=18), [Name('placeholder_16', Load(), lineno=139, col_offset=19, end_lineno=139, end_col_offset=33)], [], lineno=139, col_offset=13, end_lineno=139, end_col_offset=34), [Expr(Call(Attribute(Name('placeholder_17', Load(), lineno=140, col_offset=8, end_lineno=140, end_col_offset=25), 'append', Load(), lineno=140, col_offset=8, end_lineno=140, end_col_offset=32), [Dict([], [], lineno=140, col_offset=33, end_lineno=140, end_col_offset=35)], [], lineno=140, col_offset=8, end_lineno=140, end_col_offset=36), lineno=140, col_offset=8, end_lineno=140, end_col_offset=36), Expr(Call(Attribute(Name('placeholder_2', Load(), lineno=141, col_offset=8, end_lineno=141, end_col_offset=22), 'append', Load(), lineno=141, col_offset=8, end_lineno=141, end_col_offset=29), [Call(Name('set', Load(), lineno=141, col_offset=30, end_lineno=141, end_col_offset=33), [], [], lineno=141, col_offset=30, end_lineno=141, end_col_offset=35)], [], lineno=141, col_offset=8, end_lineno=141, end_col_offset=36), lineno=141, col_offset=8, end_lineno=141, end_col_offset=36), Expr(Call(Attribute(Name('placeholder_18', Load(), lineno=142, col_offset=8, end_lineno=142, end_col_offset=18), 'append', Load(), lineno=142, col_offset=8, end_lineno=142, end_col_offset=25), [Call(Name('set', Load(), lineno=142, col_offset=26, end_lineno=142, end_col_offset=29), [], [], lineno=142, col_offset=26, end_lineno=142, end_col_offset=31)], [], lineno=142, col_offset=8, end_lineno=142, end_col_offset=32), lineno=142, col_offset=8, end_lineno=142, end_col_offset=32)], [], lineno=139, col_offset=4, end_lineno=142, end_col_offset=32), For(Tuple([Name('placeholder_37', Store(), lineno=144, col_offset=8, end_lineno=144, end_col_offset=11), Name('placeholder_38', Store(), lineno=144, col_offset=13, end_lineno=144, end_col_offset=20)], Store(), lineno=144, col_offset=8, end_lineno=144, end_col_offset=20), Call(Name('enumerate', Load(), lineno=144, col_offset=24, end_lineno=144, end_col_offset=33), [Name('placeholder_36', Load(), lineno=144, col_offset=34, end_lineno=144, end_col_offset=42)], [], lineno=144, col_offset=24, end_lineno=144, end_col_offset=43), [Assign([Name('placeholder_43', Store(), lineno=145, col_offset=8, end_lineno=145, end_col_offset=11)], BinOp(Constant(1, lineno=145, col_offset=14, end_lineno=145, end_col_offset=15), Sub(), BinOp(Name('placeholder_37', Load(), lineno=145, col_offset=19, end_lineno=145, end_col_offset=22), LShift(), Constant(1, lineno=145, col_offset=26, end_lineno=145, end_col_offset=27), lineno=145, col_offset=19, end_lineno=145, end_col_offset=27), lineno=145, col_offset=14, end_lineno=145, end_col_offset=28), lineno=145, col_offset=8, end_lineno=145, end_col_offset=28), For(Name('placeholder_40', Store(), lineno=146, col_offset=12, end_lineno=146, end_col_offset=18), Name('placeholder_38', Load(), lineno=146, col_offset=22, end_lineno=146, end_col_offset=29), [For(Tuple([Name('placeholder_44', Store(), lineno=147, col_offset=16, end_lineno=147, end_col_offset=23), Name('placeholder_45', Store(), lineno=147, col_offset=25, end_lineno=147, end_col_offset=31)], Store(), lineno=147, col_offset=16, end_lineno=147, end_col_offset=31), Call(Name('enumerate', Load(), lineno=147, col_offset=35, end_lineno=147, end_col_offset=44), [Name('placeholder_40', Load(), lineno=147, col_offset=45, end_lineno=147, end_col_offset=51)], [], lineno=147, col_offset=35, end_lineno=147, end_col_offset=52), [If(Compare(Name('placeholder_45', Load(), lineno=148, col_offset=19, end_lineno=148, end_col_offset=25), [NotIn()], [Subscript(Name('placeholder_17', Load(), lineno=148, col_offset=33, end_lineno=148, end_col_offset=50), Name('placeholder_44', Load(), lineno=148, col_offset=51, end_lineno=148, end_col_offset=58), Load(), lineno=148, col_offset=33, end_lineno=148, end_col_offset=59)], lineno=148, col_offset=19, end_lineno=148, end_col_offset=59), [Assign([Subscript(Subscript(Name('placeholder_17', Load(), lineno=149, col_offset=20, end_lineno=149, end_col_offset=37), Name('placeholder_44', Load(), lineno=149, col_offset=38, end_lineno=149, end_col_offset=45), Load(), lineno=149, col_offset=20, end_lineno=149, end_col_offset=46), Name('placeholder_45', Load(), lineno=149, col_offset=47, end_lineno=149, end_col_offset=53), Store(), lineno=149, col_offset=20, end_lineno=149, end_col_offset=54)], Constant(0, lineno=149, col_offset=57, end_lineno=149, end_col_offset=58), lineno=149, col_offset=20, end_lineno=149, end_col_offset=58)], [], lineno=148, col_offset=16, end_lineno=149, end_col_offset=58), AugAssign(Subscript(Subscript(Name('placeholder_17', Load(), lineno=150, col_offset=16, end_lineno=150, end_col_offset=33), Name('placeholder_44', Load(), lineno=150, col_offset=34, end_lineno=150, end_col_offset=41), Load(), lineno=150, col_offset=16, end_lineno=150, end_col_offset=42), Name('placeholder_45', Load(), lineno=150, col_offset=43, end_lineno=150, end_col_offset=49), Store(), lineno=150, col_offset=16, end_lineno=150, end_col_offset=50), Add(), Name('placeholder_43', Load(), lineno=150, col_offset=54, end_lineno=150, end_col_offset=57), lineno=150, col_offset=16, end_lineno=150, end_col_offset=57)], [], lineno=147, col_offset=12, end_lineno=150, end_col_offset=57)], [], lineno=146, col_offset=8, end_lineno=150, end_col_offset=57)], [], lineno=144, col_offset=4, end_lineno=150, end_col_offset=57), Assign([Name('placeholder_46', Store(), lineno=152, col_offset=4, end_lineno=152, end_col_offset=15)], Call(Name('set', Load(), lineno=152, col_offset=18, end_lineno=152, end_col_offset=21), [], [], lineno=152, col_offset=18, end_lineno=152, end_col_offset=23), lineno=152, col_offset=4, end_lineno=152, end_col_offset=23), For(Tuple([Name('placeholder_44', Store(), lineno=154, col_offset=8, end_lineno=154, end_col_offset=15), Name('placeholder_47', Store(), lineno=154, col_offset=17, end_lineno=154, end_col_offset=25)], Store(), lineno=154, col_offset=8, end_lineno=154, end_col_offset=25), Call(Name('enumerate', Load(), lineno=154, col_offset=29, end_lineno=154, end_col_offset=38), [Name('placeholder_17', Load(), lineno=154, col_offset=39, end_lineno=154, end_col_offset=56)], [], lineno=154, col_offset=29, end_lineno=154, end_col_offset=57), [For(Tuple([Name('placeholder_26', Store(), lineno=155, col_offset=12, end_lineno=155, end_col_offset=18), Name('placeholder_48', Store(), lineno=155, col_offset=20, end_lineno=155, end_col_offset=23)], Store(), lineno=155, col_offset=12, end_lineno=155, end_col_offset=23), Call(Name('tuple', Load(), lineno=155, col_offset=27, end_lineno=155, end_col_offset=32), [Call(Attribute(Name('placeholder_47', Load(), lineno=155, col_offset=33, end_lineno=155, end_col_offset=41), 'items', Load(), lineno=155, col_offset=33, end_lineno=155, end_col_offset=47), [], [], lineno=155, col_offset=33, end_lineno=155, end_col_offset=49)], [], lineno=155, col_offset=27, end_lineno=155, end_col_offset=50), [If(Compare(Name('placeholder_48', Load(), lineno=156, col_offset=15, end_lineno=156, end_col_offset=18), [Eq()], [Constant(0, lineno=156, col_offset=22, end_lineno=156, end_col_offset=23)], lineno=156, col_offset=15, end_lineno=156, end_col_offset=23), [Delete([Subscript(Name('placeholder_47', Load(), lineno=157, col_offset=20, end_lineno=157, end_col_offset=28), Name('placeholder_26', Load(), lineno=157, col_offset=29, end_lineno=157, end_col_offset=35), Del(), lineno=157, col_offset=20, end_lineno=157, end_col_offset=36)], lineno=157, col_offset=16, end_lineno=157, end_col_offset=36)], [If(Compare(Name('placeholder_26', Load(), lineno=161, col_offset=17, end_lineno=161, end_col_offset=23), [NotIn()], [Name('placeholder_46', Load(), lineno=161, col_offset=31, end_lineno=161, end_col_offset=42)], lineno=161, col_offset=17, end_lineno=161, end_col_offset=42), [If(Compare(Name('placeholder_26', Load(), lineno=164, col_offset=19, end_lineno=164, end_col_offset=25), [In()], [Name('placeholder_41', Load(), lineno=164, col_offset=29, end_lineno=164, end_col_offset=36)], lineno=164, col_offset=19, end_lineno=164, end_col_offset=36), [Expr(Call(Attribute(Subscript(Name('placeholder_2', Load(), lineno=165, col_offset=20, end_lineno=165, end_col_offset=34), Name('placeholder_44', Load(), lineno=165, col_offset=35, end_lineno=165, end_col_offset=42), Load(), lineno=165, col_offset=20, end_lineno=165, end_col_offset=43), 'add', Load(), lineno=165, col_offset=20, end_lineno=165, end_col_offset=47), [Name('placeholder_26', Load(), lineno=165, col_offset=48, end_lineno=165, end_col_offset=54)], [], lineno=165, col_offset=20, end_lineno=165, end_col_offset=55), lineno=165, col_offset=20, end_lineno=165, end_col_offset=55)], [Expr(Call(Attribute(Subscript(Name('placeholder_18', Load(), lineno=167, col_offset=20, end_lineno=167, end_col_offset=30), Name('placeholder_44', Load(), lineno=167, col_offset=31, end_lineno=167, end_col_offset=38), Load(), lineno=167, col_offset=20, end_lineno=167, end_col_offset=39), 'add', Load(), lineno=167, col_offset=20, end_lineno=167, end_col_offset=43), [Name('placeholder_26', Load(), lineno=167, col_offset=44, end_lineno=167, end_col_offset=50)], [], lineno=167, col_offset=20, end_lineno=167, end_col_offset=51), lineno=167, col_offset=20, end_lineno=167, end_col_offset=51)], lineno=164, col_offset=16, end_lineno=167, end_col_offset=51), Expr(Call(Attribute(Name('placeholder_46', Load(), lineno=170, col_offset=16, end_lineno=170, end_col_offset=27), 'add', Load(), lineno=170, col_offset=16, end_lineno=170, end_col_offset=31), [Name('placeholder_26', Load(), lineno=170, col_offset=32, end_lineno=170, end_col_offset=38)], [], lineno=170, col_offset=16, end_lineno=170, end_col_offset=39), lineno=170, col_offset=16, end_lineno=170, end_col_offset=39)], [], lineno=161, col_offset=12, end_lineno=170, end_col_offset=39)], lineno=156, col_offset=12, end_lineno=170, end_col_offset=39)], [], lineno=155, col_offset=8, end_lineno=170, end_col_offset=39), Expr(Call(Attribute(Name('placeholder_19', Load(), lineno=173, col_offset=8, end_lineno=173, end_col_offset=20), 'append', Load(), lineno=173, col_offset=8, end_lineno=173, end_col_offset=27), [BinOp(Call(Name('tuple', Load(), lineno=173, col_offset=28, end_lineno=173, end_col_offset=33), [Subscript(Name('placeholder_2', Load(), lineno=173, col_offset=34, end_lineno=173, end_col_offset=48), Name('placeholder_44', Load(), lineno=173, col_offset=49, end_lineno=173, end_col_offset=56), Load(), lineno=173, col_offset=34, end_lineno=173, end_col_offset=57)], [], lineno=173, col_offset=28, end_lineno=173, end_col_offset=58), Add(), Call(Name('tuple', Load(), lineno=173, col_offset=61, end_lineno=173, end_col_offset=66), [Subscript(Name('placeholder_18', Load(), lineno=173, col_offset=67, end_lineno=173, end_col_offset=77), Name('placeholder_44', Load(), lineno=173, col_offset=78, end_lineno=173, end_col_offset=85), Load(), lineno=173, col_offset=67, end_lineno=173, end_col_offset=86)], [], lineno=173, col_offset=61, end_lineno=173, end_col_offset=87), lineno=173, col_offset=28, end_lineno=173, end_col_offset=87)], [], lineno=173, col_offset=8, end_lineno=173, end_col_offset=88), lineno=173, col_offset=8, end_lineno=173, end_col_offset=88), Assign([Subscript(Name('placeholder_17', Load(), lineno=175, col_offset=8, end_lineno=175, end_col_offset=25), Name('placeholder_44', Load(), lineno=175, col_offset=26, end_lineno=175, end_col_offset=33), Store(), lineno=175, col_offset=8, end_lineno=175, end_col_offset=34)], Call(Name('tuple', Load(), lineno=175, col_offset=37, end_lineno=175, end_col_offset=42), [Call(Attribute(Name('placeholder_47', Load(), lineno=175, col_offset=43, end_lineno=175, end_col_offset=51), 'items', Load(), lineno=175, col_offset=43, end_lineno=175, end_col_offset=57), [], [], lineno=175, col_offset=43, end_lineno=175, end_col_offset=59)], [], lineno=175, col_offset=37, end_lineno=175, end_col_offset=60), lineno=175, col_offset=8, end_lineno=175, end_col_offset=60)], [], lineno=154, col_offset=4, end_lineno=175, end_col_offset=60), Return(Call(Name('placeholder_12', Load(), lineno=177, col_offset=11, end_lineno=177, end_col_offset=20), [List([Name('placeholder_16', Load(), lineno=177, col_offset=22, end_lineno=177, end_col_offset=36), Name('placeholder_17', Load(), lineno=177, col_offset=38, end_lineno=177, end_col_offset=55), Name('placeholder_2', Load(), lineno=177, col_offset=57, end_lineno=177, end_col_offset=71), Name('placeholder_18', Load(), lineno=177, col_offset=73, end_lineno=177, end_col_offset=83), Name('placeholder_19', Load(), lineno=177, col_offset=85, end_lineno=177, end_col_offset=97)], Load(), lineno=177, col_offset=21, end_lineno=177, end_col_offset=98)], [], lineno=177, col_offset=11, end_lineno=177, end_col_offset=99), lineno=177, col_offset=4, end_lineno=177, end_col_offset=99)], [], lineno=119, col_offset=0, end_lineno=177, end_col_offset=99)], []) \ No newline at end of file diff --git a/test/practice-anagram/.meta/config.json b/test/practice-anagram/.meta/config.json new file mode 100644 index 0000000..6dee5e1 --- /dev/null +++ b/test/practice-anagram/.meta/config.json @@ -0,0 +1,38 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "cmccandless", + "crazymykl", + "Dog", + "dotrungkien", + "henrik", + "ikhadykin", + "kytrinyx", + "lowks", + "markijbema", + "N-Parsons", + "n1k0", + "pheanex", + "roadfoodr", + "sjakobi", + "thomasjpfan", + "tqa236", + "vgerak", + "yawpitch" + ], + "files": { + "solution": [ + "anagram.py" + ], + "test": [ + "anagram_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a word and a list of possible anagrams, select the correct sublist.", + "source": "Inspired by the Extreme Startup game", + "source_url": "https://github.com/rchatley/extreme_startup" +} diff --git a/test/practice-anagram/anagram.py b/test/practice-anagram/anagram.py new file mode 100644 index 0000000..55929ff --- /dev/null +++ b/test/practice-anagram/anagram.py @@ -0,0 +1,9 @@ +def find_anagrams(word, candidates): + return [candidate + for candidate in candidates + if _letters(candidate) == _letters(word) + if candidate.lower() != word.lower()] + + +def _letters(word): + return sorted(word.lower()) diff --git a/test/practice-anagram/mapping.json b/test/practice-anagram/mapping.json new file mode 100644 index 0000000..7fb8d99 --- /dev/null +++ b/test/practice-anagram/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "find_anagrams", + "placeholder_1": "word", + "placeholder_2": "candidates", + "placeholder_3": "candidate", + "placeholder_4": "_letters" +} \ No newline at end of file diff --git a/test/practice-anagram/representation.json b/test/practice-anagram/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-anagram/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-anagram/representation.out b/test/practice-anagram/representation.out new file mode 100644 index 0000000..ffd414a --- /dev/null +++ b/test/practice-anagram/representation.out @@ -0,0 +1,468 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return [ + placeholder_3 + for placeholder_3 in placeholder_2 + if _letters(placeholder_3) == _letters(placeholder_1) + if placeholder_3.lower() != placeholder_1.lower() + ] + + +def placeholder_4(placeholder_1): + return sorted(placeholder_1.lower()) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'find_anagrams', + arguments( + [], + [ + arg( + 'word', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=22), + arg( + 'candidates', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'candidate', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=21), + [ + comprehension( + Name( + 'candidate', + Store(), + lineno=3, + col_offset=16, + end_lineno=3, + end_col_offset=25), + Name( + 'candidates', + Load(), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=39), + [ + Compare( + Call( + Name( + '_letters', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=23), + [ + Name( + 'candidate', + Load(), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=33)], + [], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=34), + [ + Eq()], + [ + Call( + Name( + '_letters', + Load(), + lineno=4, + col_offset=38, + end_lineno=4, + end_col_offset=46), + [ + Name( + 'word', + Load(), + lineno=4, + col_offset=47, + end_lineno=4, + end_col_offset=51)], + [], + lineno=4, + col_offset=38, + end_lineno=4, + end_col_offset=52)], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=52), + Compare( + Call( + Attribute( + Name( + 'candidate', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=24), + 'lower', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=30), + [], + [], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=32), + [ + NotEq()], + [ + Call( + Attribute( + Name( + 'word', + Load(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=40), + 'lower', + Load(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=46), + [], + [], + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=48)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=48)], + 0)], + lineno=2, + col_offset=11, + end_lineno=5, + end_col_offset=49), + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=49)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=49), + FunctionDef( + '_letters', + arguments( + [], + [ + arg( + 'word', + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sorted', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=17), + [ + Call( + Attribute( + Name( + 'word', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=22), + 'lower', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=28), + [], + [], + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=30)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=31), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=31)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=31)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=22), + arg( + 'placeholder_2', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=21), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=3, + col_offset=16, + end_lineno=3, + end_col_offset=25), + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=39), + [ + Compare( + Call( + Name( + '_letters', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=23), + [ + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=33)], + [], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=34), + [ + Eq()], + [ + Call( + Name( + '_letters', + Load(), + lineno=4, + col_offset=38, + end_lineno=4, + end_col_offset=46), + [ + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=47, + end_lineno=4, + end_col_offset=51)], + [], + lineno=4, + col_offset=38, + end_lineno=4, + end_col_offset=52)], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=52), + Compare( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=24), + 'lower', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=30), + [], + [], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=32), + [ + NotEq()], + [ + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=40), + 'lower', + Load(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=46), + [], + [], + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=48)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=48)], + 0)], + lineno=2, + col_offset=11, + end_lineno=5, + end_col_offset=49), + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=49)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=49), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sorted', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=17), + [ + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=22), + 'lower', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=28), + [], + [], + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=30)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=31), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=31)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=31)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-anagram/representation.txt b/test/practice-anagram/representation.txt new file mode 100644 index 0000000..cd4836a --- /dev/null +++ b/test/practice-anagram/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=18, end_lineno=1, end_col_offset=22), arg('placeholder_2', lineno=1, col_offset=24, end_lineno=1, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Name('placeholder_3', Load(), lineno=2, col_offset=12, end_lineno=2, end_col_offset=21), [comprehension(Name('placeholder_3', Store(), lineno=3, col_offset=16, end_lineno=3, end_col_offset=25), Name('placeholder_2', Load(), lineno=3, col_offset=29, end_lineno=3, end_col_offset=39), [Compare(Call(Name('_letters', Load(), lineno=4, col_offset=15, end_lineno=4, end_col_offset=23), [Name('placeholder_3', Load(), lineno=4, col_offset=24, end_lineno=4, end_col_offset=33)], [], lineno=4, col_offset=15, end_lineno=4, end_col_offset=34), [Eq()], [Call(Name('_letters', Load(), lineno=4, col_offset=38, end_lineno=4, end_col_offset=46), [Name('placeholder_1', Load(), lineno=4, col_offset=47, end_lineno=4, end_col_offset=51)], [], lineno=4, col_offset=38, end_lineno=4, end_col_offset=52)], lineno=4, col_offset=15, end_lineno=4, end_col_offset=52), Compare(Call(Attribute(Name('placeholder_3', Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=24), 'lower', Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=30), [], [], lineno=5, col_offset=15, end_lineno=5, end_col_offset=32), [NotEq()], [Call(Attribute(Name('placeholder_1', Load(), lineno=5, col_offset=36, end_lineno=5, end_col_offset=40), 'lower', Load(), lineno=5, col_offset=36, end_lineno=5, end_col_offset=46), [], [], lineno=5, col_offset=36, end_lineno=5, end_col_offset=48)], lineno=5, col_offset=15, end_lineno=5, end_col_offset=48)], 0)], lineno=2, col_offset=11, end_lineno=5, end_col_offset=49), lineno=2, col_offset=4, end_lineno=5, end_col_offset=49)], [], lineno=1, col_offset=0, end_lineno=5, end_col_offset=49), FunctionDef('placeholder_4', arguments([], [arg('placeholder_1', lineno=8, col_offset=13, end_lineno=8, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sorted', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=17), [Call(Attribute(Name('placeholder_1', Load(), lineno=9, col_offset=18, end_lineno=9, end_col_offset=22), 'lower', Load(), lineno=9, col_offset=18, end_lineno=9, end_col_offset=28), [], [], lineno=9, col_offset=18, end_lineno=9, end_col_offset=30)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=31), lineno=9, col_offset=4, end_lineno=9, end_col_offset=31)], [], lineno=8, col_offset=0, end_lineno=9, end_col_offset=31)], []) \ No newline at end of file diff --git a/test/practice-armstrong-numbers/.meta/config.json b/test/practice-armstrong-numbers/.meta/config.json new file mode 100644 index 0000000..2febbd2 --- /dev/null +++ b/test/practice-armstrong-numbers/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "pheanex" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "K4cePhoenix", + "sukovanej", + "tqa236" + ], + "files": { + "solution": [ + "armstrong_numbers.py" + ], + "test": [ + "armstrong_numbers_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Determine if a number is an Armstrong number.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" +} diff --git a/test/practice-armstrong-numbers/armstrong_numbers.py b/test/practice-armstrong-numbers/armstrong_numbers.py new file mode 100644 index 0000000..1ea1938 --- /dev/null +++ b/test/practice-armstrong-numbers/armstrong_numbers.py @@ -0,0 +1,2 @@ +def is_armstrong_number(number): + return sum(pow(int(digit), len(str(number))) for digit in str(number)) == number diff --git a/test/practice-armstrong-numbers/mapping.json b/test/practice-armstrong-numbers/mapping.json new file mode 100644 index 0000000..bb9df6e --- /dev/null +++ b/test/practice-armstrong-numbers/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "is_armstrong_number", + "placeholder_1": "number", + "placeholder_2": "digit" +} \ No newline at end of file diff --git a/test/practice-armstrong-numbers/representation.json b/test/practice-armstrong-numbers/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-armstrong-numbers/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-armstrong-numbers/representation.out b/test/practice-armstrong-numbers/representation.out new file mode 100644 index 0000000..a459086 --- /dev/null +++ b/test/practice-armstrong-numbers/representation.out @@ -0,0 +1,347 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return ( + sum( + ( + pow(int(placeholder_2), len(str(placeholder_1))) + for placeholder_2 in str(placeholder_1) + ) + ) + == placeholder_1 + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'is_armstrong_number', + arguments( + [], + [ + arg( + 'number', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + GeneratorExp( + Call( + Name( + 'pow', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=18), + [ + Call( + Name( + 'int', + Load(), + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=22), + [ + Name( + 'digit', + Load(), + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=28)], + [], + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=29), + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=31, + end_lineno=2, + end_col_offset=34), + [ + Call( + Name( + 'str', + Load(), + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=38), + [ + Name( + 'number', + Load(), + lineno=2, + col_offset=39, + end_lineno=2, + end_col_offset=45)], + [], + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=46)], + [], + lineno=2, + col_offset=31, + end_lineno=2, + end_col_offset=47)], + [], + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=48), + [ + comprehension( + Name( + 'digit', + Store(), + lineno=2, + col_offset=53, + end_lineno=2, + end_col_offset=58), + Call( + Name( + 'str', + Load(), + lineno=2, + col_offset=62, + end_lineno=2, + end_col_offset=65), + [ + Name( + 'number', + Load(), + lineno=2, + col_offset=66, + end_lineno=2, + end_col_offset=72)], + [], + lineno=2, + col_offset=62, + end_lineno=2, + end_col_offset=73), + [], + 0)], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=74)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=74), + [ + Eq()], + [ + Name( + 'number', + Load(), + lineno=2, + col_offset=78, + end_lineno=2, + end_col_offset=84)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=84), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=84)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=84)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + GeneratorExp( + Call( + Name( + 'pow', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=18), + [ + Call( + Name( + 'int', + Load(), + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=22), + [ + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=28)], + [], + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=29), + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=31, + end_lineno=2, + end_col_offset=34), + [ + Call( + Name( + 'str', + Load(), + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=38), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=39, + end_lineno=2, + end_col_offset=45)], + [], + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=46)], + [], + lineno=2, + col_offset=31, + end_lineno=2, + end_col_offset=47)], + [], + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=48), + [ + comprehension( + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=53, + end_lineno=2, + end_col_offset=58), + Call( + Name( + 'str', + Load(), + lineno=2, + col_offset=62, + end_lineno=2, + end_col_offset=65), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=66, + end_lineno=2, + end_col_offset=72)], + [], + lineno=2, + col_offset=62, + end_lineno=2, + end_col_offset=73), + [], + 0)], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=74)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=74), + [ + Eq()], + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=78, + end_lineno=2, + end_col_offset=84)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=84), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=84)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=84)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-armstrong-numbers/representation.txt b/test/practice-armstrong-numbers/representation.txt new file mode 100644 index 0000000..5f4a2b8 --- /dev/null +++ b/test/practice-armstrong-numbers/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=24, end_lineno=1, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Call(Name('sum', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=14), [GeneratorExp(Call(Name('pow', Load(), lineno=2, col_offset=15, end_lineno=2, end_col_offset=18), [Call(Name('int', Load(), lineno=2, col_offset=19, end_lineno=2, end_col_offset=22), [Name('placeholder_2', Load(), lineno=2, col_offset=23, end_lineno=2, end_col_offset=28)], [], lineno=2, col_offset=19, end_lineno=2, end_col_offset=29), Call(Name('len', Load(), lineno=2, col_offset=31, end_lineno=2, end_col_offset=34), [Call(Name('str', Load(), lineno=2, col_offset=35, end_lineno=2, end_col_offset=38), [Name('placeholder_1', Load(), lineno=2, col_offset=39, end_lineno=2, end_col_offset=45)], [], lineno=2, col_offset=35, end_lineno=2, end_col_offset=46)], [], lineno=2, col_offset=31, end_lineno=2, end_col_offset=47)], [], lineno=2, col_offset=15, end_lineno=2, end_col_offset=48), [comprehension(Name('placeholder_2', Store(), lineno=2, col_offset=53, end_lineno=2, end_col_offset=58), Call(Name('str', Load(), lineno=2, col_offset=62, end_lineno=2, end_col_offset=65), [Name('placeholder_1', Load(), lineno=2, col_offset=66, end_lineno=2, end_col_offset=72)], [], lineno=2, col_offset=62, end_lineno=2, end_col_offset=73), [], 0)], lineno=2, col_offset=14, end_lineno=2, end_col_offset=74)], [], lineno=2, col_offset=11, end_lineno=2, end_col_offset=74), [Eq()], [Name('placeholder_1', Load(), lineno=2, col_offset=78, end_lineno=2, end_col_offset=84)], lineno=2, col_offset=11, end_lineno=2, end_col_offset=84), lineno=2, col_offset=4, end_lineno=2, end_col_offset=84)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=84)], []) \ No newline at end of file diff --git a/test/practice-atbash-cipher/.meta/config.json b/test/practice-atbash-cipher/.meta/config.json new file mode 100644 index 0000000..9f678c6 --- /dev/null +++ b/test/practice-atbash-cipher/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "jgomo3", + "kytrinyx", + "N-Parsons", + "parinporecha", + "pheanex", + "sjakobi", + "thomasjpfan", + "tqa236" + ], + "files": { + "solution": [ + "atbash_cipher.py" + ], + "test": [ + "atbash_cipher_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Atbash" +} diff --git a/test/practice-atbash-cipher/atbash_cipher.py b/test/practice-atbash-cipher/atbash_cipher.py new file mode 100644 index 0000000..a358998 --- /dev/null +++ b/test/practice-atbash-cipher/atbash_cipher.py @@ -0,0 +1,19 @@ +from string import ascii_lowercase + + +BLOCK_SIZE = 5 +trtbl = str.maketrans(ascii_lowercase, ascii_lowercase[::-1]) + + +def base_trans(text): + return ''.join([character for character in text if character.isalnum()]).lower().translate(trtbl) + + +def encode(plain): + cipher = base_trans(plain) + return ' '.join(cipher[idx:idx + BLOCK_SIZE] + for idx in range(0, len(cipher), BLOCK_SIZE)) + + +def decode(ciphered): + return base_trans(ciphered) diff --git a/test/practice-atbash-cipher/mapping.json b/test/practice-atbash-cipher/mapping.json new file mode 100644 index 0000000..a5a6452 --- /dev/null +++ b/test/practice-atbash-cipher/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "BLOCK_SIZE", + "placeholder_1": "trtbl", + "placeholder_2": "base_trans", + "placeholder_3": "text", + "placeholder_4": "character", + "placeholder_5": "encode", + "placeholder_6": "plain", + "placeholder_7": "cipher", + "placeholder_8": "idx", + "placeholder_9": "decode", + "placeholder_10": "ciphered" +} \ No newline at end of file diff --git a/test/practice-atbash-cipher/representation.json b/test/practice-atbash-cipher/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-atbash-cipher/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-atbash-cipher/representation.out b/test/practice-atbash-cipher/representation.out new file mode 100644 index 0000000..b3b7506 --- /dev/null +++ b/test/practice-atbash-cipher/representation.out @@ -0,0 +1,985 @@ +## BEGIN NORMALIZED CODE ## +from string import ascii_lowercase + +placeholder_0 = 5 +placeholder_1 = str.maketrans(ascii_lowercase, ascii_lowercase[::-1]) + + +def placeholder_2(placeholder_3): + return ( + "".join( + [ + placeholder_4 + for placeholder_4 in placeholder_3 + if placeholder_4.isalnum() + ] + ) + .lower() + .translate(placeholder_1) + ) + + +def placeholder_5(placeholder_6): + placeholder_7 = placeholder_2(placeholder_6) + return " ".join( + ( + placeholder_7[placeholder_8 : placeholder_8 + placeholder_0] + for placeholder_8 in range(0, len(placeholder_7), placeholder_0) + ) + ) + + +def placeholder_9(placeholder_10): + return placeholder_2(placeholder_10) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'string', + [ + alias( + 'ascii_lowercase', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + Assign( + [ + Name( + 'BLOCK_SIZE', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=10)], + Constant( + 5, + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=14), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=14), + Assign( + [ + Name( + 'trtbl', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=5)], + Call( + Attribute( + Name( + 'str', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=11), + 'maketrans', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=21), + [ + Name( + 'ascii_lowercase', + Load(), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=37), + Subscript( + Name( + 'ascii_lowercase', + Load(), + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=54), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=5, + col_offset=58, + end_lineno=5, + end_col_offset=59), + lineno=5, + col_offset=57, + end_lineno=5, + end_col_offset=59), + lineno=5, + col_offset=55, + end_lineno=5, + end_col_offset=59), + Load(), + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=60)], + [], + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=61), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=61), + FunctionDef( + 'base_trans', + arguments( + [], + [ + arg( + 'text', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Constant( + '', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=13), + 'join', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + [ + ListComp( + Name( + 'character', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=29), + [ + comprehension( + Name( + 'character', + Store(), + lineno=9, + col_offset=34, + end_lineno=9, + end_col_offset=43), + Name( + 'text', + Load(), + lineno=9, + col_offset=47, + end_lineno=9, + end_col_offset=51), + [ + Call( + Attribute( + Name( + 'character', + Load(), + lineno=9, + col_offset=55, + end_lineno=9, + end_col_offset=64), + 'isalnum', + Load(), + lineno=9, + col_offset=55, + end_lineno=9, + end_col_offset=72), + [], + [], + lineno=9, + col_offset=55, + end_lineno=9, + end_col_offset=74)], + 0)], + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=75)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=76), + 'lower', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=82), + [], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=84), + 'translate', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=94), + [ + Name( + 'trtbl', + Load(), + lineno=9, + col_offset=95, + end_lineno=9, + end_col_offset=100)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=101), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=101)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=101), + FunctionDef( + 'encode', + arguments( + [], + [ + arg( + 'plain', + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'cipher', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=10)], + Call( + Name( + 'base_trans', + Load(), + lineno=13, + col_offset=13, + end_lineno=13, + end_col_offset=23), + [ + Name( + 'plain', + Load(), + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=29)], + [], + lineno=13, + col_offset=13, + end_lineno=13, + end_col_offset=30), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=30), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + 'join', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=19), + [ + GeneratorExp( + Subscript( + Name( + 'cipher', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=26), + Slice( + Name( + 'idx', + Load(), + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=30), + BinOp( + Name( + 'idx', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=34), + Add(), + Name( + 'BLOCK_SIZE', + Load(), + lineno=14, + col_offset=37, + end_lineno=14, + end_col_offset=47), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=47), + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=47), + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=48), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=28), + Call( + Name( + 'range', + Load(), + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=37), + [ + Constant( + 0, + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=39), + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=44), + [ + Name( + 'cipher', + Load(), + lineno=15, + col_offset=45, + end_lineno=15, + end_col_offset=51)], + [], + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=52), + Name( + 'BLOCK_SIZE', + Load(), + lineno=15, + col_offset=54, + end_lineno=15, + end_col_offset=64)], + [], + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=65), + [], + 0)], + lineno=14, + col_offset=19, + end_lineno=15, + end_col_offset=66)], + [], + lineno=14, + col_offset=11, + end_lineno=15, + end_col_offset=66), + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=66)], + [], + lineno=12, + col_offset=0, + end_lineno=15, + end_col_offset=66), + FunctionDef( + 'decode', + arguments( + [], + [ + arg( + 'ciphered', + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'base_trans', + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=21), + [ + Name( + 'ciphered', + Load(), + lineno=19, + col_offset=22, + end_lineno=19, + end_col_offset=30)], + [], + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=31), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=31)], + [], + lineno=18, + col_offset=0, + end_lineno=19, + end_col_offset=31)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'string', + [ + alias( + 'ascii_lowercase', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=10)], + Constant( + 5, + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=14), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=5)], + Call( + Attribute( + Name( + 'str', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=11), + 'maketrans', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=21), + [ + Name( + 'ascii_lowercase', + Load(), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=37), + Subscript( + Name( + 'ascii_lowercase', + Load(), + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=54), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=5, + col_offset=58, + end_lineno=5, + end_col_offset=59), + lineno=5, + col_offset=57, + end_lineno=5, + end_col_offset=59), + lineno=5, + col_offset=55, + end_lineno=5, + end_col_offset=59), + Load(), + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=60)], + [], + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=61), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=61), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Constant( + '', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=13), + 'join', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + [ + ListComp( + Name( + 'placeholder_4', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=29), + [ + comprehension( + Name( + 'placeholder_4', + Store(), + lineno=9, + col_offset=34, + end_lineno=9, + end_col_offset=43), + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=47, + end_lineno=9, + end_col_offset=51), + [ + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=9, + col_offset=55, + end_lineno=9, + end_col_offset=64), + 'isalnum', + Load(), + lineno=9, + col_offset=55, + end_lineno=9, + end_col_offset=72), + [], + [], + lineno=9, + col_offset=55, + end_lineno=9, + end_col_offset=74)], + 0)], + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=75)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=76), + 'lower', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=82), + [], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=84), + 'translate', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=94), + [ + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=95, + end_lineno=9, + end_col_offset=100)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=101), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=101)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=101), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=10)], + Call( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=13, + end_lineno=13, + end_col_offset=23), + [ + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=29)], + [], + lineno=13, + col_offset=13, + end_lineno=13, + end_col_offset=30), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=30), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + 'join', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=19), + [ + GeneratorExp( + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=26), + Slice( + Name( + 'placeholder_8', + Load(), + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=30), + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=34), + Add(), + Name( + 'placeholder_0', + Load(), + lineno=14, + col_offset=37, + end_lineno=14, + end_col_offset=47), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=47), + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=47), + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=48), + [ + comprehension( + Name( + 'placeholder_8', + Store(), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=28), + Call( + Name( + 'range', + Load(), + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=37), + [ + Constant( + 0, + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=39), + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=44), + [ + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=45, + end_lineno=15, + end_col_offset=51)], + [], + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=52), + Name( + 'placeholder_0', + Load(), + lineno=15, + col_offset=54, + end_lineno=15, + end_col_offset=64)], + [], + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=65), + [], + 0)], + lineno=14, + col_offset=19, + end_lineno=15, + end_col_offset=66)], + [], + lineno=14, + col_offset=11, + end_lineno=15, + end_col_offset=66), + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=66)], + [], + lineno=12, + col_offset=0, + end_lineno=15, + end_col_offset=66), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_2', + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=21), + [ + Name( + 'placeholder_10', + Load(), + lineno=19, + col_offset=22, + end_lineno=19, + end_col_offset=30)], + [], + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=31), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=31)], + [], + lineno=18, + col_offset=0, + end_lineno=19, + end_col_offset=31)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-atbash-cipher/representation.txt b/test/practice-atbash-cipher/representation.txt new file mode 100644 index 0000000..e001e25 --- /dev/null +++ b/test/practice-atbash-cipher/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('string', [alias('ascii_lowercase', lineno=1, col_offset=19, end_lineno=1, end_col_offset=34)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=34), Assign([Name('placeholder_0', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=10)], Constant(5, lineno=4, col_offset=13, end_lineno=4, end_col_offset=14), lineno=4, col_offset=0, end_lineno=4, end_col_offset=14), Assign([Name('placeholder_1', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=5)], Call(Attribute(Name('str', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=11), 'maketrans', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=21), [Name('ascii_lowercase', Load(), lineno=5, col_offset=22, end_lineno=5, end_col_offset=37), Subscript(Name('ascii_lowercase', Load(), lineno=5, col_offset=39, end_lineno=5, end_col_offset=54), Slice(step=UnaryOp(USub(), Constant(1, lineno=5, col_offset=58, end_lineno=5, end_col_offset=59), lineno=5, col_offset=57, end_lineno=5, end_col_offset=59), lineno=5, col_offset=55, end_lineno=5, end_col_offset=59), Load(), lineno=5, col_offset=39, end_lineno=5, end_col_offset=60)], [], lineno=5, col_offset=8, end_lineno=5, end_col_offset=61), lineno=5, col_offset=0, end_lineno=5, end_col_offset=61), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=8, col_offset=15, end_lineno=8, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Call(Attribute(Call(Attribute(Constant('', lineno=9, col_offset=11, end_lineno=9, end_col_offset=13), 'join', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=18), [ListComp(Name('placeholder_4', Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=29), [comprehension(Name('placeholder_4', Store(), lineno=9, col_offset=34, end_lineno=9, end_col_offset=43), Name('placeholder_3', Load(), lineno=9, col_offset=47, end_lineno=9, end_col_offset=51), [Call(Attribute(Name('placeholder_4', Load(), lineno=9, col_offset=55, end_lineno=9, end_col_offset=64), 'isalnum', Load(), lineno=9, col_offset=55, end_lineno=9, end_col_offset=72), [], [], lineno=9, col_offset=55, end_lineno=9, end_col_offset=74)], 0)], lineno=9, col_offset=19, end_lineno=9, end_col_offset=75)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=76), 'lower', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=82), [], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=84), 'translate', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=94), [Name('placeholder_1', Load(), lineno=9, col_offset=95, end_lineno=9, end_col_offset=100)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=101), lineno=9, col_offset=4, end_lineno=9, end_col_offset=101)], [], lineno=8, col_offset=0, end_lineno=9, end_col_offset=101), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=12, col_offset=11, end_lineno=12, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=10)], Call(Name('placeholder_2', Load(), lineno=13, col_offset=13, end_lineno=13, end_col_offset=23), [Name('placeholder_6', Load(), lineno=13, col_offset=24, end_lineno=13, end_col_offset=29)], [], lineno=13, col_offset=13, end_lineno=13, end_col_offset=30), lineno=13, col_offset=4, end_lineno=13, end_col_offset=30), Return(Call(Attribute(Constant(' ', lineno=14, col_offset=11, end_lineno=14, end_col_offset=14), 'join', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=19), [GeneratorExp(Subscript(Name('placeholder_7', Load(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=26), Slice(Name('placeholder_8', Load(), lineno=14, col_offset=27, end_lineno=14, end_col_offset=30), BinOp(Name('placeholder_8', Load(), lineno=14, col_offset=31, end_lineno=14, end_col_offset=34), Add(), Name('placeholder_0', Load(), lineno=14, col_offset=37, end_lineno=14, end_col_offset=47), lineno=14, col_offset=31, end_lineno=14, end_col_offset=47), lineno=14, col_offset=27, end_lineno=14, end_col_offset=47), Load(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=48), [comprehension(Name('placeholder_8', Store(), lineno=15, col_offset=25, end_lineno=15, end_col_offset=28), Call(Name('range', Load(), lineno=15, col_offset=32, end_lineno=15, end_col_offset=37), [Constant(0, lineno=15, col_offset=38, end_lineno=15, end_col_offset=39), Call(Name('len', Load(), lineno=15, col_offset=41, end_lineno=15, end_col_offset=44), [Name('placeholder_7', Load(), lineno=15, col_offset=45, end_lineno=15, end_col_offset=51)], [], lineno=15, col_offset=41, end_lineno=15, end_col_offset=52), Name('placeholder_0', Load(), lineno=15, col_offset=54, end_lineno=15, end_col_offset=64)], [], lineno=15, col_offset=32, end_lineno=15, end_col_offset=65), [], 0)], lineno=14, col_offset=19, end_lineno=15, end_col_offset=66)], [], lineno=14, col_offset=11, end_lineno=15, end_col_offset=66), lineno=14, col_offset=4, end_lineno=15, end_col_offset=66)], [], lineno=12, col_offset=0, end_lineno=15, end_col_offset=66), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=18, col_offset=11, end_lineno=18, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_2', Load(), lineno=19, col_offset=11, end_lineno=19, end_col_offset=21), [Name('placeholder_10', Load(), lineno=19, col_offset=22, end_lineno=19, end_col_offset=30)], [], lineno=19, col_offset=11, end_lineno=19, end_col_offset=31), lineno=19, col_offset=4, end_lineno=19, end_col_offset=31)], [], lineno=18, col_offset=0, end_lineno=19, end_col_offset=31)], []) \ No newline at end of file diff --git a/test/practice-bank-account/.meta/config.json b/test/practice-bank-account/.meta/config.json new file mode 100644 index 0000000..51483ec --- /dev/null +++ b/test/practice-bank-account/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [], + "contributors": [ + "cmccandless", + "Dog", + "tqa236", + "bethanyg", + "meatball133" + ], + "files": { + "solution": [ + "bank_account.py" + ], + "test": [ + "bank_account_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Simulate a bank account supporting opening/closing, withdraws, and deposits of money. Watch out for concurrent transactions!" +} diff --git a/test/practice-bank-account/bank_account.py b/test/practice-bank-account/bank_account.py new file mode 100644 index 0000000..90ddf31 --- /dev/null +++ b/test/practice-bank-account/bank_account.py @@ -0,0 +1,43 @@ +import threading + + +class BankAccount: + def __init__(self): + self.is_open = False + self.balance = None + self.lock = threading.Lock() + + def get_balance(self): + with self.lock: + if not self.is_open: + raise ValueError('account not open') + return self.balance + + def open(self): + if self.is_open: + raise ValueError('account already open') + self.is_open = True + self.balance = 0 + + def deposit(self, amount): + with self.lock: + if not self.is_open: + raise ValueError('account not open') + if amount <= 0: + raise ValueError('amount must be greater than 0') + self.balance += amount + + def withdraw(self, amount): + with self.lock: + if not self.is_open: + raise ValueError('account not open') + if amount <= 0: + raise ValueError('amount must be greater than 0') + if amount > self.balance: + raise ValueError('amount must be less than balance') + self.balance -= amount + + def close(self): + if not self.is_open: + raise ValueError('account not open') + self.is_open = False diff --git a/test/practice-bank-account/mapping.json b/test/practice-bank-account/mapping.json new file mode 100644 index 0000000..ea0217b --- /dev/null +++ b/test/practice-bank-account/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "BankAccount", + "placeholder_1": "__init__", + "placeholder_2": "is_open", + "placeholder_3": "balance", + "placeholder_4": "lock", + "placeholder_5": "get_balance", + "placeholder_6": "deposit", + "placeholder_7": "amount", + "placeholder_8": "withdraw", + "placeholder_9": "close" +} \ No newline at end of file diff --git a/test/practice-bank-account/representation.json b/test/practice-bank-account/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-bank-account/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-bank-account/representation.out b/test/practice-bank-account/representation.out new file mode 100644 index 0000000..8ee261d --- /dev/null +++ b/test/practice-bank-account/representation.out @@ -0,0 +1,1828 @@ +## BEGIN NORMALIZED CODE ## +import threading + + +class placeholder_0: + def placeholder_1(self): + self.placeholder_2 = False + self.placeholder_3 = None + self.placeholder_4 = threading.Lock() + + def placeholder_5(self): + with self.placeholder_4: + if not self.placeholder_2: + raise ValueError("account not open") + return self.placeholder_3 + + def open(self): + if self.placeholder_2: + raise ValueError("account already open") + self.placeholder_2 = True + self.placeholder_3 = 0 + + def placeholder_6(self, placeholder_7): + with self.placeholder_4: + if not self.placeholder_2: + raise ValueError("account not open") + if placeholder_7 <= 0: + raise ValueError("amount must be greater than 0") + self.placeholder_3 += placeholder_7 + + def placeholder_8(self, placeholder_7): + with self.placeholder_4: + if not self.placeholder_2: + raise ValueError("account not open") + if placeholder_7 <= 0: + raise ValueError("amount must be greater than 0") + if placeholder_7 > self.placeholder_3: + raise ValueError("amount must be less than balance") + self.placeholder_3 -= placeholder_7 + + def placeholder_9(self): + if not self.placeholder_2: + raise ValueError("account not open") + self.placeholder_2 = False + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'threading', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=16)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16), + ClassDef( + 'BankAccount', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'is_open', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=20)], + Constant( + False, + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'balance', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=20)], + Constant( + None, + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=27), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'lock', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=17)], + Call( + Attribute( + Name( + 'threading', + Load(), + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=29), + 'Lock', + Load(), + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=34), + [], + [], + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=36), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=36)], + [], + lineno=5, + col_offset=4, + end_lineno=8, + end_col_offset=36), + FunctionDef( + 'get_balance', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + With( + [ + withitem( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=17), + 'lock', + Load(), + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=22))], + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=23), + 'is_open', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=31), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=32), + [ + Constant( + 'account not open', + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=51)], + [], + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=52), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=52)], + [], + lineno=12, + col_offset=12, + end_lineno=13, + end_col_offset=52), + Return( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=23), + 'balance', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=31), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=31)], + lineno=11, + col_offset=8, + end_lineno=14, + end_col_offset=31)], + [], + lineno=10, + col_offset=4, + end_lineno=14, + end_col_offset=31), + FunctionDef( + 'open', + arguments( + [], + [ + arg( + 'self', + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=15), + 'is_open', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=23), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=28), + [ + Constant( + 'account already open', + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=51)], + [], + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=52), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=52)], + [], + lineno=17, + col_offset=8, + end_lineno=18, + end_col_offset=52), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=12), + 'is_open', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=20)], + Constant( + True, + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=27), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=12), + 'balance', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=20)], + Constant( + 0, + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=24), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=24)], + [], + lineno=16, + col_offset=4, + end_lineno=20, + end_col_offset=24), + FunctionDef( + 'deposit', + arguments( + [], + [ + arg( + 'self', + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20), + arg( + 'amount', + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + With( + [ + withitem( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=17), + 'lock', + Load(), + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=22))], + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=23), + 'is_open', + Load(), + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=31), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=32), + [ + Constant( + 'account not open', + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=51)], + [], + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=52), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=52)], + [], + lineno=24, + col_offset=12, + end_lineno=25, + end_col_offset=52), + If( + Compare( + Name( + 'amount', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=21), + [ + LtE()], + [ + Constant( + 0, + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=26)], + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=32), + [ + Constant( + 'amount must be greater than 0', + lineno=27, + col_offset=33, + end_lineno=27, + end_col_offset=64)], + [], + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=65), + lineno=27, + col_offset=16, + end_lineno=27, + end_col_offset=65)], + [], + lineno=26, + col_offset=12, + end_lineno=27, + end_col_offset=65), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=16), + 'balance', + Store(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=24), + Add(), + Name( + 'amount', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=34), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=34)], + lineno=23, + col_offset=8, + end_lineno=28, + end_col_offset=34)], + [], + lineno=22, + col_offset=4, + end_lineno=28, + end_col_offset=34), + FunctionDef( + 'withdraw', + arguments( + [], + [ + arg( + 'self', + lineno=30, + col_offset=17, + end_lineno=30, + end_col_offset=21), + arg( + 'amount', + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + With( + [ + withitem( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=17), + 'lock', + Load(), + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=22))], + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=23), + 'is_open', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=31), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=32), + [ + Constant( + 'account not open', + lineno=33, + col_offset=33, + end_lineno=33, + end_col_offset=51)], + [], + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=52), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=52)], + [], + lineno=32, + col_offset=12, + end_lineno=33, + end_col_offset=52), + If( + Compare( + Name( + 'amount', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=21), + [ + LtE()], + [ + Constant( + 0, + lineno=34, + col_offset=25, + end_lineno=34, + end_col_offset=26)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=32), + [ + Constant( + 'amount must be greater than 0', + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=64)], + [], + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=65), + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=65)], + [], + lineno=34, + col_offset=12, + end_lineno=35, + end_col_offset=65), + If( + Compare( + Name( + 'amount', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=21), + [ + Gt()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=28), + 'balance', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=36)], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=32), + [ + Constant( + 'amount must be less than balance', + lineno=37, + col_offset=33, + end_lineno=37, + end_col_offset=67)], + [], + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=68), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=68)], + [], + lineno=36, + col_offset=12, + end_lineno=37, + end_col_offset=68), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=16), + 'balance', + Store(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=24), + Sub(), + Name( + 'amount', + Load(), + lineno=38, + col_offset=28, + end_lineno=38, + end_col_offset=34), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=34)], + lineno=31, + col_offset=8, + end_lineno=38, + end_col_offset=34)], + [], + lineno=30, + col_offset=4, + end_lineno=38, + end_col_offset=34), + FunctionDef( + 'close', + arguments( + [], + [ + arg( + 'self', + lineno=40, + col_offset=14, + end_lineno=40, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=19), + 'is_open', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=27), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=28), + [ + Constant( + 'account not open', + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=47)], + [], + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=48), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=48)], + [], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=48), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=12), + 'is_open', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=20)], + Constant( + False, + lineno=43, + col_offset=23, + end_lineno=43, + end_col_offset=28), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=28)], + [], + lineno=40, + col_offset=4, + end_lineno=43, + end_col_offset=28)], + [], + lineno=4, + col_offset=0, + end_lineno=43, + end_col_offset=28)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'threading', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=16)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=20)], + Constant( + False, + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=20)], + Constant( + None, + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=27), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=17)], + Call( + Attribute( + Name( + 'threading', + Load(), + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=29), + 'Lock', + Load(), + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=34), + [], + [], + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=36), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=36)], + [], + lineno=5, + col_offset=4, + end_lineno=8, + end_col_offset=36), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + With( + [ + withitem( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=17), + 'placeholder_4', + Load(), + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=22))], + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=23), + 'placeholder_2', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=31), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=32), + [ + Constant( + 'account not open', + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=51)], + [], + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=52), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=52)], + [], + lineno=12, + col_offset=12, + end_lineno=13, + end_col_offset=52), + Return( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=23), + 'placeholder_3', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=31), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=31)], + lineno=11, + col_offset=8, + end_lineno=14, + end_col_offset=31)], + [], + lineno=10, + col_offset=4, + end_lineno=14, + end_col_offset=31), + FunctionDef( + 'open', + arguments( + [], + [ + arg( + 'self', + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=15), + 'placeholder_2', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=23), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=28), + [ + Constant( + 'account already open', + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=51)], + [], + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=52), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=52)], + [], + lineno=17, + col_offset=8, + end_lineno=18, + end_col_offset=52), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=20)], + Constant( + True, + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=27), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=20)], + Constant( + 0, + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=24), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=24)], + [], + lineno=16, + col_offset=4, + end_lineno=20, + end_col_offset=24), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20), + arg( + 'placeholder_7', + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + With( + [ + withitem( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=17), + 'placeholder_4', + Load(), + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=22))], + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=23), + 'placeholder_2', + Load(), + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=31), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=32), + [ + Constant( + 'account not open', + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=51)], + [], + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=52), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=52)], + [], + lineno=24, + col_offset=12, + end_lineno=25, + end_col_offset=52), + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=21), + [ + LtE()], + [ + Constant( + 0, + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=26)], + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=32), + [ + Constant( + 'amount must be greater than 0', + lineno=27, + col_offset=33, + end_lineno=27, + end_col_offset=64)], + [], + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=65), + lineno=27, + col_offset=16, + end_lineno=27, + end_col_offset=65)], + [], + lineno=26, + col_offset=12, + end_lineno=27, + end_col_offset=65), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=16), + 'placeholder_3', + Store(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=24), + Add(), + Name( + 'placeholder_7', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=34), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=34)], + lineno=23, + col_offset=8, + end_lineno=28, + end_col_offset=34)], + [], + lineno=22, + col_offset=4, + end_lineno=28, + end_col_offset=34), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=30, + col_offset=17, + end_lineno=30, + end_col_offset=21), + arg( + 'placeholder_7', + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + With( + [ + withitem( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=17), + 'placeholder_4', + Load(), + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=22))], + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=23), + 'placeholder_2', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=31), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=32), + [ + Constant( + 'account not open', + lineno=33, + col_offset=33, + end_lineno=33, + end_col_offset=51)], + [], + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=52), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=52)], + [], + lineno=32, + col_offset=12, + end_lineno=33, + end_col_offset=52), + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=21), + [ + LtE()], + [ + Constant( + 0, + lineno=34, + col_offset=25, + end_lineno=34, + end_col_offset=26)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=32), + [ + Constant( + 'amount must be greater than 0', + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=64)], + [], + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=65), + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=65)], + [], + lineno=34, + col_offset=12, + end_lineno=35, + end_col_offset=65), + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=21), + [ + Gt()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=28), + 'placeholder_3', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=36)], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=32), + [ + Constant( + 'amount must be less than balance', + lineno=37, + col_offset=33, + end_lineno=37, + end_col_offset=67)], + [], + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=68), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=68)], + [], + lineno=36, + col_offset=12, + end_lineno=37, + end_col_offset=68), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=16), + 'placeholder_3', + Store(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=24), + Sub(), + Name( + 'placeholder_7', + Load(), + lineno=38, + col_offset=28, + end_lineno=38, + end_col_offset=34), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=34)], + lineno=31, + col_offset=8, + end_lineno=38, + end_col_offset=34)], + [], + lineno=30, + col_offset=4, + end_lineno=38, + end_col_offset=34), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=40, + col_offset=14, + end_lineno=40, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=27), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=28), + [ + Constant( + 'account not open', + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=47)], + [], + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=48), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=48)], + [], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=48), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=20)], + Constant( + False, + lineno=43, + col_offset=23, + end_lineno=43, + end_col_offset=28), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=28)], + [], + lineno=40, + col_offset=4, + end_lineno=43, + end_col_offset=28)], + [], + lineno=4, + col_offset=0, + end_lineno=43, + end_col_offset=28)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-bank-account/representation.txt b/test/practice-bank-account/representation.txt new file mode 100644 index 0000000..8cc9448 --- /dev/null +++ b/test/practice-bank-account/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('threading', lineno=1, col_offset=7, end_lineno=1, end_col_offset=16)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=16), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_2', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=20)], Constant(False, lineno=6, col_offset=23, end_lineno=6, end_col_offset=28), lineno=6, col_offset=8, end_lineno=6, end_col_offset=28), Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_3', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=20)], Constant(None, lineno=7, col_offset=23, end_lineno=7, end_col_offset=27), lineno=7, col_offset=8, end_lineno=7, end_col_offset=27), Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_4', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=17)], Call(Attribute(Name('threading', Load(), lineno=8, col_offset=20, end_lineno=8, end_col_offset=29), 'Lock', Load(), lineno=8, col_offset=20, end_lineno=8, end_col_offset=34), [], [], lineno=8, col_offset=20, end_lineno=8, end_col_offset=36), lineno=8, col_offset=8, end_lineno=8, end_col_offset=36)], [], lineno=5, col_offset=4, end_lineno=8, end_col_offset=36), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=10, col_offset=20, end_lineno=10, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [With([withitem(Attribute(Name('self', Load(), lineno=11, col_offset=13, end_lineno=11, end_col_offset=17), 'placeholder_4', Load(), lineno=11, col_offset=13, end_lineno=11, end_col_offset=22))], [If(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=12, col_offset=19, end_lineno=12, end_col_offset=23), 'placeholder_2', Load(), lineno=12, col_offset=19, end_lineno=12, end_col_offset=31), lineno=12, col_offset=15, end_lineno=12, end_col_offset=31), [Raise(Call(Name('ValueError', Load(), lineno=13, col_offset=22, end_lineno=13, end_col_offset=32), [Constant('account not open', lineno=13, col_offset=33, end_lineno=13, end_col_offset=51)], [], lineno=13, col_offset=22, end_lineno=13, end_col_offset=52), lineno=13, col_offset=16, end_lineno=13, end_col_offset=52)], [], lineno=12, col_offset=12, end_lineno=13, end_col_offset=52), Return(Attribute(Name('self', Load(), lineno=14, col_offset=19, end_lineno=14, end_col_offset=23), 'placeholder_3', Load(), lineno=14, col_offset=19, end_lineno=14, end_col_offset=31), lineno=14, col_offset=12, end_lineno=14, end_col_offset=31)], lineno=11, col_offset=8, end_lineno=14, end_col_offset=31)], [], lineno=10, col_offset=4, end_lineno=14, end_col_offset=31), FunctionDef('open', arguments([], [arg('self', lineno=16, col_offset=13, end_lineno=16, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Attribute(Name('self', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=15), 'placeholder_2', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=23), [Raise(Call(Name('ValueError', Load(), lineno=18, col_offset=18, end_lineno=18, end_col_offset=28), [Constant('account already open', lineno=18, col_offset=29, end_lineno=18, end_col_offset=51)], [], lineno=18, col_offset=18, end_lineno=18, end_col_offset=52), lineno=18, col_offset=12, end_lineno=18, end_col_offset=52)], [], lineno=17, col_offset=8, end_lineno=18, end_col_offset=52), Assign([Attribute(Name('self', Load(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=12), 'placeholder_2', Store(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=20)], Constant(True, lineno=19, col_offset=23, end_lineno=19, end_col_offset=27), lineno=19, col_offset=8, end_lineno=19, end_col_offset=27), Assign([Attribute(Name('self', Load(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=12), 'placeholder_3', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=20)], Constant(0, lineno=20, col_offset=23, end_lineno=20, end_col_offset=24), lineno=20, col_offset=8, end_lineno=20, end_col_offset=24)], [], lineno=16, col_offset=4, end_lineno=20, end_col_offset=24), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=22, col_offset=16, end_lineno=22, end_col_offset=20), arg('placeholder_7', lineno=22, col_offset=22, end_lineno=22, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [With([withitem(Attribute(Name('self', Load(), lineno=23, col_offset=13, end_lineno=23, end_col_offset=17), 'placeholder_4', Load(), lineno=23, col_offset=13, end_lineno=23, end_col_offset=22))], [If(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=24, col_offset=19, end_lineno=24, end_col_offset=23), 'placeholder_2', Load(), lineno=24, col_offset=19, end_lineno=24, end_col_offset=31), lineno=24, col_offset=15, end_lineno=24, end_col_offset=31), [Raise(Call(Name('ValueError', Load(), lineno=25, col_offset=22, end_lineno=25, end_col_offset=32), [Constant('account not open', lineno=25, col_offset=33, end_lineno=25, end_col_offset=51)], [], lineno=25, col_offset=22, end_lineno=25, end_col_offset=52), lineno=25, col_offset=16, end_lineno=25, end_col_offset=52)], [], lineno=24, col_offset=12, end_lineno=25, end_col_offset=52), If(Compare(Name('placeholder_7', Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=21), [LtE()], [Constant(0, lineno=26, col_offset=25, end_lineno=26, end_col_offset=26)], lineno=26, col_offset=15, end_lineno=26, end_col_offset=26), [Raise(Call(Name('ValueError', Load(), lineno=27, col_offset=22, end_lineno=27, end_col_offset=32), [Constant('amount must be greater than 0', lineno=27, col_offset=33, end_lineno=27, end_col_offset=64)], [], lineno=27, col_offset=22, end_lineno=27, end_col_offset=65), lineno=27, col_offset=16, end_lineno=27, end_col_offset=65)], [], lineno=26, col_offset=12, end_lineno=27, end_col_offset=65), AugAssign(Attribute(Name('self', Load(), lineno=28, col_offset=12, end_lineno=28, end_col_offset=16), 'placeholder_3', Store(), lineno=28, col_offset=12, end_lineno=28, end_col_offset=24), Add(), Name('placeholder_7', Load(), lineno=28, col_offset=28, end_lineno=28, end_col_offset=34), lineno=28, col_offset=12, end_lineno=28, end_col_offset=34)], lineno=23, col_offset=8, end_lineno=28, end_col_offset=34)], [], lineno=22, col_offset=4, end_lineno=28, end_col_offset=34), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=30, col_offset=17, end_lineno=30, end_col_offset=21), arg('placeholder_7', lineno=30, col_offset=23, end_lineno=30, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [With([withitem(Attribute(Name('self', Load(), lineno=31, col_offset=13, end_lineno=31, end_col_offset=17), 'placeholder_4', Load(), lineno=31, col_offset=13, end_lineno=31, end_col_offset=22))], [If(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=32, col_offset=19, end_lineno=32, end_col_offset=23), 'placeholder_2', Load(), lineno=32, col_offset=19, end_lineno=32, end_col_offset=31), lineno=32, col_offset=15, end_lineno=32, end_col_offset=31), [Raise(Call(Name('ValueError', Load(), lineno=33, col_offset=22, end_lineno=33, end_col_offset=32), [Constant('account not open', lineno=33, col_offset=33, end_lineno=33, end_col_offset=51)], [], lineno=33, col_offset=22, end_lineno=33, end_col_offset=52), lineno=33, col_offset=16, end_lineno=33, end_col_offset=52)], [], lineno=32, col_offset=12, end_lineno=33, end_col_offset=52), If(Compare(Name('placeholder_7', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=21), [LtE()], [Constant(0, lineno=34, col_offset=25, end_lineno=34, end_col_offset=26)], lineno=34, col_offset=15, end_lineno=34, end_col_offset=26), [Raise(Call(Name('ValueError', Load(), lineno=35, col_offset=22, end_lineno=35, end_col_offset=32), [Constant('amount must be greater than 0', lineno=35, col_offset=33, end_lineno=35, end_col_offset=64)], [], lineno=35, col_offset=22, end_lineno=35, end_col_offset=65), lineno=35, col_offset=16, end_lineno=35, end_col_offset=65)], [], lineno=34, col_offset=12, end_lineno=35, end_col_offset=65), If(Compare(Name('placeholder_7', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=21), [Gt()], [Attribute(Name('self', Load(), lineno=36, col_offset=24, end_lineno=36, end_col_offset=28), 'placeholder_3', Load(), lineno=36, col_offset=24, end_lineno=36, end_col_offset=36)], lineno=36, col_offset=15, end_lineno=36, end_col_offset=36), [Raise(Call(Name('ValueError', Load(), lineno=37, col_offset=22, end_lineno=37, end_col_offset=32), [Constant('amount must be less than balance', lineno=37, col_offset=33, end_lineno=37, end_col_offset=67)], [], lineno=37, col_offset=22, end_lineno=37, end_col_offset=68), lineno=37, col_offset=16, end_lineno=37, end_col_offset=68)], [], lineno=36, col_offset=12, end_lineno=37, end_col_offset=68), AugAssign(Attribute(Name('self', Load(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=16), 'placeholder_3', Store(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=24), Sub(), Name('placeholder_7', Load(), lineno=38, col_offset=28, end_lineno=38, end_col_offset=34), lineno=38, col_offset=12, end_lineno=38, end_col_offset=34)], lineno=31, col_offset=8, end_lineno=38, end_col_offset=34)], [], lineno=30, col_offset=4, end_lineno=38, end_col_offset=34), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=40, col_offset=14, end_lineno=40, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=19), 'placeholder_2', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=27), lineno=41, col_offset=11, end_lineno=41, end_col_offset=27), [Raise(Call(Name('ValueError', Load(), lineno=42, col_offset=18, end_lineno=42, end_col_offset=28), [Constant('account not open', lineno=42, col_offset=29, end_lineno=42, end_col_offset=47)], [], lineno=42, col_offset=18, end_lineno=42, end_col_offset=48), lineno=42, col_offset=12, end_lineno=42, end_col_offset=48)], [], lineno=41, col_offset=8, end_lineno=42, end_col_offset=48), Assign([Attribute(Name('self', Load(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=12), 'placeholder_2', Store(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=20)], Constant(False, lineno=43, col_offset=23, end_lineno=43, end_col_offset=28), lineno=43, col_offset=8, end_lineno=43, end_col_offset=28)], [], lineno=40, col_offset=4, end_lineno=43, end_col_offset=28)], [], lineno=4, col_offset=0, end_lineno=43, end_col_offset=28)], []) \ No newline at end of file diff --git a/test/practice-beer-song/.meta/config.json b/test/practice-beer-song/.meta/config.json new file mode 100644 index 0000000..834501e --- /dev/null +++ b/test/practice-beer-song/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "lowks", + "N-Parsons", + "pheanex", + "rootulp", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "beer_song.py" + ], + "test": [ + "beer_song_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.", + "source": "Learn to Program by Chris Pine", + "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" +} diff --git a/test/practice-beer-song/beer_song.py b/test/practice-beer-song/beer_song.py new file mode 100644 index 0000000..4dfa8ea --- /dev/null +++ b/test/practice-beer-song/beer_song.py @@ -0,0 +1,38 @@ +def recite(start, take=1): + results = [] + for idx in range(start, start - take, -1): + results.extend(verse(idx)) + if idx > start - take + 1: + results.append('') + return results + + +def verse(number): + return [ + f'{_bottles(number).capitalize()} of beer on the wall, {_bottles(number)} of beer.', + f'{_action(number)}{_next_bottle(number)}' + ] + + +def _action(current_verse): + if current_verse == 0: + return 'Go to the store and buy some more, ' + else: + return f'Take {"one" if current_verse > 1 else "it"} down and pass it around, ' + + +def _next_bottle(current_verse): + return f'{_bottles(_next_verse(current_verse))} of beer on the wall.' + + +def _bottles(number): + if number == 0: + return 'no more bottles' + if number == 1: + return '1 bottle' + else: + return f'{number} bottles' + + +def _next_verse(current_verse): + return current_verse - 1 if current_verse > 0 else 99 diff --git a/test/practice-beer-song/mapping.json b/test/practice-beer-song/mapping.json new file mode 100644 index 0000000..1874dbe --- /dev/null +++ b/test/practice-beer-song/mapping.json @@ -0,0 +1,14 @@ +{ + "placeholder_0": "recite", + "placeholder_1": "start", + "placeholder_2": "take", + "placeholder_3": "results", + "placeholder_4": "idx", + "placeholder_5": "verse", + "placeholder_6": "number", + "placeholder_7": "_action", + "placeholder_8": "current_verse", + "placeholder_9": "_next_bottle", + "placeholder_10": "_bottles", + "placeholder_11": "_next_verse" +} \ No newline at end of file diff --git a/test/practice-beer-song/representation.json b/test/practice-beer-song/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-beer-song/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-beer-song/representation.out b/test/practice-beer-song/representation.out new file mode 100644 index 0000000..49fc1c4 --- /dev/null +++ b/test/practice-beer-song/representation.out @@ -0,0 +1,1755 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2=1): + placeholder_3 = [] + for placeholder_4 in range(placeholder_1, placeholder_1 - placeholder_2, -1): + placeholder_3.extend(verse(placeholder_4)) + if placeholder_4 > placeholder_1 - placeholder_2 + 1: + placeholder_3.append("") + return placeholder_3 + + +def placeholder_5(placeholder_6): + return [ + f"{_bottles(placeholder_6).capitalize()} of beer on the wall, {_bottles(placeholder_6)} of beer.", + f"{_action(placeholder_6)}{_next_bottle(placeholder_6)}", + ] + + +def placeholder_7(placeholder_8): + if placeholder_8 == 0: + return "Go to the store and buy some more, " + else: + return ( + f"Take {('one' if placeholder_8 > 1 else 'it')} down and pass it around, " + ) + + +def placeholder_9(placeholder_8): + return f"{_bottles(_next_verse(placeholder_8))} of beer on the wall." + + +def placeholder_10(placeholder_6): + if placeholder_6 == 0: + return "no more bottles" + if placeholder_6 == 1: + return "1 bottle" + else: + return f"{placeholder_6} bottles" + + +def placeholder_11(placeholder_8): + return placeholder_8 - 1 if placeholder_8 > 0 else 99 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'recite', + arguments( + [], + [ + arg( + 'start', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=16), + arg( + 'take', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 1, + lineno=1, + col_offset=23, + end_lineno=1, + end_col_offset=24)]), + [ + Assign( + [ + Name( + 'results', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11)], + List( + [], + Load(), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=16), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=16), + For( + Name( + 'idx', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + [ + Name( + 'start', + Load(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=26), + BinOp( + Name( + 'start', + Load(), + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=33), + Sub(), + Name( + 'take', + Load(), + lineno=3, + col_offset=36, + end_lineno=3, + end_col_offset=40), + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=40), + UnaryOp( + USub(), + Constant( + 1, + lineno=3, + col_offset=43, + end_lineno=3, + end_col_offset=44), + lineno=3, + col_offset=42, + end_lineno=3, + end_col_offset=44)], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=45), + [ + Expr( + Call( + Attribute( + Name( + 'results', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=15), + 'extend', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=22), + [ + Call( + Name( + 'verse', + Load(), + lineno=4, + col_offset=23, + end_lineno=4, + end_col_offset=28), + [ + Name( + 'idx', + Load(), + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=32)], + [], + lineno=4, + col_offset=23, + end_lineno=4, + end_col_offset=33)], + [], + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=34), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=34), + If( + Compare( + Name( + 'idx', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + Gt()], + [ + BinOp( + BinOp( + Name( + 'start', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=22), + Sub(), + Name( + 'take', + Load(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=29), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=29), + Add(), + Constant( + 1, + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=33)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=33), + [ + Expr( + Call( + Attribute( + Name( + 'results', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=19), + 'append', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=26), + [ + Constant( + '', + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=29)], + [], + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=30), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=30)], + [], + lineno=5, + col_offset=8, + end_lineno=6, + end_col_offset=30)], + [], + lineno=3, + col_offset=4, + end_lineno=6, + end_col_offset=30), + Return( + Name( + 'results', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=18), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=18)], + [], + lineno=1, + col_offset=0, + end_lineno=7, + end_col_offset=18), + FunctionDef( + 'verse', + arguments( + [], + [ + arg( + 'number', + lineno=10, + col_offset=10, + end_lineno=10, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + List( + [ + JoinedStr( + [ + FormattedValue( + Call( + Attribute( + Call( + Name( + '_bottles', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=19), + [ + Name( + 'number', + Load(), + lineno=12, + col_offset=20, + end_lineno=12, + end_col_offset=26)], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=27), + 'capitalize', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=38), + [], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=40), + -1, + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91), + Constant( + ' of beer on the wall, ', + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91), + FormattedValue( + Call( + Name( + '_bottles', + Load(), + lineno=12, + col_offset=64, + end_lineno=12, + end_col_offset=72), + [ + Name( + 'number', + Load(), + lineno=12, + col_offset=73, + end_lineno=12, + end_col_offset=79)], + [], + lineno=12, + col_offset=64, + end_lineno=12, + end_col_offset=80), + -1, + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91), + Constant( + ' of beer.', + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91)], + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91), + JoinedStr( + [ + FormattedValue( + Call( + Name( + '_action', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=18), + [ + Name( + 'number', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=25)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=26), + -1, + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=50), + FormattedValue( + Call( + Name( + '_next_bottle', + Load(), + lineno=13, + col_offset=28, + end_lineno=13, + end_col_offset=40), + [ + Name( + 'number', + Load(), + lineno=13, + col_offset=41, + end_lineno=13, + end_col_offset=47)], + [], + lineno=13, + col_offset=28, + end_lineno=13, + end_col_offset=48), + -1, + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=50)], + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=50)], + Load(), + lineno=11, + col_offset=11, + end_lineno=14, + end_col_offset=5), + lineno=11, + col_offset=4, + end_lineno=14, + end_col_offset=5)], + [], + lineno=10, + col_offset=0, + end_lineno=14, + end_col_offset=5), + FunctionDef( + '_action', + arguments( + [], + [ + arg( + 'current_verse', + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'current_verse', + Load(), + lineno=18, + col_offset=7, + end_lineno=18, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 0, + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=25)], + lineno=18, + col_offset=7, + end_lineno=18, + end_col_offset=25), + [ + Return( + Constant( + 'Go to the store and buy some more, ', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=52), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=52)], + [ + Return( + JoinedStr( + [ + Constant( + 'Take ', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=87), + FormattedValue( + IfExp( + Compare( + Name( + 'current_verse', + Load(), + lineno=21, + col_offset=32, + end_lineno=21, + end_col_offset=45), + [ + Gt()], + [ + Constant( + 1, + lineno=21, + col_offset=48, + end_lineno=21, + end_col_offset=49)], + lineno=21, + col_offset=32, + end_lineno=21, + end_col_offset=49), + Constant( + 'one', + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=28), + Constant( + 'it', + lineno=21, + col_offset=55, + end_lineno=21, + end_col_offset=59), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=59), + -1, + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=87), + Constant( + ' down and pass it around, ', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=87)], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=87), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=87)], + lineno=18, + col_offset=4, + end_lineno=21, + end_col_offset=87)], + [], + lineno=17, + col_offset=0, + end_lineno=21, + end_col_offset=87), + FunctionDef( + '_next_bottle', + arguments( + [], + [ + arg( + 'current_verse', + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + FormattedValue( + Call( + Name( + '_bottles', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=22), + [ + Call( + Name( + '_next_verse', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=34), + [ + Name( + 'current_verse', + Load(), + lineno=25, + col_offset=35, + end_lineno=25, + end_col_offset=48)], + [], + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=49)], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=50), + -1, + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=73), + Constant( + ' of beer on the wall.', + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=73)], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=73), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=73)], + [], + lineno=24, + col_offset=0, + end_lineno=25, + end_col_offset=73), + FunctionDef( + '_bottles', + arguments( + [], + [ + arg( + 'number', + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 0, + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=18)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=18), + [ + Return( + Constant( + 'no more bottles', + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=32), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=32)], + [], + lineno=29, + col_offset=4, + end_lineno=30, + end_col_offset=32), + If( + Compare( + Name( + 'number', + Load(), + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 1, + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=18)], + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=18), + [ + Return( + Constant( + '1 bottle', + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=25), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=25)], + [ + Return( + JoinedStr( + [ + FormattedValue( + Name( + 'number', + Load(), + lineno=34, + col_offset=18, + end_lineno=34, + end_col_offset=24), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=34), + Constant( + ' bottles', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=34)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=34), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=34)], + lineno=31, + col_offset=4, + end_lineno=34, + end_col_offset=34)], + [], + lineno=28, + col_offset=0, + end_lineno=34, + end_col_offset=34), + FunctionDef( + '_next_verse', + arguments( + [], + [ + arg( + 'current_verse', + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Name( + 'current_verse', + Load(), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=45), + [ + Gt()], + [ + Constant( + 0, + lineno=38, + col_offset=48, + end_lineno=38, + end_col_offset=49)], + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=49), + BinOp( + Name( + 'current_verse', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=24), + Sub(), + Constant( + 1, + lineno=38, + col_offset=27, + end_lineno=38, + end_col_offset=28), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=28), + Constant( + 99, + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=57), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=57), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=57)], + [], + lineno=37, + col_offset=0, + end_lineno=38, + end_col_offset=57)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=16), + arg( + 'placeholder_2', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 1, + lineno=1, + col_offset=23, + end_lineno=1, + end_col_offset=24)]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11)], + List( + [], + Load(), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=16), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=16), + For( + Name( + 'placeholder_4', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + [ + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=26), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=33), + Sub(), + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=36, + end_lineno=3, + end_col_offset=40), + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=40), + UnaryOp( + USub(), + Constant( + 1, + lineno=3, + col_offset=43, + end_lineno=3, + end_col_offset=44), + lineno=3, + col_offset=42, + end_lineno=3, + end_col_offset=44)], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=45), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=15), + 'extend', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=22), + [ + Call( + Name( + 'verse', + Load(), + lineno=4, + col_offset=23, + end_lineno=4, + end_col_offset=28), + [ + Name( + 'placeholder_4', + Load(), + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=32)], + [], + lineno=4, + col_offset=23, + end_lineno=4, + end_col_offset=33)], + [], + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=34), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=34), + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + Gt()], + [ + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=22), + Sub(), + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=29), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=29), + Add(), + Constant( + 1, + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=33)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=33), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=19), + 'append', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=26), + [ + Constant( + '', + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=29)], + [], + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=30), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=30)], + [], + lineno=5, + col_offset=8, + end_lineno=6, + end_col_offset=30)], + [], + lineno=3, + col_offset=4, + end_lineno=6, + end_col_offset=30), + Return( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=18), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=18)], + [], + lineno=1, + col_offset=0, + end_lineno=7, + end_col_offset=18), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=10, + col_offset=10, + end_lineno=10, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + List( + [ + JoinedStr( + [ + FormattedValue( + Call( + Attribute( + Call( + Name( + '_bottles', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=19), + [ + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=20, + end_lineno=12, + end_col_offset=26)], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=27), + 'capitalize', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=38), + [], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=40), + -1, + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91), + Constant( + ' of beer on the wall, ', + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91), + FormattedValue( + Call( + Name( + '_bottles', + Load(), + lineno=12, + col_offset=64, + end_lineno=12, + end_col_offset=72), + [ + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=73, + end_lineno=12, + end_col_offset=79)], + [], + lineno=12, + col_offset=64, + end_lineno=12, + end_col_offset=80), + -1, + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91), + Constant( + ' of beer.', + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91)], + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=91), + JoinedStr( + [ + FormattedValue( + Call( + Name( + '_action', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=18), + [ + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=25)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=26), + -1, + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=50), + FormattedValue( + Call( + Name( + '_next_bottle', + Load(), + lineno=13, + col_offset=28, + end_lineno=13, + end_col_offset=40), + [ + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=41, + end_lineno=13, + end_col_offset=47)], + [], + lineno=13, + col_offset=28, + end_lineno=13, + end_col_offset=48), + -1, + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=50)], + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=50)], + Load(), + lineno=11, + col_offset=11, + end_lineno=14, + end_col_offset=5), + lineno=11, + col_offset=4, + end_lineno=14, + end_col_offset=5)], + [], + lineno=10, + col_offset=0, + end_lineno=14, + end_col_offset=5), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=18, + col_offset=7, + end_lineno=18, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 0, + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=25)], + lineno=18, + col_offset=7, + end_lineno=18, + end_col_offset=25), + [ + Return( + Constant( + 'Go to the store and buy some more, ', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=52), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=52)], + [ + Return( + JoinedStr( + [ + Constant( + 'Take ', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=87), + FormattedValue( + IfExp( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=32, + end_lineno=21, + end_col_offset=45), + [ + Gt()], + [ + Constant( + 1, + lineno=21, + col_offset=48, + end_lineno=21, + end_col_offset=49)], + lineno=21, + col_offset=32, + end_lineno=21, + end_col_offset=49), + Constant( + 'one', + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=28), + Constant( + 'it', + lineno=21, + col_offset=55, + end_lineno=21, + end_col_offset=59), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=59), + -1, + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=87), + Constant( + ' down and pass it around, ', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=87)], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=87), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=87)], + lineno=18, + col_offset=4, + end_lineno=21, + end_col_offset=87)], + [], + lineno=17, + col_offset=0, + end_lineno=21, + end_col_offset=87), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + FormattedValue( + Call( + Name( + '_bottles', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=22), + [ + Call( + Name( + '_next_verse', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=34), + [ + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=35, + end_lineno=25, + end_col_offset=48)], + [], + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=49)], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=50), + -1, + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=73), + Constant( + ' of beer on the wall.', + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=73)], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=73), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=73)], + [], + lineno=24, + col_offset=0, + end_lineno=25, + end_col_offset=73), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 0, + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=18)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=18), + [ + Return( + Constant( + 'no more bottles', + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=32), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=32)], + [], + lineno=29, + col_offset=4, + end_lineno=30, + end_col_offset=32), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 1, + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=18)], + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=18), + [ + Return( + Constant( + '1 bottle', + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=25), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=25)], + [ + Return( + JoinedStr( + [ + FormattedValue( + Name( + 'placeholder_6', + Load(), + lineno=34, + col_offset=18, + end_lineno=34, + end_col_offset=24), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=34), + Constant( + ' bottles', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=34)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=34), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=34)], + lineno=31, + col_offset=4, + end_lineno=34, + end_col_offset=34)], + [], + lineno=28, + col_offset=0, + end_lineno=34, + end_col_offset=34), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=45), + [ + Gt()], + [ + Constant( + 0, + lineno=38, + col_offset=48, + end_lineno=38, + end_col_offset=49)], + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=49), + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=24), + Sub(), + Constant( + 1, + lineno=38, + col_offset=27, + end_lineno=38, + end_col_offset=28), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=28), + Constant( + 99, + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=57), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=57), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=57)], + [], + lineno=37, + col_offset=0, + end_lineno=38, + end_col_offset=57)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-beer-song/representation.txt b/test/practice-beer-song/representation.txt new file mode 100644 index 0000000..1fcf7dc --- /dev/null +++ b/test/practice-beer-song/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=11, end_lineno=1, end_col_offset=16), arg('placeholder_2', lineno=1, col_offset=18, end_lineno=1, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(1, lineno=1, col_offset=23, end_lineno=1, end_col_offset=24)]), [Assign([Name('placeholder_3', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=11)], List([], Load(), lineno=2, col_offset=14, end_lineno=2, end_col_offset=16), lineno=2, col_offset=4, end_lineno=2, end_col_offset=16), For(Name('placeholder_4', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=11), Call(Name('range', Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=20), [Name('placeholder_1', Load(), lineno=3, col_offset=21, end_lineno=3, end_col_offset=26), BinOp(Name('placeholder_1', Load(), lineno=3, col_offset=28, end_lineno=3, end_col_offset=33), Sub(), Name('placeholder_2', Load(), lineno=3, col_offset=36, end_lineno=3, end_col_offset=40), lineno=3, col_offset=28, end_lineno=3, end_col_offset=40), UnaryOp(USub(), Constant(1, lineno=3, col_offset=43, end_lineno=3, end_col_offset=44), lineno=3, col_offset=42, end_lineno=3, end_col_offset=44)], [], lineno=3, col_offset=15, end_lineno=3, end_col_offset=45), [Expr(Call(Attribute(Name('placeholder_3', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=15), 'extend', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=22), [Call(Name('verse', Load(), lineno=4, col_offset=23, end_lineno=4, end_col_offset=28), [Name('placeholder_4', Load(), lineno=4, col_offset=29, end_lineno=4, end_col_offset=32)], [], lineno=4, col_offset=23, end_lineno=4, end_col_offset=33)], [], lineno=4, col_offset=8, end_lineno=4, end_col_offset=34), lineno=4, col_offset=8, end_lineno=4, end_col_offset=34), If(Compare(Name('placeholder_4', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=14), [Gt()], [BinOp(BinOp(Name('placeholder_1', Load(), lineno=5, col_offset=17, end_lineno=5, end_col_offset=22), Sub(), Name('placeholder_2', Load(), lineno=5, col_offset=25, end_lineno=5, end_col_offset=29), lineno=5, col_offset=17, end_lineno=5, end_col_offset=29), Add(), Constant(1, lineno=5, col_offset=32, end_lineno=5, end_col_offset=33), lineno=5, col_offset=17, end_lineno=5, end_col_offset=33)], lineno=5, col_offset=11, end_lineno=5, end_col_offset=33), [Expr(Call(Attribute(Name('placeholder_3', Load(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=19), 'append', Load(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=26), [Constant('', lineno=6, col_offset=27, end_lineno=6, end_col_offset=29)], [], lineno=6, col_offset=12, end_lineno=6, end_col_offset=30), lineno=6, col_offset=12, end_lineno=6, end_col_offset=30)], [], lineno=5, col_offset=8, end_lineno=6, end_col_offset=30)], [], lineno=3, col_offset=4, end_lineno=6, end_col_offset=30), Return(Name('placeholder_3', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=18), lineno=7, col_offset=4, end_lineno=7, end_col_offset=18)], [], lineno=1, col_offset=0, end_lineno=7, end_col_offset=18), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=10, col_offset=10, end_lineno=10, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(List([JoinedStr([FormattedValue(Call(Attribute(Call(Name('_bottles', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=19), [Name('placeholder_6', Load(), lineno=12, col_offset=20, end_lineno=12, end_col_offset=26)], [], lineno=12, col_offset=11, end_lineno=12, end_col_offset=27), 'capitalize', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=38), [], [], lineno=12, col_offset=11, end_lineno=12, end_col_offset=40), -1, lineno=12, col_offset=8, end_lineno=12, end_col_offset=91), Constant(' of beer on the wall, ', lineno=12, col_offset=8, end_lineno=12, end_col_offset=91), FormattedValue(Call(Name('_bottles', Load(), lineno=12, col_offset=64, end_lineno=12, end_col_offset=72), [Name('placeholder_6', Load(), lineno=12, col_offset=73, end_lineno=12, end_col_offset=79)], [], lineno=12, col_offset=64, end_lineno=12, end_col_offset=80), -1, lineno=12, col_offset=8, end_lineno=12, end_col_offset=91), Constant(' of beer.', lineno=12, col_offset=8, end_lineno=12, end_col_offset=91)], lineno=12, col_offset=8, end_lineno=12, end_col_offset=91), JoinedStr([FormattedValue(Call(Name('_action', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=18), [Name('placeholder_6', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=25)], [], lineno=13, col_offset=11, end_lineno=13, end_col_offset=26), -1, lineno=13, col_offset=8, end_lineno=13, end_col_offset=50), FormattedValue(Call(Name('_next_bottle', Load(), lineno=13, col_offset=28, end_lineno=13, end_col_offset=40), [Name('placeholder_6', Load(), lineno=13, col_offset=41, end_lineno=13, end_col_offset=47)], [], lineno=13, col_offset=28, end_lineno=13, end_col_offset=48), -1, lineno=13, col_offset=8, end_lineno=13, end_col_offset=50)], lineno=13, col_offset=8, end_lineno=13, end_col_offset=50)], Load(), lineno=11, col_offset=11, end_lineno=14, end_col_offset=5), lineno=11, col_offset=4, end_lineno=14, end_col_offset=5)], [], lineno=10, col_offset=0, end_lineno=14, end_col_offset=5), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=17, col_offset=12, end_lineno=17, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_8', Load(), lineno=18, col_offset=7, end_lineno=18, end_col_offset=20), [Eq()], [Constant(0, lineno=18, col_offset=24, end_lineno=18, end_col_offset=25)], lineno=18, col_offset=7, end_lineno=18, end_col_offset=25), [Return(Constant('Go to the store and buy some more, ', lineno=19, col_offset=15, end_lineno=19, end_col_offset=52), lineno=19, col_offset=8, end_lineno=19, end_col_offset=52)], [Return(JoinedStr([Constant('Take ', lineno=21, col_offset=15, end_lineno=21, end_col_offset=87), FormattedValue(IfExp(Compare(Name('placeholder_8', Load(), lineno=21, col_offset=32, end_lineno=21, end_col_offset=45), [Gt()], [Constant(1, lineno=21, col_offset=48, end_lineno=21, end_col_offset=49)], lineno=21, col_offset=32, end_lineno=21, end_col_offset=49), Constant('one', lineno=21, col_offset=23, end_lineno=21, end_col_offset=28), Constant('it', lineno=21, col_offset=55, end_lineno=21, end_col_offset=59), lineno=21, col_offset=23, end_lineno=21, end_col_offset=59), -1, lineno=21, col_offset=15, end_lineno=21, end_col_offset=87), Constant(' down and pass it around, ', lineno=21, col_offset=15, end_lineno=21, end_col_offset=87)], lineno=21, col_offset=15, end_lineno=21, end_col_offset=87), lineno=21, col_offset=8, end_lineno=21, end_col_offset=87)], lineno=18, col_offset=4, end_lineno=21, end_col_offset=87)], [], lineno=17, col_offset=0, end_lineno=21, end_col_offset=87), FunctionDef('placeholder_9', arguments([], [arg('placeholder_8', lineno=24, col_offset=17, end_lineno=24, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(JoinedStr([FormattedValue(Call(Name('_bottles', Load(), lineno=25, col_offset=14, end_lineno=25, end_col_offset=22), [Call(Name('_next_verse', Load(), lineno=25, col_offset=23, end_lineno=25, end_col_offset=34), [Name('placeholder_8', Load(), lineno=25, col_offset=35, end_lineno=25, end_col_offset=48)], [], lineno=25, col_offset=23, end_lineno=25, end_col_offset=49)], [], lineno=25, col_offset=14, end_lineno=25, end_col_offset=50), -1, lineno=25, col_offset=11, end_lineno=25, end_col_offset=73), Constant(' of beer on the wall.', lineno=25, col_offset=11, end_lineno=25, end_col_offset=73)], lineno=25, col_offset=11, end_lineno=25, end_col_offset=73), lineno=25, col_offset=4, end_lineno=25, end_col_offset=73)], [], lineno=24, col_offset=0, end_lineno=25, end_col_offset=73), FunctionDef('placeholder_10', arguments([], [arg('placeholder_6', lineno=28, col_offset=13, end_lineno=28, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_6', Load(), lineno=29, col_offset=7, end_lineno=29, end_col_offset=13), [Eq()], [Constant(0, lineno=29, col_offset=17, end_lineno=29, end_col_offset=18)], lineno=29, col_offset=7, end_lineno=29, end_col_offset=18), [Return(Constant('no more bottles', lineno=30, col_offset=15, end_lineno=30, end_col_offset=32), lineno=30, col_offset=8, end_lineno=30, end_col_offset=32)], [], lineno=29, col_offset=4, end_lineno=30, end_col_offset=32), If(Compare(Name('placeholder_6', Load(), lineno=31, col_offset=7, end_lineno=31, end_col_offset=13), [Eq()], [Constant(1, lineno=31, col_offset=17, end_lineno=31, end_col_offset=18)], lineno=31, col_offset=7, end_lineno=31, end_col_offset=18), [Return(Constant('1 bottle', lineno=32, col_offset=15, end_lineno=32, end_col_offset=25), lineno=32, col_offset=8, end_lineno=32, end_col_offset=25)], [Return(JoinedStr([FormattedValue(Name('placeholder_6', Load(), lineno=34, col_offset=18, end_lineno=34, end_col_offset=24), -1, lineno=34, col_offset=15, end_lineno=34, end_col_offset=34), Constant(' bottles', lineno=34, col_offset=15, end_lineno=34, end_col_offset=34)], lineno=34, col_offset=15, end_lineno=34, end_col_offset=34), lineno=34, col_offset=8, end_lineno=34, end_col_offset=34)], lineno=31, col_offset=4, end_lineno=34, end_col_offset=34)], [], lineno=28, col_offset=0, end_lineno=34, end_col_offset=34), FunctionDef('placeholder_11', arguments([], [arg('placeholder_8', lineno=37, col_offset=16, end_lineno=37, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(IfExp(Compare(Name('placeholder_8', Load(), lineno=38, col_offset=32, end_lineno=38, end_col_offset=45), [Gt()], [Constant(0, lineno=38, col_offset=48, end_lineno=38, end_col_offset=49)], lineno=38, col_offset=32, end_lineno=38, end_col_offset=49), BinOp(Name('placeholder_8', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=24), Sub(), Constant(1, lineno=38, col_offset=27, end_lineno=38, end_col_offset=28), lineno=38, col_offset=11, end_lineno=38, end_col_offset=28), Constant(99, lineno=38, col_offset=55, end_lineno=38, end_col_offset=57), lineno=38, col_offset=11, end_lineno=38, end_col_offset=57), lineno=38, col_offset=4, end_lineno=38, end_col_offset=57)], [], lineno=37, col_offset=0, end_lineno=38, end_col_offset=57)], []) \ No newline at end of file diff --git a/test/practice-binary-search-tree/.meta/config.json b/test/practice-binary-search-tree/.meta/config.json new file mode 100644 index 0000000..34a93b9 --- /dev/null +++ b/test/practice-binary-search-tree/.meta/config.json @@ -0,0 +1,26 @@ +{ + "authors": [ + "rodrigocam" + ], + "contributors": [ + "cmccandless", + "Dog", + "N-Parsons", + "tqa236", + "tsamoglou", + "wandreuscv" + ], + "files": { + "solution": [ + "binary_search_tree.py" + ], + "test": [ + "binary_search_tree_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Insert and search for numbers in a binary tree.", + "source": "Josh Cheek" +} diff --git a/test/practice-binary-search-tree/binary_search_tree.py b/test/practice-binary-search-tree/binary_search_tree.py new file mode 100644 index 0000000..fede54d --- /dev/null +++ b/test/practice-binary-search-tree/binary_search_tree.py @@ -0,0 +1,50 @@ +class TreeNode: + def __init__(self, data, left=None, right=None): + self.data = data + self.left = left + self.right = right + + def __str__(self): + return f'TreeNode(data={self.data}, left={self.left}, right={self.right})' + + +class BinarySearchTree: + def __init__(self, tree_data): + self.root = None + for data in tree_data: + self.add(data) + + def add(self, data): + if self.root is None: + self.root = TreeNode(data) + return + inserted = False + cur_node = self.root + + while not inserted: + if data <= cur_node.data: + if cur_node.left: + cur_node = cur_node.left + else: + cur_node.left = TreeNode(data) + inserted = True + elif data > cur_node.data: + if cur_node.right: + cur_node = cur_node.right + else: + cur_node.right = TreeNode(data) + inserted = True + + def _inorder_traverse(self, node, elements): + if node is not None: + self._inorder_traverse(node.left, elements) + elements.append(node.data) + self._inorder_traverse(node.right, elements) + + def data(self): + return self.root + + def sorted_data(self): + elements = [] + self._inorder_traverse(self.root, elements) + return elements diff --git a/test/practice-binary-search-tree/mapping.json b/test/practice-binary-search-tree/mapping.json new file mode 100644 index 0000000..db551b0 --- /dev/null +++ b/test/practice-binary-search-tree/mapping.json @@ -0,0 +1,18 @@ +{ + "placeholder_0": "TreeNode", + "placeholder_1": "__init__", + "placeholder_2": "data", + "placeholder_3": "left", + "placeholder_4": "right", + "placeholder_5": "__str__", + "placeholder_6": "BinarySearchTree", + "placeholder_7": "tree_data", + "placeholder_8": "root", + "placeholder_9": "add", + "placeholder_10": "inserted", + "placeholder_11": "cur_node", + "placeholder_12": "_inorder_traverse", + "placeholder_13": "node", + "placeholder_14": "elements", + "placeholder_15": "sorted_data" +} \ No newline at end of file diff --git a/test/practice-binary-search-tree/representation.json b/test/practice-binary-search-tree/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-binary-search-tree/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-binary-search-tree/representation.out b/test/practice-binary-search-tree/representation.out new file mode 100644 index 0000000..0cb8662 --- /dev/null +++ b/test/practice-binary-search-tree/representation.out @@ -0,0 +1,2394 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3=None, placeholder_4=None): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 + self.placeholder_4 = placeholder_4 + + def placeholder_5(self): + return f"TreeNode(data={self.placeholder_2}, left={self.placeholder_3}, right={self.placeholder_4})" + + +class placeholder_6: + def placeholder_1(self, placeholder_7): + self.placeholder_8 = None + for placeholder_2 in placeholder_7: + self.add(placeholder_2) + + def placeholder_9(self, placeholder_2): + if self.placeholder_8 is None: + self.placeholder_8 = placeholder_0(placeholder_2) + return + placeholder_10 = False + placeholder_11 = self.placeholder_8 + while not placeholder_10: + if placeholder_2 <= placeholder_11.placeholder_2: + if placeholder_11.placeholder_3: + placeholder_11 = placeholder_11.placeholder_3 + else: + placeholder_11.placeholder_3 = placeholder_0(placeholder_2) + placeholder_10 = True + elif placeholder_2 > placeholder_11.placeholder_2: + if placeholder_11.placeholder_4: + placeholder_11 = placeholder_11.placeholder_4 + else: + placeholder_11.placeholder_4 = placeholder_0(placeholder_2) + placeholder_10 = True + + def placeholder_12(self, placeholder_13, placeholder_14): + if placeholder_13 is not None: + self.placeholder_12(placeholder_13.placeholder_3, placeholder_14) + placeholder_14.append(placeholder_13.placeholder_2) + self.placeholder_12(placeholder_13.placeholder_4, placeholder_14) + + def placeholder_2(self): + return self.placeholder_8 + + def placeholder_15(self): + placeholder_14 = [] + self.placeholder_12(self.placeholder_8, placeholder_14) + return placeholder_14 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'TreeNode', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'data', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=27), + arg( + 'left', + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=33), + arg( + 'right', + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=38), + Constant( + None, + lineno=2, + col_offset=46, + end_lineno=2, + end_col_offset=50)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'data', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=17)], + Name( + 'data', + Load(), + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=24), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'left', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=17)], + Name( + 'left', + Load(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=24), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'right', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=18)], + Name( + 'right', + Load(), + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=26), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=26)], + [], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=26), + FunctionDef( + '__str__', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + Constant( + 'TreeNode(data=', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=36), + 'data', + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=41), + -1, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + Constant( + ', left=', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=50, + end_lineno=8, + end_col_offset=54), + 'left', + Load(), + lineno=8, + col_offset=50, + end_lineno=8, + end_col_offset=59), + -1, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + Constant( + ', right=', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=73), + 'right', + Load(), + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=79), + -1, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + Constant( + ')', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82)], + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=82)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=82)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=82), + ClassDef( + 'BinarySearchTree', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=21), + arg( + 'tree_data', + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'root', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=17)], + Constant( + None, + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=24), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=24), + For( + Name( + 'data', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=16), + Name( + 'tree_data', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=16), + 'add', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=20), + [ + Name( + 'data', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=25)], + [], + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=26), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=26)], + [], + lineno=14, + col_offset=8, + end_lineno=15, + end_col_offset=26)], + [], + lineno=12, + col_offset=4, + end_lineno=15, + end_col_offset=26), + FunctionDef( + 'add', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=16), + arg( + 'data', + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=15), + 'root', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=20), + [ + Is()], + [ + Constant( + None, + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=28)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=28), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=16), + 'root', + Store(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=21)], + Call( + Name( + 'TreeNode', + Load(), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=32), + [ + Name( + 'data', + Load(), + lineno=19, + col_offset=33, + end_lineno=19, + end_col_offset=37)], + [], + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=38), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=38), + Return( + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=18)], + [], + lineno=18, + col_offset=8, + end_lineno=20, + end_col_offset=18), + Assign( + [ + Name( + 'inserted', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=16)], + Constant( + False, + lineno=21, + col_offset=19, + end_lineno=21, + end_col_offset=24), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=24), + Assign( + [ + Name( + 'cur_node', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=16)], + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=23), + 'root', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=28), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=28), + While( + UnaryOp( + Not(), + Name( + 'inserted', + Load(), + lineno=24, + col_offset=18, + end_lineno=24, + end_col_offset=26), + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=26), + [ + If( + Compare( + Name( + 'data', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=19), + [ + LtE()], + [ + Attribute( + Name( + 'cur_node', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=31), + 'data', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=36)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=36), + [ + If( + Attribute( + Name( + 'cur_node', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=27), + 'left', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=32), + [ + Assign( + [ + Name( + 'cur_node', + Store(), + lineno=27, + col_offset=20, + end_lineno=27, + end_col_offset=28)], + Attribute( + Name( + 'cur_node', + Load(), + lineno=27, + col_offset=31, + end_lineno=27, + end_col_offset=39), + 'left', + Load(), + lineno=27, + col_offset=31, + end_lineno=27, + end_col_offset=44), + lineno=27, + col_offset=20, + end_lineno=27, + end_col_offset=44)], + [ + Assign( + [ + Attribute( + Name( + 'cur_node', + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=28), + 'left', + Store(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=33)], + Call( + Name( + 'TreeNode', + Load(), + lineno=29, + col_offset=36, + end_lineno=29, + end_col_offset=44), + [ + Name( + 'data', + Load(), + lineno=29, + col_offset=45, + end_lineno=29, + end_col_offset=49)], + [], + lineno=29, + col_offset=36, + end_lineno=29, + end_col_offset=50), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=50), + Assign( + [ + Name( + 'inserted', + Store(), + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=28)], + Constant( + True, + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=35), + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=35)], + lineno=26, + col_offset=16, + end_lineno=30, + end_col_offset=35)], + [ + If( + Compare( + Name( + 'data', + Load(), + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=21), + [ + Gt()], + [ + Attribute( + Name( + 'cur_node', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=32), + 'data', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=37)], + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=37), + [ + If( + Attribute( + Name( + 'cur_node', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=27), + 'right', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=33), + [ + Assign( + [ + Name( + 'cur_node', + Store(), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=28)], + Attribute( + Name( + 'cur_node', + Load(), + lineno=33, + col_offset=31, + end_lineno=33, + end_col_offset=39), + 'right', + Load(), + lineno=33, + col_offset=31, + end_lineno=33, + end_col_offset=45), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=45)], + [ + Assign( + [ + Attribute( + Name( + 'cur_node', + Load(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=28), + 'right', + Store(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=34)], + Call( + Name( + 'TreeNode', + Load(), + lineno=35, + col_offset=37, + end_lineno=35, + end_col_offset=45), + [ + Name( + 'data', + Load(), + lineno=35, + col_offset=46, + end_lineno=35, + end_col_offset=50)], + [], + lineno=35, + col_offset=37, + end_lineno=35, + end_col_offset=51), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=51), + Assign( + [ + Name( + 'inserted', + Store(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=28)], + Constant( + True, + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=35), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=35)], + lineno=32, + col_offset=16, + end_lineno=36, + end_col_offset=35)], + [], + lineno=31, + col_offset=12, + end_lineno=36, + end_col_offset=35)], + lineno=25, + col_offset=12, + end_lineno=36, + end_col_offset=35)], + [], + lineno=24, + col_offset=8, + end_lineno=36, + end_col_offset=35)], + [], + lineno=17, + col_offset=4, + end_lineno=36, + end_col_offset=35), + FunctionDef( + '_inorder_traverse', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=30), + arg( + 'node', + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=36), + arg( + 'elements', + lineno=38, + col_offset=38, + end_lineno=38, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'node', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=15), + [ + IsNot()], + [ + Constant( + None, + lineno=39, + col_offset=23, + end_lineno=39, + end_col_offset=27)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=27), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=16), + '_inorder_traverse', + Load(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=34), + [ + Attribute( + Name( + 'node', + Load(), + lineno=40, + col_offset=35, + end_lineno=40, + end_col_offset=39), + 'left', + Load(), + lineno=40, + col_offset=35, + end_lineno=40, + end_col_offset=44), + Name( + 'elements', + Load(), + lineno=40, + col_offset=46, + end_lineno=40, + end_col_offset=54)], + [], + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=55), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=55), + Expr( + Call( + Attribute( + Name( + 'elements', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=20), + 'append', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=27), + [ + Attribute( + Name( + 'node', + Load(), + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=32), + 'data', + Load(), + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=37)], + [], + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=38), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=38), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=16), + '_inorder_traverse', + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=34), + [ + Attribute( + Name( + 'node', + Load(), + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=39), + 'right', + Load(), + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=45), + Name( + 'elements', + Load(), + lineno=42, + col_offset=47, + end_lineno=42, + end_col_offset=55)], + [], + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=56), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=56)], + [], + lineno=39, + col_offset=8, + end_lineno=42, + end_col_offset=56)], + [], + lineno=38, + col_offset=4, + end_lineno=42, + end_col_offset=56), + FunctionDef( + 'data', + arguments( + [], + [ + arg( + 'self', + lineno=44, + col_offset=13, + end_lineno=44, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=19), + 'root', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=24), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=24)], + [], + lineno=44, + col_offset=4, + end_lineno=45, + end_col_offset=24), + FunctionDef( + 'sorted_data', + arguments( + [], + [ + arg( + 'self', + lineno=47, + col_offset=20, + end_lineno=47, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'elements', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=16)], + List( + [], + Load(), + lineno=48, + col_offset=19, + end_lineno=48, + end_col_offset=21), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=21), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=12), + '_inorder_traverse', + Load(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=30), + [ + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=31, + end_lineno=49, + end_col_offset=35), + 'root', + Load(), + lineno=49, + col_offset=31, + end_lineno=49, + end_col_offset=40), + Name( + 'elements', + Load(), + lineno=49, + col_offset=42, + end_lineno=49, + end_col_offset=50)], + [], + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=51), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=51), + Return( + Name( + 'elements', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=23), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=23)], + [], + lineno=47, + col_offset=4, + end_lineno=50, + end_col_offset=23)], + [], + lineno=11, + col_offset=0, + end_lineno=50, + end_col_offset=23)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=27), + arg( + 'placeholder_3', + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=33), + arg( + 'placeholder_4', + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=38), + Constant( + None, + lineno=2, + col_offset=46, + end_lineno=2, + end_col_offset=50)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=17)], + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=24), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=17)], + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=24), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=18)], + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=26), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=26)], + [], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=26), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + Constant( + 'TreeNode(data=', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=36), + 'placeholder_2', + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=41), + -1, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + Constant( + ', left=', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=50, + end_lineno=8, + end_col_offset=54), + 'placeholder_3', + Load(), + lineno=8, + col_offset=50, + end_lineno=8, + end_col_offset=59), + -1, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + Constant( + ', right=', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=73), + 'placeholder_4', + Load(), + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=79), + -1, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + Constant( + ')', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82)], + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=82), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=82)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=82)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=82), + ClassDef( + 'placeholder_6', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=21), + arg( + 'placeholder_7', + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=17)], + Constant( + None, + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=24), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=24), + For( + Name( + 'placeholder_2', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=16), + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=16), + 'add', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=20), + [ + Name( + 'placeholder_2', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=25)], + [], + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=26), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=26)], + [], + lineno=14, + col_offset=8, + end_lineno=15, + end_col_offset=26)], + [], + lineno=12, + col_offset=4, + end_lineno=15, + end_col_offset=26), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=16), + arg( + 'placeholder_2', + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=15), + 'placeholder_8', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=20), + [ + Is()], + [ + Constant( + None, + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=28)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=28), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=16), + 'placeholder_8', + Store(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=21)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=32), + [ + Name( + 'placeholder_2', + Load(), + lineno=19, + col_offset=33, + end_lineno=19, + end_col_offset=37)], + [], + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=38), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=38), + Return( + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=18)], + [], + lineno=18, + col_offset=8, + end_lineno=20, + end_col_offset=18), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=16)], + Constant( + False, + lineno=21, + col_offset=19, + end_lineno=21, + end_col_offset=24), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=24), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=16)], + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=23), + 'placeholder_8', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=28), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=28), + While( + UnaryOp( + Not(), + Name( + 'placeholder_10', + Load(), + lineno=24, + col_offset=18, + end_lineno=24, + end_col_offset=26), + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=26), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=19), + [ + LtE()], + [ + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=31), + 'placeholder_2', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=36)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=36), + [ + If( + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=27), + 'placeholder_3', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=32), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=27, + col_offset=20, + end_lineno=27, + end_col_offset=28)], + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=27, + col_offset=31, + end_lineno=27, + end_col_offset=39), + 'placeholder_3', + Load(), + lineno=27, + col_offset=31, + end_lineno=27, + end_col_offset=44), + lineno=27, + col_offset=20, + end_lineno=27, + end_col_offset=44)], + [ + Assign( + [ + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=28), + 'placeholder_3', + Store(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=33)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=29, + col_offset=36, + end_lineno=29, + end_col_offset=44), + [ + Name( + 'placeholder_2', + Load(), + lineno=29, + col_offset=45, + end_lineno=29, + end_col_offset=49)], + [], + lineno=29, + col_offset=36, + end_lineno=29, + end_col_offset=50), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=50), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=28)], + Constant( + True, + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=35), + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=35)], + lineno=26, + col_offset=16, + end_lineno=30, + end_col_offset=35)], + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=21), + [ + Gt()], + [ + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=32), + 'placeholder_2', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=37)], + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=37), + [ + If( + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=27), + 'placeholder_4', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=33), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=28)], + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=33, + col_offset=31, + end_lineno=33, + end_col_offset=39), + 'placeholder_4', + Load(), + lineno=33, + col_offset=31, + end_lineno=33, + end_col_offset=45), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=45)], + [ + Assign( + [ + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=28), + 'placeholder_4', + Store(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=34)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=35, + col_offset=37, + end_lineno=35, + end_col_offset=45), + [ + Name( + 'placeholder_2', + Load(), + lineno=35, + col_offset=46, + end_lineno=35, + end_col_offset=50)], + [], + lineno=35, + col_offset=37, + end_lineno=35, + end_col_offset=51), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=51), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=28)], + Constant( + True, + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=35), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=35)], + lineno=32, + col_offset=16, + end_lineno=36, + end_col_offset=35)], + [], + lineno=31, + col_offset=12, + end_lineno=36, + end_col_offset=35)], + lineno=25, + col_offset=12, + end_lineno=36, + end_col_offset=35)], + [], + lineno=24, + col_offset=8, + end_lineno=36, + end_col_offset=35)], + [], + lineno=17, + col_offset=4, + end_lineno=36, + end_col_offset=35), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=30), + arg( + 'placeholder_13', + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=36), + arg( + 'placeholder_14', + lineno=38, + col_offset=38, + end_lineno=38, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=15), + [ + IsNot()], + [ + Constant( + None, + lineno=39, + col_offset=23, + end_lineno=39, + end_col_offset=27)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=27), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=16), + 'placeholder_12', + Load(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=34), + [ + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=40, + col_offset=35, + end_lineno=40, + end_col_offset=39), + 'placeholder_3', + Load(), + lineno=40, + col_offset=35, + end_lineno=40, + end_col_offset=44), + Name( + 'placeholder_14', + Load(), + lineno=40, + col_offset=46, + end_lineno=40, + end_col_offset=54)], + [], + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=55), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=55), + Expr( + Call( + Attribute( + Name( + 'placeholder_14', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=20), + 'append', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=27), + [ + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=32), + 'placeholder_2', + Load(), + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=37)], + [], + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=38), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=38), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=16), + 'placeholder_12', + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=34), + [ + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=39), + 'placeholder_4', + Load(), + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=45), + Name( + 'placeholder_14', + Load(), + lineno=42, + col_offset=47, + end_lineno=42, + end_col_offset=55)], + [], + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=56), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=56)], + [], + lineno=39, + col_offset=8, + end_lineno=42, + end_col_offset=56)], + [], + lineno=38, + col_offset=4, + end_lineno=42, + end_col_offset=56), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=44, + col_offset=13, + end_lineno=44, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=19), + 'placeholder_8', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=24), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=24)], + [], + lineno=44, + col_offset=4, + end_lineno=45, + end_col_offset=24), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=47, + col_offset=20, + end_lineno=47, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=16)], + List( + [], + Load(), + lineno=48, + col_offset=19, + end_lineno=48, + end_col_offset=21), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=21), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=12), + 'placeholder_12', + Load(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=30), + [ + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=31, + end_lineno=49, + end_col_offset=35), + 'placeholder_8', + Load(), + lineno=49, + col_offset=31, + end_lineno=49, + end_col_offset=40), + Name( + 'placeholder_14', + Load(), + lineno=49, + col_offset=42, + end_lineno=49, + end_col_offset=50)], + [], + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=51), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=51), + Return( + Name( + 'placeholder_14', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=23), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=23)], + [], + lineno=47, + col_offset=4, + end_lineno=50, + end_col_offset=23)], + [], + lineno=11, + col_offset=0, + end_lineno=50, + end_col_offset=23)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-binary-search-tree/representation.txt b/test/practice-binary-search-tree/representation.txt new file mode 100644 index 0000000..56f07f3 --- /dev/null +++ b/test/practice-binary-search-tree/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=27), arg('placeholder_3', lineno=2, col_offset=29, end_lineno=2, end_col_offset=33), arg('placeholder_4', lineno=2, col_offset=40, end_lineno=2, end_col_offset=45)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=2, col_offset=34, end_lineno=2, end_col_offset=38), Constant(None, lineno=2, col_offset=46, end_lineno=2, end_col_offset=50)]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_2', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=17)], Name('placeholder_2', Load(), lineno=3, col_offset=20, end_lineno=3, end_col_offset=24), lineno=3, col_offset=8, end_lineno=3, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=12), 'placeholder_3', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=17)], Name('placeholder_3', Load(), lineno=4, col_offset=20, end_lineno=4, end_col_offset=24), lineno=4, col_offset=8, end_lineno=4, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=12), 'placeholder_4', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=18)], Name('placeholder_4', Load(), lineno=5, col_offset=21, end_lineno=5, end_col_offset=26), lineno=5, col_offset=8, end_lineno=5, end_col_offset=26)], [], lineno=2, col_offset=4, end_lineno=5, end_col_offset=26), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=7, col_offset=16, end_lineno=7, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(JoinedStr([Constant('TreeNode(data=', lineno=8, col_offset=15, end_lineno=8, end_col_offset=82), FormattedValue(Attribute(Name('self', Load(), lineno=8, col_offset=32, end_lineno=8, end_col_offset=36), 'placeholder_2', Load(), lineno=8, col_offset=32, end_lineno=8, end_col_offset=41), -1, lineno=8, col_offset=15, end_lineno=8, end_col_offset=82), Constant(', left=', lineno=8, col_offset=15, end_lineno=8, end_col_offset=82), FormattedValue(Attribute(Name('self', Load(), lineno=8, col_offset=50, end_lineno=8, end_col_offset=54), 'placeholder_3', Load(), lineno=8, col_offset=50, end_lineno=8, end_col_offset=59), -1, lineno=8, col_offset=15, end_lineno=8, end_col_offset=82), Constant(', right=', lineno=8, col_offset=15, end_lineno=8, end_col_offset=82), FormattedValue(Attribute(Name('self', Load(), lineno=8, col_offset=69, end_lineno=8, end_col_offset=73), 'placeholder_4', Load(), lineno=8, col_offset=69, end_lineno=8, end_col_offset=79), -1, lineno=8, col_offset=15, end_lineno=8, end_col_offset=82), Constant(')', lineno=8, col_offset=15, end_lineno=8, end_col_offset=82)], lineno=8, col_offset=15, end_lineno=8, end_col_offset=82), lineno=8, col_offset=8, end_lineno=8, end_col_offset=82)], [], lineno=7, col_offset=4, end_lineno=8, end_col_offset=82)], [], lineno=1, col_offset=0, end_lineno=8, end_col_offset=82), ClassDef('placeholder_6', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=12, col_offset=17, end_lineno=12, end_col_offset=21), arg('placeholder_7', lineno=12, col_offset=23, end_lineno=12, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=12), 'placeholder_8', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=17)], Constant(None, lineno=13, col_offset=20, end_lineno=13, end_col_offset=24), lineno=13, col_offset=8, end_lineno=13, end_col_offset=24), For(Name('placeholder_2', Store(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=16), Name('placeholder_7', Load(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=29), [Expr(Call(Attribute(Name('self', Load(), lineno=15, col_offset=12, end_lineno=15, end_col_offset=16), 'add', Load(), lineno=15, col_offset=12, end_lineno=15, end_col_offset=20), [Name('placeholder_2', Load(), lineno=15, col_offset=21, end_lineno=15, end_col_offset=25)], [], lineno=15, col_offset=12, end_lineno=15, end_col_offset=26), lineno=15, col_offset=12, end_lineno=15, end_col_offset=26)], [], lineno=14, col_offset=8, end_lineno=15, end_col_offset=26)], [], lineno=12, col_offset=4, end_lineno=15, end_col_offset=26), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=17, col_offset=12, end_lineno=17, end_col_offset=16), arg('placeholder_2', lineno=17, col_offset=18, end_lineno=17, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=15), 'placeholder_8', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=20), [Is()], [Constant(None, lineno=18, col_offset=24, end_lineno=18, end_col_offset=28)], lineno=18, col_offset=11, end_lineno=18, end_col_offset=28), [Assign([Attribute(Name('self', Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=16), 'placeholder_8', Store(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=21)], Call(Name('placeholder_0', Load(), lineno=19, col_offset=24, end_lineno=19, end_col_offset=32), [Name('placeholder_2', Load(), lineno=19, col_offset=33, end_lineno=19, end_col_offset=37)], [], lineno=19, col_offset=24, end_lineno=19, end_col_offset=38), lineno=19, col_offset=12, end_lineno=19, end_col_offset=38), Return(lineno=20, col_offset=12, end_lineno=20, end_col_offset=18)], [], lineno=18, col_offset=8, end_lineno=20, end_col_offset=18), Assign([Name('placeholder_10', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=16)], Constant(False, lineno=21, col_offset=19, end_lineno=21, end_col_offset=24), lineno=21, col_offset=8, end_lineno=21, end_col_offset=24), Assign([Name('placeholder_11', Store(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=16)], Attribute(Name('self', Load(), lineno=22, col_offset=19, end_lineno=22, end_col_offset=23), 'placeholder_8', Load(), lineno=22, col_offset=19, end_lineno=22, end_col_offset=28), lineno=22, col_offset=8, end_lineno=22, end_col_offset=28), While(UnaryOp(Not(), Name('placeholder_10', Load(), lineno=24, col_offset=18, end_lineno=24, end_col_offset=26), lineno=24, col_offset=14, end_lineno=24, end_col_offset=26), [If(Compare(Name('placeholder_2', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=19), [LtE()], [Attribute(Name('placeholder_11', Load(), lineno=25, col_offset=23, end_lineno=25, end_col_offset=31), 'placeholder_2', Load(), lineno=25, col_offset=23, end_lineno=25, end_col_offset=36)], lineno=25, col_offset=15, end_lineno=25, end_col_offset=36), [If(Attribute(Name('placeholder_11', Load(), lineno=26, col_offset=19, end_lineno=26, end_col_offset=27), 'placeholder_3', Load(), lineno=26, col_offset=19, end_lineno=26, end_col_offset=32), [Assign([Name('placeholder_11', Store(), lineno=27, col_offset=20, end_lineno=27, end_col_offset=28)], Attribute(Name('placeholder_11', Load(), lineno=27, col_offset=31, end_lineno=27, end_col_offset=39), 'placeholder_3', Load(), lineno=27, col_offset=31, end_lineno=27, end_col_offset=44), lineno=27, col_offset=20, end_lineno=27, end_col_offset=44)], [Assign([Attribute(Name('placeholder_11', Load(), lineno=29, col_offset=20, end_lineno=29, end_col_offset=28), 'placeholder_3', Store(), lineno=29, col_offset=20, end_lineno=29, end_col_offset=33)], Call(Name('placeholder_0', Load(), lineno=29, col_offset=36, end_lineno=29, end_col_offset=44), [Name('placeholder_2', Load(), lineno=29, col_offset=45, end_lineno=29, end_col_offset=49)], [], lineno=29, col_offset=36, end_lineno=29, end_col_offset=50), lineno=29, col_offset=20, end_lineno=29, end_col_offset=50), Assign([Name('placeholder_10', Store(), lineno=30, col_offset=20, end_lineno=30, end_col_offset=28)], Constant(True, lineno=30, col_offset=31, end_lineno=30, end_col_offset=35), lineno=30, col_offset=20, end_lineno=30, end_col_offset=35)], lineno=26, col_offset=16, end_lineno=30, end_col_offset=35)], [If(Compare(Name('placeholder_2', Load(), lineno=31, col_offset=17, end_lineno=31, end_col_offset=21), [Gt()], [Attribute(Name('placeholder_11', Load(), lineno=31, col_offset=24, end_lineno=31, end_col_offset=32), 'placeholder_2', Load(), lineno=31, col_offset=24, end_lineno=31, end_col_offset=37)], lineno=31, col_offset=17, end_lineno=31, end_col_offset=37), [If(Attribute(Name('placeholder_11', Load(), lineno=32, col_offset=19, end_lineno=32, end_col_offset=27), 'placeholder_4', Load(), lineno=32, col_offset=19, end_lineno=32, end_col_offset=33), [Assign([Name('placeholder_11', Store(), lineno=33, col_offset=20, end_lineno=33, end_col_offset=28)], Attribute(Name('placeholder_11', Load(), lineno=33, col_offset=31, end_lineno=33, end_col_offset=39), 'placeholder_4', Load(), lineno=33, col_offset=31, end_lineno=33, end_col_offset=45), lineno=33, col_offset=20, end_lineno=33, end_col_offset=45)], [Assign([Attribute(Name('placeholder_11', Load(), lineno=35, col_offset=20, end_lineno=35, end_col_offset=28), 'placeholder_4', Store(), lineno=35, col_offset=20, end_lineno=35, end_col_offset=34)], Call(Name('placeholder_0', Load(), lineno=35, col_offset=37, end_lineno=35, end_col_offset=45), [Name('placeholder_2', Load(), lineno=35, col_offset=46, end_lineno=35, end_col_offset=50)], [], lineno=35, col_offset=37, end_lineno=35, end_col_offset=51), lineno=35, col_offset=20, end_lineno=35, end_col_offset=51), Assign([Name('placeholder_10', Store(), lineno=36, col_offset=20, end_lineno=36, end_col_offset=28)], Constant(True, lineno=36, col_offset=31, end_lineno=36, end_col_offset=35), lineno=36, col_offset=20, end_lineno=36, end_col_offset=35)], lineno=32, col_offset=16, end_lineno=36, end_col_offset=35)], [], lineno=31, col_offset=12, end_lineno=36, end_col_offset=35)], lineno=25, col_offset=12, end_lineno=36, end_col_offset=35)], [], lineno=24, col_offset=8, end_lineno=36, end_col_offset=35)], [], lineno=17, col_offset=4, end_lineno=36, end_col_offset=35), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=38, col_offset=26, end_lineno=38, end_col_offset=30), arg('placeholder_13', lineno=38, col_offset=32, end_lineno=38, end_col_offset=36), arg('placeholder_14', lineno=38, col_offset=38, end_lineno=38, end_col_offset=46)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_13', Load(), lineno=39, col_offset=11, end_lineno=39, end_col_offset=15), [IsNot()], [Constant(None, lineno=39, col_offset=23, end_lineno=39, end_col_offset=27)], lineno=39, col_offset=11, end_lineno=39, end_col_offset=27), [Expr(Call(Attribute(Name('self', Load(), lineno=40, col_offset=12, end_lineno=40, end_col_offset=16), 'placeholder_12', Load(), lineno=40, col_offset=12, end_lineno=40, end_col_offset=34), [Attribute(Name('placeholder_13', Load(), lineno=40, col_offset=35, end_lineno=40, end_col_offset=39), 'placeholder_3', Load(), lineno=40, col_offset=35, end_lineno=40, end_col_offset=44), Name('placeholder_14', Load(), lineno=40, col_offset=46, end_lineno=40, end_col_offset=54)], [], lineno=40, col_offset=12, end_lineno=40, end_col_offset=55), lineno=40, col_offset=12, end_lineno=40, end_col_offset=55), Expr(Call(Attribute(Name('placeholder_14', Load(), lineno=41, col_offset=12, end_lineno=41, end_col_offset=20), 'append', Load(), lineno=41, col_offset=12, end_lineno=41, end_col_offset=27), [Attribute(Name('placeholder_13', Load(), lineno=41, col_offset=28, end_lineno=41, end_col_offset=32), 'placeholder_2', Load(), lineno=41, col_offset=28, end_lineno=41, end_col_offset=37)], [], lineno=41, col_offset=12, end_lineno=41, end_col_offset=38), lineno=41, col_offset=12, end_lineno=41, end_col_offset=38), Expr(Call(Attribute(Name('self', Load(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=16), 'placeholder_12', Load(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=34), [Attribute(Name('placeholder_13', Load(), lineno=42, col_offset=35, end_lineno=42, end_col_offset=39), 'placeholder_4', Load(), lineno=42, col_offset=35, end_lineno=42, end_col_offset=45), Name('placeholder_14', Load(), lineno=42, col_offset=47, end_lineno=42, end_col_offset=55)], [], lineno=42, col_offset=12, end_lineno=42, end_col_offset=56), lineno=42, col_offset=12, end_lineno=42, end_col_offset=56)], [], lineno=39, col_offset=8, end_lineno=42, end_col_offset=56)], [], lineno=38, col_offset=4, end_lineno=42, end_col_offset=56), FunctionDef('placeholder_2', arguments([], [arg('self', lineno=44, col_offset=13, end_lineno=44, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=19), 'placeholder_8', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=24), lineno=45, col_offset=8, end_lineno=45, end_col_offset=24)], [], lineno=44, col_offset=4, end_lineno=45, end_col_offset=24), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=47, col_offset=20, end_lineno=47, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=16)], List([], Load(), lineno=48, col_offset=19, end_lineno=48, end_col_offset=21), lineno=48, col_offset=8, end_lineno=48, end_col_offset=21), Expr(Call(Attribute(Name('self', Load(), lineno=49, col_offset=8, end_lineno=49, end_col_offset=12), 'placeholder_12', Load(), lineno=49, col_offset=8, end_lineno=49, end_col_offset=30), [Attribute(Name('self', Load(), lineno=49, col_offset=31, end_lineno=49, end_col_offset=35), 'placeholder_8', Load(), lineno=49, col_offset=31, end_lineno=49, end_col_offset=40), Name('placeholder_14', Load(), lineno=49, col_offset=42, end_lineno=49, end_col_offset=50)], [], lineno=49, col_offset=8, end_lineno=49, end_col_offset=51), lineno=49, col_offset=8, end_lineno=49, end_col_offset=51), Return(Name('placeholder_14', Load(), lineno=50, col_offset=15, end_lineno=50, end_col_offset=23), lineno=50, col_offset=8, end_lineno=50, end_col_offset=23)], [], lineno=47, col_offset=4, end_lineno=50, end_col_offset=23)], [], lineno=11, col_offset=0, end_lineno=50, end_col_offset=23)], []) \ No newline at end of file diff --git a/test/practice-binary-search/.meta/config.json b/test/practice-binary-search/.meta/config.json new file mode 100644 index 0000000..8b76b59 --- /dev/null +++ b/test/practice-binary-search/.meta/config.json @@ -0,0 +1,35 @@ +{ + "authors": [ + "michaelkunc" + ], + "contributors": [ + "AnAccountForReportingBugs", + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "fortrieb", + "ikhadykin", + "kytrinyx", + "mpatibandla", + "N-Parsons", + "patricksjackson", + "pheanex", + "subkrish", + "tqa236" + ], + "files": { + "solution": [ + "binary_search.py" + ], + "test": [ + "binary_search_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement a binary search algorithm.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Binary_search_algorithm" +} diff --git a/test/practice-binary-search/binary_search.py b/test/practice-binary-search/binary_search.py new file mode 100644 index 0000000..0bd7be2 --- /dev/null +++ b/test/practice-binary-search/binary_search.py @@ -0,0 +1,12 @@ +def find(search_list, value): + low = 0 + high = len(search_list) - 1 + while low <= high: + middle = (low + high) // 2 + if search_list[middle] > value: + high = middle - 1 + elif search_list[middle] < value: + low = middle + 1 + else: + return middle + raise ValueError('value not in array') diff --git a/test/practice-binary-search/mapping.json b/test/practice-binary-search/mapping.json new file mode 100644 index 0000000..481f843 --- /dev/null +++ b/test/practice-binary-search/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "find", + "placeholder_1": "search_list", + "placeholder_2": "value", + "placeholder_3": "low", + "placeholder_4": "high", + "placeholder_5": "middle" +} \ No newline at end of file diff --git a/test/practice-binary-search/representation.json b/test/practice-binary-search/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-binary-search/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-binary-search/representation.out b/test/practice-binary-search/representation.out new file mode 100644 index 0000000..32a71d1 --- /dev/null +++ b/test/practice-binary-search/representation.out @@ -0,0 +1,727 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + placeholder_3 = 0 + placeholder_4 = len(placeholder_1) - 1 + while placeholder_3 <= placeholder_4: + placeholder_5 = (placeholder_3 + placeholder_4) // 2 + if placeholder_1[placeholder_5] > placeholder_2: + placeholder_4 = placeholder_5 - 1 + elif placeholder_1[placeholder_5] < placeholder_2: + placeholder_3 = placeholder_5 + 1 + else: + return placeholder_5 + raise ValueError("value not in array") + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'find', + arguments( + [], + [ + arg( + 'search_list', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=20), + arg( + 'value', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'low', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=7)], + Constant( + 0, + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=11), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11), + Assign( + [ + Name( + 'high', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=8)], + BinOp( + Call( + Name( + 'len', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=14), + [ + Name( + 'search_list', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=26)], + [], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=27), + Sub(), + Constant( + 1, + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=31), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=31), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=31), + While( + Compare( + Name( + 'low', + Load(), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=13), + [ + LtE()], + [ + Name( + 'high', + Load(), + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=21)], + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=21), + [ + Assign( + [ + Name( + 'middle', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=14)], + BinOp( + BinOp( + Name( + 'low', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=21), + Add(), + Name( + 'high', + Load(), + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=28), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=28), + FloorDiv(), + Constant( + 2, + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=34), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=34), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=34), + If( + Compare( + Subscript( + Name( + 'search_list', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=22), + Name( + 'middle', + Load(), + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=29), + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=30), + [ + Gt()], + [ + Name( + 'value', + Load(), + lineno=6, + col_offset=33, + end_lineno=6, + end_col_offset=38)], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=38), + [ + Assign( + [ + Name( + 'high', + Store(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=16)], + BinOp( + Name( + 'middle', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=25), + Sub(), + Constant( + 1, + lineno=7, + col_offset=28, + end_lineno=7, + end_col_offset=29), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=29), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=29)], + [ + If( + Compare( + Subscript( + Name( + 'search_list', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=24), + Name( + 'middle', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=31), + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=32), + [ + Lt()], + [ + Name( + 'value', + Load(), + lineno=8, + col_offset=35, + end_lineno=8, + end_col_offset=40)], + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=40), + [ + Assign( + [ + Name( + 'low', + Store(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=15)], + BinOp( + Name( + 'middle', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=24), + Add(), + Constant( + 1, + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=28), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=28), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=28)], + [ + Return( + Name( + 'middle', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=25), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=25)], + lineno=8, + col_offset=8, + end_lineno=11, + end_col_offset=25)], + lineno=6, + col_offset=8, + end_lineno=11, + end_col_offset=25)], + [], + lineno=4, + col_offset=4, + end_lineno=11, + end_col_offset=25), + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=20), + [ + Constant( + 'value not in array', + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=41)], + [], + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=42), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=42)], + [], + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=42)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=20), + arg( + 'placeholder_2', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=7)], + Constant( + 0, + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=11), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=8)], + BinOp( + Call( + Name( + 'len', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=14), + [ + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=26)], + [], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=27), + Sub(), + Constant( + 1, + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=31), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=31), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=31), + While( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=13), + [ + LtE()], + [ + Name( + 'placeholder_4', + Load(), + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=21)], + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=21), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=14)], + BinOp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=21), + Add(), + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=28), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=28), + FloorDiv(), + Constant( + 2, + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=34), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=34), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=34), + If( + Compare( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=22), + Name( + 'placeholder_5', + Load(), + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=29), + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=30), + [ + Gt()], + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=33, + end_lineno=6, + end_col_offset=38)], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=38), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=16)], + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=25), + Sub(), + Constant( + 1, + lineno=7, + col_offset=28, + end_lineno=7, + end_col_offset=29), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=29), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=29)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=24), + Name( + 'placeholder_5', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=31), + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=32), + [ + Lt()], + [ + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=35, + end_lineno=8, + end_col_offset=40)], + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=40), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=15)], + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=24), + Add(), + Constant( + 1, + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=28), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=28), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=28)], + [ + Return( + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=25), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=25)], + lineno=8, + col_offset=8, + end_lineno=11, + end_col_offset=25)], + lineno=6, + col_offset=8, + end_lineno=11, + end_col_offset=25)], + [], + lineno=4, + col_offset=4, + end_lineno=11, + end_col_offset=25), + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=20), + [ + Constant( + 'value not in array', + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=41)], + [], + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=42), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=42)], + [], + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=42)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-binary-search/representation.txt b/test/practice-binary-search/representation.txt new file mode 100644 index 0000000..b7a8208 --- /dev/null +++ b/test/practice-binary-search/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=9, end_lineno=1, end_col_offset=20), arg('placeholder_2', lineno=1, col_offset=22, end_lineno=1, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=7)], Constant(0, lineno=2, col_offset=10, end_lineno=2, end_col_offset=11), lineno=2, col_offset=4, end_lineno=2, end_col_offset=11), Assign([Name('placeholder_4', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=8)], BinOp(Call(Name('len', Load(), lineno=3, col_offset=11, end_lineno=3, end_col_offset=14), [Name('placeholder_1', Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=26)], [], lineno=3, col_offset=11, end_lineno=3, end_col_offset=27), Sub(), Constant(1, lineno=3, col_offset=30, end_lineno=3, end_col_offset=31), lineno=3, col_offset=11, end_lineno=3, end_col_offset=31), lineno=3, col_offset=4, end_lineno=3, end_col_offset=31), While(Compare(Name('placeholder_3', Load(), lineno=4, col_offset=10, end_lineno=4, end_col_offset=13), [LtE()], [Name('placeholder_4', Load(), lineno=4, col_offset=17, end_lineno=4, end_col_offset=21)], lineno=4, col_offset=10, end_lineno=4, end_col_offset=21), [Assign([Name('placeholder_5', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=14)], BinOp(BinOp(Name('placeholder_3', Load(), lineno=5, col_offset=18, end_lineno=5, end_col_offset=21), Add(), Name('placeholder_4', Load(), lineno=5, col_offset=24, end_lineno=5, end_col_offset=28), lineno=5, col_offset=18, end_lineno=5, end_col_offset=28), FloorDiv(), Constant(2, lineno=5, col_offset=33, end_lineno=5, end_col_offset=34), lineno=5, col_offset=17, end_lineno=5, end_col_offset=34), lineno=5, col_offset=8, end_lineno=5, end_col_offset=34), If(Compare(Subscript(Name('placeholder_1', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=22), Name('placeholder_5', Load(), lineno=6, col_offset=23, end_lineno=6, end_col_offset=29), Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=30), [Gt()], [Name('placeholder_2', Load(), lineno=6, col_offset=33, end_lineno=6, end_col_offset=38)], lineno=6, col_offset=11, end_lineno=6, end_col_offset=38), [Assign([Name('placeholder_4', Store(), lineno=7, col_offset=12, end_lineno=7, end_col_offset=16)], BinOp(Name('placeholder_5', Load(), lineno=7, col_offset=19, end_lineno=7, end_col_offset=25), Sub(), Constant(1, lineno=7, col_offset=28, end_lineno=7, end_col_offset=29), lineno=7, col_offset=19, end_lineno=7, end_col_offset=29), lineno=7, col_offset=12, end_lineno=7, end_col_offset=29)], [If(Compare(Subscript(Name('placeholder_1', Load(), lineno=8, col_offset=13, end_lineno=8, end_col_offset=24), Name('placeholder_5', Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=31), Load(), lineno=8, col_offset=13, end_lineno=8, end_col_offset=32), [Lt()], [Name('placeholder_2', Load(), lineno=8, col_offset=35, end_lineno=8, end_col_offset=40)], lineno=8, col_offset=13, end_lineno=8, end_col_offset=40), [Assign([Name('placeholder_3', Store(), lineno=9, col_offset=12, end_lineno=9, end_col_offset=15)], BinOp(Name('placeholder_5', Load(), lineno=9, col_offset=18, end_lineno=9, end_col_offset=24), Add(), Constant(1, lineno=9, col_offset=27, end_lineno=9, end_col_offset=28), lineno=9, col_offset=18, end_lineno=9, end_col_offset=28), lineno=9, col_offset=12, end_lineno=9, end_col_offset=28)], [Return(Name('placeholder_5', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=25), lineno=11, col_offset=12, end_lineno=11, end_col_offset=25)], lineno=8, col_offset=8, end_lineno=11, end_col_offset=25)], lineno=6, col_offset=8, end_lineno=11, end_col_offset=25)], [], lineno=4, col_offset=4, end_lineno=11, end_col_offset=25), Raise(Call(Name('ValueError', Load(), lineno=12, col_offset=10, end_lineno=12, end_col_offset=20), [Constant('value not in array', lineno=12, col_offset=21, end_lineno=12, end_col_offset=41)], [], lineno=12, col_offset=10, end_lineno=12, end_col_offset=42), lineno=12, col_offset=4, end_lineno=12, end_col_offset=42)], [], lineno=1, col_offset=0, end_lineno=12, end_col_offset=42)], []) \ No newline at end of file diff --git a/test/practice-binary/.meta/config.json b/test/practice-binary/.meta/config.json new file mode 100644 index 0000000..b9f5b07 --- /dev/null +++ b/test/practice-binary/.meta/config.json @@ -0,0 +1,30 @@ +{ + "blurb": "Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles.", + "authors": [], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "lowks", + "mostlybadfly", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "binary.py" + ], + "test": [ + "binary_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "All of Computer Science", + "source_url": "https://www.wolframalpha.com/examples/mathematics/numbers/base-conversions" +} diff --git a/test/practice-binary/binary.py b/test/practice-binary/binary.py new file mode 100644 index 0000000..3646690 --- /dev/null +++ b/test/practice-binary/binary.py @@ -0,0 +1,5 @@ +def parse_binary(digits): + if set(digits) - set('01'): + raise ValueError('Invalid binary literal: ' + digits) + return sum(int(digit) * 2 ** idx + for (idx, digit) in enumerate(reversed(digits))) diff --git a/test/practice-binary/mapping.json b/test/practice-binary/mapping.json new file mode 100644 index 0000000..ed8999a --- /dev/null +++ b/test/practice-binary/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "parse_binary", + "placeholder_1": "digits", + "placeholder_2": "idx", + "placeholder_3": "digit" +} \ No newline at end of file diff --git a/test/practice-binary/representation.json b/test/practice-binary/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-binary/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-binary/representation.out b/test/practice-binary/representation.out new file mode 100644 index 0000000..8a16142 --- /dev/null +++ b/test/practice-binary/representation.out @@ -0,0 +1,508 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + if set(placeholder_1) - set("01"): + raise ValueError("Invalid binary literal: " + placeholder_1) + return sum( + ( + int(placeholder_3) * 2**placeholder_2 + for placeholder_2, placeholder_3 in enumerate(reversed(placeholder_1)) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'parse_binary', + arguments( + [], + [ + arg( + 'digits', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BinOp( + Call( + Name( + 'set', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=10), + [ + Name( + 'digits', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17)], + [], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=18), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=24), + [ + Constant( + '01', + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=29)], + [], + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=30), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + BinOp( + Constant( + 'Invalid binary literal: ', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=51), + Add(), + Name( + 'digits', + Load(), + lineno=3, + col_offset=54, + end_lineno=3, + end_col_offset=60), + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=60)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=61), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=61)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=61), + Return( + Call( + Name( + 'sum', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=14), + [ + GeneratorExp( + BinOp( + Call( + Name( + 'int', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=18), + [ + Name( + 'digit', + Load(), + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=24)], + [], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=25), + Mult(), + BinOp( + Constant( + 2, + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=29), + Pow(), + Name( + 'idx', + Load(), + lineno=4, + col_offset=33, + end_lineno=4, + end_col_offset=36), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=36), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=36), + [ + comprehension( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=23), + Name( + 'digit', + Store(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=30)], + Store(), + lineno=5, + col_offset=19, + end_lineno=5, + end_col_offset=31), + Call( + Name( + 'enumerate', + Load(), + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=44), + [ + Call( + Name( + 'reversed', + Load(), + lineno=5, + col_offset=45, + end_lineno=5, + end_col_offset=53), + [ + Name( + 'digits', + Load(), + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=60)], + [], + lineno=5, + col_offset=45, + end_lineno=5, + end_col_offset=61)], + [], + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=62), + [], + 0)], + lineno=4, + col_offset=14, + end_lineno=5, + end_col_offset=63)], + [], + lineno=4, + col_offset=11, + end_lineno=5, + end_col_offset=63), + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=63)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=63)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BinOp( + Call( + Name( + 'set', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=10), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17)], + [], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=18), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=24), + [ + Constant( + '01', + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=29)], + [], + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=30), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + BinOp( + Constant( + 'Invalid binary literal: ', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=51), + Add(), + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=54, + end_lineno=3, + end_col_offset=60), + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=60)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=61), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=61)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=61), + Return( + Call( + Name( + 'sum', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=14), + [ + GeneratorExp( + BinOp( + Call( + Name( + 'int', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=18), + [ + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=24)], + [], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=25), + Mult(), + BinOp( + Constant( + 2, + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=29), + Pow(), + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=33, + end_lineno=4, + end_col_offset=36), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=36), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=36), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=23), + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=30)], + Store(), + lineno=5, + col_offset=19, + end_lineno=5, + end_col_offset=31), + Call( + Name( + 'enumerate', + Load(), + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=44), + [ + Call( + Name( + 'reversed', + Load(), + lineno=5, + col_offset=45, + end_lineno=5, + end_col_offset=53), + [ + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=60)], + [], + lineno=5, + col_offset=45, + end_lineno=5, + end_col_offset=61)], + [], + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=62), + [], + 0)], + lineno=4, + col_offset=14, + end_lineno=5, + end_col_offset=63)], + [], + lineno=4, + col_offset=11, + end_lineno=5, + end_col_offset=63), + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=63)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=63)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-binary/representation.txt b/test/practice-binary/representation.txt new file mode 100644 index 0000000..a453d9f --- /dev/null +++ b/test/practice-binary/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=17, end_lineno=1, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(BinOp(Call(Name('set', Load(), lineno=2, col_offset=7, end_lineno=2, end_col_offset=10), [Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=17)], [], lineno=2, col_offset=7, end_lineno=2, end_col_offset=18), Sub(), Call(Name('set', Load(), lineno=2, col_offset=21, end_lineno=2, end_col_offset=24), [Constant('01', lineno=2, col_offset=25, end_lineno=2, end_col_offset=29)], [], lineno=2, col_offset=21, end_lineno=2, end_col_offset=30), lineno=2, col_offset=7, end_lineno=2, end_col_offset=30), [Raise(Call(Name('ValueError', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=24), [BinOp(Constant('Invalid binary literal: ', lineno=3, col_offset=25, end_lineno=3, end_col_offset=51), Add(), Name('placeholder_1', Load(), lineno=3, col_offset=54, end_lineno=3, end_col_offset=60), lineno=3, col_offset=25, end_lineno=3, end_col_offset=60)], [], lineno=3, col_offset=14, end_lineno=3, end_col_offset=61), lineno=3, col_offset=8, end_lineno=3, end_col_offset=61)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=61), Return(Call(Name('sum', Load(), lineno=4, col_offset=11, end_lineno=4, end_col_offset=14), [GeneratorExp(BinOp(Call(Name('int', Load(), lineno=4, col_offset=15, end_lineno=4, end_col_offset=18), [Name('placeholder_3', Load(), lineno=4, col_offset=19, end_lineno=4, end_col_offset=24)], [], lineno=4, col_offset=15, end_lineno=4, end_col_offset=25), Mult(), BinOp(Constant(2, lineno=4, col_offset=28, end_lineno=4, end_col_offset=29), Pow(), Name('placeholder_2', Load(), lineno=4, col_offset=33, end_lineno=4, end_col_offset=36), lineno=4, col_offset=28, end_lineno=4, end_col_offset=36), lineno=4, col_offset=15, end_lineno=4, end_col_offset=36), [comprehension(Tuple([Name('placeholder_2', Store(), lineno=5, col_offset=20, end_lineno=5, end_col_offset=23), Name('placeholder_3', Store(), lineno=5, col_offset=25, end_lineno=5, end_col_offset=30)], Store(), lineno=5, col_offset=19, end_lineno=5, end_col_offset=31), Call(Name('enumerate', Load(), lineno=5, col_offset=35, end_lineno=5, end_col_offset=44), [Call(Name('reversed', Load(), lineno=5, col_offset=45, end_lineno=5, end_col_offset=53), [Name('placeholder_1', Load(), lineno=5, col_offset=54, end_lineno=5, end_col_offset=60)], [], lineno=5, col_offset=45, end_lineno=5, end_col_offset=61)], [], lineno=5, col_offset=35, end_lineno=5, end_col_offset=62), [], 0)], lineno=4, col_offset=14, end_lineno=5, end_col_offset=63)], [], lineno=4, col_offset=11, end_lineno=5, end_col_offset=63), lineno=4, col_offset=4, end_lineno=5, end_col_offset=63)], [], lineno=1, col_offset=0, end_lineno=5, end_col_offset=63)], []) \ No newline at end of file diff --git a/test/practice-bob/.meta/config.json b/test/practice-bob/.meta/config.json new file mode 100644 index 0000000..ec0fc61 --- /dev/null +++ b/test/practice-bob/.meta/config.json @@ -0,0 +1,47 @@ +{ + "authors": [], + "contributors": [ + "0xae", + "aldraco", + "atg-abhishek", + "austinlyons", + "behrtam", + "BethanyG", + "cmccandless", + "cypher", + "Dog", + "etrepum", + "ikhadykin", + "janetriley", + "jremmen", + "koljakube", + "kytrinyx", + "lowks", + "lucasdpau", + "miketamis", + "N-Parsons", + "patricksjackson", + "pheanex", + "sdublish", + "sjakobi", + "stonemirror", + "thenigan", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "bob.py" + ], + "test": [ + "bob_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", + "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", + "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" +} diff --git a/test/practice-bob/bob.py b/test/practice-bob/bob.py new file mode 100644 index 0000000..630cccc --- /dev/null +++ b/test/practice-bob/bob.py @@ -0,0 +1,26 @@ +def response(hey_bob): + hey_bob = hey_bob.strip() + + if _is_silence(hey_bob): + return 'Fine. Be that way!' + if _is_shouting(hey_bob): + if _is_question(hey_bob): + return "Calm down, I know what I'm doing!" + else: + return 'Whoa, chill out!' + elif _is_question(hey_bob): + return 'Sure.' + else: + return 'Whatever.' + + +def _is_silence(hey_bob): + return hey_bob == '' + + +def _is_shouting(hey_bob): + return hey_bob.isupper() + + +def _is_question(hey_bob): + return hey_bob.endswith('?') diff --git a/test/practice-bob/mapping.json b/test/practice-bob/mapping.json new file mode 100644 index 0000000..b5b899f --- /dev/null +++ b/test/practice-bob/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "response", + "placeholder_1": "hey_bob", + "placeholder_2": "_is_silence", + "placeholder_3": "_is_shouting", + "placeholder_4": "_is_question" +} \ No newline at end of file diff --git a/test/practice-bob/representation.json b/test/practice-bob/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-bob/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-bob/representation.out b/test/practice-bob/representation.out new file mode 100644 index 0000000..6919f0c --- /dev/null +++ b/test/practice-bob/representation.out @@ -0,0 +1,770 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_1 = placeholder_1.strip() + if _is_silence(placeholder_1): + return "Fine. Be that way!" + if _is_shouting(placeholder_1): + if _is_question(placeholder_1): + return "Calm down, I know what I'm doing!" + else: + return "Whoa, chill out!" + elif _is_question(placeholder_1): + return "Sure." + else: + return "Whatever." + + +def placeholder_2(placeholder_1): + return placeholder_1 == "" + + +def placeholder_3(placeholder_1): + return placeholder_1.isupper() + + +def placeholder_4(placeholder_1): + return placeholder_1.endswith("?") + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'response', + arguments( + [], + [ + arg( + 'hey_bob', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'hey_bob', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11)], + Call( + Attribute( + Name( + 'hey_bob', + Load(), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=21), + 'strip', + Load(), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=27), + [], + [], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=29), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=29), + If( + Call( + Name( + '_is_silence', + Load(), + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=18), + [ + Name( + 'hey_bob', + Load(), + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=26)], + [], + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=27), + [ + Return( + Constant( + 'Fine. Be that way!', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=35)], + [], + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=35), + If( + Call( + Name( + '_is_shouting', + Load(), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=19), + [ + Name( + 'hey_bob', + Load(), + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=27)], + [], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=28), + [ + If( + Call( + Name( + '_is_question', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=23), + [ + Name( + 'hey_bob', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=31)], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=32), + [ + Return( + Constant( + "Calm down, I know what I'm doing!", + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=54), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=54)], + [ + Return( + Constant( + 'Whoa, chill out!', + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=37), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=37)], + lineno=7, + col_offset=8, + end_lineno=10, + end_col_offset=37)], + [ + If( + Call( + Name( + '_is_question', + Load(), + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=21), + [ + Name( + 'hey_bob', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=29)], + [], + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=30), + [ + Return( + Constant( + 'Sure.', + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=22), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=22)], + [ + Return( + Constant( + 'Whatever.', + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=26), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=26)], + lineno=11, + col_offset=4, + end_lineno=14, + end_col_offset=26)], + lineno=6, + col_offset=4, + end_lineno=14, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=14, + end_col_offset=26), + FunctionDef( + '_is_silence', + arguments( + [], + [ + arg( + 'hey_bob', + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Name( + 'hey_bob', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=18), + [ + Eq()], + [ + Constant( + '', + lineno=18, + col_offset=22, + end_lineno=18, + end_col_offset=24)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=24), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=24)], + [], + lineno=17, + col_offset=0, + end_lineno=18, + end_col_offset=24), + FunctionDef( + '_is_shouting', + arguments( + [], + [ + arg( + 'hey_bob', + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'hey_bob', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=18), + 'isupper', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=26), + [], + [], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=28), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=28)], + [], + lineno=21, + col_offset=0, + end_lineno=22, + end_col_offset=28), + FunctionDef( + '_is_question', + arguments( + [], + [ + arg( + 'hey_bob', + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'hey_bob', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=18), + 'endswith', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=27), + [ + Constant( + '?', + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=31)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=32), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=32)], + [], + lineno=25, + col_offset=0, + end_lineno=26, + end_col_offset=32)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11)], + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=21), + 'strip', + Load(), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=27), + [], + [], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=29), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=29), + If( + Call( + Name( + '_is_silence', + Load(), + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=18), + [ + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=26)], + [], + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=27), + [ + Return( + Constant( + 'Fine. Be that way!', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=35)], + [], + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=35), + If( + Call( + Name( + '_is_shouting', + Load(), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=19), + [ + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=27)], + [], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=28), + [ + If( + Call( + Name( + '_is_question', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=23), + [ + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=31)], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=32), + [ + Return( + Constant( + "Calm down, I know what I'm doing!", + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=54), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=54)], + [ + Return( + Constant( + 'Whoa, chill out!', + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=37), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=37)], + lineno=7, + col_offset=8, + end_lineno=10, + end_col_offset=37)], + [ + If( + Call( + Name( + '_is_question', + Load(), + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=21), + [ + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=29)], + [], + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=30), + [ + Return( + Constant( + 'Sure.', + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=22), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=22)], + [ + Return( + Constant( + 'Whatever.', + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=26), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=26)], + lineno=11, + col_offset=4, + end_lineno=14, + end_col_offset=26)], + lineno=6, + col_offset=4, + end_lineno=14, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=14, + end_col_offset=26), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=18), + [ + Eq()], + [ + Constant( + '', + lineno=18, + col_offset=22, + end_lineno=18, + end_col_offset=24)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=24), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=24)], + [], + lineno=17, + col_offset=0, + end_lineno=18, + end_col_offset=24), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=18), + 'isupper', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=26), + [], + [], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=28), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=28)], + [], + lineno=21, + col_offset=0, + end_lineno=22, + end_col_offset=28), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=18), + 'endswith', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=27), + [ + Constant( + '?', + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=31)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=32), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=32)], + [], + lineno=25, + col_offset=0, + end_lineno=26, + end_col_offset=32)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-bob/representation.txt b/test/practice-bob/representation.txt new file mode 100644 index 0000000..ef30b3d --- /dev/null +++ b/test/practice-bob/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=13, end_lineno=1, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_1', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=11)], Call(Attribute(Name('placeholder_1', Load(), lineno=2, col_offset=14, end_lineno=2, end_col_offset=21), 'strip', Load(), lineno=2, col_offset=14, end_lineno=2, end_col_offset=27), [], [], lineno=2, col_offset=14, end_lineno=2, end_col_offset=29), lineno=2, col_offset=4, end_lineno=2, end_col_offset=29), If(Call(Name('_is_silence', Load(), lineno=4, col_offset=7, end_lineno=4, end_col_offset=18), [Name('placeholder_1', Load(), lineno=4, col_offset=19, end_lineno=4, end_col_offset=26)], [], lineno=4, col_offset=7, end_lineno=4, end_col_offset=27), [Return(Constant('Fine. Be that way!', lineno=5, col_offset=15, end_lineno=5, end_col_offset=35), lineno=5, col_offset=8, end_lineno=5, end_col_offset=35)], [], lineno=4, col_offset=4, end_lineno=5, end_col_offset=35), If(Call(Name('_is_shouting', Load(), lineno=6, col_offset=7, end_lineno=6, end_col_offset=19), [Name('placeholder_1', Load(), lineno=6, col_offset=20, end_lineno=6, end_col_offset=27)], [], lineno=6, col_offset=7, end_lineno=6, end_col_offset=28), [If(Call(Name('_is_question', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=23), [Name('placeholder_1', Load(), lineno=7, col_offset=24, end_lineno=7, end_col_offset=31)], [], lineno=7, col_offset=11, end_lineno=7, end_col_offset=32), [Return(Constant("Calm down, I know what I'm doing!", lineno=8, col_offset=19, end_lineno=8, end_col_offset=54), lineno=8, col_offset=12, end_lineno=8, end_col_offset=54)], [Return(Constant('Whoa, chill out!', lineno=10, col_offset=19, end_lineno=10, end_col_offset=37), lineno=10, col_offset=12, end_lineno=10, end_col_offset=37)], lineno=7, col_offset=8, end_lineno=10, end_col_offset=37)], [If(Call(Name('_is_question', Load(), lineno=11, col_offset=9, end_lineno=11, end_col_offset=21), [Name('placeholder_1', Load(), lineno=11, col_offset=22, end_lineno=11, end_col_offset=29)], [], lineno=11, col_offset=9, end_lineno=11, end_col_offset=30), [Return(Constant('Sure.', lineno=12, col_offset=15, end_lineno=12, end_col_offset=22), lineno=12, col_offset=8, end_lineno=12, end_col_offset=22)], [Return(Constant('Whatever.', lineno=14, col_offset=15, end_lineno=14, end_col_offset=26), lineno=14, col_offset=8, end_lineno=14, end_col_offset=26)], lineno=11, col_offset=4, end_lineno=14, end_col_offset=26)], lineno=6, col_offset=4, end_lineno=14, end_col_offset=26)], [], lineno=1, col_offset=0, end_lineno=14, end_col_offset=26), FunctionDef('placeholder_2', arguments([], [arg('placeholder_1', lineno=17, col_offset=16, end_lineno=17, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Name('placeholder_1', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=18), [Eq()], [Constant('', lineno=18, col_offset=22, end_lineno=18, end_col_offset=24)], lineno=18, col_offset=11, end_lineno=18, end_col_offset=24), lineno=18, col_offset=4, end_lineno=18, end_col_offset=24)], [], lineno=17, col_offset=0, end_lineno=18, end_col_offset=24), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=21, col_offset=17, end_lineno=21, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_1', Load(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=18), 'isupper', Load(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=26), [], [], lineno=22, col_offset=11, end_lineno=22, end_col_offset=28), lineno=22, col_offset=4, end_lineno=22, end_col_offset=28)], [], lineno=21, col_offset=0, end_lineno=22, end_col_offset=28), FunctionDef('placeholder_4', arguments([], [arg('placeholder_1', lineno=25, col_offset=17, end_lineno=25, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_1', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=18), 'endswith', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=27), [Constant('?', lineno=26, col_offset=28, end_lineno=26, end_col_offset=31)], [], lineno=26, col_offset=11, end_lineno=26, end_col_offset=32), lineno=26, col_offset=4, end_lineno=26, end_col_offset=32)], [], lineno=25, col_offset=0, end_lineno=26, end_col_offset=32)], []) \ No newline at end of file diff --git a/test/practice-book-store/.meta/additional_tests.json b/test/practice-book-store/.meta/additional_tests.json new file mode 100644 index 0000000..1fb1935 --- /dev/null +++ b/test/practice-book-store/.meta/additional_tests.json @@ -0,0 +1,22 @@ +{ + "cases": [ + { + "property": "total", + "description": "Two groups of four and a group of five", + "comments": ["Suggested grouping, [[1,2,3,4],[1,2,3,5],[1,2,3,4,5]]. Solutions can pass all the other tests if they just try to group without using any groups of 5. This test case breaks that since it requires both 4-groups and 5-groups."], + "input": { + "basket": [1,1,1,2,2,2,3,3,3,4,4,5,5] + }, + "expected": 8120 + }, + { + "property": "total", + "description": "Shuffled book order", + "comments": ["Suggested grouping, [[1,2,3,4],[1,2,3,5],[1,2,3,4,5]]. All the other tests give the books in sorted order. Robust solutions should be able to handle any order"], + "input": { + "basket": [1,2,3,4,5,1,2,3,4,5,1,2,3] + }, + "expected": 8120 + } + ] +} diff --git a/test/practice-book-store/.meta/config.json b/test/practice-book-store/.meta/config.json new file mode 100644 index 0000000..87dd6d2 --- /dev/null +++ b/test/practice-book-store/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "ferhatelmas", + "hanksudo", + "ikhadykin", + "jackattack24", + "N-Parsons", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "book_store.py" + ], + "test": [ + "book_store_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "To try and encourage more sales of different books from a popular 5 book series, a bookshop has decided to offer discounts of multiple-book purchases.", + "source": "Inspired by the harry potter kata from Cyber-Dojo.", + "source_url": "https://cyber-dojo.org" +} diff --git a/test/practice-book-store/book_store.py b/test/practice-book-store/book_store.py new file mode 100644 index 0000000..f6cce8c --- /dev/null +++ b/test/practice-book-store/book_store.py @@ -0,0 +1,26 @@ +from collections import Counter + +PER_BOOK = 800.00 +PER_GROUP = { + 1: 1 * PER_BOOK * 1.00, + 2: 2 * PER_BOOK * 0.95, + 3: 3 * PER_BOOK * 0.90, + 4: 4 * PER_BOOK * 0.80, + 5: 5 * PER_BOOK * 0.75, +} + + +def _total(basket): + volumes = Counter(basket) + price = len(basket) * PER_BOOK + for size in range(len(volumes), 1, -1): + group = volumes - Counter(k for k, _ in volumes.most_common(size)) + group_books = sorted(group.elements()) + price = min(price, PER_GROUP[size] + _total(group_books)) + return price + + +def total(basket): + if not basket: + return 0 + return _total(sorted(basket)) diff --git a/test/practice-book-store/mapping.json b/test/practice-book-store/mapping.json new file mode 100644 index 0000000..3682919 --- /dev/null +++ b/test/practice-book-store/mapping.json @@ -0,0 +1,14 @@ +{ + "placeholder_0": "PER_BOOK", + "placeholder_1": "PER_GROUP", + "placeholder_2": "_total", + "placeholder_3": "basket", + "placeholder_4": "volumes", + "placeholder_5": "price", + "placeholder_6": "size", + "placeholder_7": "group", + "placeholder_8": "k", + "placeholder_9": "_", + "placeholder_10": "group_books", + "placeholder_11": "total" +} \ No newline at end of file diff --git a/test/practice-book-store/representation.json b/test/practice-book-store/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-book-store/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-book-store/representation.out b/test/practice-book-store/representation.out new file mode 100644 index 0000000..c77219f --- /dev/null +++ b/test/practice-book-store/representation.out @@ -0,0 +1,1536 @@ +## BEGIN NORMALIZED CODE ## +from collections import Counter + +placeholder_0 = 800.0 +placeholder_1 = { + 1: 1 * placeholder_0 * 1.0, + 2: 2 * placeholder_0 * 0.95, + 3: 3 * placeholder_0 * 0.9, + 4: 4 * placeholder_0 * 0.8, + 5: 5 * placeholder_0 * 0.75, +} + + +def placeholder_2(placeholder_3): + placeholder_4 = Counter(placeholder_3) + placeholder_5 = len(placeholder_3) * placeholder_0 + for placeholder_6 in range(len(placeholder_4), 1, -1): + placeholder_7 = placeholder_4 - Counter( + ( + placeholder_8 + for placeholder_8, placeholder_9 in placeholder_4.most_common( + placeholder_6 + ) + ) + ) + placeholder_10 = sorted(placeholder_7.elements()) + placeholder_5 = min( + placeholder_5, placeholder_1[placeholder_6] + placeholder_2(placeholder_10) + ) + return placeholder_5 + + +def placeholder_11(placeholder_3): + if not placeholder_3: + return 0 + return placeholder_2(sorted(placeholder_3)) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'Counter', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=31)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=31), + Assign( + [ + Name( + 'PER_BOOK', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=8)], + Constant( + 800.0, + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=17), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=17), + Assign( + [ + Name( + 'PER_GROUP', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=9)], + Dict( + [ + Constant( + 1, + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=5), + Constant( + 2, + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=5), + Constant( + 3, + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=5), + Constant( + 4, + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=5), + Constant( + 5, + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=5)], + [ + BinOp( + BinOp( + Constant( + 1, + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=8), + Mult(), + Name( + 'PER_BOOK', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=19), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=19), + Mult(), + Constant( + 1.0, + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=26), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=26), + BinOp( + BinOp( + Constant( + 2, + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=8), + Mult(), + Name( + 'PER_BOOK', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=19), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=19), + Mult(), + Constant( + 0.95, + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=26), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=26), + BinOp( + BinOp( + Constant( + 3, + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=8), + Mult(), + Name( + 'PER_BOOK', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=19), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=19), + Mult(), + Constant( + 0.9, + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=26), + BinOp( + BinOp( + Constant( + 4, + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=8), + Mult(), + Name( + 'PER_BOOK', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=19), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=19), + Mult(), + Constant( + 0.8, + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=26), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=26), + BinOp( + BinOp( + Constant( + 5, + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=8), + Mult(), + Name( + 'PER_BOOK', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=19), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=19), + Mult(), + Constant( + 0.75, + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=26), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=26)], + lineno=4, + col_offset=12, + end_lineno=10, + end_col_offset=1), + lineno=4, + col_offset=0, + end_lineno=10, + end_col_offset=1), + FunctionDef( + '_total', + arguments( + [], + [ + arg( + 'basket', + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'volumes', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=11)], + Call( + Name( + 'Counter', + Load(), + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=21), + [ + Name( + 'basket', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=28)], + [], + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=29), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=29), + Assign( + [ + Name( + 'price', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=9)], + BinOp( + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=15), + [ + Name( + 'basket', + Load(), + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=22)], + [], + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=23), + Mult(), + Name( + 'PER_BOOK', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=34), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=34), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=34), + For( + Name( + 'size', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=21), + [ + Call( + Name( + 'len', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=25), + [ + Name( + 'volumes', + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=33)], + [], + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=34), + Constant( + 1, + lineno=16, + col_offset=36, + end_lineno=16, + end_col_offset=37), + UnaryOp( + USub(), + Constant( + 1, + lineno=16, + col_offset=40, + end_lineno=16, + end_col_offset=41), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=41)], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=42), + [ + Assign( + [ + Name( + 'group', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=13)], + BinOp( + Name( + 'volumes', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=23), + Sub(), + Call( + Name( + 'Counter', + Load(), + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=33), + [ + GeneratorExp( + Name( + 'k', + Load(), + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=35), + [ + comprehension( + Tuple( + [ + Name( + 'k', + Store(), + lineno=17, + col_offset=40, + end_lineno=17, + end_col_offset=41), + Name( + '_', + Store(), + lineno=17, + col_offset=43, + end_lineno=17, + end_col_offset=44)], + Store(), + lineno=17, + col_offset=40, + end_lineno=17, + end_col_offset=44), + Call( + Attribute( + Name( + 'volumes', + Load(), + lineno=17, + col_offset=48, + end_lineno=17, + end_col_offset=55), + 'most_common', + Load(), + lineno=17, + col_offset=48, + end_lineno=17, + end_col_offset=67), + [ + Name( + 'size', + Load(), + lineno=17, + col_offset=68, + end_lineno=17, + end_col_offset=72)], + [], + lineno=17, + col_offset=48, + end_lineno=17, + end_col_offset=73), + [], + 0)], + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=74)], + [], + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=74), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=74), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=74), + Assign( + [ + Name( + 'group_books', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=19)], + Call( + Name( + 'sorted', + Load(), + lineno=18, + col_offset=22, + end_lineno=18, + end_col_offset=28), + [ + Call( + Attribute( + Name( + 'group', + Load(), + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=34), + 'elements', + Load(), + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=43), + [], + [], + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=45)], + [], + lineno=18, + col_offset=22, + end_lineno=18, + end_col_offset=46), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=46), + Assign( + [ + Name( + 'price', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=13)], + Call( + Name( + 'min', + Load(), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=19), + [ + Name( + 'price', + Load(), + lineno=19, + col_offset=20, + end_lineno=19, + end_col_offset=25), + BinOp( + Subscript( + Name( + 'PER_GROUP', + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=36), + Name( + 'size', + Load(), + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=41), + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=42), + Add(), + Call( + Name( + '_total', + Load(), + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=51), + [ + Name( + 'group_books', + Load(), + lineno=19, + col_offset=52, + end_lineno=19, + end_col_offset=63)], + [], + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=64), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=64)], + [], + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=65), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=65)], + [], + lineno=16, + col_offset=4, + end_lineno=19, + end_col_offset=65), + Return( + Name( + 'price', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=16), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=16)], + [], + lineno=13, + col_offset=0, + end_lineno=20, + end_col_offset=16), + FunctionDef( + 'total', + arguments( + [], + [ + arg( + 'basket', + lineno=23, + col_offset=10, + end_lineno=23, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'basket', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=17), + lineno=24, + col_offset=7, + end_lineno=24, + end_col_offset=17), + [ + Return( + Constant( + 0, + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=16), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=16)], + [], + lineno=24, + col_offset=4, + end_lineno=25, + end_col_offset=16), + Return( + Call( + Name( + '_total', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=17), + [ + Call( + Name( + 'sorted', + Load(), + lineno=26, + col_offset=18, + end_lineno=26, + end_col_offset=24), + [ + Name( + 'basket', + Load(), + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=31)], + [], + lineno=26, + col_offset=18, + end_lineno=26, + end_col_offset=32)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=33), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=33)], + [], + lineno=23, + col_offset=0, + end_lineno=26, + end_col_offset=33)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'Counter', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=31)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=31), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=8)], + Constant( + 800.0, + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=17), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=9)], + Dict( + [ + Constant( + 1, + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=5), + Constant( + 2, + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=5), + Constant( + 3, + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=5), + Constant( + 4, + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=5), + Constant( + 5, + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=5)], + [ + BinOp( + BinOp( + Constant( + 1, + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=8), + Mult(), + Name( + 'placeholder_0', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=19), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=19), + Mult(), + Constant( + 1.0, + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=26), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=26), + BinOp( + BinOp( + Constant( + 2, + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=8), + Mult(), + Name( + 'placeholder_0', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=19), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=19), + Mult(), + Constant( + 0.95, + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=26), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=26), + BinOp( + BinOp( + Constant( + 3, + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=8), + Mult(), + Name( + 'placeholder_0', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=19), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=19), + Mult(), + Constant( + 0.9, + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=26), + BinOp( + BinOp( + Constant( + 4, + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=8), + Mult(), + Name( + 'placeholder_0', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=19), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=19), + Mult(), + Constant( + 0.8, + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=26), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=26), + BinOp( + BinOp( + Constant( + 5, + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=8), + Mult(), + Name( + 'placeholder_0', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=19), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=19), + Mult(), + Constant( + 0.75, + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=26), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=26)], + lineno=4, + col_offset=12, + end_lineno=10, + end_col_offset=1), + lineno=4, + col_offset=0, + end_lineno=10, + end_col_offset=1), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=11)], + Call( + Name( + 'Counter', + Load(), + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=21), + [ + Name( + 'placeholder_3', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=28)], + [], + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=29), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=29), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=9)], + BinOp( + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=15), + [ + Name( + 'placeholder_3', + Load(), + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=22)], + [], + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=23), + Mult(), + Name( + 'placeholder_0', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=34), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=34), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=34), + For( + Name( + 'placeholder_6', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=12), + Call( + Name( + 'range', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=21), + [ + Call( + Name( + 'len', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=25), + [ + Name( + 'placeholder_4', + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=33)], + [], + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=34), + Constant( + 1, + lineno=16, + col_offset=36, + end_lineno=16, + end_col_offset=37), + UnaryOp( + USub(), + Constant( + 1, + lineno=16, + col_offset=40, + end_lineno=16, + end_col_offset=41), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=41)], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=42), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=13)], + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=23), + Sub(), + Call( + Name( + 'Counter', + Load(), + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=33), + [ + GeneratorExp( + Name( + 'placeholder_8', + Load(), + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=35), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_8', + Store(), + lineno=17, + col_offset=40, + end_lineno=17, + end_col_offset=41), + Name( + 'placeholder_9', + Store(), + lineno=17, + col_offset=43, + end_lineno=17, + end_col_offset=44)], + Store(), + lineno=17, + col_offset=40, + end_lineno=17, + end_col_offset=44), + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=17, + col_offset=48, + end_lineno=17, + end_col_offset=55), + 'most_common', + Load(), + lineno=17, + col_offset=48, + end_lineno=17, + end_col_offset=67), + [ + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=68, + end_lineno=17, + end_col_offset=72)], + [], + lineno=17, + col_offset=48, + end_lineno=17, + end_col_offset=73), + [], + 0)], + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=74)], + [], + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=74), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=74), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=74), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=19)], + Call( + Name( + 'sorted', + Load(), + lineno=18, + col_offset=22, + end_lineno=18, + end_col_offset=28), + [ + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=34), + 'elements', + Load(), + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=43), + [], + [], + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=45)], + [], + lineno=18, + col_offset=22, + end_lineno=18, + end_col_offset=46), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=13)], + Call( + Name( + 'min', + Load(), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=19), + [ + Name( + 'placeholder_5', + Load(), + lineno=19, + col_offset=20, + end_lineno=19, + end_col_offset=25), + BinOp( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=36), + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=41), + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=42), + Add(), + Call( + Name( + 'placeholder_2', + Load(), + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=51), + [ + Name( + 'placeholder_10', + Load(), + lineno=19, + col_offset=52, + end_lineno=19, + end_col_offset=63)], + [], + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=64), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=64)], + [], + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=65), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=65)], + [], + lineno=16, + col_offset=4, + end_lineno=19, + end_col_offset=65), + Return( + Name( + 'placeholder_5', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=16), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=16)], + [], + lineno=13, + col_offset=0, + end_lineno=20, + end_col_offset=16), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=23, + col_offset=10, + end_lineno=23, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_3', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=17), + lineno=24, + col_offset=7, + end_lineno=24, + end_col_offset=17), + [ + Return( + Constant( + 0, + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=16), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=16)], + [], + lineno=24, + col_offset=4, + end_lineno=25, + end_col_offset=16), + Return( + Call( + Name( + 'placeholder_2', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=17), + [ + Call( + Name( + 'sorted', + Load(), + lineno=26, + col_offset=18, + end_lineno=26, + end_col_offset=24), + [ + Name( + 'placeholder_3', + Load(), + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=31)], + [], + lineno=26, + col_offset=18, + end_lineno=26, + end_col_offset=32)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=33), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=33)], + [], + lineno=23, + col_offset=0, + end_lineno=26, + end_col_offset=33)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-book-store/representation.txt b/test/practice-book-store/representation.txt new file mode 100644 index 0000000..73680eb --- /dev/null +++ b/test/practice-book-store/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('collections', [alias('Counter', lineno=1, col_offset=24, end_lineno=1, end_col_offset=31)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=31), Assign([Name('placeholder_0', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=8)], Constant(800.0, lineno=3, col_offset=11, end_lineno=3, end_col_offset=17), lineno=3, col_offset=0, end_lineno=3, end_col_offset=17), Assign([Name('placeholder_1', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=9)], Dict([Constant(1, lineno=5, col_offset=4, end_lineno=5, end_col_offset=5), Constant(2, lineno=6, col_offset=4, end_lineno=6, end_col_offset=5), Constant(3, lineno=7, col_offset=4, end_lineno=7, end_col_offset=5), Constant(4, lineno=8, col_offset=4, end_lineno=8, end_col_offset=5), Constant(5, lineno=9, col_offset=4, end_lineno=9, end_col_offset=5)], [BinOp(BinOp(Constant(1, lineno=5, col_offset=7, end_lineno=5, end_col_offset=8), Mult(), Name('placeholder_0', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=19), lineno=5, col_offset=7, end_lineno=5, end_col_offset=19), Mult(), Constant(1.0, lineno=5, col_offset=22, end_lineno=5, end_col_offset=26), lineno=5, col_offset=7, end_lineno=5, end_col_offset=26), BinOp(BinOp(Constant(2, lineno=6, col_offset=7, end_lineno=6, end_col_offset=8), Mult(), Name('placeholder_0', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=19), lineno=6, col_offset=7, end_lineno=6, end_col_offset=19), Mult(), Constant(0.95, lineno=6, col_offset=22, end_lineno=6, end_col_offset=26), lineno=6, col_offset=7, end_lineno=6, end_col_offset=26), BinOp(BinOp(Constant(3, lineno=7, col_offset=7, end_lineno=7, end_col_offset=8), Mult(), Name('placeholder_0', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=19), lineno=7, col_offset=7, end_lineno=7, end_col_offset=19), Mult(), Constant(0.9, lineno=7, col_offset=22, end_lineno=7, end_col_offset=26), lineno=7, col_offset=7, end_lineno=7, end_col_offset=26), BinOp(BinOp(Constant(4, lineno=8, col_offset=7, end_lineno=8, end_col_offset=8), Mult(), Name('placeholder_0', Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=19), lineno=8, col_offset=7, end_lineno=8, end_col_offset=19), Mult(), Constant(0.8, lineno=8, col_offset=22, end_lineno=8, end_col_offset=26), lineno=8, col_offset=7, end_lineno=8, end_col_offset=26), BinOp(BinOp(Constant(5, lineno=9, col_offset=7, end_lineno=9, end_col_offset=8), Mult(), Name('placeholder_0', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=19), lineno=9, col_offset=7, end_lineno=9, end_col_offset=19), Mult(), Constant(0.75, lineno=9, col_offset=22, end_lineno=9, end_col_offset=26), lineno=9, col_offset=7, end_lineno=9, end_col_offset=26)], lineno=4, col_offset=12, end_lineno=10, end_col_offset=1), lineno=4, col_offset=0, end_lineno=10, end_col_offset=1), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=13, col_offset=11, end_lineno=13, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=11)], Call(Name('Counter', Load(), lineno=14, col_offset=14, end_lineno=14, end_col_offset=21), [Name('placeholder_3', Load(), lineno=14, col_offset=22, end_lineno=14, end_col_offset=28)], [], lineno=14, col_offset=14, end_lineno=14, end_col_offset=29), lineno=14, col_offset=4, end_lineno=14, end_col_offset=29), Assign([Name('placeholder_5', Store(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=9)], BinOp(Call(Name('len', Load(), lineno=15, col_offset=12, end_lineno=15, end_col_offset=15), [Name('placeholder_3', Load(), lineno=15, col_offset=16, end_lineno=15, end_col_offset=22)], [], lineno=15, col_offset=12, end_lineno=15, end_col_offset=23), Mult(), Name('placeholder_0', Load(), lineno=15, col_offset=26, end_lineno=15, end_col_offset=34), lineno=15, col_offset=12, end_lineno=15, end_col_offset=34), lineno=15, col_offset=4, end_lineno=15, end_col_offset=34), For(Name('placeholder_6', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=12), Call(Name('range', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=21), [Call(Name('len', Load(), lineno=16, col_offset=22, end_lineno=16, end_col_offset=25), [Name('placeholder_4', Load(), lineno=16, col_offset=26, end_lineno=16, end_col_offset=33)], [], lineno=16, col_offset=22, end_lineno=16, end_col_offset=34), Constant(1, lineno=16, col_offset=36, end_lineno=16, end_col_offset=37), UnaryOp(USub(), Constant(1, lineno=16, col_offset=40, end_lineno=16, end_col_offset=41), lineno=16, col_offset=39, end_lineno=16, end_col_offset=41)], [], lineno=16, col_offset=16, end_lineno=16, end_col_offset=42), [Assign([Name('placeholder_7', Store(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=13)], BinOp(Name('placeholder_4', Load(), lineno=17, col_offset=16, end_lineno=17, end_col_offset=23), Sub(), Call(Name('Counter', Load(), lineno=17, col_offset=26, end_lineno=17, end_col_offset=33), [GeneratorExp(Name('placeholder_8', Load(), lineno=17, col_offset=34, end_lineno=17, end_col_offset=35), [comprehension(Tuple([Name('placeholder_8', Store(), lineno=17, col_offset=40, end_lineno=17, end_col_offset=41), Name('placeholder_9', Store(), lineno=17, col_offset=43, end_lineno=17, end_col_offset=44)], Store(), lineno=17, col_offset=40, end_lineno=17, end_col_offset=44), Call(Attribute(Name('placeholder_4', Load(), lineno=17, col_offset=48, end_lineno=17, end_col_offset=55), 'most_common', Load(), lineno=17, col_offset=48, end_lineno=17, end_col_offset=67), [Name('placeholder_6', Load(), lineno=17, col_offset=68, end_lineno=17, end_col_offset=72)], [], lineno=17, col_offset=48, end_lineno=17, end_col_offset=73), [], 0)], lineno=17, col_offset=33, end_lineno=17, end_col_offset=74)], [], lineno=17, col_offset=26, end_lineno=17, end_col_offset=74), lineno=17, col_offset=16, end_lineno=17, end_col_offset=74), lineno=17, col_offset=8, end_lineno=17, end_col_offset=74), Assign([Name('placeholder_10', Store(), lineno=18, col_offset=8, end_lineno=18, end_col_offset=19)], Call(Name('sorted', Load(), lineno=18, col_offset=22, end_lineno=18, end_col_offset=28), [Call(Attribute(Name('placeholder_7', Load(), lineno=18, col_offset=29, end_lineno=18, end_col_offset=34), 'elements', Load(), lineno=18, col_offset=29, end_lineno=18, end_col_offset=43), [], [], lineno=18, col_offset=29, end_lineno=18, end_col_offset=45)], [], lineno=18, col_offset=22, end_lineno=18, end_col_offset=46), lineno=18, col_offset=8, end_lineno=18, end_col_offset=46), Assign([Name('placeholder_5', Store(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=13)], Call(Name('min', Load(), lineno=19, col_offset=16, end_lineno=19, end_col_offset=19), [Name('placeholder_5', Load(), lineno=19, col_offset=20, end_lineno=19, end_col_offset=25), BinOp(Subscript(Name('placeholder_1', Load(), lineno=19, col_offset=27, end_lineno=19, end_col_offset=36), Name('placeholder_6', Load(), lineno=19, col_offset=37, end_lineno=19, end_col_offset=41), Load(), lineno=19, col_offset=27, end_lineno=19, end_col_offset=42), Add(), Call(Name('placeholder_2', Load(), lineno=19, col_offset=45, end_lineno=19, end_col_offset=51), [Name('placeholder_10', Load(), lineno=19, col_offset=52, end_lineno=19, end_col_offset=63)], [], lineno=19, col_offset=45, end_lineno=19, end_col_offset=64), lineno=19, col_offset=27, end_lineno=19, end_col_offset=64)], [], lineno=19, col_offset=16, end_lineno=19, end_col_offset=65), lineno=19, col_offset=8, end_lineno=19, end_col_offset=65)], [], lineno=16, col_offset=4, end_lineno=19, end_col_offset=65), Return(Name('placeholder_5', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=16), lineno=20, col_offset=4, end_lineno=20, end_col_offset=16)], [], lineno=13, col_offset=0, end_lineno=20, end_col_offset=16), FunctionDef('placeholder_11', arguments([], [arg('placeholder_3', lineno=23, col_offset=10, end_lineno=23, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Name('placeholder_3', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=17), lineno=24, col_offset=7, end_lineno=24, end_col_offset=17), [Return(Constant(0, lineno=25, col_offset=15, end_lineno=25, end_col_offset=16), lineno=25, col_offset=8, end_lineno=25, end_col_offset=16)], [], lineno=24, col_offset=4, end_lineno=25, end_col_offset=16), Return(Call(Name('placeholder_2', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=17), [Call(Name('sorted', Load(), lineno=26, col_offset=18, end_lineno=26, end_col_offset=24), [Name('placeholder_3', Load(), lineno=26, col_offset=25, end_lineno=26, end_col_offset=31)], [], lineno=26, col_offset=18, end_lineno=26, end_col_offset=32)], [], lineno=26, col_offset=11, end_lineno=26, end_col_offset=33), lineno=26, col_offset=4, end_lineno=26, end_col_offset=33)], [], lineno=23, col_offset=0, end_lineno=26, end_col_offset=33)], []) \ No newline at end of file diff --git a/test/practice-bottle-song/.meta/config.json b/test/practice-bottle-song/.meta/config.json new file mode 100644 index 0000000..7845207 --- /dev/null +++ b/test/practice-bottle-song/.meta/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles.", + "authors": ["meatball133", "BethanyG"], + "contributors": [ + ], + "files": { + "solution": [ + "bottle_song.py" + ], + "test": [ + "bottle_song_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Ten_Green_Bottles" +} diff --git a/test/practice-bottle-song/bottle_song.py b/test/practice-bottle-song/bottle_song.py new file mode 100644 index 0000000..18e1167 --- /dev/null +++ b/test/practice-bottle-song/bottle_song.py @@ -0,0 +1,34 @@ +NUMBERS = {10: "ten", 9: "nine", 8: "eight", 7: "seven", 6: "six", 5: "five", 4: "four", 3: "three", 2: "two", 1: "one", 0: "no"} + +def recite(start, take=1): + results = [] + for idx in range(start, start - take, -1): + results.extend(verse(idx)) + if idx > start - take + 1: + results.append('') + return results + + +def verse(number): + return [ + *main_verse(number), + "And if one green bottle should accidentally fall,", + last_verse(number) + ] + +def main_verse(number): + if number == 1: + return [ + f'One green bottle hanging on the wall,', + f'One green bottle hanging on the wall,', + ] + else: + return [ + f'{NUMBERS[number].capitalize()} green bottles hanging on the wall,', + f'{NUMBERS[number].capitalize()} green bottles hanging on the wall,',] + +def last_verse(number): + if number -1 == 1: + return f"There'll be one green bottle hanging on the wall." + else: + return f"There'll be {NUMBERS[number-1]} green bottles hanging on the wall." diff --git a/test/practice-bottle-song/mapping.json b/test/practice-bottle-song/mapping.json new file mode 100644 index 0000000..d4555c8 --- /dev/null +++ b/test/practice-bottle-song/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "NUMBERS", + "placeholder_1": "recite", + "placeholder_2": "start", + "placeholder_3": "take", + "placeholder_4": "results", + "placeholder_5": "idx", + "placeholder_6": "verse", + "placeholder_7": "number", + "placeholder_8": "main_verse", + "placeholder_9": "last_verse" +} \ No newline at end of file diff --git a/test/practice-bottle-song/representation.json b/test/practice-bottle-song/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-bottle-song/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-bottle-song/representation.out b/test/practice-bottle-song/representation.out new file mode 100644 index 0000000..d1766cd --- /dev/null +++ b/test/practice-bottle-song/representation.out @@ -0,0 +1,1745 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = { + 10: "ten", + 9: "nine", + 8: "eight", + 7: "seven", + 6: "six", + 5: "five", + 4: "four", + 3: "three", + 2: "two", + 1: "one", + 0: "no", +} + + +def placeholder_1(placeholder_2, placeholder_3=1): + placeholder_4 = [] + for placeholder_5 in range(placeholder_2, placeholder_2 - placeholder_3, -1): + placeholder_4.extend(verse(placeholder_5)) + if placeholder_5 > placeholder_2 - placeholder_3 + 1: + placeholder_4.append("") + return placeholder_4 + + +def placeholder_6(placeholder_7): + return [ + *main_verse(placeholder_7), + "And if one green bottle should accidentally fall,", + last_verse(placeholder_7), + ] + + +def placeholder_8(placeholder_7): + if placeholder_7 == 1: + return [ + f"One green bottle hanging on the wall,", + f"One green bottle hanging on the wall,", + ] + else: + return [ + f"{placeholder_0[placeholder_7].capitalize()} green bottles hanging on the wall,", + f"{placeholder_0[placeholder_7].capitalize()} green bottles hanging on the wall,", + ] + + +def placeholder_9(placeholder_7): + if placeholder_7 - 1 == 1: + return f"There'll be one green bottle hanging on the wall." + else: + return f"There'll be {placeholder_0[placeholder_7 - 1]} green bottles hanging on the wall." + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'NUMBERS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=7)], + Dict( + [ + Constant( + 10, + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=13), + Constant( + 9, + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=23), + Constant( + 8, + lineno=1, + col_offset=33, + end_lineno=1, + end_col_offset=34), + Constant( + 7, + lineno=1, + col_offset=45, + end_lineno=1, + end_col_offset=46), + Constant( + 6, + lineno=1, + col_offset=57, + end_lineno=1, + end_col_offset=58), + Constant( + 5, + lineno=1, + col_offset=67, + end_lineno=1, + end_col_offset=68), + Constant( + 4, + lineno=1, + col_offset=78, + end_lineno=1, + end_col_offset=79), + Constant( + 3, + lineno=1, + col_offset=89, + end_lineno=1, + end_col_offset=90), + Constant( + 2, + lineno=1, + col_offset=101, + end_lineno=1, + end_col_offset=102), + Constant( + 1, + lineno=1, + col_offset=111, + end_lineno=1, + end_col_offset=112), + Constant( + 0, + lineno=1, + col_offset=121, + end_lineno=1, + end_col_offset=122)], + [ + Constant( + 'ten', + lineno=1, + col_offset=15, + end_lineno=1, + end_col_offset=20), + Constant( + 'nine', + lineno=1, + col_offset=25, + end_lineno=1, + end_col_offset=31), + Constant( + 'eight', + lineno=1, + col_offset=36, + end_lineno=1, + end_col_offset=43), + Constant( + 'seven', + lineno=1, + col_offset=48, + end_lineno=1, + end_col_offset=55), + Constant( + 'six', + lineno=1, + col_offset=60, + end_lineno=1, + end_col_offset=65), + Constant( + 'five', + lineno=1, + col_offset=70, + end_lineno=1, + end_col_offset=76), + Constant( + 'four', + lineno=1, + col_offset=81, + end_lineno=1, + end_col_offset=87), + Constant( + 'three', + lineno=1, + col_offset=92, + end_lineno=1, + end_col_offset=99), + Constant( + 'two', + lineno=1, + col_offset=104, + end_lineno=1, + end_col_offset=109), + Constant( + 'one', + lineno=1, + col_offset=114, + end_lineno=1, + end_col_offset=119), + Constant( + 'no', + lineno=1, + col_offset=124, + end_lineno=1, + end_col_offset=128)], + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=129), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=129), + FunctionDef( + 'recite', + arguments( + [], + [ + arg( + 'start', + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=16), + arg( + 'take', + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 1, + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=24)]), + [ + Assign( + [ + Name( + 'results', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=11)], + List( + [], + Load(), + lineno=4, + col_offset=14, + end_lineno=4, + end_col_offset=16), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=16), + For( + Name( + 'idx', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=20), + [ + Name( + 'start', + Load(), + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=26), + BinOp( + Name( + 'start', + Load(), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=33), + Sub(), + Name( + 'take', + Load(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=40), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=40), + UnaryOp( + USub(), + Constant( + 1, + lineno=5, + col_offset=43, + end_lineno=5, + end_col_offset=44), + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=44)], + [], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=45), + [ + Expr( + Call( + Attribute( + Name( + 'results', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=15), + 'extend', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=22), + [ + Call( + Name( + 'verse', + Load(), + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=28), + [ + Name( + 'idx', + Load(), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=32)], + [], + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=33)], + [], + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=34), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=34), + If( + Compare( + Name( + 'idx', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=14), + [ + Gt()], + [ + BinOp( + BinOp( + Name( + 'start', + Load(), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=22), + Sub(), + Name( + 'take', + Load(), + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=29), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=29), + Add(), + Constant( + 1, + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=33), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=33)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=33), + [ + Expr( + Call( + Attribute( + Name( + 'results', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=19), + 'append', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=26), + [ + Constant( + '', + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=29)], + [], + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=30), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=30)], + [], + lineno=7, + col_offset=8, + end_lineno=8, + end_col_offset=30)], + [], + lineno=5, + col_offset=4, + end_lineno=8, + end_col_offset=30), + Return( + Name( + 'results', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=18)], + [], + lineno=3, + col_offset=0, + end_lineno=9, + end_col_offset=18), + FunctionDef( + 'verse', + arguments( + [], + [ + arg( + 'number', + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + List( + [ + Starred( + Call( + Name( + 'main_verse', + Load(), + lineno=14, + col_offset=9, + end_lineno=14, + end_col_offset=19), + [ + Name( + 'number', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=26)], + [], + lineno=14, + col_offset=9, + end_lineno=14, + end_col_offset=27), + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=27), + Constant( + 'And if one green bottle should accidentally fall,', + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=59), + Call( + Name( + 'last_verse', + Load(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18), + [ + Name( + 'number', + Load(), + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=25)], + [], + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=26)], + Load(), + lineno=13, + col_offset=11, + end_lineno=17, + end_col_offset=9), + lineno=13, + col_offset=4, + end_lineno=17, + end_col_offset=9)], + [], + lineno=12, + col_offset=0, + end_lineno=17, + end_col_offset=9), + FunctionDef( + 'main_verse', + arguments( + [], + [ + arg( + 'number', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 1, + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=18)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=18), + [ + Return( + List( + [ + JoinedStr( + [ + Constant( + 'One green bottle hanging on the wall,', + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=52)], + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=52), + JoinedStr( + [ + Constant( + 'One green bottle hanging on the wall,', + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=52)], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=52)], + Load(), + lineno=21, + col_offset=15, + end_lineno=24, + end_col_offset=9), + lineno=21, + col_offset=8, + end_lineno=24, + end_col_offset=9)], + [ + Return( + List( + [ + JoinedStr( + [ + FormattedValue( + Call( + Attribute( + Subscript( + Name( + 'NUMBERS', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=18), + Name( + 'number', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=25), + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=26), + 'capitalize', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=37), + [], + [], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=39), + -1, + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=76), + Constant( + ' green bottles hanging on the wall,', + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=76)], + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=76), + JoinedStr( + [ + FormattedValue( + Call( + Attribute( + Subscript( + Name( + 'NUMBERS', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=18), + Name( + 'number', + Load(), + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=25), + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=26), + 'capitalize', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=37), + [], + [], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=39), + -1, + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=76), + Constant( + ' green bottles hanging on the wall,', + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=76)], + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=76)], + Load(), + lineno=26, + col_offset=15, + end_lineno=28, + end_col_offset=78), + lineno=26, + col_offset=8, + end_lineno=28, + end_col_offset=78)], + lineno=20, + col_offset=4, + end_lineno=28, + end_col_offset=78)], + [], + lineno=19, + col_offset=0, + end_lineno=28, + end_col_offset=78), + FunctionDef( + 'last_verse', + arguments( + [], + [ + arg( + 'number', + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=13), + Sub(), + Constant( + 1, + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=16), + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 1, + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=21)], + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=21), + [ + Return( + JoinedStr( + [ + Constant( + "There'll be one green bottle hanging on the wall.", + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=67)], + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=67), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=67)], + [ + Return( + JoinedStr( + [ + Constant( + "There'll be ", + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=84), + FormattedValue( + Subscript( + Name( + 'NUMBERS', + Load(), + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=37), + BinOp( + Name( + 'number', + Load(), + lineno=34, + col_offset=38, + end_lineno=34, + end_col_offset=44), + Sub(), + Constant( + 1, + lineno=34, + col_offset=45, + end_lineno=34, + end_col_offset=46), + lineno=34, + col_offset=38, + end_lineno=34, + end_col_offset=46), + Load(), + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=47), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=84), + Constant( + ' green bottles hanging on the wall.', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=84)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=84), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=84)], + lineno=31, + col_offset=4, + end_lineno=34, + end_col_offset=84)], + [], + lineno=30, + col_offset=0, + end_lineno=34, + end_col_offset=84)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=7)], + Dict( + [ + Constant( + 10, + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=13), + Constant( + 9, + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=23), + Constant( + 8, + lineno=1, + col_offset=33, + end_lineno=1, + end_col_offset=34), + Constant( + 7, + lineno=1, + col_offset=45, + end_lineno=1, + end_col_offset=46), + Constant( + 6, + lineno=1, + col_offset=57, + end_lineno=1, + end_col_offset=58), + Constant( + 5, + lineno=1, + col_offset=67, + end_lineno=1, + end_col_offset=68), + Constant( + 4, + lineno=1, + col_offset=78, + end_lineno=1, + end_col_offset=79), + Constant( + 3, + lineno=1, + col_offset=89, + end_lineno=1, + end_col_offset=90), + Constant( + 2, + lineno=1, + col_offset=101, + end_lineno=1, + end_col_offset=102), + Constant( + 1, + lineno=1, + col_offset=111, + end_lineno=1, + end_col_offset=112), + Constant( + 0, + lineno=1, + col_offset=121, + end_lineno=1, + end_col_offset=122)], + [ + Constant( + 'ten', + lineno=1, + col_offset=15, + end_lineno=1, + end_col_offset=20), + Constant( + 'nine', + lineno=1, + col_offset=25, + end_lineno=1, + end_col_offset=31), + Constant( + 'eight', + lineno=1, + col_offset=36, + end_lineno=1, + end_col_offset=43), + Constant( + 'seven', + lineno=1, + col_offset=48, + end_lineno=1, + end_col_offset=55), + Constant( + 'six', + lineno=1, + col_offset=60, + end_lineno=1, + end_col_offset=65), + Constant( + 'five', + lineno=1, + col_offset=70, + end_lineno=1, + end_col_offset=76), + Constant( + 'four', + lineno=1, + col_offset=81, + end_lineno=1, + end_col_offset=87), + Constant( + 'three', + lineno=1, + col_offset=92, + end_lineno=1, + end_col_offset=99), + Constant( + 'two', + lineno=1, + col_offset=104, + end_lineno=1, + end_col_offset=109), + Constant( + 'one', + lineno=1, + col_offset=114, + end_lineno=1, + end_col_offset=119), + Constant( + 'no', + lineno=1, + col_offset=124, + end_lineno=1, + end_col_offset=128)], + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=129), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=129), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=16), + arg( + 'placeholder_3', + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 1, + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=24)]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=11)], + List( + [], + Load(), + lineno=4, + col_offset=14, + end_lineno=4, + end_col_offset=16), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=16), + For( + Name( + 'placeholder_5', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=20), + [ + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=26), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=33), + Sub(), + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=40), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=40), + UnaryOp( + USub(), + Constant( + 1, + lineno=5, + col_offset=43, + end_lineno=5, + end_col_offset=44), + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=44)], + [], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=45), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=15), + 'extend', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=22), + [ + Call( + Name( + 'verse', + Load(), + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=28), + [ + Name( + 'placeholder_5', + Load(), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=32)], + [], + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=33)], + [], + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=34), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=34), + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=14), + [ + Gt()], + [ + BinOp( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=22), + Sub(), + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=29), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=29), + Add(), + Constant( + 1, + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=33), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=33)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=33), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=19), + 'append', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=26), + [ + Constant( + '', + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=29)], + [], + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=30), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=30)], + [], + lineno=7, + col_offset=8, + end_lineno=8, + end_col_offset=30)], + [], + lineno=5, + col_offset=4, + end_lineno=8, + end_col_offset=30), + Return( + Name( + 'placeholder_4', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=18)], + [], + lineno=3, + col_offset=0, + end_lineno=9, + end_col_offset=18), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + List( + [ + Starred( + Call( + Name( + 'main_verse', + Load(), + lineno=14, + col_offset=9, + end_lineno=14, + end_col_offset=19), + [ + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=26)], + [], + lineno=14, + col_offset=9, + end_lineno=14, + end_col_offset=27), + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=27), + Constant( + 'And if one green bottle should accidentally fall,', + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=59), + Call( + Name( + 'last_verse', + Load(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18), + [ + Name( + 'placeholder_7', + Load(), + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=25)], + [], + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=26)], + Load(), + lineno=13, + col_offset=11, + end_lineno=17, + end_col_offset=9), + lineno=13, + col_offset=4, + end_lineno=17, + end_col_offset=9)], + [], + lineno=12, + col_offset=0, + end_lineno=17, + end_col_offset=9), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 1, + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=18)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=18), + [ + Return( + List( + [ + JoinedStr( + [ + Constant( + 'One green bottle hanging on the wall,', + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=52)], + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=52), + JoinedStr( + [ + Constant( + 'One green bottle hanging on the wall,', + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=52)], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=52)], + Load(), + lineno=21, + col_offset=15, + end_lineno=24, + end_col_offset=9), + lineno=21, + col_offset=8, + end_lineno=24, + end_col_offset=9)], + [ + Return( + List( + [ + JoinedStr( + [ + FormattedValue( + Call( + Attribute( + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=18), + Name( + 'placeholder_7', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=25), + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=26), + 'capitalize', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=37), + [], + [], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=39), + -1, + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=76), + Constant( + ' green bottles hanging on the wall,', + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=76)], + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=76), + JoinedStr( + [ + FormattedValue( + Call( + Attribute( + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=18), + Name( + 'placeholder_7', + Load(), + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=25), + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=26), + 'capitalize', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=37), + [], + [], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=39), + -1, + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=76), + Constant( + ' green bottles hanging on the wall,', + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=76)], + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=76)], + Load(), + lineno=26, + col_offset=15, + end_lineno=28, + end_col_offset=78), + lineno=26, + col_offset=8, + end_lineno=28, + end_col_offset=78)], + lineno=20, + col_offset=4, + end_lineno=28, + end_col_offset=78)], + [], + lineno=19, + col_offset=0, + end_lineno=28, + end_col_offset=78), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=13), + Sub(), + Constant( + 1, + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=16), + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 1, + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=21)], + lineno=31, + col_offset=7, + end_lineno=31, + end_col_offset=21), + [ + Return( + JoinedStr( + [ + Constant( + "There'll be one green bottle hanging on the wall.", + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=67)], + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=67), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=67)], + [ + Return( + JoinedStr( + [ + Constant( + "There'll be ", + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=84), + FormattedValue( + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=37), + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=34, + col_offset=38, + end_lineno=34, + end_col_offset=44), + Sub(), + Constant( + 1, + lineno=34, + col_offset=45, + end_lineno=34, + end_col_offset=46), + lineno=34, + col_offset=38, + end_lineno=34, + end_col_offset=46), + Load(), + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=47), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=84), + Constant( + ' green bottles hanging on the wall.', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=84)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=84), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=84)], + lineno=31, + col_offset=4, + end_lineno=34, + end_col_offset=84)], + [], + lineno=30, + col_offset=0, + end_lineno=34, + end_col_offset=84)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-bottle-song/representation.txt b/test/practice-bottle-song/representation.txt new file mode 100644 index 0000000..4ab43b6 --- /dev/null +++ b/test/practice-bottle-song/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=7)], Dict([Constant(10, lineno=1, col_offset=11, end_lineno=1, end_col_offset=13), Constant(9, lineno=1, col_offset=22, end_lineno=1, end_col_offset=23), Constant(8, lineno=1, col_offset=33, end_lineno=1, end_col_offset=34), Constant(7, lineno=1, col_offset=45, end_lineno=1, end_col_offset=46), Constant(6, lineno=1, col_offset=57, end_lineno=1, end_col_offset=58), Constant(5, lineno=1, col_offset=67, end_lineno=1, end_col_offset=68), Constant(4, lineno=1, col_offset=78, end_lineno=1, end_col_offset=79), Constant(3, lineno=1, col_offset=89, end_lineno=1, end_col_offset=90), Constant(2, lineno=1, col_offset=101, end_lineno=1, end_col_offset=102), Constant(1, lineno=1, col_offset=111, end_lineno=1, end_col_offset=112), Constant(0, lineno=1, col_offset=121, end_lineno=1, end_col_offset=122)], [Constant('ten', lineno=1, col_offset=15, end_lineno=1, end_col_offset=20), Constant('nine', lineno=1, col_offset=25, end_lineno=1, end_col_offset=31), Constant('eight', lineno=1, col_offset=36, end_lineno=1, end_col_offset=43), Constant('seven', lineno=1, col_offset=48, end_lineno=1, end_col_offset=55), Constant('six', lineno=1, col_offset=60, end_lineno=1, end_col_offset=65), Constant('five', lineno=1, col_offset=70, end_lineno=1, end_col_offset=76), Constant('four', lineno=1, col_offset=81, end_lineno=1, end_col_offset=87), Constant('three', lineno=1, col_offset=92, end_lineno=1, end_col_offset=99), Constant('two', lineno=1, col_offset=104, end_lineno=1, end_col_offset=109), Constant('one', lineno=1, col_offset=114, end_lineno=1, end_col_offset=119), Constant('no', lineno=1, col_offset=124, end_lineno=1, end_col_offset=128)], lineno=1, col_offset=10, end_lineno=1, end_col_offset=129), lineno=1, col_offset=0, end_lineno=1, end_col_offset=129), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=3, col_offset=11, end_lineno=3, end_col_offset=16), arg('placeholder_3', lineno=3, col_offset=18, end_lineno=3, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(1, lineno=3, col_offset=23, end_lineno=3, end_col_offset=24)]), [Assign([Name('placeholder_4', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=11)], List([], Load(), lineno=4, col_offset=14, end_lineno=4, end_col_offset=16), lineno=4, col_offset=4, end_lineno=4, end_col_offset=16), For(Name('placeholder_5', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=11), Call(Name('range', Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=20), [Name('placeholder_2', Load(), lineno=5, col_offset=21, end_lineno=5, end_col_offset=26), BinOp(Name('placeholder_2', Load(), lineno=5, col_offset=28, end_lineno=5, end_col_offset=33), Sub(), Name('placeholder_3', Load(), lineno=5, col_offset=36, end_lineno=5, end_col_offset=40), lineno=5, col_offset=28, end_lineno=5, end_col_offset=40), UnaryOp(USub(), Constant(1, lineno=5, col_offset=43, end_lineno=5, end_col_offset=44), lineno=5, col_offset=42, end_lineno=5, end_col_offset=44)], [], lineno=5, col_offset=15, end_lineno=5, end_col_offset=45), [Expr(Call(Attribute(Name('placeholder_4', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=15), 'extend', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=22), [Call(Name('verse', Load(), lineno=6, col_offset=23, end_lineno=6, end_col_offset=28), [Name('placeholder_5', Load(), lineno=6, col_offset=29, end_lineno=6, end_col_offset=32)], [], lineno=6, col_offset=23, end_lineno=6, end_col_offset=33)], [], lineno=6, col_offset=8, end_lineno=6, end_col_offset=34), lineno=6, col_offset=8, end_lineno=6, end_col_offset=34), If(Compare(Name('placeholder_5', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=14), [Gt()], [BinOp(BinOp(Name('placeholder_2', Load(), lineno=7, col_offset=17, end_lineno=7, end_col_offset=22), Sub(), Name('placeholder_3', Load(), lineno=7, col_offset=25, end_lineno=7, end_col_offset=29), lineno=7, col_offset=17, end_lineno=7, end_col_offset=29), Add(), Constant(1, lineno=7, col_offset=32, end_lineno=7, end_col_offset=33), lineno=7, col_offset=17, end_lineno=7, end_col_offset=33)], lineno=7, col_offset=11, end_lineno=7, end_col_offset=33), [Expr(Call(Attribute(Name('placeholder_4', Load(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=19), 'append', Load(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=26), [Constant('', lineno=8, col_offset=27, end_lineno=8, end_col_offset=29)], [], lineno=8, col_offset=12, end_lineno=8, end_col_offset=30), lineno=8, col_offset=12, end_lineno=8, end_col_offset=30)], [], lineno=7, col_offset=8, end_lineno=8, end_col_offset=30)], [], lineno=5, col_offset=4, end_lineno=8, end_col_offset=30), Return(Name('placeholder_4', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=18), lineno=9, col_offset=4, end_lineno=9, end_col_offset=18)], [], lineno=3, col_offset=0, end_lineno=9, end_col_offset=18), FunctionDef('placeholder_6', arguments([], [arg('placeholder_7', lineno=12, col_offset=10, end_lineno=12, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(List([Starred(Call(Name('main_verse', Load(), lineno=14, col_offset=9, end_lineno=14, end_col_offset=19), [Name('placeholder_7', Load(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=26)], [], lineno=14, col_offset=9, end_lineno=14, end_col_offset=27), Load(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=27), Constant('And if one green bottle should accidentally fall,', lineno=15, col_offset=8, end_lineno=15, end_col_offset=59), Call(Name('last_verse', Load(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=18), [Name('placeholder_7', Load(), lineno=16, col_offset=19, end_lineno=16, end_col_offset=25)], [], lineno=16, col_offset=8, end_lineno=16, end_col_offset=26)], Load(), lineno=13, col_offset=11, end_lineno=17, end_col_offset=9), lineno=13, col_offset=4, end_lineno=17, end_col_offset=9)], [], lineno=12, col_offset=0, end_lineno=17, end_col_offset=9), FunctionDef('placeholder_8', arguments([], [arg('placeholder_7', lineno=19, col_offset=15, end_lineno=19, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_7', Load(), lineno=20, col_offset=7, end_lineno=20, end_col_offset=13), [Eq()], [Constant(1, lineno=20, col_offset=17, end_lineno=20, end_col_offset=18)], lineno=20, col_offset=7, end_lineno=20, end_col_offset=18), [Return(List([JoinedStr([Constant('One green bottle hanging on the wall,', lineno=22, col_offset=12, end_lineno=22, end_col_offset=52)], lineno=22, col_offset=12, end_lineno=22, end_col_offset=52), JoinedStr([Constant('One green bottle hanging on the wall,', lineno=23, col_offset=12, end_lineno=23, end_col_offset=52)], lineno=23, col_offset=12, end_lineno=23, end_col_offset=52)], Load(), lineno=21, col_offset=15, end_lineno=24, end_col_offset=9), lineno=21, col_offset=8, end_lineno=24, end_col_offset=9)], [Return(List([JoinedStr([FormattedValue(Call(Attribute(Subscript(Name('placeholder_0', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=18), Name('placeholder_7', Load(), lineno=27, col_offset=19, end_lineno=27, end_col_offset=25), Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=26), 'capitalize', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=37), [], [], lineno=27, col_offset=11, end_lineno=27, end_col_offset=39), -1, lineno=27, col_offset=8, end_lineno=27, end_col_offset=76), Constant(' green bottles hanging on the wall,', lineno=27, col_offset=8, end_lineno=27, end_col_offset=76)], lineno=27, col_offset=8, end_lineno=27, end_col_offset=76), JoinedStr([FormattedValue(Call(Attribute(Subscript(Name('placeholder_0', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=18), Name('placeholder_7', Load(), lineno=28, col_offset=19, end_lineno=28, end_col_offset=25), Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=26), 'capitalize', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=37), [], [], lineno=28, col_offset=11, end_lineno=28, end_col_offset=39), -1, lineno=28, col_offset=8, end_lineno=28, end_col_offset=76), Constant(' green bottles hanging on the wall,', lineno=28, col_offset=8, end_lineno=28, end_col_offset=76)], lineno=28, col_offset=8, end_lineno=28, end_col_offset=76)], Load(), lineno=26, col_offset=15, end_lineno=28, end_col_offset=78), lineno=26, col_offset=8, end_lineno=28, end_col_offset=78)], lineno=20, col_offset=4, end_lineno=28, end_col_offset=78)], [], lineno=19, col_offset=0, end_lineno=28, end_col_offset=78), FunctionDef('placeholder_9', arguments([], [arg('placeholder_7', lineno=30, col_offset=15, end_lineno=30, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(BinOp(Name('placeholder_7', Load(), lineno=31, col_offset=7, end_lineno=31, end_col_offset=13), Sub(), Constant(1, lineno=31, col_offset=15, end_lineno=31, end_col_offset=16), lineno=31, col_offset=7, end_lineno=31, end_col_offset=16), [Eq()], [Constant(1, lineno=31, col_offset=20, end_lineno=31, end_col_offset=21)], lineno=31, col_offset=7, end_lineno=31, end_col_offset=21), [Return(JoinedStr([Constant("There'll be one green bottle hanging on the wall.", lineno=32, col_offset=15, end_lineno=32, end_col_offset=67)], lineno=32, col_offset=15, end_lineno=32, end_col_offset=67), lineno=32, col_offset=8, end_lineno=32, end_col_offset=67)], [Return(JoinedStr([Constant("There'll be ", lineno=34, col_offset=15, end_lineno=34, end_col_offset=84), FormattedValue(Subscript(Name('placeholder_0', Load(), lineno=34, col_offset=30, end_lineno=34, end_col_offset=37), BinOp(Name('placeholder_7', Load(), lineno=34, col_offset=38, end_lineno=34, end_col_offset=44), Sub(), Constant(1, lineno=34, col_offset=45, end_lineno=34, end_col_offset=46), lineno=34, col_offset=38, end_lineno=34, end_col_offset=46), Load(), lineno=34, col_offset=30, end_lineno=34, end_col_offset=47), -1, lineno=34, col_offset=15, end_lineno=34, end_col_offset=84), Constant(' green bottles hanging on the wall.', lineno=34, col_offset=15, end_lineno=34, end_col_offset=84)], lineno=34, col_offset=15, end_lineno=34, end_col_offset=84), lineno=34, col_offset=8, end_lineno=34, end_col_offset=84)], lineno=31, col_offset=4, end_lineno=34, end_col_offset=84)], [], lineno=30, col_offset=0, end_lineno=34, end_col_offset=84)], []) \ No newline at end of file diff --git a/test/practice-bowling/.gitignore b/test/practice-bowling/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/test/practice-bowling/.meta/config.json b/test/practice-bowling/.meta/config.json new file mode 100644 index 0000000..e97b0e6 --- /dev/null +++ b/test/practice-bowling/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "aes421" + ], + "contributors": [ + "cmccandless", + "Dog", + "kytrinyx", + "RNeilsen", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "bowling.py" + ], + "test": [ + "bowling_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Score a bowling game.", + "source": "The Bowling Game Kata from UncleBob", + "source_url": "https://web.archive.org/web/20221001111000/http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata" +} diff --git a/test/practice-bowling/bowling.py b/test/practice-bowling/bowling.py new file mode 100644 index 0000000..7afb0d6 --- /dev/null +++ b/test/practice-bowling/bowling.py @@ -0,0 +1,99 @@ +MAX_FRAME = 10 + + +class Frame: + def __init__(self, idx): + self.idx = idx + self.throws = [] + + @property + def total_pins(self): + """Total pins knocked down in a frame.""" + return sum(self.throws) + + def is_strike(self): + return self.total_pins == 10 and len(self.throws) == 1 + + def is_spare(self): + return self.total_pins == 10 and len(self.throws) == 2 + + def is_open(self): + return self.total_pins < 10 and len(self.throws) == 2 + + def is_closed(self): + """Return whether a frame is over.""" + return self.total_pins == 10 or len(self.throws) == 2 + + def throw(self, pins): + if self.total_pins + pins > 10: + raise ValueError("a frame's rolls cannot exceed 10") + self.throws.append(pins) + + def score(self, next_throws): + result = self.total_pins + if self.is_strike(): + result += sum(next_throws[:2]) + elif self.is_spare(): + result += sum(next_throws[:1]) + return result + + +class BowlingGame: + def __init__(self): + self.current_frame_idx = 0 + self.bonus_throws = [] + self.frames = [Frame(idx) for idx in range(MAX_FRAME)] + + @property + def current_frame(self): + return self.frames[self.current_frame_idx] + + def next_throws(self, frame_idx): + """Return a frame's next throws in the form of a list.""" + throws = [] + for idx in range(frame_idx + 1, MAX_FRAME): + throws.extend(self.frames[idx].throws) + throws.extend(self.bonus_throws) + return throws + + def roll_bonus(self, pins): + tenth_frame = self.frames[-1] + if tenth_frame.is_open(): + raise IndexError('cannot throw bonus with an open tenth frame') + + self.bonus_throws.append(pins) + + # Check against invalid fill balls, e.g. [3, 10] + if (len(self.bonus_throws) == 2 and self.bonus_throws[0] != 10 and + sum(self.bonus_throws) > 10): + raise ValueError('invalid fill balls') + + # Check if there are more bonuses than it should be + if tenth_frame.is_strike() and len(self.bonus_throws) > 2: + raise IndexError( + 'wrong number of fill balls when the tenth frame is a strike') + elif tenth_frame.is_spare() and len(self.bonus_throws) > 1: + raise IndexError( + 'wrong number of fill balls when the tenth frame is a spare') + + def roll(self, pins): + if not 0 <= pins <= 10: + raise ValueError('invalid pins') + elif self.current_frame_idx == MAX_FRAME: + self.roll_bonus(pins) + else: + self.current_frame.throw(pins) + if self.current_frame.is_closed(): + self.current_frame_idx += 1 + + def score(self): + if self.current_frame_idx < MAX_FRAME: + raise IndexError('frame less than 10') + if self.frames[-1].is_spare() and len(self.bonus_throws) != 1: + raise IndexError( + 'one bonus must be rolled when the tenth frame is spare') + if self.frames[-1].is_strike() and len(self.bonus_throws) != 2: + raise IndexError( + 'two bonuses must be rolled when the tenth frame is strike') + return sum(frame.score(self.next_throws(frame.idx)) + for frame in self.frames) diff --git a/test/practice-bowling/mapping.json b/test/practice-bowling/mapping.json new file mode 100644 index 0000000..9a88a89 --- /dev/null +++ b/test/practice-bowling/mapping.json @@ -0,0 +1,27 @@ +{ + "placeholder_0": "MAX_FRAME", + "placeholder_1": "Frame", + "placeholder_2": "__init__", + "placeholder_3": "idx", + "placeholder_4": "throws", + "placeholder_5": "total_pins", + "placeholder_6": "is_strike", + "placeholder_7": "is_spare", + "placeholder_8": "is_open", + "placeholder_9": "is_closed", + "placeholder_10": "throw", + "placeholder_11": "pins", + "placeholder_12": "score", + "placeholder_13": "next_throws", + "placeholder_14": "result", + "placeholder_15": "BowlingGame", + "placeholder_16": "current_frame_idx", + "placeholder_17": "bonus_throws", + "placeholder_18": "frames", + "placeholder_19": "current_frame", + "placeholder_20": "frame_idx", + "placeholder_21": "roll_bonus", + "placeholder_22": "tenth_frame", + "placeholder_23": "roll", + "placeholder_24": "frame" +} \ No newline at end of file diff --git a/test/practice-bowling/representation.json b/test/practice-bowling/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-bowling/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-bowling/representation.out b/test/practice-bowling/representation.out new file mode 100644 index 0000000..4301ce7 --- /dev/null +++ b/test/practice-bowling/representation.out @@ -0,0 +1,5374 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = 10 + + +class placeholder_1: + def placeholder_2(self, placeholder_3): + self.placeholder_3 = placeholder_3 + self.placeholder_4 = [] + + @property + def placeholder_5(self): + return sum(self.placeholder_4) + + def placeholder_6(self): + return self.placeholder_5 == 10 and len(self.placeholder_4) == 1 + + def placeholder_7(self): + return self.placeholder_5 == 10 and len(self.placeholder_4) == 2 + + def placeholder_8(self): + return self.placeholder_5 < 10 and len(self.placeholder_4) == 2 + + def placeholder_9(self): + return self.placeholder_5 == 10 or len(self.placeholder_4) == 2 + + def placeholder_10(self, placeholder_11): + if self.placeholder_5 + placeholder_11 > 10: + raise ValueError("a frame's rolls cannot exceed 10") + self.placeholder_4.append(placeholder_11) + + def placeholder_12(self, placeholder_13): + placeholder_14 = self.placeholder_5 + if self.placeholder_6(): + placeholder_14 += sum(placeholder_13[:2]) + elif self.placeholder_7(): + placeholder_14 += sum(placeholder_13[:1]) + return placeholder_14 + + +class placeholder_15: + def placeholder_2(self): + self.placeholder_16 = 0 + self.placeholder_17 = [] + self.placeholder_18 = [ + placeholder_1(placeholder_3) for placeholder_3 in range(placeholder_0) + ] + + @property + def placeholder_19(self): + return self.placeholder_18[self.placeholder_16] + + def placeholder_13(self, placeholder_20): + placeholder_4 = [] + for placeholder_3 in range(placeholder_20 + 1, placeholder_0): + placeholder_4.extend(self.placeholder_18[placeholder_3].placeholder_4) + placeholder_4.extend(self.placeholder_17) + return placeholder_4 + + def placeholder_21(self, placeholder_11): + placeholder_22 = self.placeholder_18[-1] + if placeholder_22.placeholder_8(): + raise IndexError("cannot throw bonus with an open tenth frame") + self.placeholder_17.append(placeholder_11) + if ( + len(self.placeholder_17) == 2 + and self.placeholder_17[0] != 10 + and (sum(self.placeholder_17) > 10) + ): + raise ValueError("invalid fill balls") + if placeholder_22.placeholder_6() and len(self.placeholder_17) > 2: + raise IndexError( + "wrong number of fill balls when the tenth frame is a strike" + ) + elif placeholder_22.placeholder_7() and len(self.placeholder_17) > 1: + raise IndexError( + "wrong number of fill balls when the tenth frame is a spare" + ) + + def placeholder_23(self, placeholder_11): + if not 0 <= placeholder_11 <= 10: + raise ValueError("invalid pins") + elif self.placeholder_16 == placeholder_0: + self.placeholder_21(placeholder_11) + else: + self.placeholder_19.placeholder_10(placeholder_11) + if self.placeholder_19.placeholder_9(): + self.placeholder_16 += 1 + + def placeholder_12(self): + if self.placeholder_16 < placeholder_0: + raise IndexError("frame less than 10") + if self.placeholder_18[-1].placeholder_7() and len(self.placeholder_17) != 1: + raise IndexError("one bonus must be rolled when the tenth frame is spare") + if self.placeholder_18[-1].placeholder_6() and len(self.placeholder_17) != 2: + raise IndexError( + "two bonuses must be rolled when the tenth frame is strike" + ) + return sum( + ( + placeholder_24.placeholder_12( + self.placeholder_13(placeholder_24.placeholder_3) + ) + for placeholder_24 in self.placeholder_18 + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'MAX_FRAME', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9)], + Constant( + 10, + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=14), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=14), + ClassDef( + 'Frame', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'idx', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'idx', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=16)], + Name( + 'idx', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=22), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'throws', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=19)], + List( + [], + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=24), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=24)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=24), + FunctionDef( + 'total_pins', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Total pins knocked down in a frame.', + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=49), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=49), + Return( + Call( + Name( + 'sum', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=18), + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=23), + 'throws', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=30)], + [], + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=31), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=31)], + [ + Name( + 'property', + Load(), + lineno=9, + col_offset=5, + end_lineno=9, + end_col_offset=13)], + lineno=10, + col_offset=4, + end_lineno=12, + end_col_offset=31), + FunctionDef( + 'is_strike', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + 'total_pins', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 10, + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=36)], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=36), + Compare( + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=44), + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=45, + end_lineno=15, + end_col_offset=49), + 'throws', + Load(), + lineno=15, + col_offset=45, + end_lineno=15, + end_col_offset=56)], + [], + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=57), + [ + Eq()], + [ + Constant( + 1, + lineno=15, + col_offset=61, + end_lineno=15, + end_col_offset=62)], + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=62)], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=62), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=62)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=62), + FunctionDef( + 'is_spare', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + 'total_pins', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 10, + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=36)], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=36), + Compare( + Call( + Name( + 'len', + Load(), + lineno=18, + col_offset=41, + end_lineno=18, + end_col_offset=44), + [ + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=45, + end_lineno=18, + end_col_offset=49), + 'throws', + Load(), + lineno=18, + col_offset=45, + end_lineno=18, + end_col_offset=56)], + [], + lineno=18, + col_offset=41, + end_lineno=18, + end_col_offset=57), + [ + Eq()], + [ + Constant( + 2, + lineno=18, + col_offset=61, + end_lineno=18, + end_col_offset=62)], + lineno=18, + col_offset=41, + end_lineno=18, + end_col_offset=62)], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=62), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=62)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=62), + FunctionDef( + 'is_open', + arguments( + [], + [ + arg( + 'self', + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + 'total_pins', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=30), + [ + Lt()], + [ + Constant( + 10, + lineno=21, + col_offset=33, + end_lineno=21, + end_col_offset=35)], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=35), + Compare( + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=43), + [ + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=44, + end_lineno=21, + end_col_offset=48), + 'throws', + Load(), + lineno=21, + col_offset=44, + end_lineno=21, + end_col_offset=55)], + [], + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=56), + [ + Eq()], + [ + Constant( + 2, + lineno=21, + col_offset=60, + end_lineno=21, + end_col_offset=61)], + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=61)], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=61), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=61)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=61), + FunctionDef( + 'is_closed', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Return whether a frame is over.', + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=45), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=45), + Return( + BoolOp( + Or(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=19), + 'total_pins', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 10, + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=36)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=36), + Compare( + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=40, + end_lineno=25, + end_col_offset=43), + [ + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=44, + end_lineno=25, + end_col_offset=48), + 'throws', + Load(), + lineno=25, + col_offset=44, + end_lineno=25, + end_col_offset=55)], + [], + lineno=25, + col_offset=40, + end_lineno=25, + end_col_offset=56), + [ + Eq()], + [ + Constant( + 2, + lineno=25, + col_offset=60, + end_lineno=25, + end_col_offset=61)], + lineno=25, + col_offset=40, + end_lineno=25, + end_col_offset=61)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=61), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=61)], + [], + lineno=23, + col_offset=4, + end_lineno=25, + end_col_offset=61), + FunctionDef( + 'throw', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=18), + arg( + 'pins', + lineno=27, + col_offset=20, + end_lineno=27, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=15), + 'total_pins', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=26), + Add(), + Name( + 'pins', + Load(), + lineno=28, + col_offset=29, + end_lineno=28, + end_col_offset=33), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=33), + [ + Gt()], + [ + Constant( + 10, + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=38)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=38), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=29, + col_offset=18, + end_lineno=29, + end_col_offset=28), + [ + Constant( + "a frame's rolls cannot exceed 10", + lineno=29, + col_offset=29, + end_lineno=29, + end_col_offset=63)], + [], + lineno=29, + col_offset=18, + end_lineno=29, + end_col_offset=64), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=64)], + [], + lineno=28, + col_offset=8, + end_lineno=29, + end_col_offset=64), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=12), + 'throws', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=19), + 'append', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=26), + [ + Name( + 'pins', + Load(), + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=31)], + [], + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=32), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=32)], + [], + lineno=27, + col_offset=4, + end_lineno=30, + end_col_offset=32), + FunctionDef( + 'score', + arguments( + [], + [ + arg( + 'self', + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=18), + arg( + 'next_throws', + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=14)], + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=21), + 'total_pins', + Load(), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=32), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=32), + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=15), + 'is_strike', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=25), + [], + [], + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=27), + [ + AugAssign( + Name( + 'result', + Store(), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=18), + Add(), + Call( + Name( + 'sum', + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=25), + [ + Subscript( + Name( + 'next_throws', + Load(), + lineno=35, + col_offset=26, + end_lineno=35, + end_col_offset=37), + Slice( + upper=Constant( + 2, + lineno=35, + col_offset=39, + end_lineno=35, + end_col_offset=40), + lineno=35, + col_offset=38, + end_lineno=35, + end_col_offset=40), + Load(), + lineno=35, + col_offset=26, + end_lineno=35, + end_col_offset=41)], + [], + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=42), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=42)], + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=17), + 'is_spare', + Load(), + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=26), + [], + [], + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=28), + [ + AugAssign( + Name( + 'result', + Store(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=18), + Add(), + Call( + Name( + 'sum', + Load(), + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=25), + [ + Subscript( + Name( + 'next_throws', + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=37), + Slice( + upper=Constant( + 1, + lineno=37, + col_offset=39, + end_lineno=37, + end_col_offset=40), + lineno=37, + col_offset=38, + end_lineno=37, + end_col_offset=40), + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=41)], + [], + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=42), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=42)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=42)], + lineno=34, + col_offset=8, + end_lineno=37, + end_col_offset=42), + Return( + Name( + 'result', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=21), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=21)], + [], + lineno=32, + col_offset=4, + end_lineno=38, + end_col_offset=21)], + [], + lineno=4, + col_offset=0, + end_lineno=38, + end_col_offset=21), + ClassDef( + 'BowlingGame', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=12), + 'current_frame_idx', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=30)], + Constant( + 0, + lineno=43, + col_offset=33, + end_lineno=43, + end_col_offset=34), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=12), + 'bonus_throws', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=25)], + List( + [], + Load(), + lineno=44, + col_offset=28, + end_lineno=44, + end_col_offset=30), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=30), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=12), + 'frames', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=19)], + ListComp( + Call( + Name( + 'Frame', + Load(), + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=28), + [ + Name( + 'idx', + Load(), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=32)], + [], + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=33), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=45, + col_offset=38, + end_lineno=45, + end_col_offset=41), + Call( + Name( + 'range', + Load(), + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=50), + [ + Name( + 'MAX_FRAME', + Load(), + lineno=45, + col_offset=51, + end_lineno=45, + end_col_offset=60)], + [], + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=61), + [], + 0)], + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=62), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=62)], + [], + lineno=42, + col_offset=4, + end_lineno=45, + end_col_offset=62), + FunctionDef( + 'current_frame', + arguments( + [], + [ + arg( + 'self', + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=19), + 'frames', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=26), + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=27, + end_lineno=49, + end_col_offset=31), + 'current_frame_idx', + Load(), + lineno=49, + col_offset=27, + end_lineno=49, + end_col_offset=49), + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=50), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=50)], + [ + Name( + 'property', + Load(), + lineno=47, + col_offset=5, + end_lineno=47, + end_col_offset=13)], + lineno=48, + col_offset=4, + end_lineno=49, + end_col_offset=50), + FunctionDef( + 'next_throws', + arguments( + [], + [ + arg( + 'self', + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=24), + arg( + 'frame_idx', + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "Return a frame's next throws in the form of a list.", + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=65), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=65), + Assign( + [ + Name( + 'throws', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=14)], + List( + [], + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=19), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=19), + For( + Name( + 'idx', + Store(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=54, + col_offset=19, + end_lineno=54, + end_col_offset=24), + [ + BinOp( + Name( + 'frame_idx', + Load(), + lineno=54, + col_offset=25, + end_lineno=54, + end_col_offset=34), + Add(), + Constant( + 1, + lineno=54, + col_offset=37, + end_lineno=54, + end_col_offset=38), + lineno=54, + col_offset=25, + end_lineno=54, + end_col_offset=38), + Name( + 'MAX_FRAME', + Load(), + lineno=54, + col_offset=40, + end_lineno=54, + end_col_offset=49)], + [], + lineno=54, + col_offset=19, + end_lineno=54, + end_col_offset=50), + [ + Expr( + Call( + Attribute( + Name( + 'throws', + Load(), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=18), + 'extend', + Load(), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=25), + [ + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=30), + 'frames', + Load(), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=37), + Name( + 'idx', + Load(), + lineno=55, + col_offset=38, + end_lineno=55, + end_col_offset=41), + Load(), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=42), + 'throws', + Load(), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=49)], + [], + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=50), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=50)], + [], + lineno=54, + col_offset=8, + end_lineno=55, + end_col_offset=50), + Expr( + Call( + Attribute( + Name( + 'throws', + Load(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=14), + 'extend', + Load(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=21), + [ + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=22, + end_lineno=56, + end_col_offset=26), + 'bonus_throws', + Load(), + lineno=56, + col_offset=22, + end_lineno=56, + end_col_offset=39)], + [], + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=40), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=40), + Return( + Name( + 'throws', + Load(), + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=21), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=21)], + [], + lineno=51, + col_offset=4, + end_lineno=57, + end_col_offset=21), + FunctionDef( + 'roll_bonus', + arguments( + [], + [ + arg( + 'self', + lineno=59, + col_offset=19, + end_lineno=59, + end_col_offset=23), + arg( + 'pins', + lineno=59, + col_offset=25, + end_lineno=59, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'tenth_frame', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=19)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=26), + 'frames', + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=33), + UnaryOp( + USub(), + Constant( + 1, + lineno=60, + col_offset=35, + end_lineno=60, + end_col_offset=36), + lineno=60, + col_offset=34, + end_lineno=60, + end_col_offset=36), + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=37), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=37), + If( + Call( + Attribute( + Name( + 'tenth_frame', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=22), + 'is_open', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=30), + [], + [], + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=32), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=62, + col_offset=18, + end_lineno=62, + end_col_offset=28), + [ + Constant( + 'cannot throw bonus with an open tenth frame', + lineno=62, + col_offset=29, + end_lineno=62, + end_col_offset=74)], + [], + lineno=62, + col_offset=18, + end_lineno=62, + end_col_offset=75), + lineno=62, + col_offset=12, + end_lineno=62, + end_col_offset=75)], + [], + lineno=61, + col_offset=8, + end_lineno=62, + end_col_offset=75), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=12), + 'bonus_throws', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=25), + 'append', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=32), + [ + Name( + 'pins', + Load(), + lineno=64, + col_offset=33, + end_lineno=64, + end_col_offset=37)], + [], + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=38), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=38), + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=15), + [ + Attribute( + Name( + 'self', + Load(), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=20), + 'bonus_throws', + Load(), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=33)], + [], + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=34), + [ + Eq()], + [ + Constant( + 2, + lineno=67, + col_offset=38, + end_lineno=67, + end_col_offset=39)], + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=39), + Compare( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=48), + 'bonus_throws', + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=61), + Constant( + 0, + lineno=67, + col_offset=62, + end_lineno=67, + end_col_offset=63), + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=64), + [ + NotEq()], + [ + Constant( + 10, + lineno=67, + col_offset=68, + end_lineno=67, + end_col_offset=70)], + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=70), + Compare( + Call( + Name( + 'sum', + Load(), + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=19), + [ + Attribute( + Name( + 'self', + Load(), + lineno=68, + col_offset=20, + end_lineno=68, + end_col_offset=24), + 'bonus_throws', + Load(), + lineno=68, + col_offset=20, + end_lineno=68, + end_col_offset=37)], + [], + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=38), + [ + Gt()], + [ + Constant( + 10, + lineno=68, + col_offset=41, + end_lineno=68, + end_col_offset=43)], + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=43)], + lineno=67, + col_offset=12, + end_lineno=68, + end_col_offset=43), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=69, + col_offset=18, + end_lineno=69, + end_col_offset=28), + [ + Constant( + 'invalid fill balls', + lineno=69, + col_offset=29, + end_lineno=69, + end_col_offset=49)], + [], + lineno=69, + col_offset=18, + end_lineno=69, + end_col_offset=50), + lineno=69, + col_offset=12, + end_lineno=69, + end_col_offset=50)], + [], + lineno=67, + col_offset=8, + end_lineno=69, + end_col_offset=50), + If( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'tenth_frame', + Load(), + lineno=72, + col_offset=11, + end_lineno=72, + end_col_offset=22), + 'is_strike', + Load(), + lineno=72, + col_offset=11, + end_lineno=72, + end_col_offset=32), + [], + [], + lineno=72, + col_offset=11, + end_lineno=72, + end_col_offset=34), + Compare( + Call( + Name( + 'len', + Load(), + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=42), + [ + Attribute( + Name( + 'self', + Load(), + lineno=72, + col_offset=43, + end_lineno=72, + end_col_offset=47), + 'bonus_throws', + Load(), + lineno=72, + col_offset=43, + end_lineno=72, + end_col_offset=60)], + [], + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=61), + [ + Gt()], + [ + Constant( + 2, + lineno=72, + col_offset=64, + end_lineno=72, + end_col_offset=65)], + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=65)], + lineno=72, + col_offset=11, + end_lineno=72, + end_col_offset=65), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=73, + col_offset=18, + end_lineno=73, + end_col_offset=28), + [ + Constant( + 'wrong number of fill balls when the tenth frame is a strike', + lineno=74, + col_offset=16, + end_lineno=74, + end_col_offset=77)], + [], + lineno=73, + col_offset=18, + end_lineno=74, + end_col_offset=78), + lineno=73, + col_offset=12, + end_lineno=74, + end_col_offset=78)], + [ + If( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'tenth_frame', + Load(), + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=24), + 'is_spare', + Load(), + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=33), + [], + [], + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=35), + Compare( + Call( + Name( + 'len', + Load(), + lineno=75, + col_offset=40, + end_lineno=75, + end_col_offset=43), + [ + Attribute( + Name( + 'self', + Load(), + lineno=75, + col_offset=44, + end_lineno=75, + end_col_offset=48), + 'bonus_throws', + Load(), + lineno=75, + col_offset=44, + end_lineno=75, + end_col_offset=61)], + [], + lineno=75, + col_offset=40, + end_lineno=75, + end_col_offset=62), + [ + Gt()], + [ + Constant( + 1, + lineno=75, + col_offset=65, + end_lineno=75, + end_col_offset=66)], + lineno=75, + col_offset=40, + end_lineno=75, + end_col_offset=66)], + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=66), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=76, + col_offset=18, + end_lineno=76, + end_col_offset=28), + [ + Constant( + 'wrong number of fill balls when the tenth frame is a spare', + lineno=77, + col_offset=16, + end_lineno=77, + end_col_offset=76)], + [], + lineno=76, + col_offset=18, + end_lineno=77, + end_col_offset=77), + lineno=76, + col_offset=12, + end_lineno=77, + end_col_offset=77)], + [], + lineno=75, + col_offset=8, + end_lineno=77, + end_col_offset=77)], + lineno=72, + col_offset=8, + end_lineno=77, + end_col_offset=77)], + [], + lineno=59, + col_offset=4, + end_lineno=77, + end_col_offset=77), + FunctionDef( + 'roll', + arguments( + [], + [ + arg( + 'self', + lineno=79, + col_offset=13, + end_lineno=79, + end_col_offset=17), + arg( + 'pins', + lineno=79, + col_offset=19, + end_lineno=79, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=80, + col_offset=15, + end_lineno=80, + end_col_offset=16), + [ + LtE(), + LtE()], + [ + Name( + 'pins', + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=24), + Constant( + 10, + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=30)], + lineno=80, + col_offset=15, + end_lineno=80, + end_col_offset=30), + lineno=80, + col_offset=11, + end_lineno=80, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=81, + col_offset=18, + end_lineno=81, + end_col_offset=28), + [ + Constant( + 'invalid pins', + lineno=81, + col_offset=29, + end_lineno=81, + end_col_offset=43)], + [], + lineno=81, + col_offset=18, + end_lineno=81, + end_col_offset=44), + lineno=81, + col_offset=12, + end_lineno=81, + end_col_offset=44)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=82, + col_offset=13, + end_lineno=82, + end_col_offset=17), + 'current_frame_idx', + Load(), + lineno=82, + col_offset=13, + end_lineno=82, + end_col_offset=35), + [ + Eq()], + [ + Name( + 'MAX_FRAME', + Load(), + lineno=82, + col_offset=39, + end_lineno=82, + end_col_offset=48)], + lineno=82, + col_offset=13, + end_lineno=82, + end_col_offset=48), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=16), + 'roll_bonus', + Load(), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=27), + [ + Name( + 'pins', + Load(), + lineno=83, + col_offset=28, + end_lineno=83, + end_col_offset=32)], + [], + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=33), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=33)], + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=16), + 'current_frame', + Load(), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=30), + 'throw', + Load(), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=36), + [ + Name( + 'pins', + Load(), + lineno=85, + col_offset=37, + end_lineno=85, + end_col_offset=41)], + [], + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=42), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=42), + If( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=19), + 'current_frame', + Load(), + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=33), + 'is_closed', + Load(), + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=43), + [], + [], + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=45), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=16, + end_lineno=87, + end_col_offset=20), + 'current_frame_idx', + Store(), + lineno=87, + col_offset=16, + end_lineno=87, + end_col_offset=38), + Add(), + Constant( + 1, + lineno=87, + col_offset=42, + end_lineno=87, + end_col_offset=43), + lineno=87, + col_offset=16, + end_lineno=87, + end_col_offset=43)], + [], + lineno=86, + col_offset=12, + end_lineno=87, + end_col_offset=43)], + lineno=82, + col_offset=8, + end_lineno=87, + end_col_offset=43)], + lineno=80, + col_offset=8, + end_lineno=87, + end_col_offset=43)], + [], + lineno=79, + col_offset=4, + end_lineno=87, + end_col_offset=43), + FunctionDef( + 'score', + arguments( + [], + [ + arg( + 'self', + lineno=89, + col_offset=14, + end_lineno=89, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=90, + col_offset=11, + end_lineno=90, + end_col_offset=15), + 'current_frame_idx', + Load(), + lineno=90, + col_offset=11, + end_lineno=90, + end_col_offset=33), + [ + Lt()], + [ + Name( + 'MAX_FRAME', + Load(), + lineno=90, + col_offset=36, + end_lineno=90, + end_col_offset=45)], + lineno=90, + col_offset=11, + end_lineno=90, + end_col_offset=45), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=91, + col_offset=18, + end_lineno=91, + end_col_offset=28), + [ + Constant( + 'frame less than 10', + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=49)], + [], + lineno=91, + col_offset=18, + end_lineno=91, + end_col_offset=50), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=50)], + [], + lineno=90, + col_offset=8, + end_lineno=91, + end_col_offset=50), + If( + BoolOp( + And(), + [ + Call( + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=15), + 'frames', + Load(), + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=22), + UnaryOp( + USub(), + Constant( + 1, + lineno=92, + col_offset=24, + end_lineno=92, + end_col_offset=25), + lineno=92, + col_offset=23, + end_lineno=92, + end_col_offset=25), + Load(), + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=26), + 'is_spare', + Load(), + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=35), + [], + [], + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=37), + Compare( + Call( + Name( + 'len', + Load(), + lineno=92, + col_offset=42, + end_lineno=92, + end_col_offset=45), + [ + Attribute( + Name( + 'self', + Load(), + lineno=92, + col_offset=46, + end_lineno=92, + end_col_offset=50), + 'bonus_throws', + Load(), + lineno=92, + col_offset=46, + end_lineno=92, + end_col_offset=63)], + [], + lineno=92, + col_offset=42, + end_lineno=92, + end_col_offset=64), + [ + NotEq()], + [ + Constant( + 1, + lineno=92, + col_offset=68, + end_lineno=92, + end_col_offset=69)], + lineno=92, + col_offset=42, + end_lineno=92, + end_col_offset=69)], + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=69), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=93, + col_offset=18, + end_lineno=93, + end_col_offset=28), + [ + Constant( + 'one bonus must be rolled when the tenth frame is spare', + lineno=94, + col_offset=16, + end_lineno=94, + end_col_offset=72)], + [], + lineno=93, + col_offset=18, + end_lineno=94, + end_col_offset=73), + lineno=93, + col_offset=12, + end_lineno=94, + end_col_offset=73)], + [], + lineno=92, + col_offset=8, + end_lineno=94, + end_col_offset=73), + If( + BoolOp( + And(), + [ + Call( + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=15), + 'frames', + Load(), + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=22), + UnaryOp( + USub(), + Constant( + 1, + lineno=95, + col_offset=24, + end_lineno=95, + end_col_offset=25), + lineno=95, + col_offset=23, + end_lineno=95, + end_col_offset=25), + Load(), + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=26), + 'is_strike', + Load(), + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=36), + [], + [], + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=38), + Compare( + Call( + Name( + 'len', + Load(), + lineno=95, + col_offset=43, + end_lineno=95, + end_col_offset=46), + [ + Attribute( + Name( + 'self', + Load(), + lineno=95, + col_offset=47, + end_lineno=95, + end_col_offset=51), + 'bonus_throws', + Load(), + lineno=95, + col_offset=47, + end_lineno=95, + end_col_offset=64)], + [], + lineno=95, + col_offset=43, + end_lineno=95, + end_col_offset=65), + [ + NotEq()], + [ + Constant( + 2, + lineno=95, + col_offset=69, + end_lineno=95, + end_col_offset=70)], + lineno=95, + col_offset=43, + end_lineno=95, + end_col_offset=70)], + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=70), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=96, + col_offset=18, + end_lineno=96, + end_col_offset=28), + [ + Constant( + 'two bonuses must be rolled when the tenth frame is strike', + lineno=97, + col_offset=16, + end_lineno=97, + end_col_offset=75)], + [], + lineno=96, + col_offset=18, + end_lineno=97, + end_col_offset=76), + lineno=96, + col_offset=12, + end_lineno=97, + end_col_offset=76)], + [], + lineno=95, + col_offset=8, + end_lineno=97, + end_col_offset=76), + Return( + Call( + Name( + 'sum', + Load(), + lineno=98, + col_offset=15, + end_lineno=98, + end_col_offset=18), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'frame', + Load(), + lineno=98, + col_offset=19, + end_lineno=98, + end_col_offset=24), + 'score', + Load(), + lineno=98, + col_offset=19, + end_lineno=98, + end_col_offset=30), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=98, + col_offset=31, + end_lineno=98, + end_col_offset=35), + 'next_throws', + Load(), + lineno=98, + col_offset=31, + end_lineno=98, + end_col_offset=47), + [ + Attribute( + Name( + 'frame', + Load(), + lineno=98, + col_offset=48, + end_lineno=98, + end_col_offset=53), + 'idx', + Load(), + lineno=98, + col_offset=48, + end_lineno=98, + end_col_offset=57)], + [], + lineno=98, + col_offset=31, + end_lineno=98, + end_col_offset=58)], + [], + lineno=98, + col_offset=19, + end_lineno=98, + end_col_offset=59), + [ + comprehension( + Name( + 'frame', + Store(), + lineno=99, + col_offset=23, + end_lineno=99, + end_col_offset=28), + Attribute( + Name( + 'self', + Load(), + lineno=99, + col_offset=32, + end_lineno=99, + end_col_offset=36), + 'frames', + Load(), + lineno=99, + col_offset=32, + end_lineno=99, + end_col_offset=43), + [], + 0)], + lineno=98, + col_offset=18, + end_lineno=99, + end_col_offset=44)], + [], + lineno=98, + col_offset=15, + end_lineno=99, + end_col_offset=44), + lineno=98, + col_offset=8, + end_lineno=99, + end_col_offset=44)], + [], + lineno=89, + col_offset=4, + end_lineno=99, + end_col_offset=44)], + [], + lineno=41, + col_offset=0, + end_lineno=99, + end_col_offset=44)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9)], + Constant( + 10, + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=14), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=14), + ClassDef( + 'placeholder_1', + [], + [], + [ + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'placeholder_3', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=16)], + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=22), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=19)], + List( + [], + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=24), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=24)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=24), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=18), + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=23), + 'placeholder_4', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=30)], + [], + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=31), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=31)], + [ + Name( + 'property', + Load(), + lineno=9, + col_offset=5, + end_lineno=9, + end_col_offset=13)], + lineno=10, + col_offset=4, + end_lineno=12, + end_col_offset=31), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + 'placeholder_5', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 10, + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=36)], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=36), + Compare( + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=44), + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=45, + end_lineno=15, + end_col_offset=49), + 'placeholder_4', + Load(), + lineno=15, + col_offset=45, + end_lineno=15, + end_col_offset=56)], + [], + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=57), + [ + Eq()], + [ + Constant( + 1, + lineno=15, + col_offset=61, + end_lineno=15, + end_col_offset=62)], + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=62)], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=62), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=62)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=62), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + 'placeholder_5', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 10, + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=36)], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=36), + Compare( + Call( + Name( + 'len', + Load(), + lineno=18, + col_offset=41, + end_lineno=18, + end_col_offset=44), + [ + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=45, + end_lineno=18, + end_col_offset=49), + 'placeholder_4', + Load(), + lineno=18, + col_offset=45, + end_lineno=18, + end_col_offset=56)], + [], + lineno=18, + col_offset=41, + end_lineno=18, + end_col_offset=57), + [ + Eq()], + [ + Constant( + 2, + lineno=18, + col_offset=61, + end_lineno=18, + end_col_offset=62)], + lineno=18, + col_offset=41, + end_lineno=18, + end_col_offset=62)], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=62), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=62)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=62), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + 'placeholder_5', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=30), + [ + Lt()], + [ + Constant( + 10, + lineno=21, + col_offset=33, + end_lineno=21, + end_col_offset=35)], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=35), + Compare( + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=43), + [ + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=44, + end_lineno=21, + end_col_offset=48), + 'placeholder_4', + Load(), + lineno=21, + col_offset=44, + end_lineno=21, + end_col_offset=55)], + [], + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=56), + [ + Eq()], + [ + Constant( + 2, + lineno=21, + col_offset=60, + end_lineno=21, + end_col_offset=61)], + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=61)], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=61), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=61)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=61), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + Or(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=19), + 'placeholder_5', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 10, + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=36)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=36), + Compare( + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=40, + end_lineno=25, + end_col_offset=43), + [ + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=44, + end_lineno=25, + end_col_offset=48), + 'placeholder_4', + Load(), + lineno=25, + col_offset=44, + end_lineno=25, + end_col_offset=55)], + [], + lineno=25, + col_offset=40, + end_lineno=25, + end_col_offset=56), + [ + Eq()], + [ + Constant( + 2, + lineno=25, + col_offset=60, + end_lineno=25, + end_col_offset=61)], + lineno=25, + col_offset=40, + end_lineno=25, + end_col_offset=61)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=61), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=61)], + [], + lineno=23, + col_offset=4, + end_lineno=25, + end_col_offset=61), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=18), + arg( + 'placeholder_11', + lineno=27, + col_offset=20, + end_lineno=27, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=15), + 'placeholder_5', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=26), + Add(), + Name( + 'placeholder_11', + Load(), + lineno=28, + col_offset=29, + end_lineno=28, + end_col_offset=33), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=33), + [ + Gt()], + [ + Constant( + 10, + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=38)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=38), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=29, + col_offset=18, + end_lineno=29, + end_col_offset=28), + [ + Constant( + "a frame's rolls cannot exceed 10", + lineno=29, + col_offset=29, + end_lineno=29, + end_col_offset=63)], + [], + lineno=29, + col_offset=18, + end_lineno=29, + end_col_offset=64), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=64)], + [], + lineno=28, + col_offset=8, + end_lineno=29, + end_col_offset=64), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=12), + 'placeholder_4', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=19), + 'append', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=26), + [ + Name( + 'placeholder_11', + Load(), + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=31)], + [], + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=32), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=32)], + [], + lineno=27, + col_offset=4, + end_lineno=30, + end_col_offset=32), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=18), + arg( + 'placeholder_13', + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=14)], + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=21), + 'placeholder_5', + Load(), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=32), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=32), + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=15), + 'placeholder_6', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=25), + [], + [], + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=27), + [ + AugAssign( + Name( + 'placeholder_14', + Store(), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=18), + Add(), + Call( + Name( + 'sum', + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=25), + [ + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=35, + col_offset=26, + end_lineno=35, + end_col_offset=37), + Slice( + upper=Constant( + 2, + lineno=35, + col_offset=39, + end_lineno=35, + end_col_offset=40), + lineno=35, + col_offset=38, + end_lineno=35, + end_col_offset=40), + Load(), + lineno=35, + col_offset=26, + end_lineno=35, + end_col_offset=41)], + [], + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=42), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=42)], + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=17), + 'placeholder_7', + Load(), + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=26), + [], + [], + lineno=36, + col_offset=13, + end_lineno=36, + end_col_offset=28), + [ + AugAssign( + Name( + 'placeholder_14', + Store(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=18), + Add(), + Call( + Name( + 'sum', + Load(), + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=25), + [ + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=37), + Slice( + upper=Constant( + 1, + lineno=37, + col_offset=39, + end_lineno=37, + end_col_offset=40), + lineno=37, + col_offset=38, + end_lineno=37, + end_col_offset=40), + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=41)], + [], + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=42), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=42)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=42)], + lineno=34, + col_offset=8, + end_lineno=37, + end_col_offset=42), + Return( + Name( + 'placeholder_14', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=21), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=21)], + [], + lineno=32, + col_offset=4, + end_lineno=38, + end_col_offset=21)], + [], + lineno=4, + col_offset=0, + end_lineno=38, + end_col_offset=21), + ClassDef( + 'placeholder_15', + [], + [], + [ + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=12), + 'placeholder_16', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=30)], + Constant( + 0, + lineno=43, + col_offset=33, + end_lineno=43, + end_col_offset=34), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=12), + 'placeholder_17', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=25)], + List( + [], + Load(), + lineno=44, + col_offset=28, + end_lineno=44, + end_col_offset=30), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=30), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=12), + 'placeholder_18', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=19)], + ListComp( + Call( + Name( + 'placeholder_1', + Load(), + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=28), + [ + Name( + 'placeholder_3', + Load(), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=32)], + [], + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=33), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=45, + col_offset=38, + end_lineno=45, + end_col_offset=41), + Call( + Name( + 'range', + Load(), + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=50), + [ + Name( + 'placeholder_0', + Load(), + lineno=45, + col_offset=51, + end_lineno=45, + end_col_offset=60)], + [], + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=61), + [], + 0)], + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=62), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=62)], + [], + lineno=42, + col_offset=4, + end_lineno=45, + end_col_offset=62), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'self', + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=19), + 'placeholder_18', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=26), + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=27, + end_lineno=49, + end_col_offset=31), + 'placeholder_16', + Load(), + lineno=49, + col_offset=27, + end_lineno=49, + end_col_offset=49), + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=50), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=50)], + [ + Name( + 'property', + Load(), + lineno=47, + col_offset=5, + end_lineno=47, + end_col_offset=13)], + lineno=48, + col_offset=4, + end_lineno=49, + end_col_offset=50), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=24), + arg( + 'placeholder_20', + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=14)], + List( + [], + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=19), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=19), + For( + Name( + 'placeholder_3', + Store(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=54, + col_offset=19, + end_lineno=54, + end_col_offset=24), + [ + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=54, + col_offset=25, + end_lineno=54, + end_col_offset=34), + Add(), + Constant( + 1, + lineno=54, + col_offset=37, + end_lineno=54, + end_col_offset=38), + lineno=54, + col_offset=25, + end_lineno=54, + end_col_offset=38), + Name( + 'placeholder_0', + Load(), + lineno=54, + col_offset=40, + end_lineno=54, + end_col_offset=49)], + [], + lineno=54, + col_offset=19, + end_lineno=54, + end_col_offset=50), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=18), + 'extend', + Load(), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=25), + [ + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=30), + 'placeholder_18', + Load(), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=37), + Name( + 'placeholder_3', + Load(), + lineno=55, + col_offset=38, + end_lineno=55, + end_col_offset=41), + Load(), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=42), + 'placeholder_4', + Load(), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=49)], + [], + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=50), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=50)], + [], + lineno=54, + col_offset=8, + end_lineno=55, + end_col_offset=50), + Expr( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=14), + 'extend', + Load(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=21), + [ + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=22, + end_lineno=56, + end_col_offset=26), + 'placeholder_17', + Load(), + lineno=56, + col_offset=22, + end_lineno=56, + end_col_offset=39)], + [], + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=40), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=40), + Return( + Name( + 'placeholder_4', + Load(), + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=21), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=21)], + [], + lineno=51, + col_offset=4, + end_lineno=57, + end_col_offset=21), + FunctionDef( + 'placeholder_21', + arguments( + [], + [ + arg( + 'self', + lineno=59, + col_offset=19, + end_lineno=59, + end_col_offset=23), + arg( + 'placeholder_11', + lineno=59, + col_offset=25, + end_lineno=59, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=19)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=26), + 'placeholder_18', + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=33), + UnaryOp( + USub(), + Constant( + 1, + lineno=60, + col_offset=35, + end_lineno=60, + end_col_offset=36), + lineno=60, + col_offset=34, + end_lineno=60, + end_col_offset=36), + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=37), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=37), + If( + Call( + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=22), + 'placeholder_8', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=30), + [], + [], + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=32), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=62, + col_offset=18, + end_lineno=62, + end_col_offset=28), + [ + Constant( + 'cannot throw bonus with an open tenth frame', + lineno=62, + col_offset=29, + end_lineno=62, + end_col_offset=74)], + [], + lineno=62, + col_offset=18, + end_lineno=62, + end_col_offset=75), + lineno=62, + col_offset=12, + end_lineno=62, + end_col_offset=75)], + [], + lineno=61, + col_offset=8, + end_lineno=62, + end_col_offset=75), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=12), + 'placeholder_17', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=25), + 'append', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=32), + [ + Name( + 'placeholder_11', + Load(), + lineno=64, + col_offset=33, + end_lineno=64, + end_col_offset=37)], + [], + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=38), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=38), + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=15), + [ + Attribute( + Name( + 'self', + Load(), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=20), + 'placeholder_17', + Load(), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=33)], + [], + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=34), + [ + Eq()], + [ + Constant( + 2, + lineno=67, + col_offset=38, + end_lineno=67, + end_col_offset=39)], + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=39), + Compare( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=48), + 'placeholder_17', + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=61), + Constant( + 0, + lineno=67, + col_offset=62, + end_lineno=67, + end_col_offset=63), + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=64), + [ + NotEq()], + [ + Constant( + 10, + lineno=67, + col_offset=68, + end_lineno=67, + end_col_offset=70)], + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=70), + Compare( + Call( + Name( + 'sum', + Load(), + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=19), + [ + Attribute( + Name( + 'self', + Load(), + lineno=68, + col_offset=20, + end_lineno=68, + end_col_offset=24), + 'placeholder_17', + Load(), + lineno=68, + col_offset=20, + end_lineno=68, + end_col_offset=37)], + [], + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=38), + [ + Gt()], + [ + Constant( + 10, + lineno=68, + col_offset=41, + end_lineno=68, + end_col_offset=43)], + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=43)], + lineno=67, + col_offset=12, + end_lineno=68, + end_col_offset=43), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=69, + col_offset=18, + end_lineno=69, + end_col_offset=28), + [ + Constant( + 'invalid fill balls', + lineno=69, + col_offset=29, + end_lineno=69, + end_col_offset=49)], + [], + lineno=69, + col_offset=18, + end_lineno=69, + end_col_offset=50), + lineno=69, + col_offset=12, + end_lineno=69, + end_col_offset=50)], + [], + lineno=67, + col_offset=8, + end_lineno=69, + end_col_offset=50), + If( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=72, + col_offset=11, + end_lineno=72, + end_col_offset=22), + 'placeholder_6', + Load(), + lineno=72, + col_offset=11, + end_lineno=72, + end_col_offset=32), + [], + [], + lineno=72, + col_offset=11, + end_lineno=72, + end_col_offset=34), + Compare( + Call( + Name( + 'len', + Load(), + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=42), + [ + Attribute( + Name( + 'self', + Load(), + lineno=72, + col_offset=43, + end_lineno=72, + end_col_offset=47), + 'placeholder_17', + Load(), + lineno=72, + col_offset=43, + end_lineno=72, + end_col_offset=60)], + [], + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=61), + [ + Gt()], + [ + Constant( + 2, + lineno=72, + col_offset=64, + end_lineno=72, + end_col_offset=65)], + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=65)], + lineno=72, + col_offset=11, + end_lineno=72, + end_col_offset=65), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=73, + col_offset=18, + end_lineno=73, + end_col_offset=28), + [ + Constant( + 'wrong number of fill balls when the tenth frame is a strike', + lineno=74, + col_offset=16, + end_lineno=74, + end_col_offset=77)], + [], + lineno=73, + col_offset=18, + end_lineno=74, + end_col_offset=78), + lineno=73, + col_offset=12, + end_lineno=74, + end_col_offset=78)], + [ + If( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=24), + 'placeholder_7', + Load(), + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=33), + [], + [], + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=35), + Compare( + Call( + Name( + 'len', + Load(), + lineno=75, + col_offset=40, + end_lineno=75, + end_col_offset=43), + [ + Attribute( + Name( + 'self', + Load(), + lineno=75, + col_offset=44, + end_lineno=75, + end_col_offset=48), + 'placeholder_17', + Load(), + lineno=75, + col_offset=44, + end_lineno=75, + end_col_offset=61)], + [], + lineno=75, + col_offset=40, + end_lineno=75, + end_col_offset=62), + [ + Gt()], + [ + Constant( + 1, + lineno=75, + col_offset=65, + end_lineno=75, + end_col_offset=66)], + lineno=75, + col_offset=40, + end_lineno=75, + end_col_offset=66)], + lineno=75, + col_offset=13, + end_lineno=75, + end_col_offset=66), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=76, + col_offset=18, + end_lineno=76, + end_col_offset=28), + [ + Constant( + 'wrong number of fill balls when the tenth frame is a spare', + lineno=77, + col_offset=16, + end_lineno=77, + end_col_offset=76)], + [], + lineno=76, + col_offset=18, + end_lineno=77, + end_col_offset=77), + lineno=76, + col_offset=12, + end_lineno=77, + end_col_offset=77)], + [], + lineno=75, + col_offset=8, + end_lineno=77, + end_col_offset=77)], + lineno=72, + col_offset=8, + end_lineno=77, + end_col_offset=77)], + [], + lineno=59, + col_offset=4, + end_lineno=77, + end_col_offset=77), + FunctionDef( + 'placeholder_23', + arguments( + [], + [ + arg( + 'self', + lineno=79, + col_offset=13, + end_lineno=79, + end_col_offset=17), + arg( + 'placeholder_11', + lineno=79, + col_offset=19, + end_lineno=79, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=80, + col_offset=15, + end_lineno=80, + end_col_offset=16), + [ + LtE(), + LtE()], + [ + Name( + 'placeholder_11', + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=24), + Constant( + 10, + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=30)], + lineno=80, + col_offset=15, + end_lineno=80, + end_col_offset=30), + lineno=80, + col_offset=11, + end_lineno=80, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=81, + col_offset=18, + end_lineno=81, + end_col_offset=28), + [ + Constant( + 'invalid pins', + lineno=81, + col_offset=29, + end_lineno=81, + end_col_offset=43)], + [], + lineno=81, + col_offset=18, + end_lineno=81, + end_col_offset=44), + lineno=81, + col_offset=12, + end_lineno=81, + end_col_offset=44)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=82, + col_offset=13, + end_lineno=82, + end_col_offset=17), + 'placeholder_16', + Load(), + lineno=82, + col_offset=13, + end_lineno=82, + end_col_offset=35), + [ + Eq()], + [ + Name( + 'placeholder_0', + Load(), + lineno=82, + col_offset=39, + end_lineno=82, + end_col_offset=48)], + lineno=82, + col_offset=13, + end_lineno=82, + end_col_offset=48), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=16), + 'placeholder_21', + Load(), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=27), + [ + Name( + 'placeholder_11', + Load(), + lineno=83, + col_offset=28, + end_lineno=83, + end_col_offset=32)], + [], + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=33), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=33)], + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=16), + 'placeholder_19', + Load(), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=30), + 'placeholder_10', + Load(), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=36), + [ + Name( + 'placeholder_11', + Load(), + lineno=85, + col_offset=37, + end_lineno=85, + end_col_offset=41)], + [], + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=42), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=42), + If( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=19), + 'placeholder_19', + Load(), + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=33), + 'placeholder_9', + Load(), + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=43), + [], + [], + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=45), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=16, + end_lineno=87, + end_col_offset=20), + 'placeholder_16', + Store(), + lineno=87, + col_offset=16, + end_lineno=87, + end_col_offset=38), + Add(), + Constant( + 1, + lineno=87, + col_offset=42, + end_lineno=87, + end_col_offset=43), + lineno=87, + col_offset=16, + end_lineno=87, + end_col_offset=43)], + [], + lineno=86, + col_offset=12, + end_lineno=87, + end_col_offset=43)], + lineno=82, + col_offset=8, + end_lineno=87, + end_col_offset=43)], + lineno=80, + col_offset=8, + end_lineno=87, + end_col_offset=43)], + [], + lineno=79, + col_offset=4, + end_lineno=87, + end_col_offset=43), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=89, + col_offset=14, + end_lineno=89, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=90, + col_offset=11, + end_lineno=90, + end_col_offset=15), + 'placeholder_16', + Load(), + lineno=90, + col_offset=11, + end_lineno=90, + end_col_offset=33), + [ + Lt()], + [ + Name( + 'placeholder_0', + Load(), + lineno=90, + col_offset=36, + end_lineno=90, + end_col_offset=45)], + lineno=90, + col_offset=11, + end_lineno=90, + end_col_offset=45), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=91, + col_offset=18, + end_lineno=91, + end_col_offset=28), + [ + Constant( + 'frame less than 10', + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=49)], + [], + lineno=91, + col_offset=18, + end_lineno=91, + end_col_offset=50), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=50)], + [], + lineno=90, + col_offset=8, + end_lineno=91, + end_col_offset=50), + If( + BoolOp( + And(), + [ + Call( + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=15), + 'placeholder_18', + Load(), + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=22), + UnaryOp( + USub(), + Constant( + 1, + lineno=92, + col_offset=24, + end_lineno=92, + end_col_offset=25), + lineno=92, + col_offset=23, + end_lineno=92, + end_col_offset=25), + Load(), + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=26), + 'placeholder_7', + Load(), + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=35), + [], + [], + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=37), + Compare( + Call( + Name( + 'len', + Load(), + lineno=92, + col_offset=42, + end_lineno=92, + end_col_offset=45), + [ + Attribute( + Name( + 'self', + Load(), + lineno=92, + col_offset=46, + end_lineno=92, + end_col_offset=50), + 'placeholder_17', + Load(), + lineno=92, + col_offset=46, + end_lineno=92, + end_col_offset=63)], + [], + lineno=92, + col_offset=42, + end_lineno=92, + end_col_offset=64), + [ + NotEq()], + [ + Constant( + 1, + lineno=92, + col_offset=68, + end_lineno=92, + end_col_offset=69)], + lineno=92, + col_offset=42, + end_lineno=92, + end_col_offset=69)], + lineno=92, + col_offset=11, + end_lineno=92, + end_col_offset=69), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=93, + col_offset=18, + end_lineno=93, + end_col_offset=28), + [ + Constant( + 'one bonus must be rolled when the tenth frame is spare', + lineno=94, + col_offset=16, + end_lineno=94, + end_col_offset=72)], + [], + lineno=93, + col_offset=18, + end_lineno=94, + end_col_offset=73), + lineno=93, + col_offset=12, + end_lineno=94, + end_col_offset=73)], + [], + lineno=92, + col_offset=8, + end_lineno=94, + end_col_offset=73), + If( + BoolOp( + And(), + [ + Call( + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=15), + 'placeholder_18', + Load(), + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=22), + UnaryOp( + USub(), + Constant( + 1, + lineno=95, + col_offset=24, + end_lineno=95, + end_col_offset=25), + lineno=95, + col_offset=23, + end_lineno=95, + end_col_offset=25), + Load(), + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=26), + 'placeholder_6', + Load(), + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=36), + [], + [], + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=38), + Compare( + Call( + Name( + 'len', + Load(), + lineno=95, + col_offset=43, + end_lineno=95, + end_col_offset=46), + [ + Attribute( + Name( + 'self', + Load(), + lineno=95, + col_offset=47, + end_lineno=95, + end_col_offset=51), + 'placeholder_17', + Load(), + lineno=95, + col_offset=47, + end_lineno=95, + end_col_offset=64)], + [], + lineno=95, + col_offset=43, + end_lineno=95, + end_col_offset=65), + [ + NotEq()], + [ + Constant( + 2, + lineno=95, + col_offset=69, + end_lineno=95, + end_col_offset=70)], + lineno=95, + col_offset=43, + end_lineno=95, + end_col_offset=70)], + lineno=95, + col_offset=11, + end_lineno=95, + end_col_offset=70), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=96, + col_offset=18, + end_lineno=96, + end_col_offset=28), + [ + Constant( + 'two bonuses must be rolled when the tenth frame is strike', + lineno=97, + col_offset=16, + end_lineno=97, + end_col_offset=75)], + [], + lineno=96, + col_offset=18, + end_lineno=97, + end_col_offset=76), + lineno=96, + col_offset=12, + end_lineno=97, + end_col_offset=76)], + [], + lineno=95, + col_offset=8, + end_lineno=97, + end_col_offset=76), + Return( + Call( + Name( + 'sum', + Load(), + lineno=98, + col_offset=15, + end_lineno=98, + end_col_offset=18), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'placeholder_24', + Load(), + lineno=98, + col_offset=19, + end_lineno=98, + end_col_offset=24), + 'placeholder_12', + Load(), + lineno=98, + col_offset=19, + end_lineno=98, + end_col_offset=30), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=98, + col_offset=31, + end_lineno=98, + end_col_offset=35), + 'placeholder_13', + Load(), + lineno=98, + col_offset=31, + end_lineno=98, + end_col_offset=47), + [ + Attribute( + Name( + 'placeholder_24', + Load(), + lineno=98, + col_offset=48, + end_lineno=98, + end_col_offset=53), + 'placeholder_3', + Load(), + lineno=98, + col_offset=48, + end_lineno=98, + end_col_offset=57)], + [], + lineno=98, + col_offset=31, + end_lineno=98, + end_col_offset=58)], + [], + lineno=98, + col_offset=19, + end_lineno=98, + end_col_offset=59), + [ + comprehension( + Name( + 'placeholder_24', + Store(), + lineno=99, + col_offset=23, + end_lineno=99, + end_col_offset=28), + Attribute( + Name( + 'self', + Load(), + lineno=99, + col_offset=32, + end_lineno=99, + end_col_offset=36), + 'placeholder_18', + Load(), + lineno=99, + col_offset=32, + end_lineno=99, + end_col_offset=43), + [], + 0)], + lineno=98, + col_offset=18, + end_lineno=99, + end_col_offset=44)], + [], + lineno=98, + col_offset=15, + end_lineno=99, + end_col_offset=44), + lineno=98, + col_offset=8, + end_lineno=99, + end_col_offset=44)], + [], + lineno=89, + col_offset=4, + end_lineno=99, + end_col_offset=44)], + [], + lineno=41, + col_offset=0, + end_lineno=99, + end_col_offset=44)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-bowling/representation.txt b/test/practice-bowling/representation.txt new file mode 100644 index 0000000..ccd7375 --- /dev/null +++ b/test/practice-bowling/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=9)], Constant(10, lineno=1, col_offset=12, end_lineno=1, end_col_offset=14), lineno=1, col_offset=0, end_lineno=1, end_col_offset=14), ClassDef('placeholder_1', [], [], [FunctionDef('placeholder_2', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21), arg('placeholder_3', lineno=5, col_offset=23, end_lineno=5, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_3', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=16)], Name('placeholder_3', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=22), lineno=6, col_offset=8, end_lineno=6, end_col_offset=22), Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_4', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=19)], List([], Load(), lineno=7, col_offset=22, end_lineno=7, end_col_offset=24), lineno=7, col_offset=8, end_lineno=7, end_col_offset=24)], [], lineno=5, col_offset=4, end_lineno=7, end_col_offset=24), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=10, col_offset=19, end_lineno=10, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sum', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=18), [Attribute(Name('self', Load(), lineno=12, col_offset=19, end_lineno=12, end_col_offset=23), 'placeholder_4', Load(), lineno=12, col_offset=19, end_lineno=12, end_col_offset=30)], [], lineno=12, col_offset=15, end_lineno=12, end_col_offset=31), lineno=12, col_offset=8, end_lineno=12, end_col_offset=31)], [Name('property', Load(), lineno=9, col_offset=5, end_lineno=9, end_col_offset=13)], lineno=10, col_offset=4, end_lineno=12, end_col_offset=31), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=14, col_offset=18, end_lineno=14, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), 'placeholder_5', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=30), [Eq()], [Constant(10, lineno=15, col_offset=34, end_lineno=15, end_col_offset=36)], lineno=15, col_offset=15, end_lineno=15, end_col_offset=36), Compare(Call(Name('len', Load(), lineno=15, col_offset=41, end_lineno=15, end_col_offset=44), [Attribute(Name('self', Load(), lineno=15, col_offset=45, end_lineno=15, end_col_offset=49), 'placeholder_4', Load(), lineno=15, col_offset=45, end_lineno=15, end_col_offset=56)], [], lineno=15, col_offset=41, end_lineno=15, end_col_offset=57), [Eq()], [Constant(1, lineno=15, col_offset=61, end_lineno=15, end_col_offset=62)], lineno=15, col_offset=41, end_lineno=15, end_col_offset=62)], lineno=15, col_offset=15, end_lineno=15, end_col_offset=62), lineno=15, col_offset=8, end_lineno=15, end_col_offset=62)], [], lineno=14, col_offset=4, end_lineno=15, end_col_offset=62), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=17, col_offset=17, end_lineno=17, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=19), 'placeholder_5', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=30), [Eq()], [Constant(10, lineno=18, col_offset=34, end_lineno=18, end_col_offset=36)], lineno=18, col_offset=15, end_lineno=18, end_col_offset=36), Compare(Call(Name('len', Load(), lineno=18, col_offset=41, end_lineno=18, end_col_offset=44), [Attribute(Name('self', Load(), lineno=18, col_offset=45, end_lineno=18, end_col_offset=49), 'placeholder_4', Load(), lineno=18, col_offset=45, end_lineno=18, end_col_offset=56)], [], lineno=18, col_offset=41, end_lineno=18, end_col_offset=57), [Eq()], [Constant(2, lineno=18, col_offset=61, end_lineno=18, end_col_offset=62)], lineno=18, col_offset=41, end_lineno=18, end_col_offset=62)], lineno=18, col_offset=15, end_lineno=18, end_col_offset=62), lineno=18, col_offset=8, end_lineno=18, end_col_offset=62)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=62), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=20, col_offset=16, end_lineno=20, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=19), 'placeholder_5', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=30), [Lt()], [Constant(10, lineno=21, col_offset=33, end_lineno=21, end_col_offset=35)], lineno=21, col_offset=15, end_lineno=21, end_col_offset=35), Compare(Call(Name('len', Load(), lineno=21, col_offset=40, end_lineno=21, end_col_offset=43), [Attribute(Name('self', Load(), lineno=21, col_offset=44, end_lineno=21, end_col_offset=48), 'placeholder_4', Load(), lineno=21, col_offset=44, end_lineno=21, end_col_offset=55)], [], lineno=21, col_offset=40, end_lineno=21, end_col_offset=56), [Eq()], [Constant(2, lineno=21, col_offset=60, end_lineno=21, end_col_offset=61)], lineno=21, col_offset=40, end_lineno=21, end_col_offset=61)], lineno=21, col_offset=15, end_lineno=21, end_col_offset=61), lineno=21, col_offset=8, end_lineno=21, end_col_offset=61)], [], lineno=20, col_offset=4, end_lineno=21, end_col_offset=61), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=23, col_offset=18, end_lineno=23, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(Or(), [Compare(Attribute(Name('self', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=19), 'placeholder_5', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=30), [Eq()], [Constant(10, lineno=25, col_offset=34, end_lineno=25, end_col_offset=36)], lineno=25, col_offset=15, end_lineno=25, end_col_offset=36), Compare(Call(Name('len', Load(), lineno=25, col_offset=40, end_lineno=25, end_col_offset=43), [Attribute(Name('self', Load(), lineno=25, col_offset=44, end_lineno=25, end_col_offset=48), 'placeholder_4', Load(), lineno=25, col_offset=44, end_lineno=25, end_col_offset=55)], [], lineno=25, col_offset=40, end_lineno=25, end_col_offset=56), [Eq()], [Constant(2, lineno=25, col_offset=60, end_lineno=25, end_col_offset=61)], lineno=25, col_offset=40, end_lineno=25, end_col_offset=61)], lineno=25, col_offset=15, end_lineno=25, end_col_offset=61), lineno=25, col_offset=8, end_lineno=25, end_col_offset=61)], [], lineno=23, col_offset=4, end_lineno=25, end_col_offset=61), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=27, col_offset=14, end_lineno=27, end_col_offset=18), arg('placeholder_11', lineno=27, col_offset=20, end_lineno=27, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(BinOp(Attribute(Name('self', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=15), 'placeholder_5', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=26), Add(), Name('placeholder_11', Load(), lineno=28, col_offset=29, end_lineno=28, end_col_offset=33), lineno=28, col_offset=11, end_lineno=28, end_col_offset=33), [Gt()], [Constant(10, lineno=28, col_offset=36, end_lineno=28, end_col_offset=38)], lineno=28, col_offset=11, end_lineno=28, end_col_offset=38), [Raise(Call(Name('ValueError', Load(), lineno=29, col_offset=18, end_lineno=29, end_col_offset=28), [Constant("a frame's rolls cannot exceed 10", lineno=29, col_offset=29, end_lineno=29, end_col_offset=63)], [], lineno=29, col_offset=18, end_lineno=29, end_col_offset=64), lineno=29, col_offset=12, end_lineno=29, end_col_offset=64)], [], lineno=28, col_offset=8, end_lineno=29, end_col_offset=64), Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=12), 'placeholder_4', Load(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=19), 'append', Load(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=26), [Name('placeholder_11', Load(), lineno=30, col_offset=27, end_lineno=30, end_col_offset=31)], [], lineno=30, col_offset=8, end_lineno=30, end_col_offset=32), lineno=30, col_offset=8, end_lineno=30, end_col_offset=32)], [], lineno=27, col_offset=4, end_lineno=30, end_col_offset=32), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=32, col_offset=14, end_lineno=32, end_col_offset=18), arg('placeholder_13', lineno=32, col_offset=20, end_lineno=32, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=14)], Attribute(Name('self', Load(), lineno=33, col_offset=17, end_lineno=33, end_col_offset=21), 'placeholder_5', Load(), lineno=33, col_offset=17, end_lineno=33, end_col_offset=32), lineno=33, col_offset=8, end_lineno=33, end_col_offset=32), If(Call(Attribute(Name('self', Load(), lineno=34, col_offset=11, end_lineno=34, end_col_offset=15), 'placeholder_6', Load(), lineno=34, col_offset=11, end_lineno=34, end_col_offset=25), [], [], lineno=34, col_offset=11, end_lineno=34, end_col_offset=27), [AugAssign(Name('placeholder_14', Store(), lineno=35, col_offset=12, end_lineno=35, end_col_offset=18), Add(), Call(Name('sum', Load(), lineno=35, col_offset=22, end_lineno=35, end_col_offset=25), [Subscript(Name('placeholder_13', Load(), lineno=35, col_offset=26, end_lineno=35, end_col_offset=37), Slice(upper=Constant(2, lineno=35, col_offset=39, end_lineno=35, end_col_offset=40), lineno=35, col_offset=38, end_lineno=35, end_col_offset=40), Load(), lineno=35, col_offset=26, end_lineno=35, end_col_offset=41)], [], lineno=35, col_offset=22, end_lineno=35, end_col_offset=42), lineno=35, col_offset=12, end_lineno=35, end_col_offset=42)], [If(Call(Attribute(Name('self', Load(), lineno=36, col_offset=13, end_lineno=36, end_col_offset=17), 'placeholder_7', Load(), lineno=36, col_offset=13, end_lineno=36, end_col_offset=26), [], [], lineno=36, col_offset=13, end_lineno=36, end_col_offset=28), [AugAssign(Name('placeholder_14', Store(), lineno=37, col_offset=12, end_lineno=37, end_col_offset=18), Add(), Call(Name('sum', Load(), lineno=37, col_offset=22, end_lineno=37, end_col_offset=25), [Subscript(Name('placeholder_13', Load(), lineno=37, col_offset=26, end_lineno=37, end_col_offset=37), Slice(upper=Constant(1, lineno=37, col_offset=39, end_lineno=37, end_col_offset=40), lineno=37, col_offset=38, end_lineno=37, end_col_offset=40), Load(), lineno=37, col_offset=26, end_lineno=37, end_col_offset=41)], [], lineno=37, col_offset=22, end_lineno=37, end_col_offset=42), lineno=37, col_offset=12, end_lineno=37, end_col_offset=42)], [], lineno=36, col_offset=8, end_lineno=37, end_col_offset=42)], lineno=34, col_offset=8, end_lineno=37, end_col_offset=42), Return(Name('placeholder_14', Load(), lineno=38, col_offset=15, end_lineno=38, end_col_offset=21), lineno=38, col_offset=8, end_lineno=38, end_col_offset=21)], [], lineno=32, col_offset=4, end_lineno=38, end_col_offset=21)], [], lineno=4, col_offset=0, end_lineno=38, end_col_offset=21), ClassDef('placeholder_15', [], [], [FunctionDef('placeholder_2', arguments([], [arg('self', lineno=42, col_offset=17, end_lineno=42, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=12), 'placeholder_16', Store(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=30)], Constant(0, lineno=43, col_offset=33, end_lineno=43, end_col_offset=34), lineno=43, col_offset=8, end_lineno=43, end_col_offset=34), Assign([Attribute(Name('self', Load(), lineno=44, col_offset=8, end_lineno=44, end_col_offset=12), 'placeholder_17', Store(), lineno=44, col_offset=8, end_lineno=44, end_col_offset=25)], List([], Load(), lineno=44, col_offset=28, end_lineno=44, end_col_offset=30), lineno=44, col_offset=8, end_lineno=44, end_col_offset=30), Assign([Attribute(Name('self', Load(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=12), 'placeholder_18', Store(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=19)], ListComp(Call(Name('placeholder_1', Load(), lineno=45, col_offset=23, end_lineno=45, end_col_offset=28), [Name('placeholder_3', Load(), lineno=45, col_offset=29, end_lineno=45, end_col_offset=32)], [], lineno=45, col_offset=23, end_lineno=45, end_col_offset=33), [comprehension(Name('placeholder_3', Store(), lineno=45, col_offset=38, end_lineno=45, end_col_offset=41), Call(Name('range', Load(), lineno=45, col_offset=45, end_lineno=45, end_col_offset=50), [Name('placeholder_0', Load(), lineno=45, col_offset=51, end_lineno=45, end_col_offset=60)], [], lineno=45, col_offset=45, end_lineno=45, end_col_offset=61), [], 0)], lineno=45, col_offset=22, end_lineno=45, end_col_offset=62), lineno=45, col_offset=8, end_lineno=45, end_col_offset=62)], [], lineno=42, col_offset=4, end_lineno=45, end_col_offset=62), FunctionDef('placeholder_19', arguments([], [arg('self', lineno=48, col_offset=22, end_lineno=48, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Subscript(Attribute(Name('self', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=19), 'placeholder_18', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=26), Attribute(Name('self', Load(), lineno=49, col_offset=27, end_lineno=49, end_col_offset=31), 'placeholder_16', Load(), lineno=49, col_offset=27, end_lineno=49, end_col_offset=49), Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=50), lineno=49, col_offset=8, end_lineno=49, end_col_offset=50)], [Name('property', Load(), lineno=47, col_offset=5, end_lineno=47, end_col_offset=13)], lineno=48, col_offset=4, end_lineno=49, end_col_offset=50), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=51, col_offset=20, end_lineno=51, end_col_offset=24), arg('placeholder_20', lineno=51, col_offset=26, end_lineno=51, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=14)], List([], Load(), lineno=53, col_offset=17, end_lineno=53, end_col_offset=19), lineno=53, col_offset=8, end_lineno=53, end_col_offset=19), For(Name('placeholder_3', Store(), lineno=54, col_offset=12, end_lineno=54, end_col_offset=15), Call(Name('range', Load(), lineno=54, col_offset=19, end_lineno=54, end_col_offset=24), [BinOp(Name('placeholder_20', Load(), lineno=54, col_offset=25, end_lineno=54, end_col_offset=34), Add(), Constant(1, lineno=54, col_offset=37, end_lineno=54, end_col_offset=38), lineno=54, col_offset=25, end_lineno=54, end_col_offset=38), Name('placeholder_0', Load(), lineno=54, col_offset=40, end_lineno=54, end_col_offset=49)], [], lineno=54, col_offset=19, end_lineno=54, end_col_offset=50), [Expr(Call(Attribute(Name('placeholder_4', Load(), lineno=55, col_offset=12, end_lineno=55, end_col_offset=18), 'extend', Load(), lineno=55, col_offset=12, end_lineno=55, end_col_offset=25), [Attribute(Subscript(Attribute(Name('self', Load(), lineno=55, col_offset=26, end_lineno=55, end_col_offset=30), 'placeholder_18', Load(), lineno=55, col_offset=26, end_lineno=55, end_col_offset=37), Name('placeholder_3', Load(), lineno=55, col_offset=38, end_lineno=55, end_col_offset=41), Load(), lineno=55, col_offset=26, end_lineno=55, end_col_offset=42), 'placeholder_4', Load(), lineno=55, col_offset=26, end_lineno=55, end_col_offset=49)], [], lineno=55, col_offset=12, end_lineno=55, end_col_offset=50), lineno=55, col_offset=12, end_lineno=55, end_col_offset=50)], [], lineno=54, col_offset=8, end_lineno=55, end_col_offset=50), Expr(Call(Attribute(Name('placeholder_4', Load(), lineno=56, col_offset=8, end_lineno=56, end_col_offset=14), 'extend', Load(), lineno=56, col_offset=8, end_lineno=56, end_col_offset=21), [Attribute(Name('self', Load(), lineno=56, col_offset=22, end_lineno=56, end_col_offset=26), 'placeholder_17', Load(), lineno=56, col_offset=22, end_lineno=56, end_col_offset=39)], [], lineno=56, col_offset=8, end_lineno=56, end_col_offset=40), lineno=56, col_offset=8, end_lineno=56, end_col_offset=40), Return(Name('placeholder_4', Load(), lineno=57, col_offset=15, end_lineno=57, end_col_offset=21), lineno=57, col_offset=8, end_lineno=57, end_col_offset=21)], [], lineno=51, col_offset=4, end_lineno=57, end_col_offset=21), FunctionDef('placeholder_21', arguments([], [arg('self', lineno=59, col_offset=19, end_lineno=59, end_col_offset=23), arg('placeholder_11', lineno=59, col_offset=25, end_lineno=59, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_22', Store(), lineno=60, col_offset=8, end_lineno=60, end_col_offset=19)], Subscript(Attribute(Name('self', Load(), lineno=60, col_offset=22, end_lineno=60, end_col_offset=26), 'placeholder_18', Load(), lineno=60, col_offset=22, end_lineno=60, end_col_offset=33), UnaryOp(USub(), Constant(1, lineno=60, col_offset=35, end_lineno=60, end_col_offset=36), lineno=60, col_offset=34, end_lineno=60, end_col_offset=36), Load(), lineno=60, col_offset=22, end_lineno=60, end_col_offset=37), lineno=60, col_offset=8, end_lineno=60, end_col_offset=37), If(Call(Attribute(Name('placeholder_22', Load(), lineno=61, col_offset=11, end_lineno=61, end_col_offset=22), 'placeholder_8', Load(), lineno=61, col_offset=11, end_lineno=61, end_col_offset=30), [], [], lineno=61, col_offset=11, end_lineno=61, end_col_offset=32), [Raise(Call(Name('IndexError', Load(), lineno=62, col_offset=18, end_lineno=62, end_col_offset=28), [Constant('cannot throw bonus with an open tenth frame', lineno=62, col_offset=29, end_lineno=62, end_col_offset=74)], [], lineno=62, col_offset=18, end_lineno=62, end_col_offset=75), lineno=62, col_offset=12, end_lineno=62, end_col_offset=75)], [], lineno=61, col_offset=8, end_lineno=62, end_col_offset=75), Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=12), 'placeholder_17', Load(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=25), 'append', Load(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=32), [Name('placeholder_11', Load(), lineno=64, col_offset=33, end_lineno=64, end_col_offset=37)], [], lineno=64, col_offset=8, end_lineno=64, end_col_offset=38), lineno=64, col_offset=8, end_lineno=64, end_col_offset=38), If(BoolOp(And(), [Compare(Call(Name('len', Load(), lineno=67, col_offset=12, end_lineno=67, end_col_offset=15), [Attribute(Name('self', Load(), lineno=67, col_offset=16, end_lineno=67, end_col_offset=20), 'placeholder_17', Load(), lineno=67, col_offset=16, end_lineno=67, end_col_offset=33)], [], lineno=67, col_offset=12, end_lineno=67, end_col_offset=34), [Eq()], [Constant(2, lineno=67, col_offset=38, end_lineno=67, end_col_offset=39)], lineno=67, col_offset=12, end_lineno=67, end_col_offset=39), Compare(Subscript(Attribute(Name('self', Load(), lineno=67, col_offset=44, end_lineno=67, end_col_offset=48), 'placeholder_17', Load(), lineno=67, col_offset=44, end_lineno=67, end_col_offset=61), Constant(0, lineno=67, col_offset=62, end_lineno=67, end_col_offset=63), Load(), lineno=67, col_offset=44, end_lineno=67, end_col_offset=64), [NotEq()], [Constant(10, lineno=67, col_offset=68, end_lineno=67, end_col_offset=70)], lineno=67, col_offset=44, end_lineno=67, end_col_offset=70), Compare(Call(Name('sum', Load(), lineno=68, col_offset=16, end_lineno=68, end_col_offset=19), [Attribute(Name('self', Load(), lineno=68, col_offset=20, end_lineno=68, end_col_offset=24), 'placeholder_17', Load(), lineno=68, col_offset=20, end_lineno=68, end_col_offset=37)], [], lineno=68, col_offset=16, end_lineno=68, end_col_offset=38), [Gt()], [Constant(10, lineno=68, col_offset=41, end_lineno=68, end_col_offset=43)], lineno=68, col_offset=16, end_lineno=68, end_col_offset=43)], lineno=67, col_offset=12, end_lineno=68, end_col_offset=43), [Raise(Call(Name('ValueError', Load(), lineno=69, col_offset=18, end_lineno=69, end_col_offset=28), [Constant('invalid fill balls', lineno=69, col_offset=29, end_lineno=69, end_col_offset=49)], [], lineno=69, col_offset=18, end_lineno=69, end_col_offset=50), lineno=69, col_offset=12, end_lineno=69, end_col_offset=50)], [], lineno=67, col_offset=8, end_lineno=69, end_col_offset=50), If(BoolOp(And(), [Call(Attribute(Name('placeholder_22', Load(), lineno=72, col_offset=11, end_lineno=72, end_col_offset=22), 'placeholder_6', Load(), lineno=72, col_offset=11, end_lineno=72, end_col_offset=32), [], [], lineno=72, col_offset=11, end_lineno=72, end_col_offset=34), Compare(Call(Name('len', Load(), lineno=72, col_offset=39, end_lineno=72, end_col_offset=42), [Attribute(Name('self', Load(), lineno=72, col_offset=43, end_lineno=72, end_col_offset=47), 'placeholder_17', Load(), lineno=72, col_offset=43, end_lineno=72, end_col_offset=60)], [], lineno=72, col_offset=39, end_lineno=72, end_col_offset=61), [Gt()], [Constant(2, lineno=72, col_offset=64, end_lineno=72, end_col_offset=65)], lineno=72, col_offset=39, end_lineno=72, end_col_offset=65)], lineno=72, col_offset=11, end_lineno=72, end_col_offset=65), [Raise(Call(Name('IndexError', Load(), lineno=73, col_offset=18, end_lineno=73, end_col_offset=28), [Constant('wrong number of fill balls when the tenth frame is a strike', lineno=74, col_offset=16, end_lineno=74, end_col_offset=77)], [], lineno=73, col_offset=18, end_lineno=74, end_col_offset=78), lineno=73, col_offset=12, end_lineno=74, end_col_offset=78)], [If(BoolOp(And(), [Call(Attribute(Name('placeholder_22', Load(), lineno=75, col_offset=13, end_lineno=75, end_col_offset=24), 'placeholder_7', Load(), lineno=75, col_offset=13, end_lineno=75, end_col_offset=33), [], [], lineno=75, col_offset=13, end_lineno=75, end_col_offset=35), Compare(Call(Name('len', Load(), lineno=75, col_offset=40, end_lineno=75, end_col_offset=43), [Attribute(Name('self', Load(), lineno=75, col_offset=44, end_lineno=75, end_col_offset=48), 'placeholder_17', Load(), lineno=75, col_offset=44, end_lineno=75, end_col_offset=61)], [], lineno=75, col_offset=40, end_lineno=75, end_col_offset=62), [Gt()], [Constant(1, lineno=75, col_offset=65, end_lineno=75, end_col_offset=66)], lineno=75, col_offset=40, end_lineno=75, end_col_offset=66)], lineno=75, col_offset=13, end_lineno=75, end_col_offset=66), [Raise(Call(Name('IndexError', Load(), lineno=76, col_offset=18, end_lineno=76, end_col_offset=28), [Constant('wrong number of fill balls when the tenth frame is a spare', lineno=77, col_offset=16, end_lineno=77, end_col_offset=76)], [], lineno=76, col_offset=18, end_lineno=77, end_col_offset=77), lineno=76, col_offset=12, end_lineno=77, end_col_offset=77)], [], lineno=75, col_offset=8, end_lineno=77, end_col_offset=77)], lineno=72, col_offset=8, end_lineno=77, end_col_offset=77)], [], lineno=59, col_offset=4, end_lineno=77, end_col_offset=77), FunctionDef('placeholder_23', arguments([], [arg('self', lineno=79, col_offset=13, end_lineno=79, end_col_offset=17), arg('placeholder_11', lineno=79, col_offset=19, end_lineno=79, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Compare(Constant(0, lineno=80, col_offset=15, end_lineno=80, end_col_offset=16), [LtE(), LtE()], [Name('placeholder_11', Load(), lineno=80, col_offset=20, end_lineno=80, end_col_offset=24), Constant(10, lineno=80, col_offset=28, end_lineno=80, end_col_offset=30)], lineno=80, col_offset=15, end_lineno=80, end_col_offset=30), lineno=80, col_offset=11, end_lineno=80, end_col_offset=30), [Raise(Call(Name('ValueError', Load(), lineno=81, col_offset=18, end_lineno=81, end_col_offset=28), [Constant('invalid pins', lineno=81, col_offset=29, end_lineno=81, end_col_offset=43)], [], lineno=81, col_offset=18, end_lineno=81, end_col_offset=44), lineno=81, col_offset=12, end_lineno=81, end_col_offset=44)], [If(Compare(Attribute(Name('self', Load(), lineno=82, col_offset=13, end_lineno=82, end_col_offset=17), 'placeholder_16', Load(), lineno=82, col_offset=13, end_lineno=82, end_col_offset=35), [Eq()], [Name('placeholder_0', Load(), lineno=82, col_offset=39, end_lineno=82, end_col_offset=48)], lineno=82, col_offset=13, end_lineno=82, end_col_offset=48), [Expr(Call(Attribute(Name('self', Load(), lineno=83, col_offset=12, end_lineno=83, end_col_offset=16), 'placeholder_21', Load(), lineno=83, col_offset=12, end_lineno=83, end_col_offset=27), [Name('placeholder_11', Load(), lineno=83, col_offset=28, end_lineno=83, end_col_offset=32)], [], lineno=83, col_offset=12, end_lineno=83, end_col_offset=33), lineno=83, col_offset=12, end_lineno=83, end_col_offset=33)], [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=85, col_offset=12, end_lineno=85, end_col_offset=16), 'placeholder_19', Load(), lineno=85, col_offset=12, end_lineno=85, end_col_offset=30), 'placeholder_10', Load(), lineno=85, col_offset=12, end_lineno=85, end_col_offset=36), [Name('placeholder_11', Load(), lineno=85, col_offset=37, end_lineno=85, end_col_offset=41)], [], lineno=85, col_offset=12, end_lineno=85, end_col_offset=42), lineno=85, col_offset=12, end_lineno=85, end_col_offset=42), If(Call(Attribute(Attribute(Name('self', Load(), lineno=86, col_offset=15, end_lineno=86, end_col_offset=19), 'placeholder_19', Load(), lineno=86, col_offset=15, end_lineno=86, end_col_offset=33), 'placeholder_9', Load(), lineno=86, col_offset=15, end_lineno=86, end_col_offset=43), [], [], lineno=86, col_offset=15, end_lineno=86, end_col_offset=45), [AugAssign(Attribute(Name('self', Load(), lineno=87, col_offset=16, end_lineno=87, end_col_offset=20), 'placeholder_16', Store(), lineno=87, col_offset=16, end_lineno=87, end_col_offset=38), Add(), Constant(1, lineno=87, col_offset=42, end_lineno=87, end_col_offset=43), lineno=87, col_offset=16, end_lineno=87, end_col_offset=43)], [], lineno=86, col_offset=12, end_lineno=87, end_col_offset=43)], lineno=82, col_offset=8, end_lineno=87, end_col_offset=43)], lineno=80, col_offset=8, end_lineno=87, end_col_offset=43)], [], lineno=79, col_offset=4, end_lineno=87, end_col_offset=43), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=89, col_offset=14, end_lineno=89, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=90, col_offset=11, end_lineno=90, end_col_offset=15), 'placeholder_16', Load(), lineno=90, col_offset=11, end_lineno=90, end_col_offset=33), [Lt()], [Name('placeholder_0', Load(), lineno=90, col_offset=36, end_lineno=90, end_col_offset=45)], lineno=90, col_offset=11, end_lineno=90, end_col_offset=45), [Raise(Call(Name('IndexError', Load(), lineno=91, col_offset=18, end_lineno=91, end_col_offset=28), [Constant('frame less than 10', lineno=91, col_offset=29, end_lineno=91, end_col_offset=49)], [], lineno=91, col_offset=18, end_lineno=91, end_col_offset=50), lineno=91, col_offset=12, end_lineno=91, end_col_offset=50)], [], lineno=90, col_offset=8, end_lineno=91, end_col_offset=50), If(BoolOp(And(), [Call(Attribute(Subscript(Attribute(Name('self', Load(), lineno=92, col_offset=11, end_lineno=92, end_col_offset=15), 'placeholder_18', Load(), lineno=92, col_offset=11, end_lineno=92, end_col_offset=22), UnaryOp(USub(), Constant(1, lineno=92, col_offset=24, end_lineno=92, end_col_offset=25), lineno=92, col_offset=23, end_lineno=92, end_col_offset=25), Load(), lineno=92, col_offset=11, end_lineno=92, end_col_offset=26), 'placeholder_7', Load(), lineno=92, col_offset=11, end_lineno=92, end_col_offset=35), [], [], lineno=92, col_offset=11, end_lineno=92, end_col_offset=37), Compare(Call(Name('len', Load(), lineno=92, col_offset=42, end_lineno=92, end_col_offset=45), [Attribute(Name('self', Load(), lineno=92, col_offset=46, end_lineno=92, end_col_offset=50), 'placeholder_17', Load(), lineno=92, col_offset=46, end_lineno=92, end_col_offset=63)], [], lineno=92, col_offset=42, end_lineno=92, end_col_offset=64), [NotEq()], [Constant(1, lineno=92, col_offset=68, end_lineno=92, end_col_offset=69)], lineno=92, col_offset=42, end_lineno=92, end_col_offset=69)], lineno=92, col_offset=11, end_lineno=92, end_col_offset=69), [Raise(Call(Name('IndexError', Load(), lineno=93, col_offset=18, end_lineno=93, end_col_offset=28), [Constant('one bonus must be rolled when the tenth frame is spare', lineno=94, col_offset=16, end_lineno=94, end_col_offset=72)], [], lineno=93, col_offset=18, end_lineno=94, end_col_offset=73), lineno=93, col_offset=12, end_lineno=94, end_col_offset=73)], [], lineno=92, col_offset=8, end_lineno=94, end_col_offset=73), If(BoolOp(And(), [Call(Attribute(Subscript(Attribute(Name('self', Load(), lineno=95, col_offset=11, end_lineno=95, end_col_offset=15), 'placeholder_18', Load(), lineno=95, col_offset=11, end_lineno=95, end_col_offset=22), UnaryOp(USub(), Constant(1, lineno=95, col_offset=24, end_lineno=95, end_col_offset=25), lineno=95, col_offset=23, end_lineno=95, end_col_offset=25), Load(), lineno=95, col_offset=11, end_lineno=95, end_col_offset=26), 'placeholder_6', Load(), lineno=95, col_offset=11, end_lineno=95, end_col_offset=36), [], [], lineno=95, col_offset=11, end_lineno=95, end_col_offset=38), Compare(Call(Name('len', Load(), lineno=95, col_offset=43, end_lineno=95, end_col_offset=46), [Attribute(Name('self', Load(), lineno=95, col_offset=47, end_lineno=95, end_col_offset=51), 'placeholder_17', Load(), lineno=95, col_offset=47, end_lineno=95, end_col_offset=64)], [], lineno=95, col_offset=43, end_lineno=95, end_col_offset=65), [NotEq()], [Constant(2, lineno=95, col_offset=69, end_lineno=95, end_col_offset=70)], lineno=95, col_offset=43, end_lineno=95, end_col_offset=70)], lineno=95, col_offset=11, end_lineno=95, end_col_offset=70), [Raise(Call(Name('IndexError', Load(), lineno=96, col_offset=18, end_lineno=96, end_col_offset=28), [Constant('two bonuses must be rolled when the tenth frame is strike', lineno=97, col_offset=16, end_lineno=97, end_col_offset=75)], [], lineno=96, col_offset=18, end_lineno=97, end_col_offset=76), lineno=96, col_offset=12, end_lineno=97, end_col_offset=76)], [], lineno=95, col_offset=8, end_lineno=97, end_col_offset=76), Return(Call(Name('sum', Load(), lineno=98, col_offset=15, end_lineno=98, end_col_offset=18), [GeneratorExp(Call(Attribute(Name('placeholder_24', Load(), lineno=98, col_offset=19, end_lineno=98, end_col_offset=24), 'placeholder_12', Load(), lineno=98, col_offset=19, end_lineno=98, end_col_offset=30), [Call(Attribute(Name('self', Load(), lineno=98, col_offset=31, end_lineno=98, end_col_offset=35), 'placeholder_13', Load(), lineno=98, col_offset=31, end_lineno=98, end_col_offset=47), [Attribute(Name('placeholder_24', Load(), lineno=98, col_offset=48, end_lineno=98, end_col_offset=53), 'placeholder_3', Load(), lineno=98, col_offset=48, end_lineno=98, end_col_offset=57)], [], lineno=98, col_offset=31, end_lineno=98, end_col_offset=58)], [], lineno=98, col_offset=19, end_lineno=98, end_col_offset=59), [comprehension(Name('placeholder_24', Store(), lineno=99, col_offset=23, end_lineno=99, end_col_offset=28), Attribute(Name('self', Load(), lineno=99, col_offset=32, end_lineno=99, end_col_offset=36), 'placeholder_18', Load(), lineno=99, col_offset=32, end_lineno=99, end_col_offset=43), [], 0)], lineno=98, col_offset=18, end_lineno=99, end_col_offset=44)], [], lineno=98, col_offset=15, end_lineno=99, end_col_offset=44), lineno=98, col_offset=8, end_lineno=99, end_col_offset=44)], [], lineno=89, col_offset=4, end_lineno=99, end_col_offset=44)], [], lineno=41, col_offset=0, end_lineno=99, end_col_offset=44)], []) \ No newline at end of file diff --git a/test/practice-change/.meta/config.json b/test/practice-change/.meta/config.json new file mode 100644 index 0000000..2d117fe --- /dev/null +++ b/test/practice-change/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "justani" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "ikhadykin", + "lucasdpau", + "N-Parsons", + "RJTK", + "sdublish", + "smalley", + "tqa236" + ], + "files": { + "solution": [ + "change.py" + ], + "test": [ + "change_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Correctly determine change to be given using the least number of coins.", + "source": "Software Craftsmanship - Coin Change Kata", + "source_url": "https://web.archive.org/web/20130115115225/http://craftsmanship.sv.cmu.edu:80/exercises/coin-change-kata" +} diff --git a/test/practice-change/change.py b/test/practice-change/change.py new file mode 100644 index 0000000..b62fa0c --- /dev/null +++ b/test/practice-change/change.py @@ -0,0 +1,25 @@ +def find_fewest_coins(coins, target): + if target < 0: + raise ValueError("target can't be negative") + min_coins_required = [1e9] * (target + 1) + last_coin = [0] * (target + 1) + min_coins_required[0] = 0 + last_coin[0] = -1 + for change in range(1, target + 1): + final_result = min_coins_required[change] + for coin in coins: + if coin <= change: + result = min_coins_required[change - coin] + 1 + if result < final_result: + final_result = result + last_coin[change] = change - coin + min_coins_required[change] = final_result + if min_coins_required[target] == 1e9: + raise ValueError("can't make target with given coins") + else: + last_coin_value = target + array = [] + while last_coin[last_coin_value] != -1: + array.append(last_coin_value-last_coin[last_coin_value]) + last_coin_value = last_coin[last_coin_value] + return array diff --git a/test/practice-change/mapping.json b/test/practice-change/mapping.json new file mode 100644 index 0000000..54b1d7d --- /dev/null +++ b/test/practice-change/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "find_fewest_coins", + "placeholder_1": "coins", + "placeholder_2": "target", + "placeholder_3": "min_coins_required", + "placeholder_4": "last_coin", + "placeholder_5": "change", + "placeholder_6": "final_result", + "placeholder_7": "coin", + "placeholder_8": "result", + "placeholder_9": "last_coin_value", + "placeholder_10": "array" +} \ No newline at end of file diff --git a/test/practice-change/representation.json b/test/practice-change/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-change/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-change/representation.out b/test/practice-change/representation.out new file mode 100644 index 0000000..fcac7fb --- /dev/null +++ b/test/practice-change/representation.out @@ -0,0 +1,1696 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + if placeholder_2 < 0: + raise ValueError("target can't be negative") + placeholder_3 = [1000000000.0] * (placeholder_2 + 1) + placeholder_4 = [0] * (placeholder_2 + 1) + placeholder_3[0] = 0 + placeholder_4[0] = -1 + for placeholder_5 in range(1, placeholder_2 + 1): + placeholder_6 = placeholder_3[placeholder_5] + for placeholder_7 in placeholder_1: + if placeholder_7 <= placeholder_5: + placeholder_8 = placeholder_3[placeholder_5 - placeholder_7] + 1 + if placeholder_8 < placeholder_6: + placeholder_6 = placeholder_8 + placeholder_4[placeholder_5] = placeholder_5 - placeholder_7 + placeholder_3[placeholder_5] = placeholder_6 + if placeholder_3[placeholder_2] == 1000000000.0: + raise ValueError("can't make target with given coins") + else: + placeholder_9 = placeholder_2 + placeholder_10 = [] + while placeholder_4[placeholder_9] != -1: + placeholder_10.append(placeholder_9 - placeholder_4[placeholder_9]) + placeholder_9 = placeholder_4[placeholder_9] + return placeholder_10 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'find_fewest_coins', + arguments( + [], + [ + arg( + 'coins', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27), + arg( + 'target', + lineno=1, + col_offset=29, + end_lineno=1, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'target', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 0, + lineno=2, + col_offset=16, + end_lineno=2, + end_col_offset=17)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=17), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + "target can't be negative", + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=51)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=52), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=52)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=52), + Assign( + [ + Name( + 'min_coins_required', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=22)], + BinOp( + List( + [ + Constant( + 1000000000.0, + lineno=4, + col_offset=26, + end_lineno=4, + end_col_offset=29)], + Load(), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=30), + Mult(), + BinOp( + Name( + 'target', + Load(), + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=4, + col_offset=43, + end_lineno=4, + end_col_offset=44), + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=44), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=45), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=45), + Assign( + [ + Name( + 'last_coin', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=13)], + BinOp( + List( + [ + Constant( + 0, + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=18)], + Load(), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=19), + Mult(), + BinOp( + Name( + 'target', + Load(), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=29), + Add(), + Constant( + 1, + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=34), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=34), + Assign( + [ + Subscript( + Name( + 'min_coins_required', + Load(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=22), + Constant( + 0, + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=24), + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=25)], + Constant( + 0, + lineno=6, + col_offset=28, + end_lineno=6, + end_col_offset=29), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=29), + Assign( + [ + Subscript( + Name( + 'last_coin', + Load(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=13), + Constant( + 0, + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=15), + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=16)], + UnaryOp( + USub(), + Constant( + 1, + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=21), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=21), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=21), + For( + Name( + 'change', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=14), + Call( + Name( + 'range', + Load(), + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=23), + [ + Constant( + 1, + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=25), + BinOp( + Name( + 'target', + Load(), + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=33), + Add(), + Constant( + 1, + lineno=8, + col_offset=36, + end_lineno=8, + end_col_offset=37), + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=37)], + [], + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=38), + [ + Assign( + [ + Name( + 'final_result', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=20)], + Subscript( + Name( + 'min_coins_required', + Load(), + lineno=9, + col_offset=23, + end_lineno=9, + end_col_offset=41), + Name( + 'change', + Load(), + lineno=9, + col_offset=42, + end_lineno=9, + end_col_offset=48), + Load(), + lineno=9, + col_offset=23, + end_lineno=9, + end_col_offset=49), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=49), + For( + Name( + 'coin', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=16), + Name( + 'coins', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=25), + [ + If( + Compare( + Name( + 'coin', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=19), + [ + LtE()], + [ + Name( + 'change', + Load(), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=29)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=29), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=22)], + BinOp( + Subscript( + Name( + 'min_coins_required', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=43), + BinOp( + Name( + 'change', + Load(), + lineno=12, + col_offset=44, + end_lineno=12, + end_col_offset=50), + Sub(), + Name( + 'coin', + Load(), + lineno=12, + col_offset=53, + end_lineno=12, + end_col_offset=57), + lineno=12, + col_offset=44, + end_lineno=12, + end_col_offset=57), + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=58), + Add(), + Constant( + 1, + lineno=12, + col_offset=61, + end_lineno=12, + end_col_offset=62), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=62), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=62), + If( + Compare( + Name( + 'result', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=25), + [ + Lt()], + [ + Name( + 'final_result', + Load(), + lineno=13, + col_offset=28, + end_lineno=13, + end_col_offset=40)], + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=40), + [ + Assign( + [ + Name( + 'final_result', + Store(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=32)], + Name( + 'result', + Load(), + lineno=14, + col_offset=35, + end_lineno=14, + end_col_offset=41), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=41), + Assign( + [ + Subscript( + Name( + 'last_coin', + Load(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=29), + Name( + 'change', + Load(), + lineno=15, + col_offset=30, + end_lineno=15, + end_col_offset=36), + Store(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=37)], + BinOp( + Name( + 'change', + Load(), + lineno=15, + col_offset=40, + end_lineno=15, + end_col_offset=46), + Sub(), + Name( + 'coin', + Load(), + lineno=15, + col_offset=49, + end_lineno=15, + end_col_offset=53), + lineno=15, + col_offset=40, + end_lineno=15, + end_col_offset=53), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=53)], + [], + lineno=13, + col_offset=16, + end_lineno=15, + end_col_offset=53)], + [], + lineno=11, + col_offset=12, + end_lineno=15, + end_col_offset=53)], + [], + lineno=10, + col_offset=8, + end_lineno=15, + end_col_offset=53), + Assign( + [ + Subscript( + Name( + 'min_coins_required', + Load(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=26), + Name( + 'change', + Load(), + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=33), + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=34)], + Name( + 'final_result', + Load(), + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=49), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=49)], + [], + lineno=8, + col_offset=4, + end_lineno=16, + end_col_offset=49), + If( + Compare( + Subscript( + Name( + 'min_coins_required', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=25), + Name( + 'target', + Load(), + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=32), + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=33), + [ + Eq()], + [ + Constant( + 1000000000.0, + lineno=17, + col_offset=37, + end_lineno=17, + end_col_offset=40)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=40), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + Constant( + "can't make target with given coins", + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=61)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=62), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=62)], + [ + Assign( + [ + Name( + 'last_coin_value', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=23)], + Name( + 'target', + Load(), + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=32), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=32), + Assign( + [ + Name( + 'array', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=13)], + List( + [], + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=18), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=18), + While( + Compare( + Subscript( + Name( + 'last_coin', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=23), + Name( + 'last_coin_value', + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=39), + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=40), + [ + NotEq()], + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=22, + col_offset=45, + end_lineno=22, + end_col_offset=46), + lineno=22, + col_offset=44, + end_lineno=22, + end_col_offset=46)], + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=46), + [ + Expr( + Call( + Attribute( + Name( + 'array', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + 'append', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=24), + [ + BinOp( + Name( + 'last_coin_value', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=40), + Sub(), + Subscript( + Name( + 'last_coin', + Load(), + lineno=23, + col_offset=41, + end_lineno=23, + end_col_offset=50), + Name( + 'last_coin_value', + Load(), + lineno=23, + col_offset=51, + end_lineno=23, + end_col_offset=66), + Load(), + lineno=23, + col_offset=41, + end_lineno=23, + end_col_offset=67), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=67)], + [], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=68), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=68), + Assign( + [ + Name( + 'last_coin_value', + Store(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=27)], + Subscript( + Name( + 'last_coin', + Load(), + lineno=24, + col_offset=30, + end_lineno=24, + end_col_offset=39), + Name( + 'last_coin_value', + Load(), + lineno=24, + col_offset=40, + end_lineno=24, + end_col_offset=55), + Load(), + lineno=24, + col_offset=30, + end_lineno=24, + end_col_offset=56), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=56)], + [], + lineno=22, + col_offset=8, + end_lineno=24, + end_col_offset=56), + Return( + Name( + 'array', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=20), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=20)], + lineno=17, + col_offset=4, + end_lineno=25, + end_col_offset=20)], + [], + lineno=1, + col_offset=0, + end_lineno=25, + end_col_offset=20)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27), + arg( + 'placeholder_2', + lineno=1, + col_offset=29, + end_lineno=1, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 0, + lineno=2, + col_offset=16, + end_lineno=2, + end_col_offset=17)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=17), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + "target can't be negative", + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=51)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=52), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=52)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=22)], + BinOp( + List( + [ + Constant( + 1000000000.0, + lineno=4, + col_offset=26, + end_lineno=4, + end_col_offset=29)], + Load(), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=30), + Mult(), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=4, + col_offset=43, + end_lineno=4, + end_col_offset=44), + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=44), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=45), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=13)], + BinOp( + List( + [ + Constant( + 0, + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=18)], + Load(), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=19), + Mult(), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=29), + Add(), + Constant( + 1, + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=34), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=34), + Assign( + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=22), + Constant( + 0, + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=24), + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=25)], + Constant( + 0, + lineno=6, + col_offset=28, + end_lineno=6, + end_col_offset=29), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=29), + Assign( + [ + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=13), + Constant( + 0, + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=15), + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=16)], + UnaryOp( + USub(), + Constant( + 1, + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=21), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=21), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=21), + For( + Name( + 'placeholder_5', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=14), + Call( + Name( + 'range', + Load(), + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=23), + [ + Constant( + 1, + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=25), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=33), + Add(), + Constant( + 1, + lineno=8, + col_offset=36, + end_lineno=8, + end_col_offset=37), + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=37)], + [], + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=38), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=20)], + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=23, + end_lineno=9, + end_col_offset=41), + Name( + 'placeholder_5', + Load(), + lineno=9, + col_offset=42, + end_lineno=9, + end_col_offset=48), + Load(), + lineno=9, + col_offset=23, + end_lineno=9, + end_col_offset=49), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=49), + For( + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=16), + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=25), + [ + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=19), + [ + LtE()], + [ + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=29)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=29), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=22)], + BinOp( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=43), + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=44, + end_lineno=12, + end_col_offset=50), + Sub(), + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=53, + end_lineno=12, + end_col_offset=57), + lineno=12, + col_offset=44, + end_lineno=12, + end_col_offset=57), + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=58), + Add(), + Constant( + 1, + lineno=12, + col_offset=61, + end_lineno=12, + end_col_offset=62), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=62), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=62), + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=25), + [ + Lt()], + [ + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=28, + end_lineno=13, + end_col_offset=40)], + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=40), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=32)], + Name( + 'placeholder_8', + Load(), + lineno=14, + col_offset=35, + end_lineno=14, + end_col_offset=41), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=41), + Assign( + [ + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=29), + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=30, + end_lineno=15, + end_col_offset=36), + Store(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=37)], + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=40, + end_lineno=15, + end_col_offset=46), + Sub(), + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=49, + end_lineno=15, + end_col_offset=53), + lineno=15, + col_offset=40, + end_lineno=15, + end_col_offset=53), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=53)], + [], + lineno=13, + col_offset=16, + end_lineno=15, + end_col_offset=53)], + [], + lineno=11, + col_offset=12, + end_lineno=15, + end_col_offset=53)], + [], + lineno=10, + col_offset=8, + end_lineno=15, + end_col_offset=53), + Assign( + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=26), + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=33), + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=34)], + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=49), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=49)], + [], + lineno=8, + col_offset=4, + end_lineno=16, + end_col_offset=49), + If( + Compare( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=25), + Name( + 'placeholder_2', + Load(), + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=32), + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=33), + [ + Eq()], + [ + Constant( + 1000000000.0, + lineno=17, + col_offset=37, + end_lineno=17, + end_col_offset=40)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=40), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + Constant( + "can't make target with given coins", + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=61)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=62), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=62)], + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=23)], + Name( + 'placeholder_2', + Load(), + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=32), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=13)], + List( + [], + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=18), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=18), + While( + Compare( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=23), + Name( + 'placeholder_9', + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=39), + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=40), + [ + NotEq()], + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=22, + col_offset=45, + end_lineno=22, + end_col_offset=46), + lineno=22, + col_offset=44, + end_lineno=22, + end_col_offset=46)], + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=46), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_10', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + 'append', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=24), + [ + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=40), + Sub(), + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=23, + col_offset=41, + end_lineno=23, + end_col_offset=50), + Name( + 'placeholder_9', + Load(), + lineno=23, + col_offset=51, + end_lineno=23, + end_col_offset=66), + Load(), + lineno=23, + col_offset=41, + end_lineno=23, + end_col_offset=67), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=67)], + [], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=68), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=68), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=27)], + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=24, + col_offset=30, + end_lineno=24, + end_col_offset=39), + Name( + 'placeholder_9', + Load(), + lineno=24, + col_offset=40, + end_lineno=24, + end_col_offset=55), + Load(), + lineno=24, + col_offset=30, + end_lineno=24, + end_col_offset=56), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=56)], + [], + lineno=22, + col_offset=8, + end_lineno=24, + end_col_offset=56), + Return( + Name( + 'placeholder_10', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=20), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=20)], + lineno=17, + col_offset=4, + end_lineno=25, + end_col_offset=20)], + [], + lineno=1, + col_offset=0, + end_lineno=25, + end_col_offset=20)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-change/representation.txt b/test/practice-change/representation.txt new file mode 100644 index 0000000..870ee88 --- /dev/null +++ b/test/practice-change/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=22, end_lineno=1, end_col_offset=27), arg('placeholder_2', lineno=1, col_offset=29, end_lineno=1, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_2', Load(), lineno=2, col_offset=7, end_lineno=2, end_col_offset=13), [Lt()], [Constant(0, lineno=2, col_offset=16, end_lineno=2, end_col_offset=17)], lineno=2, col_offset=7, end_lineno=2, end_col_offset=17), [Raise(Call(Name('ValueError', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=24), [Constant("target can't be negative", lineno=3, col_offset=25, end_lineno=3, end_col_offset=51)], [], lineno=3, col_offset=14, end_lineno=3, end_col_offset=52), lineno=3, col_offset=8, end_lineno=3, end_col_offset=52)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=52), Assign([Name('placeholder_3', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=22)], BinOp(List([Constant(1000000000.0, lineno=4, col_offset=26, end_lineno=4, end_col_offset=29)], Load(), lineno=4, col_offset=25, end_lineno=4, end_col_offset=30), Mult(), BinOp(Name('placeholder_2', Load(), lineno=4, col_offset=34, end_lineno=4, end_col_offset=40), Add(), Constant(1, lineno=4, col_offset=43, end_lineno=4, end_col_offset=44), lineno=4, col_offset=34, end_lineno=4, end_col_offset=44), lineno=4, col_offset=25, end_lineno=4, end_col_offset=45), lineno=4, col_offset=4, end_lineno=4, end_col_offset=45), Assign([Name('placeholder_4', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=13)], BinOp(List([Constant(0, lineno=5, col_offset=17, end_lineno=5, end_col_offset=18)], Load(), lineno=5, col_offset=16, end_lineno=5, end_col_offset=19), Mult(), BinOp(Name('placeholder_2', Load(), lineno=5, col_offset=23, end_lineno=5, end_col_offset=29), Add(), Constant(1, lineno=5, col_offset=32, end_lineno=5, end_col_offset=33), lineno=5, col_offset=23, end_lineno=5, end_col_offset=33), lineno=5, col_offset=16, end_lineno=5, end_col_offset=34), lineno=5, col_offset=4, end_lineno=5, end_col_offset=34), Assign([Subscript(Name('placeholder_3', Load(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=22), Constant(0, lineno=6, col_offset=23, end_lineno=6, end_col_offset=24), Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=25)], Constant(0, lineno=6, col_offset=28, end_lineno=6, end_col_offset=29), lineno=6, col_offset=4, end_lineno=6, end_col_offset=29), Assign([Subscript(Name('placeholder_4', Load(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=13), Constant(0, lineno=7, col_offset=14, end_lineno=7, end_col_offset=15), Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=16)], UnaryOp(USub(), Constant(1, lineno=7, col_offset=20, end_lineno=7, end_col_offset=21), lineno=7, col_offset=19, end_lineno=7, end_col_offset=21), lineno=7, col_offset=4, end_lineno=7, end_col_offset=21), For(Name('placeholder_5', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=14), Call(Name('range', Load(), lineno=8, col_offset=18, end_lineno=8, end_col_offset=23), [Constant(1, lineno=8, col_offset=24, end_lineno=8, end_col_offset=25), BinOp(Name('placeholder_2', Load(), lineno=8, col_offset=27, end_lineno=8, end_col_offset=33), Add(), Constant(1, lineno=8, col_offset=36, end_lineno=8, end_col_offset=37), lineno=8, col_offset=27, end_lineno=8, end_col_offset=37)], [], lineno=8, col_offset=18, end_lineno=8, end_col_offset=38), [Assign([Name('placeholder_6', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=20)], Subscript(Name('placeholder_3', Load(), lineno=9, col_offset=23, end_lineno=9, end_col_offset=41), Name('placeholder_5', Load(), lineno=9, col_offset=42, end_lineno=9, end_col_offset=48), Load(), lineno=9, col_offset=23, end_lineno=9, end_col_offset=49), lineno=9, col_offset=8, end_lineno=9, end_col_offset=49), For(Name('placeholder_7', Store(), lineno=10, col_offset=12, end_lineno=10, end_col_offset=16), Name('placeholder_1', Load(), lineno=10, col_offset=20, end_lineno=10, end_col_offset=25), [If(Compare(Name('placeholder_7', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=19), [LtE()], [Name('placeholder_5', Load(), lineno=11, col_offset=23, end_lineno=11, end_col_offset=29)], lineno=11, col_offset=15, end_lineno=11, end_col_offset=29), [Assign([Name('placeholder_8', Store(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=22)], BinOp(Subscript(Name('placeholder_3', Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=43), BinOp(Name('placeholder_5', Load(), lineno=12, col_offset=44, end_lineno=12, end_col_offset=50), Sub(), Name('placeholder_7', Load(), lineno=12, col_offset=53, end_lineno=12, end_col_offset=57), lineno=12, col_offset=44, end_lineno=12, end_col_offset=57), Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=58), Add(), Constant(1, lineno=12, col_offset=61, end_lineno=12, end_col_offset=62), lineno=12, col_offset=25, end_lineno=12, end_col_offset=62), lineno=12, col_offset=16, end_lineno=12, end_col_offset=62), If(Compare(Name('placeholder_8', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=25), [Lt()], [Name('placeholder_6', Load(), lineno=13, col_offset=28, end_lineno=13, end_col_offset=40)], lineno=13, col_offset=19, end_lineno=13, end_col_offset=40), [Assign([Name('placeholder_6', Store(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=32)], Name('placeholder_8', Load(), lineno=14, col_offset=35, end_lineno=14, end_col_offset=41), lineno=14, col_offset=20, end_lineno=14, end_col_offset=41), Assign([Subscript(Name('placeholder_4', Load(), lineno=15, col_offset=20, end_lineno=15, end_col_offset=29), Name('placeholder_5', Load(), lineno=15, col_offset=30, end_lineno=15, end_col_offset=36), Store(), lineno=15, col_offset=20, end_lineno=15, end_col_offset=37)], BinOp(Name('placeholder_5', Load(), lineno=15, col_offset=40, end_lineno=15, end_col_offset=46), Sub(), Name('placeholder_7', Load(), lineno=15, col_offset=49, end_lineno=15, end_col_offset=53), lineno=15, col_offset=40, end_lineno=15, end_col_offset=53), lineno=15, col_offset=20, end_lineno=15, end_col_offset=53)], [], lineno=13, col_offset=16, end_lineno=15, end_col_offset=53)], [], lineno=11, col_offset=12, end_lineno=15, end_col_offset=53)], [], lineno=10, col_offset=8, end_lineno=15, end_col_offset=53), Assign([Subscript(Name('placeholder_3', Load(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=26), Name('placeholder_5', Load(), lineno=16, col_offset=27, end_lineno=16, end_col_offset=33), Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=34)], Name('placeholder_6', Load(), lineno=16, col_offset=37, end_lineno=16, end_col_offset=49), lineno=16, col_offset=8, end_lineno=16, end_col_offset=49)], [], lineno=8, col_offset=4, end_lineno=16, end_col_offset=49), If(Compare(Subscript(Name('placeholder_3', Load(), lineno=17, col_offset=7, end_lineno=17, end_col_offset=25), Name('placeholder_2', Load(), lineno=17, col_offset=26, end_lineno=17, end_col_offset=32), Load(), lineno=17, col_offset=7, end_lineno=17, end_col_offset=33), [Eq()], [Constant(1000000000.0, lineno=17, col_offset=37, end_lineno=17, end_col_offset=40)], lineno=17, col_offset=7, end_lineno=17, end_col_offset=40), [Raise(Call(Name('ValueError', Load(), lineno=18, col_offset=14, end_lineno=18, end_col_offset=24), [Constant("can't make target with given coins", lineno=18, col_offset=25, end_lineno=18, end_col_offset=61)], [], lineno=18, col_offset=14, end_lineno=18, end_col_offset=62), lineno=18, col_offset=8, end_lineno=18, end_col_offset=62)], [Assign([Name('placeholder_9', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=23)], Name('placeholder_2', Load(), lineno=20, col_offset=26, end_lineno=20, end_col_offset=32), lineno=20, col_offset=8, end_lineno=20, end_col_offset=32), Assign([Name('placeholder_10', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=13)], List([], Load(), lineno=21, col_offset=16, end_lineno=21, end_col_offset=18), lineno=21, col_offset=8, end_lineno=21, end_col_offset=18), While(Compare(Subscript(Name('placeholder_4', Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=23), Name('placeholder_9', Load(), lineno=22, col_offset=24, end_lineno=22, end_col_offset=39), Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=40), [NotEq()], [UnaryOp(USub(), Constant(1, lineno=22, col_offset=45, end_lineno=22, end_col_offset=46), lineno=22, col_offset=44, end_lineno=22, end_col_offset=46)], lineno=22, col_offset=14, end_lineno=22, end_col_offset=46), [Expr(Call(Attribute(Name('placeholder_10', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=17), 'append', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=24), [BinOp(Name('placeholder_9', Load(), lineno=23, col_offset=25, end_lineno=23, end_col_offset=40), Sub(), Subscript(Name('placeholder_4', Load(), lineno=23, col_offset=41, end_lineno=23, end_col_offset=50), Name('placeholder_9', Load(), lineno=23, col_offset=51, end_lineno=23, end_col_offset=66), Load(), lineno=23, col_offset=41, end_lineno=23, end_col_offset=67), lineno=23, col_offset=25, end_lineno=23, end_col_offset=67)], [], lineno=23, col_offset=12, end_lineno=23, end_col_offset=68), lineno=23, col_offset=12, end_lineno=23, end_col_offset=68), Assign([Name('placeholder_9', Store(), lineno=24, col_offset=12, end_lineno=24, end_col_offset=27)], Subscript(Name('placeholder_4', Load(), lineno=24, col_offset=30, end_lineno=24, end_col_offset=39), Name('placeholder_9', Load(), lineno=24, col_offset=40, end_lineno=24, end_col_offset=55), Load(), lineno=24, col_offset=30, end_lineno=24, end_col_offset=56), lineno=24, col_offset=12, end_lineno=24, end_col_offset=56)], [], lineno=22, col_offset=8, end_lineno=24, end_col_offset=56), Return(Name('placeholder_10', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=20), lineno=25, col_offset=8, end_lineno=25, end_col_offset=20)], lineno=17, col_offset=4, end_lineno=25, end_col_offset=20)], [], lineno=1, col_offset=0, end_lineno=25, end_col_offset=20)], []) \ No newline at end of file diff --git a/test/practice-circular-buffer/.meta/config.json b/test/practice-circular-buffer/.meta/config.json new file mode 100644 index 0000000..09fc60b --- /dev/null +++ b/test/practice-circular-buffer/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "cmccandless", + "Dog", + "elyssonmr", + "ikhadykin", + "Mofeywalker", + "N-Parsons", + "pheanex", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "circular_buffer.py" + ], + "test": [ + "circular_buffer_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Circular_buffer" +} diff --git a/test/practice-circular-buffer/circular_buffer.py b/test/practice-circular-buffer/circular_buffer.py new file mode 100644 index 0000000..538cc7b --- /dev/null +++ b/test/practice-circular-buffer/circular_buffer.py @@ -0,0 +1,56 @@ +class BufferFullException(BufferError): + """Exception raised when CircularBuffer is full. + + message: explanation of the error. + + """ + def __init__(self, message): + self.message = message + + +class BufferEmptyException(BufferError): + """Exception raised when CircularBuffer is empty. + + message: explanation of the error. + + """ + def __init__(self, message): + self.message = message + + +class CircularBuffer: + + def __init__(self, capacity): + self.buffer = bytearray(capacity) + self.read_point = 0 + self.write_point = 0 + + # (protected) helper method + def _update_buffer(self, data): + try: + self.buffer[self.write_point] = data + except TypeError: + self.buffer[self.write_point] = ord(data) + + def clear(self): + self.buffer = bytearray(len(self.buffer)) + + def write(self, data): + if all(self.buffer): + raise BufferFullException('Circular buffer is full') + self._update_buffer(data) + self.write_point = (self.write_point + 1) % len(self.buffer) + + def overwrite(self, data): + self._update_buffer(data) + if all(self.buffer) and self.write_point == self.read_point: + self.read_point = (self.read_point + 1) % len(self.buffer) + self.write_point = (self.write_point + 1) % len(self.buffer) + + def read(self): + if not any(self.buffer): + raise BufferEmptyException('Circular buffer is empty') + data = chr(self.buffer[self.read_point]) + self.buffer[self.read_point] = 0 + self.read_point = (self.read_point + 1) % len(self.buffer) + return data diff --git a/test/practice-circular-buffer/mapping.json b/test/practice-circular-buffer/mapping.json new file mode 100644 index 0000000..5f42b32 --- /dev/null +++ b/test/practice-circular-buffer/mapping.json @@ -0,0 +1,17 @@ +{ + "placeholder_0": "BufferFullException", + "placeholder_1": "__init__", + "placeholder_2": "message", + "placeholder_3": "BufferEmptyException", + "placeholder_4": "CircularBuffer", + "placeholder_5": "capacity", + "placeholder_6": "buffer", + "placeholder_7": "read_point", + "placeholder_8": "write_point", + "placeholder_9": "_update_buffer", + "placeholder_10": "data", + "placeholder_11": "clear", + "placeholder_12": "write", + "placeholder_13": "overwrite", + "placeholder_14": "read" +} \ No newline at end of file diff --git a/test/practice-circular-buffer/representation.json b/test/practice-circular-buffer/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-circular-buffer/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-circular-buffer/representation.out b/test/practice-circular-buffer/representation.out new file mode 100644 index 0000000..341153b --- /dev/null +++ b/test/practice-circular-buffer/representation.out @@ -0,0 +1,2657 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0(BufferError): + def placeholder_1(self, placeholder_2): + self.placeholder_2 = placeholder_2 + + +class placeholder_3(BufferError): + def placeholder_1(self, placeholder_2): + self.placeholder_2 = placeholder_2 + + +class placeholder_4: + def placeholder_1(self, placeholder_5): + self.placeholder_6 = bytearray(placeholder_5) + self.placeholder_7 = 0 + self.placeholder_8 = 0 + + def placeholder_9(self, placeholder_10): + try: + self.placeholder_6[self.placeholder_8] = placeholder_10 + except TypeError: + self.placeholder_6[self.placeholder_8] = ord(placeholder_10) + + def placeholder_11(self): + self.placeholder_6 = bytearray(len(self.placeholder_6)) + + def placeholder_12(self, placeholder_10): + if all(self.placeholder_6): + raise placeholder_0("Circular buffer is full") + self.placeholder_9(placeholder_10) + self.placeholder_8 = (self.placeholder_8 + 1) % len(self.placeholder_6) + + def placeholder_13(self, placeholder_10): + self.placeholder_9(placeholder_10) + if all(self.placeholder_6) and self.placeholder_8 == self.placeholder_7: + self.placeholder_7 = (self.placeholder_7 + 1) % len(self.placeholder_6) + self.placeholder_8 = (self.placeholder_8 + 1) % len(self.placeholder_6) + + def placeholder_14(self): + if not any(self.placeholder_6): + raise placeholder_3("Circular buffer is empty") + placeholder_10 = chr(self.placeholder_6[self.placeholder_7]) + self.placeholder_6[self.placeholder_7] = 0 + self.placeholder_7 = (self.placeholder_7 + 1) % len(self.placeholder_6) + return placeholder_10 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'BufferFullException', + [ + Name( + 'BufferError', + Load(), + lineno=1, + col_offset=26, + end_lineno=1, + end_col_offset=37)], + [], + [ + Expr( + Constant( + 'Exception raised when CircularBuffer is full.\n\n message: explanation of the error.\n\n ', + lineno=2, + col_offset=4, + end_lineno=6, + end_col_offset=7), + lineno=2, + col_offset=4, + end_lineno=6, + end_col_offset=7), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21), + arg( + 'message', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'message', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=20)], + Name( + 'message', + Load(), + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=30), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=30)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=30)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=30), + ClassDef( + 'BufferEmptyException', + [ + Name( + 'BufferError', + Load(), + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=38)], + [], + [ + Expr( + Constant( + 'Exception raised when CircularBuffer is empty.\n\n message: explanation of the error.\n\n ', + lineno=12, + col_offset=4, + end_lineno=16, + end_col_offset=7), + lineno=12, + col_offset=4, + end_lineno=16, + end_col_offset=7), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21), + arg( + 'message', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=12), + 'message', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=20)], + Name( + 'message', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=30), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=30)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=30)], + [], + lineno=11, + col_offset=0, + end_lineno=18, + end_col_offset=30), + ClassDef( + 'CircularBuffer', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + arg( + 'capacity', + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12), + 'buffer', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=19)], + Call( + Name( + 'bytearray', + Load(), + lineno=24, + col_offset=22, + end_lineno=24, + end_col_offset=31), + [ + Name( + 'capacity', + Load(), + lineno=24, + col_offset=32, + end_lineno=24, + end_col_offset=40)], + [], + lineno=24, + col_offset=22, + end_lineno=24, + end_col_offset=41), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=41), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=12), + 'read_point', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=23)], + Constant( + 0, + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=27), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=12), + 'write_point', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=24)], + Constant( + 0, + lineno=26, + col_offset=27, + end_lineno=26, + end_col_offset=28), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=28)], + [], + lineno=23, + col_offset=4, + end_lineno=26, + end_col_offset=28), + FunctionDef( + '_update_buffer', + arguments( + [], + [ + arg( + 'self', + lineno=29, + col_offset=23, + end_lineno=29, + end_col_offset=27), + arg( + 'data', + lineno=29, + col_offset=29, + end_lineno=29, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=16), + 'buffer', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=23), + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=28), + 'write_point', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=40), + Store(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=41)], + Name( + 'data', + Load(), + lineno=31, + col_offset=44, + end_lineno=31, + end_col_offset=48), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=48)], + [ + ExceptHandler( + Name( + 'TypeError', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=24), + body=[ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=16), + 'buffer', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=23), + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=28), + 'write_point', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=40), + Store(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=41)], + Call( + Name( + 'ord', + Load(), + lineno=33, + col_offset=44, + end_lineno=33, + end_col_offset=47), + [ + Name( + 'data', + Load(), + lineno=33, + col_offset=48, + end_lineno=33, + end_col_offset=52)], + [], + lineno=33, + col_offset=44, + end_lineno=33, + end_col_offset=53), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=53)], + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=53)], + [], + [], + lineno=30, + col_offset=8, + end_lineno=33, + end_col_offset=53)], + [], + lineno=29, + col_offset=4, + end_lineno=33, + end_col_offset=53), + FunctionDef( + 'clear', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=14, + end_lineno=35, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=12), + 'buffer', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=19)], + Call( + Name( + 'bytearray', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=31), + [ + Call( + Name( + 'len', + Load(), + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=35), + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=36, + end_lineno=36, + end_col_offset=40), + 'buffer', + Load(), + lineno=36, + col_offset=36, + end_lineno=36, + end_col_offset=47)], + [], + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=48)], + [], + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=49), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=49)], + [], + lineno=35, + col_offset=4, + end_lineno=36, + end_col_offset=49), + FunctionDef( + 'write', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=14, + end_lineno=38, + end_col_offset=18), + arg( + 'data', + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Call( + Name( + 'all', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=14), + [ + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=19), + 'buffer', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=26)], + [], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'BufferFullException', + Load(), + lineno=40, + col_offset=18, + end_lineno=40, + end_col_offset=37), + [ + Constant( + 'Circular buffer is full', + lineno=40, + col_offset=38, + end_lineno=40, + end_col_offset=63)], + [], + lineno=40, + col_offset=18, + end_lineno=40, + end_col_offset=64), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=64)], + [], + lineno=39, + col_offset=8, + end_lineno=40, + end_col_offset=64), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=12), + '_update_buffer', + Load(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=27), + [ + Name( + 'data', + Load(), + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=32)], + [], + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=33), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=33), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=12), + 'write_point', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=24)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=28, + end_lineno=42, + end_col_offset=32), + 'write_point', + Load(), + lineno=42, + col_offset=28, + end_lineno=42, + end_col_offset=44), + Add(), + Constant( + 1, + lineno=42, + col_offset=47, + end_lineno=42, + end_col_offset=48), + lineno=42, + col_offset=28, + end_lineno=42, + end_col_offset=48), + Mod(), + Call( + Name( + 'len', + Load(), + lineno=42, + col_offset=52, + end_lineno=42, + end_col_offset=55), + [ + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=56, + end_lineno=42, + end_col_offset=60), + 'buffer', + Load(), + lineno=42, + col_offset=56, + end_lineno=42, + end_col_offset=67)], + [], + lineno=42, + col_offset=52, + end_lineno=42, + end_col_offset=68), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=68), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=68)], + [], + lineno=38, + col_offset=4, + end_lineno=42, + end_col_offset=68), + FunctionDef( + 'overwrite', + arguments( + [], + [ + arg( + 'self', + lineno=44, + col_offset=18, + end_lineno=44, + end_col_offset=22), + arg( + 'data', + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=12), + '_update_buffer', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=27), + [ + Name( + 'data', + Load(), + lineno=45, + col_offset=28, + end_lineno=45, + end_col_offset=32)], + [], + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=33), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=33), + If( + BoolOp( + And(), + [ + Call( + Name( + 'all', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=14), + [ + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19), + 'buffer', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=26)], + [], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=27), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=36), + 'write_point', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=48), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=52, + end_lineno=46, + end_col_offset=56), + 'read_point', + Load(), + lineno=46, + col_offset=52, + end_lineno=46, + end_col_offset=67)], + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=67)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=67), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=16), + 'read_point', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=27)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=31, + end_lineno=47, + end_col_offset=35), + 'read_point', + Load(), + lineno=47, + col_offset=31, + end_lineno=47, + end_col_offset=46), + Add(), + Constant( + 1, + lineno=47, + col_offset=49, + end_lineno=47, + end_col_offset=50), + lineno=47, + col_offset=31, + end_lineno=47, + end_col_offset=50), + Mod(), + Call( + Name( + 'len', + Load(), + lineno=47, + col_offset=54, + end_lineno=47, + end_col_offset=57), + [ + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=58, + end_lineno=47, + end_col_offset=62), + 'buffer', + Load(), + lineno=47, + col_offset=58, + end_lineno=47, + end_col_offset=69)], + [], + lineno=47, + col_offset=54, + end_lineno=47, + end_col_offset=70), + lineno=47, + col_offset=30, + end_lineno=47, + end_col_offset=70), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=70)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=70), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=12), + 'write_point', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=24)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=28, + end_lineno=48, + end_col_offset=32), + 'write_point', + Load(), + lineno=48, + col_offset=28, + end_lineno=48, + end_col_offset=44), + Add(), + Constant( + 1, + lineno=48, + col_offset=47, + end_lineno=48, + end_col_offset=48), + lineno=48, + col_offset=28, + end_lineno=48, + end_col_offset=48), + Mod(), + Call( + Name( + 'len', + Load(), + lineno=48, + col_offset=52, + end_lineno=48, + end_col_offset=55), + [ + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=56, + end_lineno=48, + end_col_offset=60), + 'buffer', + Load(), + lineno=48, + col_offset=56, + end_lineno=48, + end_col_offset=67)], + [], + lineno=48, + col_offset=52, + end_lineno=48, + end_col_offset=68), + lineno=48, + col_offset=27, + end_lineno=48, + end_col_offset=68), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=68)], + [], + lineno=44, + col_offset=4, + end_lineno=48, + end_col_offset=68), + FunctionDef( + 'read', + arguments( + [], + [ + arg( + 'self', + lineno=50, + col_offset=13, + end_lineno=50, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'any', + Load(), + lineno=51, + col_offset=15, + end_lineno=51, + end_col_offset=18), + [ + Attribute( + Name( + 'self', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=23), + 'buffer', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=30)], + [], + lineno=51, + col_offset=15, + end_lineno=51, + end_col_offset=31), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'BufferEmptyException', + Load(), + lineno=52, + col_offset=18, + end_lineno=52, + end_col_offset=38), + [ + Constant( + 'Circular buffer is empty', + lineno=52, + col_offset=39, + end_lineno=52, + end_col_offset=65)], + [], + lineno=52, + col_offset=18, + end_lineno=52, + end_col_offset=66), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=66)], + [], + lineno=51, + col_offset=8, + end_lineno=52, + end_col_offset=66), + Assign( + [ + Name( + 'data', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=12)], + Call( + Name( + 'chr', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=18), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=23), + 'buffer', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=30), + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=31, + end_lineno=53, + end_col_offset=35), + 'read_point', + Load(), + lineno=53, + col_offset=31, + end_lineno=53, + end_col_offset=46), + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=47)], + [], + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=48), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=48), + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=12), + 'buffer', + Load(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=19), + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=20, + end_lineno=54, + end_col_offset=24), + 'read_point', + Load(), + lineno=54, + col_offset=20, + end_lineno=54, + end_col_offset=35), + Store(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=36)], + Constant( + 0, + lineno=54, + col_offset=39, + end_lineno=54, + end_col_offset=40), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=12), + 'read_point', + Store(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=23)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=31), + 'read_point', + Load(), + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=42), + Add(), + Constant( + 1, + lineno=55, + col_offset=45, + end_lineno=55, + end_col_offset=46), + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=46), + Mod(), + Call( + Name( + 'len', + Load(), + lineno=55, + col_offset=50, + end_lineno=55, + end_col_offset=53), + [ + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=54, + end_lineno=55, + end_col_offset=58), + 'buffer', + Load(), + lineno=55, + col_offset=54, + end_lineno=55, + end_col_offset=65)], + [], + lineno=55, + col_offset=50, + end_lineno=55, + end_col_offset=66), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=66), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=66), + Return( + Name( + 'data', + Load(), + lineno=56, + col_offset=15, + end_lineno=56, + end_col_offset=19), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=19)], + [], + lineno=50, + col_offset=4, + end_lineno=56, + end_col_offset=19)], + [], + lineno=21, + col_offset=0, + end_lineno=56, + end_col_offset=19)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [ + Name( + 'BufferError', + Load(), + lineno=1, + col_offset=26, + end_lineno=1, + end_col_offset=37)], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=20)], + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=30), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=30)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=30)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=30), + ClassDef( + 'placeholder_3', + [ + Name( + 'BufferError', + Load(), + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=38)], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=20)], + Name( + 'placeholder_2', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=30), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=30)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=30)], + [], + lineno=11, + col_offset=0, + end_lineno=18, + end_col_offset=30), + ClassDef( + 'placeholder_4', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + arg( + 'placeholder_5', + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=19)], + Call( + Name( + 'bytearray', + Load(), + lineno=24, + col_offset=22, + end_lineno=24, + end_col_offset=31), + [ + Name( + 'placeholder_5', + Load(), + lineno=24, + col_offset=32, + end_lineno=24, + end_col_offset=40)], + [], + lineno=24, + col_offset=22, + end_lineno=24, + end_col_offset=41), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=41), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=23)], + Constant( + 0, + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=27), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=24)], + Constant( + 0, + lineno=26, + col_offset=27, + end_lineno=26, + end_col_offset=28), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=28)], + [], + lineno=23, + col_offset=4, + end_lineno=26, + end_col_offset=28), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=29, + col_offset=23, + end_lineno=29, + end_col_offset=27), + arg( + 'placeholder_10', + lineno=29, + col_offset=29, + end_lineno=29, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=16), + 'placeholder_6', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=23), + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=28), + 'placeholder_8', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=40), + Store(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=41)], + Name( + 'placeholder_10', + Load(), + lineno=31, + col_offset=44, + end_lineno=31, + end_col_offset=48), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=48)], + [ + ExceptHandler( + Name( + 'TypeError', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=24), + body=[ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=16), + 'placeholder_6', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=23), + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=28), + 'placeholder_8', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=40), + Store(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=41)], + Call( + Name( + 'ord', + Load(), + lineno=33, + col_offset=44, + end_lineno=33, + end_col_offset=47), + [ + Name( + 'placeholder_10', + Load(), + lineno=33, + col_offset=48, + end_lineno=33, + end_col_offset=52)], + [], + lineno=33, + col_offset=44, + end_lineno=33, + end_col_offset=53), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=53)], + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=53)], + [], + [], + lineno=30, + col_offset=8, + end_lineno=33, + end_col_offset=53)], + [], + lineno=29, + col_offset=4, + end_lineno=33, + end_col_offset=53), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=14, + end_lineno=35, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=19)], + Call( + Name( + 'bytearray', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=31), + [ + Call( + Name( + 'len', + Load(), + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=35), + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=36, + end_lineno=36, + end_col_offset=40), + 'placeholder_6', + Load(), + lineno=36, + col_offset=36, + end_lineno=36, + end_col_offset=47)], + [], + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=48)], + [], + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=49), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=49)], + [], + lineno=35, + col_offset=4, + end_lineno=36, + end_col_offset=49), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=14, + end_lineno=38, + end_col_offset=18), + arg( + 'placeholder_10', + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Call( + Name( + 'all', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=14), + [ + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=19), + 'placeholder_6', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=26)], + [], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'placeholder_0', + Load(), + lineno=40, + col_offset=18, + end_lineno=40, + end_col_offset=37), + [ + Constant( + 'Circular buffer is full', + lineno=40, + col_offset=38, + end_lineno=40, + end_col_offset=63)], + [], + lineno=40, + col_offset=18, + end_lineno=40, + end_col_offset=64), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=64)], + [], + lineno=39, + col_offset=8, + end_lineno=40, + end_col_offset=64), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=12), + 'placeholder_9', + Load(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=27), + [ + Name( + 'placeholder_10', + Load(), + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=32)], + [], + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=33), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=33), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=24)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=28, + end_lineno=42, + end_col_offset=32), + 'placeholder_8', + Load(), + lineno=42, + col_offset=28, + end_lineno=42, + end_col_offset=44), + Add(), + Constant( + 1, + lineno=42, + col_offset=47, + end_lineno=42, + end_col_offset=48), + lineno=42, + col_offset=28, + end_lineno=42, + end_col_offset=48), + Mod(), + Call( + Name( + 'len', + Load(), + lineno=42, + col_offset=52, + end_lineno=42, + end_col_offset=55), + [ + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=56, + end_lineno=42, + end_col_offset=60), + 'placeholder_6', + Load(), + lineno=42, + col_offset=56, + end_lineno=42, + end_col_offset=67)], + [], + lineno=42, + col_offset=52, + end_lineno=42, + end_col_offset=68), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=68), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=68)], + [], + lineno=38, + col_offset=4, + end_lineno=42, + end_col_offset=68), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=44, + col_offset=18, + end_lineno=44, + end_col_offset=22), + arg( + 'placeholder_10', + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=12), + 'placeholder_9', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=27), + [ + Name( + 'placeholder_10', + Load(), + lineno=45, + col_offset=28, + end_lineno=45, + end_col_offset=32)], + [], + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=33), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=33), + If( + BoolOp( + And(), + [ + Call( + Name( + 'all', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=14), + [ + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19), + 'placeholder_6', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=26)], + [], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=27), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=36), + 'placeholder_8', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=48), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=52, + end_lineno=46, + end_col_offset=56), + 'placeholder_7', + Load(), + lineno=46, + col_offset=52, + end_lineno=46, + end_col_offset=67)], + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=67)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=67), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=27)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=31, + end_lineno=47, + end_col_offset=35), + 'placeholder_7', + Load(), + lineno=47, + col_offset=31, + end_lineno=47, + end_col_offset=46), + Add(), + Constant( + 1, + lineno=47, + col_offset=49, + end_lineno=47, + end_col_offset=50), + lineno=47, + col_offset=31, + end_lineno=47, + end_col_offset=50), + Mod(), + Call( + Name( + 'len', + Load(), + lineno=47, + col_offset=54, + end_lineno=47, + end_col_offset=57), + [ + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=58, + end_lineno=47, + end_col_offset=62), + 'placeholder_6', + Load(), + lineno=47, + col_offset=58, + end_lineno=47, + end_col_offset=69)], + [], + lineno=47, + col_offset=54, + end_lineno=47, + end_col_offset=70), + lineno=47, + col_offset=30, + end_lineno=47, + end_col_offset=70), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=70)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=70), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=24)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=28, + end_lineno=48, + end_col_offset=32), + 'placeholder_8', + Load(), + lineno=48, + col_offset=28, + end_lineno=48, + end_col_offset=44), + Add(), + Constant( + 1, + lineno=48, + col_offset=47, + end_lineno=48, + end_col_offset=48), + lineno=48, + col_offset=28, + end_lineno=48, + end_col_offset=48), + Mod(), + Call( + Name( + 'len', + Load(), + lineno=48, + col_offset=52, + end_lineno=48, + end_col_offset=55), + [ + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=56, + end_lineno=48, + end_col_offset=60), + 'placeholder_6', + Load(), + lineno=48, + col_offset=56, + end_lineno=48, + end_col_offset=67)], + [], + lineno=48, + col_offset=52, + end_lineno=48, + end_col_offset=68), + lineno=48, + col_offset=27, + end_lineno=48, + end_col_offset=68), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=68)], + [], + lineno=44, + col_offset=4, + end_lineno=48, + end_col_offset=68), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'self', + lineno=50, + col_offset=13, + end_lineno=50, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'any', + Load(), + lineno=51, + col_offset=15, + end_lineno=51, + end_col_offset=18), + [ + Attribute( + Name( + 'self', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=23), + 'placeholder_6', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=30)], + [], + lineno=51, + col_offset=15, + end_lineno=51, + end_col_offset=31), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'placeholder_3', + Load(), + lineno=52, + col_offset=18, + end_lineno=52, + end_col_offset=38), + [ + Constant( + 'Circular buffer is empty', + lineno=52, + col_offset=39, + end_lineno=52, + end_col_offset=65)], + [], + lineno=52, + col_offset=18, + end_lineno=52, + end_col_offset=66), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=66)], + [], + lineno=51, + col_offset=8, + end_lineno=52, + end_col_offset=66), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=12)], + Call( + Name( + 'chr', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=18), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=23), + 'placeholder_6', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=30), + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=31, + end_lineno=53, + end_col_offset=35), + 'placeholder_7', + Load(), + lineno=53, + col_offset=31, + end_lineno=53, + end_col_offset=46), + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=47)], + [], + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=48), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=48), + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=12), + 'placeholder_6', + Load(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=19), + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=20, + end_lineno=54, + end_col_offset=24), + 'placeholder_7', + Load(), + lineno=54, + col_offset=20, + end_lineno=54, + end_col_offset=35), + Store(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=36)], + Constant( + 0, + lineno=54, + col_offset=39, + end_lineno=54, + end_col_offset=40), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=23)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=31), + 'placeholder_7', + Load(), + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=42), + Add(), + Constant( + 1, + lineno=55, + col_offset=45, + end_lineno=55, + end_col_offset=46), + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=46), + Mod(), + Call( + Name( + 'len', + Load(), + lineno=55, + col_offset=50, + end_lineno=55, + end_col_offset=53), + [ + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=54, + end_lineno=55, + end_col_offset=58), + 'placeholder_6', + Load(), + lineno=55, + col_offset=54, + end_lineno=55, + end_col_offset=65)], + [], + lineno=55, + col_offset=50, + end_lineno=55, + end_col_offset=66), + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=66), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=66), + Return( + Name( + 'placeholder_10', + Load(), + lineno=56, + col_offset=15, + end_lineno=56, + end_col_offset=19), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=19)], + [], + lineno=50, + col_offset=4, + end_lineno=56, + end_col_offset=19)], + [], + lineno=21, + col_offset=0, + end_lineno=56, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-circular-buffer/representation.txt b/test/practice-circular-buffer/representation.txt new file mode 100644 index 0000000..b3d15e2 --- /dev/null +++ b/test/practice-circular-buffer/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [Name('BufferError', Load(), lineno=1, col_offset=26, end_lineno=1, end_col_offset=37)], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=7, col_offset=17, end_lineno=7, end_col_offset=21), arg('placeholder_2', lineno=7, col_offset=23, end_lineno=7, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_2', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=20)], Name('placeholder_2', Load(), lineno=8, col_offset=23, end_lineno=8, end_col_offset=30), lineno=8, col_offset=8, end_lineno=8, end_col_offset=30)], [], lineno=7, col_offset=4, end_lineno=8, end_col_offset=30)], [], lineno=1, col_offset=0, end_lineno=8, end_col_offset=30), ClassDef('placeholder_3', [Name('BufferError', Load(), lineno=11, col_offset=27, end_lineno=11, end_col_offset=38)], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=17, col_offset=17, end_lineno=17, end_col_offset=21), arg('placeholder_2', lineno=17, col_offset=23, end_lineno=17, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=18, col_offset=8, end_lineno=18, end_col_offset=12), 'placeholder_2', Store(), lineno=18, col_offset=8, end_lineno=18, end_col_offset=20)], Name('placeholder_2', Load(), lineno=18, col_offset=23, end_lineno=18, end_col_offset=30), lineno=18, col_offset=8, end_lineno=18, end_col_offset=30)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=30)], [], lineno=11, col_offset=0, end_lineno=18, end_col_offset=30), ClassDef('placeholder_4', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=23, col_offset=17, end_lineno=23, end_col_offset=21), arg('placeholder_5', lineno=23, col_offset=23, end_lineno=23, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=12), 'placeholder_6', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=19)], Call(Name('bytearray', Load(), lineno=24, col_offset=22, end_lineno=24, end_col_offset=31), [Name('placeholder_5', Load(), lineno=24, col_offset=32, end_lineno=24, end_col_offset=40)], [], lineno=24, col_offset=22, end_lineno=24, end_col_offset=41), lineno=24, col_offset=8, end_lineno=24, end_col_offset=41), Assign([Attribute(Name('self', Load(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=12), 'placeholder_7', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=23)], Constant(0, lineno=25, col_offset=26, end_lineno=25, end_col_offset=27), lineno=25, col_offset=8, end_lineno=25, end_col_offset=27), Assign([Attribute(Name('self', Load(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=12), 'placeholder_8', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=24)], Constant(0, lineno=26, col_offset=27, end_lineno=26, end_col_offset=28), lineno=26, col_offset=8, end_lineno=26, end_col_offset=28)], [], lineno=23, col_offset=4, end_lineno=26, end_col_offset=28), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=29, col_offset=23, end_lineno=29, end_col_offset=27), arg('placeholder_10', lineno=29, col_offset=29, end_lineno=29, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Try([Assign([Subscript(Attribute(Name('self', Load(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=16), 'placeholder_6', Load(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=23), Attribute(Name('self', Load(), lineno=31, col_offset=24, end_lineno=31, end_col_offset=28), 'placeholder_8', Load(), lineno=31, col_offset=24, end_lineno=31, end_col_offset=40), Store(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=41)], Name('placeholder_10', Load(), lineno=31, col_offset=44, end_lineno=31, end_col_offset=48), lineno=31, col_offset=12, end_lineno=31, end_col_offset=48)], [ExceptHandler(Name('TypeError', Load(), lineno=32, col_offset=15, end_lineno=32, end_col_offset=24), body=[Assign([Subscript(Attribute(Name('self', Load(), lineno=33, col_offset=12, end_lineno=33, end_col_offset=16), 'placeholder_6', Load(), lineno=33, col_offset=12, end_lineno=33, end_col_offset=23), Attribute(Name('self', Load(), lineno=33, col_offset=24, end_lineno=33, end_col_offset=28), 'placeholder_8', Load(), lineno=33, col_offset=24, end_lineno=33, end_col_offset=40), Store(), lineno=33, col_offset=12, end_lineno=33, end_col_offset=41)], Call(Name('ord', Load(), lineno=33, col_offset=44, end_lineno=33, end_col_offset=47), [Name('placeholder_10', Load(), lineno=33, col_offset=48, end_lineno=33, end_col_offset=52)], [], lineno=33, col_offset=44, end_lineno=33, end_col_offset=53), lineno=33, col_offset=12, end_lineno=33, end_col_offset=53)], lineno=32, col_offset=8, end_lineno=33, end_col_offset=53)], [], [], lineno=30, col_offset=8, end_lineno=33, end_col_offset=53)], [], lineno=29, col_offset=4, end_lineno=33, end_col_offset=53), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=35, col_offset=14, end_lineno=35, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=36, col_offset=8, end_lineno=36, end_col_offset=12), 'placeholder_6', Store(), lineno=36, col_offset=8, end_lineno=36, end_col_offset=19)], Call(Name('bytearray', Load(), lineno=36, col_offset=22, end_lineno=36, end_col_offset=31), [Call(Name('len', Load(), lineno=36, col_offset=32, end_lineno=36, end_col_offset=35), [Attribute(Name('self', Load(), lineno=36, col_offset=36, end_lineno=36, end_col_offset=40), 'placeholder_6', Load(), lineno=36, col_offset=36, end_lineno=36, end_col_offset=47)], [], lineno=36, col_offset=32, end_lineno=36, end_col_offset=48)], [], lineno=36, col_offset=22, end_lineno=36, end_col_offset=49), lineno=36, col_offset=8, end_lineno=36, end_col_offset=49)], [], lineno=35, col_offset=4, end_lineno=36, end_col_offset=49), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=38, col_offset=14, end_lineno=38, end_col_offset=18), arg('placeholder_10', lineno=38, col_offset=20, end_lineno=38, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Call(Name('all', Load(), lineno=39, col_offset=11, end_lineno=39, end_col_offset=14), [Attribute(Name('self', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=19), 'placeholder_6', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=26)], [], lineno=39, col_offset=11, end_lineno=39, end_col_offset=27), [Raise(Call(Name('placeholder_0', Load(), lineno=40, col_offset=18, end_lineno=40, end_col_offset=37), [Constant('Circular buffer is full', lineno=40, col_offset=38, end_lineno=40, end_col_offset=63)], [], lineno=40, col_offset=18, end_lineno=40, end_col_offset=64), lineno=40, col_offset=12, end_lineno=40, end_col_offset=64)], [], lineno=39, col_offset=8, end_lineno=40, end_col_offset=64), Expr(Call(Attribute(Name('self', Load(), lineno=41, col_offset=8, end_lineno=41, end_col_offset=12), 'placeholder_9', Load(), lineno=41, col_offset=8, end_lineno=41, end_col_offset=27), [Name('placeholder_10', Load(), lineno=41, col_offset=28, end_lineno=41, end_col_offset=32)], [], lineno=41, col_offset=8, end_lineno=41, end_col_offset=33), lineno=41, col_offset=8, end_lineno=41, end_col_offset=33), Assign([Attribute(Name('self', Load(), lineno=42, col_offset=8, end_lineno=42, end_col_offset=12), 'placeholder_8', Store(), lineno=42, col_offset=8, end_lineno=42, end_col_offset=24)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=42, col_offset=28, end_lineno=42, end_col_offset=32), 'placeholder_8', Load(), lineno=42, col_offset=28, end_lineno=42, end_col_offset=44), Add(), Constant(1, lineno=42, col_offset=47, end_lineno=42, end_col_offset=48), lineno=42, col_offset=28, end_lineno=42, end_col_offset=48), Mod(), Call(Name('len', Load(), lineno=42, col_offset=52, end_lineno=42, end_col_offset=55), [Attribute(Name('self', Load(), lineno=42, col_offset=56, end_lineno=42, end_col_offset=60), 'placeholder_6', Load(), lineno=42, col_offset=56, end_lineno=42, end_col_offset=67)], [], lineno=42, col_offset=52, end_lineno=42, end_col_offset=68), lineno=42, col_offset=27, end_lineno=42, end_col_offset=68), lineno=42, col_offset=8, end_lineno=42, end_col_offset=68)], [], lineno=38, col_offset=4, end_lineno=42, end_col_offset=68), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=44, col_offset=18, end_lineno=44, end_col_offset=22), arg('placeholder_10', lineno=44, col_offset=24, end_lineno=44, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Name('self', Load(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=12), 'placeholder_9', Load(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=27), [Name('placeholder_10', Load(), lineno=45, col_offset=28, end_lineno=45, end_col_offset=32)], [], lineno=45, col_offset=8, end_lineno=45, end_col_offset=33), lineno=45, col_offset=8, end_lineno=45, end_col_offset=33), If(BoolOp(And(), [Call(Name('all', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=14), [Attribute(Name('self', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=19), 'placeholder_6', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=26)], [], lineno=46, col_offset=11, end_lineno=46, end_col_offset=27), Compare(Attribute(Name('self', Load(), lineno=46, col_offset=32, end_lineno=46, end_col_offset=36), 'placeholder_8', Load(), lineno=46, col_offset=32, end_lineno=46, end_col_offset=48), [Eq()], [Attribute(Name('self', Load(), lineno=46, col_offset=52, end_lineno=46, end_col_offset=56), 'placeholder_7', Load(), lineno=46, col_offset=52, end_lineno=46, end_col_offset=67)], lineno=46, col_offset=32, end_lineno=46, end_col_offset=67)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=67), [Assign([Attribute(Name('self', Load(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=16), 'placeholder_7', Store(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=27)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=47, col_offset=31, end_lineno=47, end_col_offset=35), 'placeholder_7', Load(), lineno=47, col_offset=31, end_lineno=47, end_col_offset=46), Add(), Constant(1, lineno=47, col_offset=49, end_lineno=47, end_col_offset=50), lineno=47, col_offset=31, end_lineno=47, end_col_offset=50), Mod(), Call(Name('len', Load(), lineno=47, col_offset=54, end_lineno=47, end_col_offset=57), [Attribute(Name('self', Load(), lineno=47, col_offset=58, end_lineno=47, end_col_offset=62), 'placeholder_6', Load(), lineno=47, col_offset=58, end_lineno=47, end_col_offset=69)], [], lineno=47, col_offset=54, end_lineno=47, end_col_offset=70), lineno=47, col_offset=30, end_lineno=47, end_col_offset=70), lineno=47, col_offset=12, end_lineno=47, end_col_offset=70)], [], lineno=46, col_offset=8, end_lineno=47, end_col_offset=70), Assign([Attribute(Name('self', Load(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=12), 'placeholder_8', Store(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=24)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=48, col_offset=28, end_lineno=48, end_col_offset=32), 'placeholder_8', Load(), lineno=48, col_offset=28, end_lineno=48, end_col_offset=44), Add(), Constant(1, lineno=48, col_offset=47, end_lineno=48, end_col_offset=48), lineno=48, col_offset=28, end_lineno=48, end_col_offset=48), Mod(), Call(Name('len', Load(), lineno=48, col_offset=52, end_lineno=48, end_col_offset=55), [Attribute(Name('self', Load(), lineno=48, col_offset=56, end_lineno=48, end_col_offset=60), 'placeholder_6', Load(), lineno=48, col_offset=56, end_lineno=48, end_col_offset=67)], [], lineno=48, col_offset=52, end_lineno=48, end_col_offset=68), lineno=48, col_offset=27, end_lineno=48, end_col_offset=68), lineno=48, col_offset=8, end_lineno=48, end_col_offset=68)], [], lineno=44, col_offset=4, end_lineno=48, end_col_offset=68), FunctionDef('placeholder_14', arguments([], [arg('self', lineno=50, col_offset=13, end_lineno=50, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('any', Load(), lineno=51, col_offset=15, end_lineno=51, end_col_offset=18), [Attribute(Name('self', Load(), lineno=51, col_offset=19, end_lineno=51, end_col_offset=23), 'placeholder_6', Load(), lineno=51, col_offset=19, end_lineno=51, end_col_offset=30)], [], lineno=51, col_offset=15, end_lineno=51, end_col_offset=31), lineno=51, col_offset=11, end_lineno=51, end_col_offset=31), [Raise(Call(Name('placeholder_3', Load(), lineno=52, col_offset=18, end_lineno=52, end_col_offset=38), [Constant('Circular buffer is empty', lineno=52, col_offset=39, end_lineno=52, end_col_offset=65)], [], lineno=52, col_offset=18, end_lineno=52, end_col_offset=66), lineno=52, col_offset=12, end_lineno=52, end_col_offset=66)], [], lineno=51, col_offset=8, end_lineno=52, end_col_offset=66), Assign([Name('placeholder_10', Store(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=12)], Call(Name('chr', Load(), lineno=53, col_offset=15, end_lineno=53, end_col_offset=18), [Subscript(Attribute(Name('self', Load(), lineno=53, col_offset=19, end_lineno=53, end_col_offset=23), 'placeholder_6', Load(), lineno=53, col_offset=19, end_lineno=53, end_col_offset=30), Attribute(Name('self', Load(), lineno=53, col_offset=31, end_lineno=53, end_col_offset=35), 'placeholder_7', Load(), lineno=53, col_offset=31, end_lineno=53, end_col_offset=46), Load(), lineno=53, col_offset=19, end_lineno=53, end_col_offset=47)], [], lineno=53, col_offset=15, end_lineno=53, end_col_offset=48), lineno=53, col_offset=8, end_lineno=53, end_col_offset=48), Assign([Subscript(Attribute(Name('self', Load(), lineno=54, col_offset=8, end_lineno=54, end_col_offset=12), 'placeholder_6', Load(), lineno=54, col_offset=8, end_lineno=54, end_col_offset=19), Attribute(Name('self', Load(), lineno=54, col_offset=20, end_lineno=54, end_col_offset=24), 'placeholder_7', Load(), lineno=54, col_offset=20, end_lineno=54, end_col_offset=35), Store(), lineno=54, col_offset=8, end_lineno=54, end_col_offset=36)], Constant(0, lineno=54, col_offset=39, end_lineno=54, end_col_offset=40), lineno=54, col_offset=8, end_lineno=54, end_col_offset=40), Assign([Attribute(Name('self', Load(), lineno=55, col_offset=8, end_lineno=55, end_col_offset=12), 'placeholder_7', Store(), lineno=55, col_offset=8, end_lineno=55, end_col_offset=23)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=55, col_offset=27, end_lineno=55, end_col_offset=31), 'placeholder_7', Load(), lineno=55, col_offset=27, end_lineno=55, end_col_offset=42), Add(), Constant(1, lineno=55, col_offset=45, end_lineno=55, end_col_offset=46), lineno=55, col_offset=27, end_lineno=55, end_col_offset=46), Mod(), Call(Name('len', Load(), lineno=55, col_offset=50, end_lineno=55, end_col_offset=53), [Attribute(Name('self', Load(), lineno=55, col_offset=54, end_lineno=55, end_col_offset=58), 'placeholder_6', Load(), lineno=55, col_offset=54, end_lineno=55, end_col_offset=65)], [], lineno=55, col_offset=50, end_lineno=55, end_col_offset=66), lineno=55, col_offset=26, end_lineno=55, end_col_offset=66), lineno=55, col_offset=8, end_lineno=55, end_col_offset=66), Return(Name('placeholder_10', Load(), lineno=56, col_offset=15, end_lineno=56, end_col_offset=19), lineno=56, col_offset=8, end_lineno=56, end_col_offset=19)], [], lineno=50, col_offset=4, end_lineno=56, end_col_offset=19)], [], lineno=21, col_offset=0, end_lineno=56, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/practice-clock/.meta/additional_tests.json b/test/practice-clock/.meta/additional_tests.json new file mode 100644 index 0000000..ba0c72b --- /dev/null +++ b/test/practice-clock/.meta/additional_tests.json @@ -0,0 +1,39 @@ +{ + "cases": [ + { + "description": "Create a string representation", + "cases": [ + { + "uuid": "d2c8f173-018d-488c-8c4c-009f8c772313", + "description": "lunch time", + "property": "repr", + "input": { + "hour": 12, + "minute": 0 + }, + "expected": "Clock(12, 0)" + }, + { + "uuid": "61a68f88-b980-46cd-a9f5-844832618092", + "description": "breakfast time", + "property": "repr", + "input": { + "hour": 6, + "minute": 45 + }, + "expected": "Clock(6, 45)" + }, + { + "uuid": "ea93b367-fb03-44e4-a845-51756b8c9f3a", + "description": "dinner time", + "property": "repr", + "input": { + "hour": 18, + "minute": 30 + }, + "expected": "Clock(18, 30)" + } + ] + } + ] +} diff --git a/test/practice-clock/.meta/config.json b/test/practice-clock/.meta/config.json new file mode 100644 index 0000000..b56a4bd --- /dev/null +++ b/test/practice-clock/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [ + "chrisftw" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "GascaK", + "guaneec", + "ikhadykin", + "Mofeywalker", + "N-Parsons", + "pheanex", + "rootulp", + "smalley", + "thomasjpfan", + "tqa236", + "chrismay" + ], + "files": { + "solution": [ + "clock.py" + ], + "test": [ + "clock_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement a clock that handles times without dates.", + "source": "Pairing session with Erin Drummond" +} diff --git a/test/practice-clock/clock.py b/test/practice-clock/clock.py new file mode 100644 index 0000000..47d5268 --- /dev/null +++ b/test/practice-clock/clock.py @@ -0,0 +1,30 @@ +class Clock: + """Clock that displays 24 hour clock that rollsover properly""" + + def __init__(self, hour, minute): + self.hour = hour + self.minute = minute + self.cleanup() + + def __repr__(self): + return f'Clock({self.hour}, {self.minute})' + + def __str__(self): + return '{:02d}:{:02d}'.format(self.hour, self.minute) + + def __eq__(self, other): + return repr(self) == repr(other) + + def __add__(self, minutes): + self.minute += minutes + return self.cleanup() + + def __sub__(self, minutes): + self.minute -= minutes + return self.cleanup() + + def cleanup(self): + self.hour += self.minute // 60 + self.hour %= 24 + self.minute %= 60 + return self diff --git a/test/practice-clock/mapping.json b/test/practice-clock/mapping.json new file mode 100644 index 0000000..ea8a694 --- /dev/null +++ b/test/practice-clock/mapping.json @@ -0,0 +1,14 @@ +{ + "placeholder_0": "Clock", + "placeholder_1": "__init__", + "placeholder_2": "hour", + "placeholder_3": "minute", + "placeholder_4": "__repr__", + "placeholder_5": "__str__", + "placeholder_6": "__eq__", + "placeholder_7": "other", + "placeholder_8": "__add__", + "placeholder_9": "minutes", + "placeholder_10": "__sub__", + "placeholder_11": "cleanup" +} \ No newline at end of file diff --git a/test/practice-clock/representation.json b/test/practice-clock/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-clock/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-clock/representation.out b/test/practice-clock/representation.out new file mode 100644 index 0000000..02e3816 --- /dev/null +++ b/test/practice-clock/representation.out @@ -0,0 +1,1360 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 + self.cleanup() + + def placeholder_4(self): + return f"Clock({self.placeholder_2}, {self.placeholder_3})" + + def placeholder_5(self): + return "{:02d}:{:02d}".format(self.placeholder_2, self.placeholder_3) + + def placeholder_6(self, placeholder_7): + return repr(self) == repr(placeholder_7) + + def placeholder_8(self, placeholder_9): + self.placeholder_3 += placeholder_9 + return self.cleanup() + + def placeholder_10(self, placeholder_9): + self.placeholder_3 -= placeholder_9 + return self.cleanup() + + def placeholder_11(self): + self.placeholder_2 += self.placeholder_3 // 60 + self.placeholder_2 %= 24 + self.placeholder_3 %= 60 + return self + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Clock', + [], + [], + [ + Expr( + Constant( + 'Clock that displays 24 hour clock that rollsover properly', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=67), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=67), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=21), + arg( + 'hour', + lineno=4, + col_offset=23, + end_lineno=4, + end_col_offset=27), + arg( + 'minute', + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'hour', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17)], + Name( + 'hour', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=24), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'minute', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=19)], + Name( + 'minute', + Load(), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=28), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'cleanup', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=20), + [], + [], + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=22), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=22)], + [], + lineno=4, + col_offset=4, + end_lineno=7, + end_col_offset=22), + FunctionDef( + '__repr__', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + Constant( + 'Clock(', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=28), + 'hour', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=33), + -1, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + Constant( + ', ', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=41), + 'minute', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=48), + -1, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + Constant( + ')', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=51)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=51), + FunctionDef( + '__str__', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '{:02d}:{:02d}', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=30), + 'format', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=37), + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=42), + 'hour', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=47), + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=53), + 'minute', + Load(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=60)], + [], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=61), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=61)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=61), + FunctionDef( + '__eq__', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + arg( + 'other', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'repr', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + [ + Name( + 'self', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=24)], + [], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=25), + [ + Eq()], + [ + Call( + Name( + 'repr', + Load(), + lineno=16, + col_offset=29, + end_lineno=16, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=39)], + [], + lineno=16, + col_offset=29, + end_lineno=16, + end_col_offset=40)], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=40)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=40), + FunctionDef( + '__add__', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=20), + arg( + 'minutes', + lineno=18, + col_offset=22, + end_lineno=18, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=12), + 'minute', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=19), + Add(), + Name( + 'minutes', + Load(), + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=30), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=30), + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=19), + 'cleanup', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=27), + [], + [], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=29), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=29)], + [], + lineno=18, + col_offset=4, + end_lineno=20, + end_col_offset=29), + FunctionDef( + '__sub__', + arguments( + [], + [ + arg( + 'self', + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20), + arg( + 'minutes', + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=12), + 'minute', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=19), + Sub(), + Name( + 'minutes', + Load(), + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=30), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=30), + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=19), + 'cleanup', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=27), + [], + [], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=29), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=29)], + [], + lineno=22, + col_offset=4, + end_lineno=24, + end_col_offset=29), + FunctionDef( + 'cleanup', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=12), + 'hour', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=17), + Add(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=25), + 'minute', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=32), + FloorDiv(), + Constant( + 60, + lineno=27, + col_offset=36, + end_lineno=27, + end_col_offset=38), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=38), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=38), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=12), + 'hour', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=17), + Mod(), + Constant( + 24, + lineno=28, + col_offset=21, + end_lineno=28, + end_col_offset=23), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=23), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=12), + 'minute', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=19), + Mod(), + Constant( + 60, + lineno=29, + col_offset=23, + end_lineno=29, + end_col_offset=25), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=25), + Return( + Name( + 'self', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=19), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=19)], + [], + lineno=26, + col_offset=4, + end_lineno=30, + end_col_offset=19)], + [], + lineno=1, + col_offset=0, + end_lineno=30, + end_col_offset=19)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=4, + col_offset=23, + end_lineno=4, + end_col_offset=27), + arg( + 'placeholder_3', + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17)], + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=24), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=19)], + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=28), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'cleanup', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=20), + [], + [], + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=22), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=22)], + [], + lineno=4, + col_offset=4, + end_lineno=7, + end_col_offset=22), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + Constant( + 'Clock(', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=33), + -1, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + Constant( + ', ', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=41), + 'placeholder_3', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=48), + -1, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + Constant( + ')', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=51), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=51)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=51), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '{:02d}:{:02d}', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=30), + 'format', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=37), + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=42), + 'placeholder_2', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=47), + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=53), + 'placeholder_3', + Load(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=60)], + [], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=61), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=61)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=61), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + arg( + 'placeholder_7', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'repr', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + [ + Name( + 'self', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=24)], + [], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=25), + [ + Eq()], + [ + Call( + Name( + 'repr', + Load(), + lineno=16, + col_offset=29, + end_lineno=16, + end_col_offset=33), + [ + Name( + 'placeholder_7', + Load(), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=39)], + [], + lineno=16, + col_offset=29, + end_lineno=16, + end_col_offset=40)], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=40)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=40), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=20), + arg( + 'placeholder_9', + lineno=18, + col_offset=22, + end_lineno=18, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=19), + Add(), + Name( + 'placeholder_9', + Load(), + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=30), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=30), + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=19), + 'cleanup', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=27), + [], + [], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=29), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=29)], + [], + lineno=18, + col_offset=4, + end_lineno=20, + end_col_offset=29), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20), + arg( + 'placeholder_9', + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=19), + Sub(), + Name( + 'placeholder_9', + Load(), + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=30), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=30), + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=19), + 'cleanup', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=27), + [], + [], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=29), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=29)], + [], + lineno=22, + col_offset=4, + end_lineno=24, + end_col_offset=29), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=17), + Add(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=25), + 'placeholder_3', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=32), + FloorDiv(), + Constant( + 60, + lineno=27, + col_offset=36, + end_lineno=27, + end_col_offset=38), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=38), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=38), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=17), + Mod(), + Constant( + 24, + lineno=28, + col_offset=21, + end_lineno=28, + end_col_offset=23), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=23), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=19), + Mod(), + Constant( + 60, + lineno=29, + col_offset=23, + end_lineno=29, + end_col_offset=25), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=25), + Return( + Name( + 'self', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=19), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=19)], + [], + lineno=26, + col_offset=4, + end_lineno=30, + end_col_offset=19)], + [], + lineno=1, + col_offset=0, + end_lineno=30, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-clock/representation.txt b/test/practice-clock/representation.txt new file mode 100644 index 0000000..70713a4 --- /dev/null +++ b/test/practice-clock/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=4, col_offset=17, end_lineno=4, end_col_offset=21), arg('placeholder_2', lineno=4, col_offset=23, end_lineno=4, end_col_offset=27), arg('placeholder_3', lineno=4, col_offset=29, end_lineno=4, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=12), 'placeholder_2', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=17)], Name('placeholder_2', Load(), lineno=5, col_offset=20, end_lineno=5, end_col_offset=24), lineno=5, col_offset=8, end_lineno=5, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_3', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=19)], Name('placeholder_3', Load(), lineno=6, col_offset=22, end_lineno=6, end_col_offset=28), lineno=6, col_offset=8, end_lineno=6, end_col_offset=28), Expr(Call(Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'cleanup', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=20), [], [], lineno=7, col_offset=8, end_lineno=7, end_col_offset=22), lineno=7, col_offset=8, end_lineno=7, end_col_offset=22)], [], lineno=4, col_offset=4, end_lineno=7, end_col_offset=22), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=9, col_offset=17, end_lineno=9, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(JoinedStr([Constant('Clock(', lineno=10, col_offset=15, end_lineno=10, end_col_offset=51), FormattedValue(Attribute(Name('self', Load(), lineno=10, col_offset=24, end_lineno=10, end_col_offset=28), 'placeholder_2', Load(), lineno=10, col_offset=24, end_lineno=10, end_col_offset=33), -1, lineno=10, col_offset=15, end_lineno=10, end_col_offset=51), Constant(', ', lineno=10, col_offset=15, end_lineno=10, end_col_offset=51), FormattedValue(Attribute(Name('self', Load(), lineno=10, col_offset=37, end_lineno=10, end_col_offset=41), 'placeholder_3', Load(), lineno=10, col_offset=37, end_lineno=10, end_col_offset=48), -1, lineno=10, col_offset=15, end_lineno=10, end_col_offset=51), Constant(')', lineno=10, col_offset=15, end_lineno=10, end_col_offset=51)], lineno=10, col_offset=15, end_lineno=10, end_col_offset=51), lineno=10, col_offset=8, end_lineno=10, end_col_offset=51)], [], lineno=9, col_offset=4, end_lineno=10, end_col_offset=51), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=12, col_offset=16, end_lineno=12, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Constant('{:02d}:{:02d}', lineno=13, col_offset=15, end_lineno=13, end_col_offset=30), 'format', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=37), [Attribute(Name('self', Load(), lineno=13, col_offset=38, end_lineno=13, end_col_offset=42), 'placeholder_2', Load(), lineno=13, col_offset=38, end_lineno=13, end_col_offset=47), Attribute(Name('self', Load(), lineno=13, col_offset=49, end_lineno=13, end_col_offset=53), 'placeholder_3', Load(), lineno=13, col_offset=49, end_lineno=13, end_col_offset=60)], [], lineno=13, col_offset=15, end_lineno=13, end_col_offset=61), lineno=13, col_offset=8, end_lineno=13, end_col_offset=61)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=61), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), arg('placeholder_7', lineno=15, col_offset=21, end_lineno=15, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Call(Name('repr', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=19), [Name('self', Load(), lineno=16, col_offset=20, end_lineno=16, end_col_offset=24)], [], lineno=16, col_offset=15, end_lineno=16, end_col_offset=25), [Eq()], [Call(Name('repr', Load(), lineno=16, col_offset=29, end_lineno=16, end_col_offset=33), [Name('placeholder_7', Load(), lineno=16, col_offset=34, end_lineno=16, end_col_offset=39)], [], lineno=16, col_offset=29, end_lineno=16, end_col_offset=40)], lineno=16, col_offset=15, end_lineno=16, end_col_offset=40), lineno=16, col_offset=8, end_lineno=16, end_col_offset=40)], [], lineno=15, col_offset=4, end_lineno=16, end_col_offset=40), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=18, col_offset=16, end_lineno=18, end_col_offset=20), arg('placeholder_9', lineno=18, col_offset=22, end_lineno=18, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [AugAssign(Attribute(Name('self', Load(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=12), 'placeholder_3', Store(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=19), Add(), Name('placeholder_9', Load(), lineno=19, col_offset=23, end_lineno=19, end_col_offset=30), lineno=19, col_offset=8, end_lineno=19, end_col_offset=30), Return(Call(Attribute(Name('self', Load(), lineno=20, col_offset=15, end_lineno=20, end_col_offset=19), 'cleanup', Load(), lineno=20, col_offset=15, end_lineno=20, end_col_offset=27), [], [], lineno=20, col_offset=15, end_lineno=20, end_col_offset=29), lineno=20, col_offset=8, end_lineno=20, end_col_offset=29)], [], lineno=18, col_offset=4, end_lineno=20, end_col_offset=29), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=22, col_offset=16, end_lineno=22, end_col_offset=20), arg('placeholder_9', lineno=22, col_offset=22, end_lineno=22, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [AugAssign(Attribute(Name('self', Load(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=12), 'placeholder_3', Store(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=19), Sub(), Name('placeholder_9', Load(), lineno=23, col_offset=23, end_lineno=23, end_col_offset=30), lineno=23, col_offset=8, end_lineno=23, end_col_offset=30), Return(Call(Attribute(Name('self', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=19), 'cleanup', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=27), [], [], lineno=24, col_offset=15, end_lineno=24, end_col_offset=29), lineno=24, col_offset=8, end_lineno=24, end_col_offset=29)], [], lineno=22, col_offset=4, end_lineno=24, end_col_offset=29), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=26, col_offset=16, end_lineno=26, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [AugAssign(Attribute(Name('self', Load(), lineno=27, col_offset=8, end_lineno=27, end_col_offset=12), 'placeholder_2', Store(), lineno=27, col_offset=8, end_lineno=27, end_col_offset=17), Add(), BinOp(Attribute(Name('self', Load(), lineno=27, col_offset=21, end_lineno=27, end_col_offset=25), 'placeholder_3', Load(), lineno=27, col_offset=21, end_lineno=27, end_col_offset=32), FloorDiv(), Constant(60, lineno=27, col_offset=36, end_lineno=27, end_col_offset=38), lineno=27, col_offset=21, end_lineno=27, end_col_offset=38), lineno=27, col_offset=8, end_lineno=27, end_col_offset=38), AugAssign(Attribute(Name('self', Load(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=12), 'placeholder_2', Store(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=17), Mod(), Constant(24, lineno=28, col_offset=21, end_lineno=28, end_col_offset=23), lineno=28, col_offset=8, end_lineno=28, end_col_offset=23), AugAssign(Attribute(Name('self', Load(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=12), 'placeholder_3', Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=19), Mod(), Constant(60, lineno=29, col_offset=23, end_lineno=29, end_col_offset=25), lineno=29, col_offset=8, end_lineno=29, end_col_offset=25), Return(Name('self', Load(), lineno=30, col_offset=15, end_lineno=30, end_col_offset=19), lineno=30, col_offset=8, end_lineno=30, end_col_offset=19)], [], lineno=26, col_offset=4, end_lineno=30, end_col_offset=19)], [], lineno=1, col_offset=0, end_lineno=30, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/practice-collatz-conjecture/.meta/config.json b/test/practice-collatz-conjecture/.meta/config.json new file mode 100644 index 0000000..e5eda73 --- /dev/null +++ b/test/practice-collatz-conjecture/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "zwaltman" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "ikhadykin", + "K4cePhoenix", + "N-Parsons", + "smt923", + "Stigjb", + "thomasjpfan", + "tqa236" + ], + "files": { + "solution": [ + "collatz_conjecture.py" + ], + "test": [ + "collatz_conjecture_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.", + "source": "An unsolved problem in mathematics named after mathematician Lothar Collatz", + "source_url": "https://en.wikipedia.org/wiki/3x_%2B_1_problem" +} diff --git a/test/practice-collatz-conjecture/collatz_conjecture.py b/test/practice-collatz-conjecture/collatz_conjecture.py new file mode 100644 index 0000000..843fe43 --- /dev/null +++ b/test/practice-collatz-conjecture/collatz_conjecture.py @@ -0,0 +1,17 @@ +def steps(number): + if number <= 0: + raise ValueError('Only positive integers are allowed') + + step_count = 0 + while number > 1: + if is_odd(number): + number = number * 3 + 1 + else: + number = number / 2 + step_count += 1 + + return step_count + + +def is_odd(number): + return number % 2 == 1 diff --git a/test/practice-collatz-conjecture/mapping.json b/test/practice-collatz-conjecture/mapping.json new file mode 100644 index 0000000..d6a7d8c --- /dev/null +++ b/test/practice-collatz-conjecture/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "steps", + "placeholder_1": "number", + "placeholder_2": "step_count", + "placeholder_3": "is_odd" +} \ No newline at end of file diff --git a/test/practice-collatz-conjecture/representation.json b/test/practice-collatz-conjecture/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-collatz-conjecture/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-collatz-conjecture/representation.out b/test/practice-collatz-conjecture/representation.out new file mode 100644 index 0000000..d9836c7 --- /dev/null +++ b/test/practice-collatz-conjecture/representation.out @@ -0,0 +1,656 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + if placeholder_1 <= 0: + raise ValueError("Only positive integers are allowed") + placeholder_2 = 0 + while placeholder_1 > 1: + if is_odd(placeholder_1): + placeholder_1 = placeholder_1 * 3 + 1 + else: + placeholder_1 = placeholder_1 / 2 + placeholder_2 += 1 + return placeholder_2 + + +def placeholder_3(placeholder_1): + return placeholder_1 % 2 == 1 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'steps', + arguments( + [], + [ + arg( + 'number', + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=13), + [ + LtE()], + [ + Constant( + 0, + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=18)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'Only positive integers are allowed', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=61)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=62), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=62)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=62), + Assign( + [ + Name( + 'step_count', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=14)], + Constant( + 0, + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=18), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=18), + While( + Compare( + Name( + 'number', + Load(), + lineno=6, + col_offset=10, + end_lineno=6, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 1, + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=20)], + lineno=6, + col_offset=10, + end_lineno=6, + end_col_offset=20), + [ + If( + Call( + Name( + 'is_odd', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=17), + [ + Name( + 'number', + Load(), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=24)], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=25), + [ + Assign( + [ + Name( + 'number', + Store(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=18)], + BinOp( + BinOp( + Name( + 'number', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=27), + Mult(), + Constant( + 3, + lineno=8, + col_offset=30, + end_lineno=8, + end_col_offset=31), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=31), + Add(), + Constant( + 1, + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=35), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=35), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=35)], + [ + Assign( + [ + Name( + 'number', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=18)], + BinOp( + Name( + 'number', + Load(), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=27), + Div(), + Constant( + 2, + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=31), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=31), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=31)], + lineno=7, + col_offset=8, + end_lineno=10, + end_col_offset=31), + AugAssign( + Name( + 'step_count', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=18), + Add(), + Constant( + 1, + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=23), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=23)], + [], + lineno=6, + col_offset=4, + end_lineno=11, + end_col_offset=23), + Return( + Name( + 'step_count', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=21), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=21)], + [], + lineno=1, + col_offset=0, + end_lineno=13, + end_col_offset=21), + FunctionDef( + 'is_odd', + arguments( + [], + [ + arg( + 'number', + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=17), + Mod(), + Constant( + 2, + lineno=17, + col_offset=20, + end_lineno=17, + end_col_offset=21), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 1, + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=26)], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=26), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=26)], + [], + lineno=16, + col_offset=0, + end_lineno=17, + end_col_offset=26)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=13), + [ + LtE()], + [ + Constant( + 0, + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=18)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'Only positive integers are allowed', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=61)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=62), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=62)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=62), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=14)], + Constant( + 0, + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=18), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=18), + While( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=10, + end_lineno=6, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 1, + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=20)], + lineno=6, + col_offset=10, + end_lineno=6, + end_col_offset=20), + [ + If( + Call( + Name( + 'is_odd', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=17), + [ + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=24)], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=25), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=18)], + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=27), + Mult(), + Constant( + 3, + lineno=8, + col_offset=30, + end_lineno=8, + end_col_offset=31), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=31), + Add(), + Constant( + 1, + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=35), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=35), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=35)], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=18)], + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=27), + Div(), + Constant( + 2, + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=31), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=31), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=31)], + lineno=7, + col_offset=8, + end_lineno=10, + end_col_offset=31), + AugAssign( + Name( + 'placeholder_2', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=18), + Add(), + Constant( + 1, + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=23), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=23)], + [], + lineno=6, + col_offset=4, + end_lineno=11, + end_col_offset=23), + Return( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=21), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=21)], + [], + lineno=1, + col_offset=0, + end_lineno=13, + end_col_offset=21), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=17), + Mod(), + Constant( + 2, + lineno=17, + col_offset=20, + end_lineno=17, + end_col_offset=21), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 1, + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=26)], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=26), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=26)], + [], + lineno=16, + col_offset=0, + end_lineno=17, + end_col_offset=26)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-collatz-conjecture/representation.txt b/test/practice-collatz-conjecture/representation.txt new file mode 100644 index 0000000..9cf38a4 --- /dev/null +++ b/test/practice-collatz-conjecture/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=10, end_lineno=1, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_1', Load(), lineno=2, col_offset=7, end_lineno=2, end_col_offset=13), [LtE()], [Constant(0, lineno=2, col_offset=17, end_lineno=2, end_col_offset=18)], lineno=2, col_offset=7, end_lineno=2, end_col_offset=18), [Raise(Call(Name('ValueError', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=24), [Constant('Only positive integers are allowed', lineno=3, col_offset=25, end_lineno=3, end_col_offset=61)], [], lineno=3, col_offset=14, end_lineno=3, end_col_offset=62), lineno=3, col_offset=8, end_lineno=3, end_col_offset=62)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=62), Assign([Name('placeholder_2', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=14)], Constant(0, lineno=5, col_offset=17, end_lineno=5, end_col_offset=18), lineno=5, col_offset=4, end_lineno=5, end_col_offset=18), While(Compare(Name('placeholder_1', Load(), lineno=6, col_offset=10, end_lineno=6, end_col_offset=16), [Gt()], [Constant(1, lineno=6, col_offset=19, end_lineno=6, end_col_offset=20)], lineno=6, col_offset=10, end_lineno=6, end_col_offset=20), [If(Call(Name('is_odd', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=17), [Name('placeholder_1', Load(), lineno=7, col_offset=18, end_lineno=7, end_col_offset=24)], [], lineno=7, col_offset=11, end_lineno=7, end_col_offset=25), [Assign([Name('placeholder_1', Store(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=18)], BinOp(BinOp(Name('placeholder_1', Load(), lineno=8, col_offset=21, end_lineno=8, end_col_offset=27), Mult(), Constant(3, lineno=8, col_offset=30, end_lineno=8, end_col_offset=31), lineno=8, col_offset=21, end_lineno=8, end_col_offset=31), Add(), Constant(1, lineno=8, col_offset=34, end_lineno=8, end_col_offset=35), lineno=8, col_offset=21, end_lineno=8, end_col_offset=35), lineno=8, col_offset=12, end_lineno=8, end_col_offset=35)], [Assign([Name('placeholder_1', Store(), lineno=10, col_offset=12, end_lineno=10, end_col_offset=18)], BinOp(Name('placeholder_1', Load(), lineno=10, col_offset=21, end_lineno=10, end_col_offset=27), Div(), Constant(2, lineno=10, col_offset=30, end_lineno=10, end_col_offset=31), lineno=10, col_offset=21, end_lineno=10, end_col_offset=31), lineno=10, col_offset=12, end_lineno=10, end_col_offset=31)], lineno=7, col_offset=8, end_lineno=10, end_col_offset=31), AugAssign(Name('placeholder_2', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=18), Add(), Constant(1, lineno=11, col_offset=22, end_lineno=11, end_col_offset=23), lineno=11, col_offset=8, end_lineno=11, end_col_offset=23)], [], lineno=6, col_offset=4, end_lineno=11, end_col_offset=23), Return(Name('placeholder_2', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=21), lineno=13, col_offset=4, end_lineno=13, end_col_offset=21)], [], lineno=1, col_offset=0, end_lineno=13, end_col_offset=21), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=16, col_offset=11, end_lineno=16, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(BinOp(Name('placeholder_1', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=17), Mod(), Constant(2, lineno=17, col_offset=20, end_lineno=17, end_col_offset=21), lineno=17, col_offset=11, end_lineno=17, end_col_offset=21), [Eq()], [Constant(1, lineno=17, col_offset=25, end_lineno=17, end_col_offset=26)], lineno=17, col_offset=11, end_lineno=17, end_col_offset=26), lineno=17, col_offset=4, end_lineno=17, end_col_offset=26)], [], lineno=16, col_offset=0, end_lineno=17, end_col_offset=26)], []) \ No newline at end of file diff --git a/test/practice-complex-numbers/.meta/additional_tests.json b/test/practice-complex-numbers/.meta/additional_tests.json new file mode 100644 index 0000000..621ffb5 --- /dev/null +++ b/test/practice-complex-numbers/.meta/additional_tests.json @@ -0,0 +1,31 @@ +{ + "cases": [ + { + "description": "equality of complex numbers", + "property": "eq", + "input": { + "z1": [1, 2], + "z2": [1, 2] + }, + "expected": true + }, + { + "description": "inequality of real part", + "property": "eq", + "input": { + "z1": [1, 2], + "z2": [2, 2] + }, + "expected": false + }, + { + "description": "inequality of imaginary part", + "property": "eq", + "input": { + "z1": [1, 2], + "z2": [1, 1] + }, + "expected": false + } + ] +} \ No newline at end of file diff --git a/test/practice-complex-numbers/.meta/config.json b/test/practice-complex-numbers/.meta/config.json new file mode 100644 index 0000000..b79e654 --- /dev/null +++ b/test/practice-complex-numbers/.meta/config.json @@ -0,0 +1,29 @@ +{ + "authors": [], + "contributors": [ + "cmccandless", + "Dog", + "dvermd", + "gsbullmer", + "N-Parsons", + "pranasziaukas", + "susg", + "tqa236", + "trangttt", + "yawpitch" + ], + "files": { + "solution": [ + "complex_numbers.py" + ], + "test": [ + "complex_numbers_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement complex numbers.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Complex_number" +} diff --git a/test/practice-complex-numbers/complex_numbers.py b/test/practice-complex-numbers/complex_numbers.py new file mode 100644 index 0000000..b833c38 --- /dev/null +++ b/test/practice-complex-numbers/complex_numbers.py @@ -0,0 +1,96 @@ +import math + +class ComplexNumber: + def __init__(self, real=0, imaginary=0): + self.real = real + self.imaginary = imaginary + + def __eq__(self, other): + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + return self.real == other.real and self.imaginary == other.imaginary + + def __add__(self, other): + + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + + real_part = self.real + other.real + imaginary_part = self.imaginary + other.imaginary + + return ComplexNumber(real_part, imaginary_part) + + def __radd__(self, other): + + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + + real_part = self.real + other.real + imaginary_part = self.imaginary + other.imaginary + + return ComplexNumber(real_part, imaginary_part) + + def __mul__(self, other): + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + + real_part = self.real * other.real - self.imaginary * other.imaginary + imaginary_part = self.real * other.imaginary + self.imaginary * other.real + return ComplexNumber(real_part, imaginary_part) + + def __rmul__(self, other): + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + + real_part = self.real * other.real - self.imaginary * other.imaginary + imaginary_part = self.real * other.imaginary + self.imaginary * other.real + return ComplexNumber(real_part, imaginary_part) + + def __sub__(self, other): + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + real_part = self.real - other.real + imaginary_part = self.imaginary - other.imaginary + return ComplexNumber(real_part, imaginary_part) + + def __rsub__(self, other): + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + + real_part = other.real - self.real + imaginary_part = other.imaginary - self.imaginary + return ComplexNumber(real_part, imaginary_part) + + def __truediv__(self, other): + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + + conjugation = other.conjugate() + denominator_all = other * conjugation + denominator = denominator_all.real + numerator = self * conjugation + + return ComplexNumber((numerator.real / denominator), (numerator.imaginary / denominator)) + + def __rtruediv__(self, other): + if not isinstance(other, ComplexNumber): + other = ComplexNumber(other) + + conjugation = self.conjugate() + denominator_all = self * conjugation + denominator = float(denominator_all.real) + numerator = other * conjugation + + return ComplexNumber((numerator.real / denominator), (numerator.imaginary / denominator)) + + def __abs__(self): + square_sum = self.real * self.real + self.imaginary * self.imaginary + return math.sqrt(square_sum) + + def conjugate(self): + return ComplexNumber(self.real, -1 * self.imaginary) + + def exp(self): + real_part = math.cos(self.imaginary) * math.exp(self.real) + imaginary_part = math.sin(self.imaginary) * math.exp(self.real) + return ComplexNumber(real_part, imaginary_part) diff --git a/test/practice-complex-numbers/mapping.json b/test/practice-complex-numbers/mapping.json new file mode 100644 index 0000000..ac29040 --- /dev/null +++ b/test/practice-complex-numbers/mapping.json @@ -0,0 +1,26 @@ +{ + "placeholder_0": "ComplexNumber", + "placeholder_1": "__init__", + "placeholder_2": "real", + "placeholder_3": "imaginary", + "placeholder_4": "__eq__", + "placeholder_5": "other", + "placeholder_6": "__add__", + "placeholder_7": "real_part", + "placeholder_8": "imaginary_part", + "placeholder_9": "__radd__", + "placeholder_10": "__mul__", + "placeholder_11": "__rmul__", + "placeholder_12": "__sub__", + "placeholder_13": "__rsub__", + "placeholder_14": "__truediv__", + "placeholder_15": "conjugation", + "placeholder_16": "denominator_all", + "placeholder_17": "denominator", + "placeholder_18": "numerator", + "placeholder_19": "__rtruediv__", + "placeholder_20": "__abs__", + "placeholder_21": "square_sum", + "placeholder_22": "conjugate", + "placeholder_23": "exp" +} \ No newline at end of file diff --git a/test/practice-complex-numbers/representation.json b/test/practice-complex-numbers/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-complex-numbers/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-complex-numbers/representation.out b/test/practice-complex-numbers/representation.out new file mode 100644 index 0000000..110568f --- /dev/null +++ b/test/practice-complex-numbers/representation.out @@ -0,0 +1,5937 @@ +## BEGIN NORMALIZED CODE ## +import math + + +class placeholder_0: + def placeholder_1(self, placeholder_2=0, placeholder_3=0): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 + + def placeholder_4(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + return ( + self.placeholder_2 == placeholder_5.placeholder_2 + and self.placeholder_3 == placeholder_5.placeholder_3 + ) + + def placeholder_6(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + placeholder_7 = self.placeholder_2 + placeholder_5.placeholder_2 + placeholder_8 = self.placeholder_3 + placeholder_5.placeholder_3 + return placeholder_0(placeholder_7, placeholder_8) + + def placeholder_9(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + placeholder_7 = self.placeholder_2 + placeholder_5.placeholder_2 + placeholder_8 = self.placeholder_3 + placeholder_5.placeholder_3 + return placeholder_0(placeholder_7, placeholder_8) + + def placeholder_10(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + placeholder_7 = ( + self.placeholder_2 * placeholder_5.placeholder_2 + - self.placeholder_3 * placeholder_5.placeholder_3 + ) + placeholder_8 = ( + self.placeholder_2 * placeholder_5.placeholder_3 + + self.placeholder_3 * placeholder_5.placeholder_2 + ) + return placeholder_0(placeholder_7, placeholder_8) + + def placeholder_11(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + placeholder_7 = ( + self.placeholder_2 * placeholder_5.placeholder_2 + - self.placeholder_3 * placeholder_5.placeholder_3 + ) + placeholder_8 = ( + self.placeholder_2 * placeholder_5.placeholder_3 + + self.placeholder_3 * placeholder_5.placeholder_2 + ) + return placeholder_0(placeholder_7, placeholder_8) + + def placeholder_12(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + placeholder_7 = self.placeholder_2 - placeholder_5.placeholder_2 + placeholder_8 = self.placeholder_3 - placeholder_5.placeholder_3 + return placeholder_0(placeholder_7, placeholder_8) + + def placeholder_13(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + placeholder_7 = placeholder_5.placeholder_2 - self.placeholder_2 + placeholder_8 = placeholder_5.placeholder_3 - self.placeholder_3 + return placeholder_0(placeholder_7, placeholder_8) + + def placeholder_14(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + placeholder_15 = placeholder_5.conjugate() + placeholder_16 = placeholder_5 * placeholder_15 + placeholder_17 = placeholder_16.placeholder_2 + placeholder_18 = self * placeholder_15 + return placeholder_0( + placeholder_18.placeholder_2 / placeholder_17, + placeholder_18.placeholder_3 / placeholder_17, + ) + + def placeholder_19(self, placeholder_5): + if not isinstance(placeholder_5, placeholder_0): + placeholder_5 = placeholder_0(placeholder_5) + placeholder_15 = self.conjugate() + placeholder_16 = self * placeholder_15 + placeholder_17 = float(placeholder_16.placeholder_2) + placeholder_18 = placeholder_5 * placeholder_15 + return placeholder_0( + placeholder_18.placeholder_2 / placeholder_17, + placeholder_18.placeholder_3 / placeholder_17, + ) + + def placeholder_20(self): + placeholder_21 = ( + self.placeholder_2 * self.placeholder_2 + + self.placeholder_3 * self.placeholder_3 + ) + return math.sqrt(placeholder_21) + + def placeholder_22(self): + return placeholder_0(self.placeholder_2, -1 * self.placeholder_3) + + def placeholder_23(self): + placeholder_7 = math.cos(self.placeholder_3) * math.placeholder_23( + self.placeholder_2 + ) + placeholder_8 = math.sin(self.placeholder_3) * math.placeholder_23( + self.placeholder_2 + ) + return placeholder_0(placeholder_7, placeholder_8) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'math', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + ClassDef( + 'ComplexNumber', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=21), + arg( + 'real', + lineno=4, + col_offset=23, + end_lineno=4, + end_col_offset=27), + arg( + 'imaginary', + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 0, + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=29), + Constant( + 0, + lineno=4, + col_offset=41, + end_lineno=4, + end_col_offset=42)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'real', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17)], + Name( + 'real', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=24), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'imaginary', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=22)], + Name( + 'imaginary', + Load(), + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=34), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=34)], + [], + lineno=4, + col_offset=4, + end_lineno=6, + end_col_offset=34), + FunctionDef( + '__eq__', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=19), + arg( + 'other', + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=9, + col_offset=26, + end_lineno=9, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=9, + col_offset=33, + end_lineno=9, + end_col_offset=46)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=47), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=10, + col_offset=34, + end_lineno=10, + end_col_offset=39)], + [], + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=40), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=40)], + [], + lineno=9, + col_offset=8, + end_lineno=10, + end_col_offset=40), + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=19), + 'real', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=33), + 'real', + Load(), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=38)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=38), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=47), + 'imaginary', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=57), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=11, + col_offset=61, + end_lineno=11, + end_col_offset=66), + 'imaginary', + Load(), + lineno=11, + col_offset=61, + end_lineno=11, + end_col_offset=76)], + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=76)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=76), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=76)], + [], + lineno=8, + col_offset=4, + end_lineno=11, + end_col_offset=76), + FunctionDef( + '__add__', + arguments( + [], + [ + arg( + 'self', + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=20), + arg( + 'other', + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=46)], + [], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=47), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=39)], + [], + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=40)], + [], + lineno=15, + col_offset=8, + end_lineno=16, + end_col_offset=40), + Assign( + [ + Name( + 'real_part', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=17)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=24), + 'real', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=29), + Add(), + Attribute( + Name( + 'other', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=37), + 'real', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=42), + Assign( + [ + Name( + 'imaginary_part', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=29), + 'imaginary', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=39), + Add(), + Attribute( + Name( + 'other', + Load(), + lineno=19, + col_offset=42, + end_lineno=19, + end_col_offset=47), + 'imaginary', + Load(), + lineno=19, + col_offset=42, + end_lineno=19, + end_col_offset=57), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=57), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=57), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=28), + [ + Name( + 'real_part', + Load(), + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=38), + Name( + 'imaginary_part', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=54)], + [], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=55), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=55)], + [], + lineno=13, + col_offset=4, + end_lineno=21, + end_col_offset=55), + FunctionDef( + '__radd__', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + arg( + 'other', + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=46)], + [], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=47), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=26, + col_offset=34, + end_lineno=26, + end_col_offset=39)], + [], + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=40), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=40)], + [], + lineno=25, + col_offset=8, + end_lineno=26, + end_col_offset=40), + Assign( + [ + Name( + 'real_part', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=17)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=24), + 'real', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=29), + Add(), + Attribute( + Name( + 'other', + Load(), + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=37), + 'real', + Load(), + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=42), + Assign( + [ + Name( + 'imaginary_part', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=29), + 'imaginary', + Load(), + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=39), + Add(), + Attribute( + Name( + 'other', + Load(), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=47), + 'imaginary', + Load(), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=57), + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=57), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=57), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=28), + [ + Name( + 'real_part', + Load(), + lineno=31, + col_offset=29, + end_lineno=31, + end_col_offset=38), + Name( + 'imaginary_part', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=54)], + [], + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=55), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=55)], + [], + lineno=23, + col_offset=4, + end_lineno=31, + end_col_offset=55), + FunctionDef( + '__mul__', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=20), + arg( + 'other', + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=34, + col_offset=33, + end_lineno=34, + end_col_offset=46)], + [], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=47), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=35, + col_offset=34, + end_lineno=35, + end_col_offset=39)], + [], + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=40), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=40)], + [], + lineno=34, + col_offset=8, + end_lineno=35, + end_col_offset=40), + Assign( + [ + Name( + 'real_part', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=17)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=24), + 'real', + Load(), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=29), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=37), + 'real', + Load(), + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=42), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=42), + Sub(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=37, + col_offset=45, + end_lineno=37, + end_col_offset=49), + 'imaginary', + Load(), + lineno=37, + col_offset=45, + end_lineno=37, + end_col_offset=59), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=37, + col_offset=62, + end_lineno=37, + end_col_offset=67), + 'imaginary', + Load(), + lineno=37, + col_offset=62, + end_lineno=37, + end_col_offset=77), + lineno=37, + col_offset=45, + end_lineno=37, + end_col_offset=77), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=77), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=77), + Assign( + [ + Name( + 'imaginary_part', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=22)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=29), + 'real', + Load(), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=34), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=38, + col_offset=37, + end_lineno=38, + end_col_offset=42), + 'imaginary', + Load(), + lineno=38, + col_offset=37, + end_lineno=38, + end_col_offset=52), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=52), + Add(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=59), + 'imaginary', + Load(), + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=69), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=38, + col_offset=72, + end_lineno=38, + end_col_offset=77), + 'real', + Load(), + lineno=38, + col_offset=72, + end_lineno=38, + end_col_offset=82), + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=82), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=82), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=82), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=28), + [ + Name( + 'real_part', + Load(), + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=38), + Name( + 'imaginary_part', + Load(), + lineno=39, + col_offset=40, + end_lineno=39, + end_col_offset=54)], + [], + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=55), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=55)], + [], + lineno=33, + col_offset=4, + end_lineno=39, + end_col_offset=55), + FunctionDef( + '__rmul__', + arguments( + [], + [ + arg( + 'self', + lineno=41, + col_offset=17, + end_lineno=41, + end_col_offset=21), + arg( + 'other', + lineno=41, + col_offset=23, + end_lineno=41, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=42, + col_offset=26, + end_lineno=42, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=42, + col_offset=33, + end_lineno=42, + end_col_offset=46)], + [], + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=47), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=43, + col_offset=20, + end_lineno=43, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=39)], + [], + lineno=43, + col_offset=20, + end_lineno=43, + end_col_offset=40), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=40)], + [], + lineno=42, + col_offset=8, + end_lineno=43, + end_col_offset=40), + Assign( + [ + Name( + 'real_part', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=17)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=24), + 'real', + Load(), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=29), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=37), + 'real', + Load(), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=42), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=42), + Sub(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=49), + 'imaginary', + Load(), + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=59), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=45, + col_offset=62, + end_lineno=45, + end_col_offset=67), + 'imaginary', + Load(), + lineno=45, + col_offset=62, + end_lineno=45, + end_col_offset=77), + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=77), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=77), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=77), + Assign( + [ + Name( + 'imaginary_part', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=22)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=29), + 'real', + Load(), + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=34), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=46, + col_offset=37, + end_lineno=46, + end_col_offset=42), + 'imaginary', + Load(), + lineno=46, + col_offset=37, + end_lineno=46, + end_col_offset=52), + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=52), + Add(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=55, + end_lineno=46, + end_col_offset=59), + 'imaginary', + Load(), + lineno=46, + col_offset=55, + end_lineno=46, + end_col_offset=69), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=46, + col_offset=72, + end_lineno=46, + end_col_offset=77), + 'real', + Load(), + lineno=46, + col_offset=72, + end_lineno=46, + end_col_offset=82), + lineno=46, + col_offset=55, + end_lineno=46, + end_col_offset=82), + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=82), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=82), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=28), + [ + Name( + 'real_part', + Load(), + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=38), + Name( + 'imaginary_part', + Load(), + lineno=47, + col_offset=40, + end_lineno=47, + end_col_offset=54)], + [], + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=55), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=55)], + [], + lineno=41, + col_offset=4, + end_lineno=47, + end_col_offset=55), + FunctionDef( + '__sub__', + arguments( + [], + [ + arg( + 'self', + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=20), + arg( + 'other', + lineno=49, + col_offset=22, + end_lineno=49, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=50, + col_offset=26, + end_lineno=50, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=50, + col_offset=33, + end_lineno=50, + end_col_offset=46)], + [], + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=47), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=51, + col_offset=34, + end_lineno=51, + end_col_offset=39)], + [], + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=40), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=40)], + [], + lineno=50, + col_offset=8, + end_lineno=51, + end_col_offset=40), + Assign( + [ + Name( + 'real_part', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=17)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=24), + 'real', + Load(), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=29), + Sub(), + Attribute( + Name( + 'other', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=37), + 'real', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=42), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=42), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=42), + Assign( + [ + Name( + 'imaginary_part', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=29), + 'imaginary', + Load(), + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=39), + Sub(), + Attribute( + Name( + 'other', + Load(), + lineno=53, + col_offset=42, + end_lineno=53, + end_col_offset=47), + 'imaginary', + Load(), + lineno=53, + col_offset=42, + end_lineno=53, + end_col_offset=57), + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=57), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=57), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=28), + [ + Name( + 'real_part', + Load(), + lineno=54, + col_offset=29, + end_lineno=54, + end_col_offset=38), + Name( + 'imaginary_part', + Load(), + lineno=54, + col_offset=40, + end_lineno=54, + end_col_offset=54)], + [], + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=55), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=55)], + [], + lineno=49, + col_offset=4, + end_lineno=54, + end_col_offset=55), + FunctionDef( + '__rsub__', + arguments( + [], + [ + arg( + 'self', + lineno=56, + col_offset=17, + end_lineno=56, + end_col_offset=21), + arg( + 'other', + lineno=56, + col_offset=23, + end_lineno=56, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=57, + col_offset=26, + end_lineno=57, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=57, + col_offset=33, + end_lineno=57, + end_col_offset=46)], + [], + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=47), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=58, + col_offset=20, + end_lineno=58, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=58, + col_offset=34, + end_lineno=58, + end_col_offset=39)], + [], + lineno=58, + col_offset=20, + end_lineno=58, + end_col_offset=40), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=40)], + [], + lineno=57, + col_offset=8, + end_lineno=58, + end_col_offset=40), + Assign( + [ + Name( + 'real_part', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=17)], + BinOp( + Attribute( + Name( + 'other', + Load(), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=25), + 'real', + Load(), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=30), + Sub(), + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=33, + end_lineno=60, + end_col_offset=37), + 'real', + Load(), + lineno=60, + col_offset=33, + end_lineno=60, + end_col_offset=42), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=42), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=42), + Assign( + [ + Name( + 'imaginary_part', + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'other', + Load(), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=30), + 'imaginary', + Load(), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=40), + Sub(), + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=43, + end_lineno=61, + end_col_offset=47), + 'imaginary', + Load(), + lineno=61, + col_offset=43, + end_lineno=61, + end_col_offset=57), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=57), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=57), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=28), + [ + Name( + 'real_part', + Load(), + lineno=62, + col_offset=29, + end_lineno=62, + end_col_offset=38), + Name( + 'imaginary_part', + Load(), + lineno=62, + col_offset=40, + end_lineno=62, + end_col_offset=54)], + [], + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=55), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=55)], + [], + lineno=56, + col_offset=4, + end_lineno=62, + end_col_offset=55), + FunctionDef( + '__truediv__', + arguments( + [], + [ + arg( + 'self', + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=24), + arg( + 'other', + lineno=64, + col_offset=26, + end_lineno=64, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=65, + col_offset=26, + end_lineno=65, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=65, + col_offset=33, + end_lineno=65, + end_col_offset=46)], + [], + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=47), + lineno=65, + col_offset=11, + end_lineno=65, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=66, + col_offset=34, + end_lineno=66, + end_col_offset=39)], + [], + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=40), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=40)], + [], + lineno=65, + col_offset=8, + end_lineno=66, + end_col_offset=40), + Assign( + [ + Name( + 'conjugation', + Store(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=19)], + Call( + Attribute( + Name( + 'other', + Load(), + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=27), + 'conjugate', + Load(), + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=37), + [], + [], + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=39), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=39), + Assign( + [ + Name( + 'denominator_all', + Store(), + lineno=69, + col_offset=8, + end_lineno=69, + end_col_offset=23)], + BinOp( + Name( + 'other', + Load(), + lineno=69, + col_offset=26, + end_lineno=69, + end_col_offset=31), + Mult(), + Name( + 'conjugation', + Load(), + lineno=69, + col_offset=34, + end_lineno=69, + end_col_offset=45), + lineno=69, + col_offset=26, + end_lineno=69, + end_col_offset=45), + lineno=69, + col_offset=8, + end_lineno=69, + end_col_offset=45), + Assign( + [ + Name( + 'denominator', + Store(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=19)], + Attribute( + Name( + 'denominator_all', + Load(), + lineno=70, + col_offset=22, + end_lineno=70, + end_col_offset=37), + 'real', + Load(), + lineno=70, + col_offset=22, + end_lineno=70, + end_col_offset=42), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=42), + Assign( + [ + Name( + 'numerator', + Store(), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=17)], + BinOp( + Name( + 'self', + Load(), + lineno=71, + col_offset=20, + end_lineno=71, + end_col_offset=24), + Mult(), + Name( + 'conjugation', + Load(), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=38), + lineno=71, + col_offset=20, + end_lineno=71, + end_col_offset=38), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=38), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=73, + col_offset=15, + end_lineno=73, + end_col_offset=28), + [ + BinOp( + Attribute( + Name( + 'numerator', + Load(), + lineno=73, + col_offset=30, + end_lineno=73, + end_col_offset=39), + 'real', + Load(), + lineno=73, + col_offset=30, + end_lineno=73, + end_col_offset=44), + Div(), + Name( + 'denominator', + Load(), + lineno=73, + col_offset=47, + end_lineno=73, + end_col_offset=58), + lineno=73, + col_offset=30, + end_lineno=73, + end_col_offset=58), + BinOp( + Attribute( + Name( + 'numerator', + Load(), + lineno=73, + col_offset=62, + end_lineno=73, + end_col_offset=71), + 'imaginary', + Load(), + lineno=73, + col_offset=62, + end_lineno=73, + end_col_offset=81), + Div(), + Name( + 'denominator', + Load(), + lineno=73, + col_offset=84, + end_lineno=73, + end_col_offset=95), + lineno=73, + col_offset=62, + end_lineno=73, + end_col_offset=95)], + [], + lineno=73, + col_offset=15, + end_lineno=73, + end_col_offset=97), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=97)], + [], + lineno=64, + col_offset=4, + end_lineno=73, + end_col_offset=97), + FunctionDef( + '__rtruediv__', + arguments( + [], + [ + arg( + 'self', + lineno=75, + col_offset=21, + end_lineno=75, + end_col_offset=25), + arg( + 'other', + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=76, + col_offset=15, + end_lineno=76, + end_col_offset=25), + [ + Name( + 'other', + Load(), + lineno=76, + col_offset=26, + end_lineno=76, + end_col_offset=31), + Name( + 'ComplexNumber', + Load(), + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=46)], + [], + lineno=76, + col_offset=15, + end_lineno=76, + end_col_offset=47), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=47), + [ + Assign( + [ + Name( + 'other', + Store(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=17)], + Call( + Name( + 'ComplexNumber', + Load(), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=33), + [ + Name( + 'other', + Load(), + lineno=77, + col_offset=34, + end_lineno=77, + end_col_offset=39)], + [], + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=40), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=40)], + [], + lineno=76, + col_offset=8, + end_lineno=77, + end_col_offset=40), + Assign( + [ + Name( + 'conjugation', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=19)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=26), + 'conjugate', + Load(), + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=36), + [], + [], + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=38), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=38), + Assign( + [ + Name( + 'denominator_all', + Store(), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=23)], + BinOp( + Name( + 'self', + Load(), + lineno=80, + col_offset=26, + end_lineno=80, + end_col_offset=30), + Mult(), + Name( + 'conjugation', + Load(), + lineno=80, + col_offset=33, + end_lineno=80, + end_col_offset=44), + lineno=80, + col_offset=26, + end_lineno=80, + end_col_offset=44), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=44), + Assign( + [ + Name( + 'denominator', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=19)], + Call( + Name( + 'float', + Load(), + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=27), + [ + Attribute( + Name( + 'denominator_all', + Load(), + lineno=81, + col_offset=28, + end_lineno=81, + end_col_offset=43), + 'real', + Load(), + lineno=81, + col_offset=28, + end_lineno=81, + end_col_offset=48)], + [], + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=49), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=49), + Assign( + [ + Name( + 'numerator', + Store(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=17)], + BinOp( + Name( + 'other', + Load(), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=25), + Mult(), + Name( + 'conjugation', + Load(), + lineno=82, + col_offset=28, + end_lineno=82, + end_col_offset=39), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=39), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=39), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=28), + [ + BinOp( + Attribute( + Name( + 'numerator', + Load(), + lineno=84, + col_offset=30, + end_lineno=84, + end_col_offset=39), + 'real', + Load(), + lineno=84, + col_offset=30, + end_lineno=84, + end_col_offset=44), + Div(), + Name( + 'denominator', + Load(), + lineno=84, + col_offset=47, + end_lineno=84, + end_col_offset=58), + lineno=84, + col_offset=30, + end_lineno=84, + end_col_offset=58), + BinOp( + Attribute( + Name( + 'numerator', + Load(), + lineno=84, + col_offset=62, + end_lineno=84, + end_col_offset=71), + 'imaginary', + Load(), + lineno=84, + col_offset=62, + end_lineno=84, + end_col_offset=81), + Div(), + Name( + 'denominator', + Load(), + lineno=84, + col_offset=84, + end_lineno=84, + end_col_offset=95), + lineno=84, + col_offset=62, + end_lineno=84, + end_col_offset=95)], + [], + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=97), + lineno=84, + col_offset=8, + end_lineno=84, + end_col_offset=97)], + [], + lineno=75, + col_offset=4, + end_lineno=84, + end_col_offset=97), + FunctionDef( + '__abs__', + arguments( + [], + [ + arg( + 'self', + lineno=86, + col_offset=16, + end_lineno=86, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'square_sum', + Store(), + lineno=87, + col_offset=8, + end_lineno=87, + end_col_offset=18)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=21, + end_lineno=87, + end_col_offset=25), + 'real', + Load(), + lineno=87, + col_offset=21, + end_lineno=87, + end_col_offset=30), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=33, + end_lineno=87, + end_col_offset=37), + 'real', + Load(), + lineno=87, + col_offset=33, + end_lineno=87, + end_col_offset=42), + lineno=87, + col_offset=21, + end_lineno=87, + end_col_offset=42), + Add(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=45, + end_lineno=87, + end_col_offset=49), + 'imaginary', + Load(), + lineno=87, + col_offset=45, + end_lineno=87, + end_col_offset=59), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=62, + end_lineno=87, + end_col_offset=66), + 'imaginary', + Load(), + lineno=87, + col_offset=62, + end_lineno=87, + end_col_offset=76), + lineno=87, + col_offset=45, + end_lineno=87, + end_col_offset=76), + lineno=87, + col_offset=21, + end_lineno=87, + end_col_offset=76), + lineno=87, + col_offset=8, + end_lineno=87, + end_col_offset=76), + Return( + Call( + Attribute( + Name( + 'math', + Load(), + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=19), + 'sqrt', + Load(), + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=24), + [ + Name( + 'square_sum', + Load(), + lineno=88, + col_offset=25, + end_lineno=88, + end_col_offset=35)], + [], + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=36), + lineno=88, + col_offset=8, + end_lineno=88, + end_col_offset=36)], + [], + lineno=86, + col_offset=4, + end_lineno=88, + end_col_offset=36), + FunctionDef( + 'conjugate', + arguments( + [], + [ + arg( + 'self', + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=28), + [ + Attribute( + Name( + 'self', + Load(), + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=33), + 'real', + Load(), + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=38), + BinOp( + UnaryOp( + USub(), + Constant( + 1, + lineno=91, + col_offset=41, + end_lineno=91, + end_col_offset=42), + lineno=91, + col_offset=40, + end_lineno=91, + end_col_offset=42), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=91, + col_offset=45, + end_lineno=91, + end_col_offset=49), + 'imaginary', + Load(), + lineno=91, + col_offset=45, + end_lineno=91, + end_col_offset=59), + lineno=91, + col_offset=40, + end_lineno=91, + end_col_offset=59)], + [], + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=60), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=60)], + [], + lineno=90, + col_offset=4, + end_lineno=91, + end_col_offset=60), + FunctionDef( + 'exp', + arguments( + [], + [ + arg( + 'self', + lineno=93, + col_offset=12, + end_lineno=93, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'real_part', + Store(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=17)], + BinOp( + Call( + Attribute( + Name( + 'math', + Load(), + lineno=94, + col_offset=20, + end_lineno=94, + end_col_offset=24), + 'cos', + Load(), + lineno=94, + col_offset=20, + end_lineno=94, + end_col_offset=28), + [ + Attribute( + Name( + 'self', + Load(), + lineno=94, + col_offset=29, + end_lineno=94, + end_col_offset=33), + 'imaginary', + Load(), + lineno=94, + col_offset=29, + end_lineno=94, + end_col_offset=43)], + [], + lineno=94, + col_offset=20, + end_lineno=94, + end_col_offset=44), + Mult(), + Call( + Attribute( + Name( + 'math', + Load(), + lineno=94, + col_offset=47, + end_lineno=94, + end_col_offset=51), + 'exp', + Load(), + lineno=94, + col_offset=47, + end_lineno=94, + end_col_offset=55), + [ + Attribute( + Name( + 'self', + Load(), + lineno=94, + col_offset=56, + end_lineno=94, + end_col_offset=60), + 'real', + Load(), + lineno=94, + col_offset=56, + end_lineno=94, + end_col_offset=65)], + [], + lineno=94, + col_offset=47, + end_lineno=94, + end_col_offset=66), + lineno=94, + col_offset=20, + end_lineno=94, + end_col_offset=66), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=66), + Assign( + [ + Name( + 'imaginary_part', + Store(), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=22)], + BinOp( + Call( + Attribute( + Name( + 'math', + Load(), + lineno=95, + col_offset=25, + end_lineno=95, + end_col_offset=29), + 'sin', + Load(), + lineno=95, + col_offset=25, + end_lineno=95, + end_col_offset=33), + [ + Attribute( + Name( + 'self', + Load(), + lineno=95, + col_offset=34, + end_lineno=95, + end_col_offset=38), + 'imaginary', + Load(), + lineno=95, + col_offset=34, + end_lineno=95, + end_col_offset=48)], + [], + lineno=95, + col_offset=25, + end_lineno=95, + end_col_offset=49), + Mult(), + Call( + Attribute( + Name( + 'math', + Load(), + lineno=95, + col_offset=52, + end_lineno=95, + end_col_offset=56), + 'exp', + Load(), + lineno=95, + col_offset=52, + end_lineno=95, + end_col_offset=60), + [ + Attribute( + Name( + 'self', + Load(), + lineno=95, + col_offset=61, + end_lineno=95, + end_col_offset=65), + 'real', + Load(), + lineno=95, + col_offset=61, + end_lineno=95, + end_col_offset=70)], + [], + lineno=95, + col_offset=52, + end_lineno=95, + end_col_offset=71), + lineno=95, + col_offset=25, + end_lineno=95, + end_col_offset=71), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=71), + Return( + Call( + Name( + 'ComplexNumber', + Load(), + lineno=96, + col_offset=15, + end_lineno=96, + end_col_offset=28), + [ + Name( + 'real_part', + Load(), + lineno=96, + col_offset=29, + end_lineno=96, + end_col_offset=38), + Name( + 'imaginary_part', + Load(), + lineno=96, + col_offset=40, + end_lineno=96, + end_col_offset=54)], + [], + lineno=96, + col_offset=15, + end_lineno=96, + end_col_offset=55), + lineno=96, + col_offset=8, + end_lineno=96, + end_col_offset=55)], + [], + lineno=93, + col_offset=4, + end_lineno=96, + end_col_offset=55)], + [], + lineno=3, + col_offset=0, + end_lineno=96, + end_col_offset=55)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'math', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=4, + col_offset=23, + end_lineno=4, + end_col_offset=27), + arg( + 'placeholder_3', + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 0, + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=29), + Constant( + 0, + lineno=4, + col_offset=41, + end_lineno=4, + end_col_offset=42)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17)], + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=24), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=22)], + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=34), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=34)], + [], + lineno=4, + col_offset=4, + end_lineno=6, + end_col_offset=34), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=19), + arg( + 'placeholder_5', + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=9, + col_offset=26, + end_lineno=9, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=9, + col_offset=33, + end_lineno=9, + end_col_offset=46)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=47), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=34, + end_lineno=10, + end_col_offset=39)], + [], + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=40), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=40)], + [], + lineno=9, + col_offset=8, + end_lineno=10, + end_col_offset=40), + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=33), + 'placeholder_2', + Load(), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=38)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=38), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=47), + 'placeholder_3', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=57), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=61, + end_lineno=11, + end_col_offset=66), + 'placeholder_3', + Load(), + lineno=11, + col_offset=61, + end_lineno=11, + end_col_offset=76)], + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=76)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=76), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=76)], + [], + lineno=8, + col_offset=4, + end_lineno=11, + end_col_offset=76), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=20), + arg( + 'placeholder_5', + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=46)], + [], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=47), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=39)], + [], + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=40)], + [], + lineno=15, + col_offset=8, + end_lineno=16, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=17)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=29), + Add(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=29), + 'placeholder_3', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=39), + Add(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=19, + col_offset=42, + end_lineno=19, + end_col_offset=47), + 'placeholder_3', + Load(), + lineno=19, + col_offset=42, + end_lineno=19, + end_col_offset=57), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=57), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=57), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=28), + [ + Name( + 'placeholder_7', + Load(), + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=38), + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=54)], + [], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=55), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=55)], + [], + lineno=13, + col_offset=4, + end_lineno=21, + end_col_offset=55), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + arg( + 'placeholder_5', + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=46)], + [], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=47), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=26, + col_offset=34, + end_lineno=26, + end_col_offset=39)], + [], + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=40), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=40)], + [], + lineno=25, + col_offset=8, + end_lineno=26, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=17)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=29), + Add(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=29), + 'placeholder_3', + Load(), + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=39), + Add(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=47), + 'placeholder_3', + Load(), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=57), + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=57), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=57), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=28), + [ + Name( + 'placeholder_7', + Load(), + lineno=31, + col_offset=29, + end_lineno=31, + end_col_offset=38), + Name( + 'placeholder_8', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=54)], + [], + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=55), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=55)], + [], + lineno=23, + col_offset=4, + end_lineno=31, + end_col_offset=55), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=20), + arg( + 'placeholder_5', + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=34, + col_offset=33, + end_lineno=34, + end_col_offset=46)], + [], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=47), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=35, + col_offset=34, + end_lineno=35, + end_col_offset=39)], + [], + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=40), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=40)], + [], + lineno=34, + col_offset=8, + end_lineno=35, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=17)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=29), + Mult(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=42), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=42), + Sub(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=37, + col_offset=45, + end_lineno=37, + end_col_offset=49), + 'placeholder_3', + Load(), + lineno=37, + col_offset=45, + end_lineno=37, + end_col_offset=59), + Mult(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=37, + col_offset=62, + end_lineno=37, + end_col_offset=67), + 'placeholder_3', + Load(), + lineno=37, + col_offset=62, + end_lineno=37, + end_col_offset=77), + lineno=37, + col_offset=45, + end_lineno=37, + end_col_offset=77), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=77), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=77), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=22)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=29), + 'placeholder_2', + Load(), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=34), + Mult(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=38, + col_offset=37, + end_lineno=38, + end_col_offset=42), + 'placeholder_3', + Load(), + lineno=38, + col_offset=37, + end_lineno=38, + end_col_offset=52), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=52), + Add(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=59), + 'placeholder_3', + Load(), + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=69), + Mult(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=38, + col_offset=72, + end_lineno=38, + end_col_offset=77), + 'placeholder_2', + Load(), + lineno=38, + col_offset=72, + end_lineno=38, + end_col_offset=82), + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=82), + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=82), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=82), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=28), + [ + Name( + 'placeholder_7', + Load(), + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=38), + Name( + 'placeholder_8', + Load(), + lineno=39, + col_offset=40, + end_lineno=39, + end_col_offset=54)], + [], + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=55), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=55)], + [], + lineno=33, + col_offset=4, + end_lineno=39, + end_col_offset=55), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=41, + col_offset=17, + end_lineno=41, + end_col_offset=21), + arg( + 'placeholder_5', + lineno=41, + col_offset=23, + end_lineno=41, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=42, + col_offset=26, + end_lineno=42, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=42, + col_offset=33, + end_lineno=42, + end_col_offset=46)], + [], + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=47), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=43, + col_offset=20, + end_lineno=43, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=43, + col_offset=34, + end_lineno=43, + end_col_offset=39)], + [], + lineno=43, + col_offset=20, + end_lineno=43, + end_col_offset=40), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=40)], + [], + lineno=42, + col_offset=8, + end_lineno=43, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=17)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=29), + Mult(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=42), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=42), + Sub(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=49), + 'placeholder_3', + Load(), + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=59), + Mult(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=45, + col_offset=62, + end_lineno=45, + end_col_offset=67), + 'placeholder_3', + Load(), + lineno=45, + col_offset=62, + end_lineno=45, + end_col_offset=77), + lineno=45, + col_offset=45, + end_lineno=45, + end_col_offset=77), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=77), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=77), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=22)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=29), + 'placeholder_2', + Load(), + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=34), + Mult(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=46, + col_offset=37, + end_lineno=46, + end_col_offset=42), + 'placeholder_3', + Load(), + lineno=46, + col_offset=37, + end_lineno=46, + end_col_offset=52), + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=52), + Add(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=55, + end_lineno=46, + end_col_offset=59), + 'placeholder_3', + Load(), + lineno=46, + col_offset=55, + end_lineno=46, + end_col_offset=69), + Mult(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=46, + col_offset=72, + end_lineno=46, + end_col_offset=77), + 'placeholder_2', + Load(), + lineno=46, + col_offset=72, + end_lineno=46, + end_col_offset=82), + lineno=46, + col_offset=55, + end_lineno=46, + end_col_offset=82), + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=82), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=82), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=28), + [ + Name( + 'placeholder_7', + Load(), + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=38), + Name( + 'placeholder_8', + Load(), + lineno=47, + col_offset=40, + end_lineno=47, + end_col_offset=54)], + [], + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=55), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=55)], + [], + lineno=41, + col_offset=4, + end_lineno=47, + end_col_offset=55), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=20), + arg( + 'placeholder_5', + lineno=49, + col_offset=22, + end_lineno=49, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=50, + col_offset=26, + end_lineno=50, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=50, + col_offset=33, + end_lineno=50, + end_col_offset=46)], + [], + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=47), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=51, + col_offset=34, + end_lineno=51, + end_col_offset=39)], + [], + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=40), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=40)], + [], + lineno=50, + col_offset=8, + end_lineno=51, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=17)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=29), + Sub(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=42), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=42), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=29), + 'placeholder_3', + Load(), + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=39), + Sub(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=53, + col_offset=42, + end_lineno=53, + end_col_offset=47), + 'placeholder_3', + Load(), + lineno=53, + col_offset=42, + end_lineno=53, + end_col_offset=57), + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=57), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=57), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=28), + [ + Name( + 'placeholder_7', + Load(), + lineno=54, + col_offset=29, + end_lineno=54, + end_col_offset=38), + Name( + 'placeholder_8', + Load(), + lineno=54, + col_offset=40, + end_lineno=54, + end_col_offset=54)], + [], + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=55), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=55)], + [], + lineno=49, + col_offset=4, + end_lineno=54, + end_col_offset=55), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=56, + col_offset=17, + end_lineno=56, + end_col_offset=21), + arg( + 'placeholder_5', + lineno=56, + col_offset=23, + end_lineno=56, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=57, + col_offset=26, + end_lineno=57, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=57, + col_offset=33, + end_lineno=57, + end_col_offset=46)], + [], + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=47), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=58, + col_offset=20, + end_lineno=58, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=58, + col_offset=34, + end_lineno=58, + end_col_offset=39)], + [], + lineno=58, + col_offset=20, + end_lineno=58, + end_col_offset=40), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=40)], + [], + lineno=57, + col_offset=8, + end_lineno=58, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=17)], + BinOp( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=25), + 'placeholder_2', + Load(), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=30), + Sub(), + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=33, + end_lineno=60, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=60, + col_offset=33, + end_lineno=60, + end_col_offset=42), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=42), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=30), + 'placeholder_3', + Load(), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=40), + Sub(), + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=43, + end_lineno=61, + end_col_offset=47), + 'placeholder_3', + Load(), + lineno=61, + col_offset=43, + end_lineno=61, + end_col_offset=57), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=57), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=57), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=28), + [ + Name( + 'placeholder_7', + Load(), + lineno=62, + col_offset=29, + end_lineno=62, + end_col_offset=38), + Name( + 'placeholder_8', + Load(), + lineno=62, + col_offset=40, + end_lineno=62, + end_col_offset=54)], + [], + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=55), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=55)], + [], + lineno=56, + col_offset=4, + end_lineno=62, + end_col_offset=55), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'self', + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=24), + arg( + 'placeholder_5', + lineno=64, + col_offset=26, + end_lineno=64, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=65, + col_offset=26, + end_lineno=65, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=65, + col_offset=33, + end_lineno=65, + end_col_offset=46)], + [], + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=47), + lineno=65, + col_offset=11, + end_lineno=65, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=66, + col_offset=34, + end_lineno=66, + end_col_offset=39)], + [], + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=40), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=40)], + [], + lineno=65, + col_offset=8, + end_lineno=66, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=19)], + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=27), + 'conjugate', + Load(), + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=37), + [], + [], + lineno=68, + col_offset=22, + end_lineno=68, + end_col_offset=39), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=69, + col_offset=8, + end_lineno=69, + end_col_offset=23)], + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=69, + col_offset=26, + end_lineno=69, + end_col_offset=31), + Mult(), + Name( + 'placeholder_15', + Load(), + lineno=69, + col_offset=34, + end_lineno=69, + end_col_offset=45), + lineno=69, + col_offset=26, + end_lineno=69, + end_col_offset=45), + lineno=69, + col_offset=8, + end_lineno=69, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=19)], + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=70, + col_offset=22, + end_lineno=70, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=70, + col_offset=22, + end_lineno=70, + end_col_offset=42), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=17)], + BinOp( + Name( + 'self', + Load(), + lineno=71, + col_offset=20, + end_lineno=71, + end_col_offset=24), + Mult(), + Name( + 'placeholder_15', + Load(), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=38), + lineno=71, + col_offset=20, + end_lineno=71, + end_col_offset=38), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=38), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=73, + col_offset=15, + end_lineno=73, + end_col_offset=28), + [ + BinOp( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=73, + col_offset=30, + end_lineno=73, + end_col_offset=39), + 'placeholder_2', + Load(), + lineno=73, + col_offset=30, + end_lineno=73, + end_col_offset=44), + Div(), + Name( + 'placeholder_17', + Load(), + lineno=73, + col_offset=47, + end_lineno=73, + end_col_offset=58), + lineno=73, + col_offset=30, + end_lineno=73, + end_col_offset=58), + BinOp( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=73, + col_offset=62, + end_lineno=73, + end_col_offset=71), + 'placeholder_3', + Load(), + lineno=73, + col_offset=62, + end_lineno=73, + end_col_offset=81), + Div(), + Name( + 'placeholder_17', + Load(), + lineno=73, + col_offset=84, + end_lineno=73, + end_col_offset=95), + lineno=73, + col_offset=62, + end_lineno=73, + end_col_offset=95)], + [], + lineno=73, + col_offset=15, + end_lineno=73, + end_col_offset=97), + lineno=73, + col_offset=8, + end_lineno=73, + end_col_offset=97)], + [], + lineno=64, + col_offset=4, + end_lineno=73, + end_col_offset=97), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'self', + lineno=75, + col_offset=21, + end_lineno=75, + end_col_offset=25), + arg( + 'placeholder_5', + lineno=75, + col_offset=27, + end_lineno=75, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=76, + col_offset=15, + end_lineno=76, + end_col_offset=25), + [ + Name( + 'placeholder_5', + Load(), + lineno=76, + col_offset=26, + end_lineno=76, + end_col_offset=31), + Name( + 'placeholder_0', + Load(), + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=46)], + [], + lineno=76, + col_offset=15, + end_lineno=76, + end_col_offset=47), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=17)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=77, + col_offset=34, + end_lineno=77, + end_col_offset=39)], + [], + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=40), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=40)], + [], + lineno=76, + col_offset=8, + end_lineno=77, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=19)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=26), + 'conjugate', + Load(), + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=36), + [], + [], + lineno=79, + col_offset=22, + end_lineno=79, + end_col_offset=38), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=38), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=23)], + BinOp( + Name( + 'self', + Load(), + lineno=80, + col_offset=26, + end_lineno=80, + end_col_offset=30), + Mult(), + Name( + 'placeholder_15', + Load(), + lineno=80, + col_offset=33, + end_lineno=80, + end_col_offset=44), + lineno=80, + col_offset=26, + end_lineno=80, + end_col_offset=44), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=19)], + Call( + Name( + 'float', + Load(), + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=27), + [ + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=81, + col_offset=28, + end_lineno=81, + end_col_offset=43), + 'placeholder_2', + Load(), + lineno=81, + col_offset=28, + end_lineno=81, + end_col_offset=48)], + [], + lineno=81, + col_offset=22, + end_lineno=81, + end_col_offset=49), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=49), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=17)], + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=25), + Mult(), + Name( + 'placeholder_15', + Load(), + lineno=82, + col_offset=28, + end_lineno=82, + end_col_offset=39), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=39), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=39), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=28), + [ + BinOp( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=84, + col_offset=30, + end_lineno=84, + end_col_offset=39), + 'placeholder_2', + Load(), + lineno=84, + col_offset=30, + end_lineno=84, + end_col_offset=44), + Div(), + Name( + 'placeholder_17', + Load(), + lineno=84, + col_offset=47, + end_lineno=84, + end_col_offset=58), + lineno=84, + col_offset=30, + end_lineno=84, + end_col_offset=58), + BinOp( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=84, + col_offset=62, + end_lineno=84, + end_col_offset=71), + 'placeholder_3', + Load(), + lineno=84, + col_offset=62, + end_lineno=84, + end_col_offset=81), + Div(), + Name( + 'placeholder_17', + Load(), + lineno=84, + col_offset=84, + end_lineno=84, + end_col_offset=95), + lineno=84, + col_offset=62, + end_lineno=84, + end_col_offset=95)], + [], + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=97), + lineno=84, + col_offset=8, + end_lineno=84, + end_col_offset=97)], + [], + lineno=75, + col_offset=4, + end_lineno=84, + end_col_offset=97), + FunctionDef( + 'placeholder_20', + arguments( + [], + [ + arg( + 'self', + lineno=86, + col_offset=16, + end_lineno=86, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=87, + col_offset=8, + end_lineno=87, + end_col_offset=18)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=21, + end_lineno=87, + end_col_offset=25), + 'placeholder_2', + Load(), + lineno=87, + col_offset=21, + end_lineno=87, + end_col_offset=30), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=33, + end_lineno=87, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=87, + col_offset=33, + end_lineno=87, + end_col_offset=42), + lineno=87, + col_offset=21, + end_lineno=87, + end_col_offset=42), + Add(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=45, + end_lineno=87, + end_col_offset=49), + 'placeholder_3', + Load(), + lineno=87, + col_offset=45, + end_lineno=87, + end_col_offset=59), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=62, + end_lineno=87, + end_col_offset=66), + 'placeholder_3', + Load(), + lineno=87, + col_offset=62, + end_lineno=87, + end_col_offset=76), + lineno=87, + col_offset=45, + end_lineno=87, + end_col_offset=76), + lineno=87, + col_offset=21, + end_lineno=87, + end_col_offset=76), + lineno=87, + col_offset=8, + end_lineno=87, + end_col_offset=76), + Return( + Call( + Attribute( + Name( + 'math', + Load(), + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=19), + 'sqrt', + Load(), + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=24), + [ + Name( + 'placeholder_21', + Load(), + lineno=88, + col_offset=25, + end_lineno=88, + end_col_offset=35)], + [], + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=36), + lineno=88, + col_offset=8, + end_lineno=88, + end_col_offset=36)], + [], + lineno=86, + col_offset=4, + end_lineno=88, + end_col_offset=36), + FunctionDef( + 'placeholder_22', + arguments( + [], + [ + arg( + 'self', + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=28), + [ + Attribute( + Name( + 'self', + Load(), + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=33), + 'placeholder_2', + Load(), + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=38), + BinOp( + UnaryOp( + USub(), + Constant( + 1, + lineno=91, + col_offset=41, + end_lineno=91, + end_col_offset=42), + lineno=91, + col_offset=40, + end_lineno=91, + end_col_offset=42), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=91, + col_offset=45, + end_lineno=91, + end_col_offset=49), + 'placeholder_3', + Load(), + lineno=91, + col_offset=45, + end_lineno=91, + end_col_offset=59), + lineno=91, + col_offset=40, + end_lineno=91, + end_col_offset=59)], + [], + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=60), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=60)], + [], + lineno=90, + col_offset=4, + end_lineno=91, + end_col_offset=60), + FunctionDef( + 'placeholder_23', + arguments( + [], + [ + arg( + 'self', + lineno=93, + col_offset=12, + end_lineno=93, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=17)], + BinOp( + Call( + Attribute( + Name( + 'math', + Load(), + lineno=94, + col_offset=20, + end_lineno=94, + end_col_offset=24), + 'cos', + Load(), + lineno=94, + col_offset=20, + end_lineno=94, + end_col_offset=28), + [ + Attribute( + Name( + 'self', + Load(), + lineno=94, + col_offset=29, + end_lineno=94, + end_col_offset=33), + 'placeholder_3', + Load(), + lineno=94, + col_offset=29, + end_lineno=94, + end_col_offset=43)], + [], + lineno=94, + col_offset=20, + end_lineno=94, + end_col_offset=44), + Mult(), + Call( + Attribute( + Name( + 'math', + Load(), + lineno=94, + col_offset=47, + end_lineno=94, + end_col_offset=51), + 'placeholder_23', + Load(), + lineno=94, + col_offset=47, + end_lineno=94, + end_col_offset=55), + [ + Attribute( + Name( + 'self', + Load(), + lineno=94, + col_offset=56, + end_lineno=94, + end_col_offset=60), + 'placeholder_2', + Load(), + lineno=94, + col_offset=56, + end_lineno=94, + end_col_offset=65)], + [], + lineno=94, + col_offset=47, + end_lineno=94, + end_col_offset=66), + lineno=94, + col_offset=20, + end_lineno=94, + end_col_offset=66), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=66), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=22)], + BinOp( + Call( + Attribute( + Name( + 'math', + Load(), + lineno=95, + col_offset=25, + end_lineno=95, + end_col_offset=29), + 'sin', + Load(), + lineno=95, + col_offset=25, + end_lineno=95, + end_col_offset=33), + [ + Attribute( + Name( + 'self', + Load(), + lineno=95, + col_offset=34, + end_lineno=95, + end_col_offset=38), + 'placeholder_3', + Load(), + lineno=95, + col_offset=34, + end_lineno=95, + end_col_offset=48)], + [], + lineno=95, + col_offset=25, + end_lineno=95, + end_col_offset=49), + Mult(), + Call( + Attribute( + Name( + 'math', + Load(), + lineno=95, + col_offset=52, + end_lineno=95, + end_col_offset=56), + 'placeholder_23', + Load(), + lineno=95, + col_offset=52, + end_lineno=95, + end_col_offset=60), + [ + Attribute( + Name( + 'self', + Load(), + lineno=95, + col_offset=61, + end_lineno=95, + end_col_offset=65), + 'placeholder_2', + Load(), + lineno=95, + col_offset=61, + end_lineno=95, + end_col_offset=70)], + [], + lineno=95, + col_offset=52, + end_lineno=95, + end_col_offset=71), + lineno=95, + col_offset=25, + end_lineno=95, + end_col_offset=71), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=71), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=96, + col_offset=15, + end_lineno=96, + end_col_offset=28), + [ + Name( + 'placeholder_7', + Load(), + lineno=96, + col_offset=29, + end_lineno=96, + end_col_offset=38), + Name( + 'placeholder_8', + Load(), + lineno=96, + col_offset=40, + end_lineno=96, + end_col_offset=54)], + [], + lineno=96, + col_offset=15, + end_lineno=96, + end_col_offset=55), + lineno=96, + col_offset=8, + end_lineno=96, + end_col_offset=55)], + [], + lineno=93, + col_offset=4, + end_lineno=96, + end_col_offset=55)], + [], + lineno=3, + col_offset=0, + end_lineno=96, + end_col_offset=55)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-complex-numbers/representation.txt b/test/practice-complex-numbers/representation.txt new file mode 100644 index 0000000..eb6f187 --- /dev/null +++ b/test/practice-complex-numbers/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('math', lineno=1, col_offset=7, end_lineno=1, end_col_offset=11)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=11), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=4, col_offset=17, end_lineno=4, end_col_offset=21), arg('placeholder_2', lineno=4, col_offset=23, end_lineno=4, end_col_offset=27), arg('placeholder_3', lineno=4, col_offset=31, end_lineno=4, end_col_offset=40)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(0, lineno=4, col_offset=28, end_lineno=4, end_col_offset=29), Constant(0, lineno=4, col_offset=41, end_lineno=4, end_col_offset=42)]), [Assign([Attribute(Name('self', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=12), 'placeholder_2', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=17)], Name('placeholder_2', Load(), lineno=5, col_offset=20, end_lineno=5, end_col_offset=24), lineno=5, col_offset=8, end_lineno=5, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_3', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=22)], Name('placeholder_3', Load(), lineno=6, col_offset=25, end_lineno=6, end_col_offset=34), lineno=6, col_offset=8, end_lineno=6, end_col_offset=34)], [], lineno=4, col_offset=4, end_lineno=6, end_col_offset=34), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=8, col_offset=15, end_lineno=8, end_col_offset=19), arg('placeholder_5', lineno=8, col_offset=21, end_lineno=8, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=9, col_offset=15, end_lineno=9, end_col_offset=25), [Name('placeholder_5', Load(), lineno=9, col_offset=26, end_lineno=9, end_col_offset=31), Name('placeholder_0', Load(), lineno=9, col_offset=33, end_lineno=9, end_col_offset=46)], [], lineno=9, col_offset=15, end_lineno=9, end_col_offset=47), lineno=9, col_offset=11, end_lineno=9, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=10, col_offset=12, end_lineno=10, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=10, col_offset=20, end_lineno=10, end_col_offset=33), [Name('placeholder_5', Load(), lineno=10, col_offset=34, end_lineno=10, end_col_offset=39)], [], lineno=10, col_offset=20, end_lineno=10, end_col_offset=40), lineno=10, col_offset=12, end_lineno=10, end_col_offset=40)], [], lineno=9, col_offset=8, end_lineno=10, end_col_offset=40), Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=19), 'placeholder_2', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=24), [Eq()], [Attribute(Name('placeholder_5', Load(), lineno=11, col_offset=28, end_lineno=11, end_col_offset=33), 'placeholder_2', Load(), lineno=11, col_offset=28, end_lineno=11, end_col_offset=38)], lineno=11, col_offset=15, end_lineno=11, end_col_offset=38), Compare(Attribute(Name('self', Load(), lineno=11, col_offset=43, end_lineno=11, end_col_offset=47), 'placeholder_3', Load(), lineno=11, col_offset=43, end_lineno=11, end_col_offset=57), [Eq()], [Attribute(Name('placeholder_5', Load(), lineno=11, col_offset=61, end_lineno=11, end_col_offset=66), 'placeholder_3', Load(), lineno=11, col_offset=61, end_lineno=11, end_col_offset=76)], lineno=11, col_offset=43, end_lineno=11, end_col_offset=76)], lineno=11, col_offset=15, end_lineno=11, end_col_offset=76), lineno=11, col_offset=8, end_lineno=11, end_col_offset=76)], [], lineno=8, col_offset=4, end_lineno=11, end_col_offset=76), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=13, col_offset=16, end_lineno=13, end_col_offset=20), arg('placeholder_5', lineno=13, col_offset=22, end_lineno=13, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=25), [Name('placeholder_5', Load(), lineno=15, col_offset=26, end_lineno=15, end_col_offset=31), Name('placeholder_0', Load(), lineno=15, col_offset=33, end_lineno=15, end_col_offset=46)], [], lineno=15, col_offset=15, end_lineno=15, end_col_offset=47), lineno=15, col_offset=11, end_lineno=15, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=16, col_offset=20, end_lineno=16, end_col_offset=33), [Name('placeholder_5', Load(), lineno=16, col_offset=34, end_lineno=16, end_col_offset=39)], [], lineno=16, col_offset=20, end_lineno=16, end_col_offset=40), lineno=16, col_offset=12, end_lineno=16, end_col_offset=40)], [], lineno=15, col_offset=8, end_lineno=16, end_col_offset=40), Assign([Name('placeholder_7', Store(), lineno=18, col_offset=8, end_lineno=18, end_col_offset=17)], BinOp(Attribute(Name('self', Load(), lineno=18, col_offset=20, end_lineno=18, end_col_offset=24), 'placeholder_2', Load(), lineno=18, col_offset=20, end_lineno=18, end_col_offset=29), Add(), Attribute(Name('placeholder_5', Load(), lineno=18, col_offset=32, end_lineno=18, end_col_offset=37), 'placeholder_2', Load(), lineno=18, col_offset=32, end_lineno=18, end_col_offset=42), lineno=18, col_offset=20, end_lineno=18, end_col_offset=42), lineno=18, col_offset=8, end_lineno=18, end_col_offset=42), Assign([Name('placeholder_8', Store(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=22)], BinOp(Attribute(Name('self', Load(), lineno=19, col_offset=25, end_lineno=19, end_col_offset=29), 'placeholder_3', Load(), lineno=19, col_offset=25, end_lineno=19, end_col_offset=39), Add(), Attribute(Name('placeholder_5', Load(), lineno=19, col_offset=42, end_lineno=19, end_col_offset=47), 'placeholder_3', Load(), lineno=19, col_offset=42, end_lineno=19, end_col_offset=57), lineno=19, col_offset=25, end_lineno=19, end_col_offset=57), lineno=19, col_offset=8, end_lineno=19, end_col_offset=57), Return(Call(Name('placeholder_0', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=28), [Name('placeholder_7', Load(), lineno=21, col_offset=29, end_lineno=21, end_col_offset=38), Name('placeholder_8', Load(), lineno=21, col_offset=40, end_lineno=21, end_col_offset=54)], [], lineno=21, col_offset=15, end_lineno=21, end_col_offset=55), lineno=21, col_offset=8, end_lineno=21, end_col_offset=55)], [], lineno=13, col_offset=4, end_lineno=21, end_col_offset=55), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=23, col_offset=17, end_lineno=23, end_col_offset=21), arg('placeholder_5', lineno=23, col_offset=23, end_lineno=23, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=25), [Name('placeholder_5', Load(), lineno=25, col_offset=26, end_lineno=25, end_col_offset=31), Name('placeholder_0', Load(), lineno=25, col_offset=33, end_lineno=25, end_col_offset=46)], [], lineno=25, col_offset=15, end_lineno=25, end_col_offset=47), lineno=25, col_offset=11, end_lineno=25, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=26, col_offset=20, end_lineno=26, end_col_offset=33), [Name('placeholder_5', Load(), lineno=26, col_offset=34, end_lineno=26, end_col_offset=39)], [], lineno=26, col_offset=20, end_lineno=26, end_col_offset=40), lineno=26, col_offset=12, end_lineno=26, end_col_offset=40)], [], lineno=25, col_offset=8, end_lineno=26, end_col_offset=40), Assign([Name('placeholder_7', Store(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=17)], BinOp(Attribute(Name('self', Load(), lineno=28, col_offset=20, end_lineno=28, end_col_offset=24), 'placeholder_2', Load(), lineno=28, col_offset=20, end_lineno=28, end_col_offset=29), Add(), Attribute(Name('placeholder_5', Load(), lineno=28, col_offset=32, end_lineno=28, end_col_offset=37), 'placeholder_2', Load(), lineno=28, col_offset=32, end_lineno=28, end_col_offset=42), lineno=28, col_offset=20, end_lineno=28, end_col_offset=42), lineno=28, col_offset=8, end_lineno=28, end_col_offset=42), Assign([Name('placeholder_8', Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=22)], BinOp(Attribute(Name('self', Load(), lineno=29, col_offset=25, end_lineno=29, end_col_offset=29), 'placeholder_3', Load(), lineno=29, col_offset=25, end_lineno=29, end_col_offset=39), Add(), Attribute(Name('placeholder_5', Load(), lineno=29, col_offset=42, end_lineno=29, end_col_offset=47), 'placeholder_3', Load(), lineno=29, col_offset=42, end_lineno=29, end_col_offset=57), lineno=29, col_offset=25, end_lineno=29, end_col_offset=57), lineno=29, col_offset=8, end_lineno=29, end_col_offset=57), Return(Call(Name('placeholder_0', Load(), lineno=31, col_offset=15, end_lineno=31, end_col_offset=28), [Name('placeholder_7', Load(), lineno=31, col_offset=29, end_lineno=31, end_col_offset=38), Name('placeholder_8', Load(), lineno=31, col_offset=40, end_lineno=31, end_col_offset=54)], [], lineno=31, col_offset=15, end_lineno=31, end_col_offset=55), lineno=31, col_offset=8, end_lineno=31, end_col_offset=55)], [], lineno=23, col_offset=4, end_lineno=31, end_col_offset=55), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=33, col_offset=16, end_lineno=33, end_col_offset=20), arg('placeholder_5', lineno=33, col_offset=22, end_lineno=33, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=25), [Name('placeholder_5', Load(), lineno=34, col_offset=26, end_lineno=34, end_col_offset=31), Name('placeholder_0', Load(), lineno=34, col_offset=33, end_lineno=34, end_col_offset=46)], [], lineno=34, col_offset=15, end_lineno=34, end_col_offset=47), lineno=34, col_offset=11, end_lineno=34, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=35, col_offset=12, end_lineno=35, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=35, col_offset=20, end_lineno=35, end_col_offset=33), [Name('placeholder_5', Load(), lineno=35, col_offset=34, end_lineno=35, end_col_offset=39)], [], lineno=35, col_offset=20, end_lineno=35, end_col_offset=40), lineno=35, col_offset=12, end_lineno=35, end_col_offset=40)], [], lineno=34, col_offset=8, end_lineno=35, end_col_offset=40), Assign([Name('placeholder_7', Store(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=17)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=37, col_offset=20, end_lineno=37, end_col_offset=24), 'placeholder_2', Load(), lineno=37, col_offset=20, end_lineno=37, end_col_offset=29), Mult(), Attribute(Name('placeholder_5', Load(), lineno=37, col_offset=32, end_lineno=37, end_col_offset=37), 'placeholder_2', Load(), lineno=37, col_offset=32, end_lineno=37, end_col_offset=42), lineno=37, col_offset=20, end_lineno=37, end_col_offset=42), Sub(), BinOp(Attribute(Name('self', Load(), lineno=37, col_offset=45, end_lineno=37, end_col_offset=49), 'placeholder_3', Load(), lineno=37, col_offset=45, end_lineno=37, end_col_offset=59), Mult(), Attribute(Name('placeholder_5', Load(), lineno=37, col_offset=62, end_lineno=37, end_col_offset=67), 'placeholder_3', Load(), lineno=37, col_offset=62, end_lineno=37, end_col_offset=77), lineno=37, col_offset=45, end_lineno=37, end_col_offset=77), lineno=37, col_offset=20, end_lineno=37, end_col_offset=77), lineno=37, col_offset=8, end_lineno=37, end_col_offset=77), Assign([Name('placeholder_8', Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=22)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=38, col_offset=25, end_lineno=38, end_col_offset=29), 'placeholder_2', Load(), lineno=38, col_offset=25, end_lineno=38, end_col_offset=34), Mult(), Attribute(Name('placeholder_5', Load(), lineno=38, col_offset=37, end_lineno=38, end_col_offset=42), 'placeholder_3', Load(), lineno=38, col_offset=37, end_lineno=38, end_col_offset=52), lineno=38, col_offset=25, end_lineno=38, end_col_offset=52), Add(), BinOp(Attribute(Name('self', Load(), lineno=38, col_offset=55, end_lineno=38, end_col_offset=59), 'placeholder_3', Load(), lineno=38, col_offset=55, end_lineno=38, end_col_offset=69), Mult(), Attribute(Name('placeholder_5', Load(), lineno=38, col_offset=72, end_lineno=38, end_col_offset=77), 'placeholder_2', Load(), lineno=38, col_offset=72, end_lineno=38, end_col_offset=82), lineno=38, col_offset=55, end_lineno=38, end_col_offset=82), lineno=38, col_offset=25, end_lineno=38, end_col_offset=82), lineno=38, col_offset=8, end_lineno=38, end_col_offset=82), Return(Call(Name('placeholder_0', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=28), [Name('placeholder_7', Load(), lineno=39, col_offset=29, end_lineno=39, end_col_offset=38), Name('placeholder_8', Load(), lineno=39, col_offset=40, end_lineno=39, end_col_offset=54)], [], lineno=39, col_offset=15, end_lineno=39, end_col_offset=55), lineno=39, col_offset=8, end_lineno=39, end_col_offset=55)], [], lineno=33, col_offset=4, end_lineno=39, end_col_offset=55), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=41, col_offset=17, end_lineno=41, end_col_offset=21), arg('placeholder_5', lineno=41, col_offset=23, end_lineno=41, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=42, col_offset=15, end_lineno=42, end_col_offset=25), [Name('placeholder_5', Load(), lineno=42, col_offset=26, end_lineno=42, end_col_offset=31), Name('placeholder_0', Load(), lineno=42, col_offset=33, end_lineno=42, end_col_offset=46)], [], lineno=42, col_offset=15, end_lineno=42, end_col_offset=47), lineno=42, col_offset=11, end_lineno=42, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=43, col_offset=20, end_lineno=43, end_col_offset=33), [Name('placeholder_5', Load(), lineno=43, col_offset=34, end_lineno=43, end_col_offset=39)], [], lineno=43, col_offset=20, end_lineno=43, end_col_offset=40), lineno=43, col_offset=12, end_lineno=43, end_col_offset=40)], [], lineno=42, col_offset=8, end_lineno=43, end_col_offset=40), Assign([Name('placeholder_7', Store(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=17)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=45, col_offset=20, end_lineno=45, end_col_offset=24), 'placeholder_2', Load(), lineno=45, col_offset=20, end_lineno=45, end_col_offset=29), Mult(), Attribute(Name('placeholder_5', Load(), lineno=45, col_offset=32, end_lineno=45, end_col_offset=37), 'placeholder_2', Load(), lineno=45, col_offset=32, end_lineno=45, end_col_offset=42), lineno=45, col_offset=20, end_lineno=45, end_col_offset=42), Sub(), BinOp(Attribute(Name('self', Load(), lineno=45, col_offset=45, end_lineno=45, end_col_offset=49), 'placeholder_3', Load(), lineno=45, col_offset=45, end_lineno=45, end_col_offset=59), Mult(), Attribute(Name('placeholder_5', Load(), lineno=45, col_offset=62, end_lineno=45, end_col_offset=67), 'placeholder_3', Load(), lineno=45, col_offset=62, end_lineno=45, end_col_offset=77), lineno=45, col_offset=45, end_lineno=45, end_col_offset=77), lineno=45, col_offset=20, end_lineno=45, end_col_offset=77), lineno=45, col_offset=8, end_lineno=45, end_col_offset=77), Assign([Name('placeholder_8', Store(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=22)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=46, col_offset=25, end_lineno=46, end_col_offset=29), 'placeholder_2', Load(), lineno=46, col_offset=25, end_lineno=46, end_col_offset=34), Mult(), Attribute(Name('placeholder_5', Load(), lineno=46, col_offset=37, end_lineno=46, end_col_offset=42), 'placeholder_3', Load(), lineno=46, col_offset=37, end_lineno=46, end_col_offset=52), lineno=46, col_offset=25, end_lineno=46, end_col_offset=52), Add(), BinOp(Attribute(Name('self', Load(), lineno=46, col_offset=55, end_lineno=46, end_col_offset=59), 'placeholder_3', Load(), lineno=46, col_offset=55, end_lineno=46, end_col_offset=69), Mult(), Attribute(Name('placeholder_5', Load(), lineno=46, col_offset=72, end_lineno=46, end_col_offset=77), 'placeholder_2', Load(), lineno=46, col_offset=72, end_lineno=46, end_col_offset=82), lineno=46, col_offset=55, end_lineno=46, end_col_offset=82), lineno=46, col_offset=25, end_lineno=46, end_col_offset=82), lineno=46, col_offset=8, end_lineno=46, end_col_offset=82), Return(Call(Name('placeholder_0', Load(), lineno=47, col_offset=15, end_lineno=47, end_col_offset=28), [Name('placeholder_7', Load(), lineno=47, col_offset=29, end_lineno=47, end_col_offset=38), Name('placeholder_8', Load(), lineno=47, col_offset=40, end_lineno=47, end_col_offset=54)], [], lineno=47, col_offset=15, end_lineno=47, end_col_offset=55), lineno=47, col_offset=8, end_lineno=47, end_col_offset=55)], [], lineno=41, col_offset=4, end_lineno=47, end_col_offset=55), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=49, col_offset=16, end_lineno=49, end_col_offset=20), arg('placeholder_5', lineno=49, col_offset=22, end_lineno=49, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=50, col_offset=15, end_lineno=50, end_col_offset=25), [Name('placeholder_5', Load(), lineno=50, col_offset=26, end_lineno=50, end_col_offset=31), Name('placeholder_0', Load(), lineno=50, col_offset=33, end_lineno=50, end_col_offset=46)], [], lineno=50, col_offset=15, end_lineno=50, end_col_offset=47), lineno=50, col_offset=11, end_lineno=50, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=51, col_offset=12, end_lineno=51, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=51, col_offset=20, end_lineno=51, end_col_offset=33), [Name('placeholder_5', Load(), lineno=51, col_offset=34, end_lineno=51, end_col_offset=39)], [], lineno=51, col_offset=20, end_lineno=51, end_col_offset=40), lineno=51, col_offset=12, end_lineno=51, end_col_offset=40)], [], lineno=50, col_offset=8, end_lineno=51, end_col_offset=40), Assign([Name('placeholder_7', Store(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=17)], BinOp(Attribute(Name('self', Load(), lineno=52, col_offset=20, end_lineno=52, end_col_offset=24), 'placeholder_2', Load(), lineno=52, col_offset=20, end_lineno=52, end_col_offset=29), Sub(), Attribute(Name('placeholder_5', Load(), lineno=52, col_offset=32, end_lineno=52, end_col_offset=37), 'placeholder_2', Load(), lineno=52, col_offset=32, end_lineno=52, end_col_offset=42), lineno=52, col_offset=20, end_lineno=52, end_col_offset=42), lineno=52, col_offset=8, end_lineno=52, end_col_offset=42), Assign([Name('placeholder_8', Store(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=22)], BinOp(Attribute(Name('self', Load(), lineno=53, col_offset=25, end_lineno=53, end_col_offset=29), 'placeholder_3', Load(), lineno=53, col_offset=25, end_lineno=53, end_col_offset=39), Sub(), Attribute(Name('placeholder_5', Load(), lineno=53, col_offset=42, end_lineno=53, end_col_offset=47), 'placeholder_3', Load(), lineno=53, col_offset=42, end_lineno=53, end_col_offset=57), lineno=53, col_offset=25, end_lineno=53, end_col_offset=57), lineno=53, col_offset=8, end_lineno=53, end_col_offset=57), Return(Call(Name('placeholder_0', Load(), lineno=54, col_offset=15, end_lineno=54, end_col_offset=28), [Name('placeholder_7', Load(), lineno=54, col_offset=29, end_lineno=54, end_col_offset=38), Name('placeholder_8', Load(), lineno=54, col_offset=40, end_lineno=54, end_col_offset=54)], [], lineno=54, col_offset=15, end_lineno=54, end_col_offset=55), lineno=54, col_offset=8, end_lineno=54, end_col_offset=55)], [], lineno=49, col_offset=4, end_lineno=54, end_col_offset=55), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=56, col_offset=17, end_lineno=56, end_col_offset=21), arg('placeholder_5', lineno=56, col_offset=23, end_lineno=56, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=57, col_offset=15, end_lineno=57, end_col_offset=25), [Name('placeholder_5', Load(), lineno=57, col_offset=26, end_lineno=57, end_col_offset=31), Name('placeholder_0', Load(), lineno=57, col_offset=33, end_lineno=57, end_col_offset=46)], [], lineno=57, col_offset=15, end_lineno=57, end_col_offset=47), lineno=57, col_offset=11, end_lineno=57, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=58, col_offset=12, end_lineno=58, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=58, col_offset=20, end_lineno=58, end_col_offset=33), [Name('placeholder_5', Load(), lineno=58, col_offset=34, end_lineno=58, end_col_offset=39)], [], lineno=58, col_offset=20, end_lineno=58, end_col_offset=40), lineno=58, col_offset=12, end_lineno=58, end_col_offset=40)], [], lineno=57, col_offset=8, end_lineno=58, end_col_offset=40), Assign([Name('placeholder_7', Store(), lineno=60, col_offset=8, end_lineno=60, end_col_offset=17)], BinOp(Attribute(Name('placeholder_5', Load(), lineno=60, col_offset=20, end_lineno=60, end_col_offset=25), 'placeholder_2', Load(), lineno=60, col_offset=20, end_lineno=60, end_col_offset=30), Sub(), Attribute(Name('self', Load(), lineno=60, col_offset=33, end_lineno=60, end_col_offset=37), 'placeholder_2', Load(), lineno=60, col_offset=33, end_lineno=60, end_col_offset=42), lineno=60, col_offset=20, end_lineno=60, end_col_offset=42), lineno=60, col_offset=8, end_lineno=60, end_col_offset=42), Assign([Name('placeholder_8', Store(), lineno=61, col_offset=8, end_lineno=61, end_col_offset=22)], BinOp(Attribute(Name('placeholder_5', Load(), lineno=61, col_offset=25, end_lineno=61, end_col_offset=30), 'placeholder_3', Load(), lineno=61, col_offset=25, end_lineno=61, end_col_offset=40), Sub(), Attribute(Name('self', Load(), lineno=61, col_offset=43, end_lineno=61, end_col_offset=47), 'placeholder_3', Load(), lineno=61, col_offset=43, end_lineno=61, end_col_offset=57), lineno=61, col_offset=25, end_lineno=61, end_col_offset=57), lineno=61, col_offset=8, end_lineno=61, end_col_offset=57), Return(Call(Name('placeholder_0', Load(), lineno=62, col_offset=15, end_lineno=62, end_col_offset=28), [Name('placeholder_7', Load(), lineno=62, col_offset=29, end_lineno=62, end_col_offset=38), Name('placeholder_8', Load(), lineno=62, col_offset=40, end_lineno=62, end_col_offset=54)], [], lineno=62, col_offset=15, end_lineno=62, end_col_offset=55), lineno=62, col_offset=8, end_lineno=62, end_col_offset=55)], [], lineno=56, col_offset=4, end_lineno=62, end_col_offset=55), FunctionDef('placeholder_14', arguments([], [arg('self', lineno=64, col_offset=20, end_lineno=64, end_col_offset=24), arg('placeholder_5', lineno=64, col_offset=26, end_lineno=64, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=65, col_offset=15, end_lineno=65, end_col_offset=25), [Name('placeholder_5', Load(), lineno=65, col_offset=26, end_lineno=65, end_col_offset=31), Name('placeholder_0', Load(), lineno=65, col_offset=33, end_lineno=65, end_col_offset=46)], [], lineno=65, col_offset=15, end_lineno=65, end_col_offset=47), lineno=65, col_offset=11, end_lineno=65, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=66, col_offset=12, end_lineno=66, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=66, col_offset=20, end_lineno=66, end_col_offset=33), [Name('placeholder_5', Load(), lineno=66, col_offset=34, end_lineno=66, end_col_offset=39)], [], lineno=66, col_offset=20, end_lineno=66, end_col_offset=40), lineno=66, col_offset=12, end_lineno=66, end_col_offset=40)], [], lineno=65, col_offset=8, end_lineno=66, end_col_offset=40), Assign([Name('placeholder_15', Store(), lineno=68, col_offset=8, end_lineno=68, end_col_offset=19)], Call(Attribute(Name('placeholder_5', Load(), lineno=68, col_offset=22, end_lineno=68, end_col_offset=27), 'conjugate', Load(), lineno=68, col_offset=22, end_lineno=68, end_col_offset=37), [], [], lineno=68, col_offset=22, end_lineno=68, end_col_offset=39), lineno=68, col_offset=8, end_lineno=68, end_col_offset=39), Assign([Name('placeholder_16', Store(), lineno=69, col_offset=8, end_lineno=69, end_col_offset=23)], BinOp(Name('placeholder_5', Load(), lineno=69, col_offset=26, end_lineno=69, end_col_offset=31), Mult(), Name('placeholder_15', Load(), lineno=69, col_offset=34, end_lineno=69, end_col_offset=45), lineno=69, col_offset=26, end_lineno=69, end_col_offset=45), lineno=69, col_offset=8, end_lineno=69, end_col_offset=45), Assign([Name('placeholder_17', Store(), lineno=70, col_offset=8, end_lineno=70, end_col_offset=19)], Attribute(Name('placeholder_16', Load(), lineno=70, col_offset=22, end_lineno=70, end_col_offset=37), 'placeholder_2', Load(), lineno=70, col_offset=22, end_lineno=70, end_col_offset=42), lineno=70, col_offset=8, end_lineno=70, end_col_offset=42), Assign([Name('placeholder_18', Store(), lineno=71, col_offset=8, end_lineno=71, end_col_offset=17)], BinOp(Name('self', Load(), lineno=71, col_offset=20, end_lineno=71, end_col_offset=24), Mult(), Name('placeholder_15', Load(), lineno=71, col_offset=27, end_lineno=71, end_col_offset=38), lineno=71, col_offset=20, end_lineno=71, end_col_offset=38), lineno=71, col_offset=8, end_lineno=71, end_col_offset=38), Return(Call(Name('placeholder_0', Load(), lineno=73, col_offset=15, end_lineno=73, end_col_offset=28), [BinOp(Attribute(Name('placeholder_18', Load(), lineno=73, col_offset=30, end_lineno=73, end_col_offset=39), 'placeholder_2', Load(), lineno=73, col_offset=30, end_lineno=73, end_col_offset=44), Div(), Name('placeholder_17', Load(), lineno=73, col_offset=47, end_lineno=73, end_col_offset=58), lineno=73, col_offset=30, end_lineno=73, end_col_offset=58), BinOp(Attribute(Name('placeholder_18', Load(), lineno=73, col_offset=62, end_lineno=73, end_col_offset=71), 'placeholder_3', Load(), lineno=73, col_offset=62, end_lineno=73, end_col_offset=81), Div(), Name('placeholder_17', Load(), lineno=73, col_offset=84, end_lineno=73, end_col_offset=95), lineno=73, col_offset=62, end_lineno=73, end_col_offset=95)], [], lineno=73, col_offset=15, end_lineno=73, end_col_offset=97), lineno=73, col_offset=8, end_lineno=73, end_col_offset=97)], [], lineno=64, col_offset=4, end_lineno=73, end_col_offset=97), FunctionDef('placeholder_19', arguments([], [arg('self', lineno=75, col_offset=21, end_lineno=75, end_col_offset=25), arg('placeholder_5', lineno=75, col_offset=27, end_lineno=75, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=76, col_offset=15, end_lineno=76, end_col_offset=25), [Name('placeholder_5', Load(), lineno=76, col_offset=26, end_lineno=76, end_col_offset=31), Name('placeholder_0', Load(), lineno=76, col_offset=33, end_lineno=76, end_col_offset=46)], [], lineno=76, col_offset=15, end_lineno=76, end_col_offset=47), lineno=76, col_offset=11, end_lineno=76, end_col_offset=47), [Assign([Name('placeholder_5', Store(), lineno=77, col_offset=12, end_lineno=77, end_col_offset=17)], Call(Name('placeholder_0', Load(), lineno=77, col_offset=20, end_lineno=77, end_col_offset=33), [Name('placeholder_5', Load(), lineno=77, col_offset=34, end_lineno=77, end_col_offset=39)], [], lineno=77, col_offset=20, end_lineno=77, end_col_offset=40), lineno=77, col_offset=12, end_lineno=77, end_col_offset=40)], [], lineno=76, col_offset=8, end_lineno=77, end_col_offset=40), Assign([Name('placeholder_15', Store(), lineno=79, col_offset=8, end_lineno=79, end_col_offset=19)], Call(Attribute(Name('self', Load(), lineno=79, col_offset=22, end_lineno=79, end_col_offset=26), 'conjugate', Load(), lineno=79, col_offset=22, end_lineno=79, end_col_offset=36), [], [], lineno=79, col_offset=22, end_lineno=79, end_col_offset=38), lineno=79, col_offset=8, end_lineno=79, end_col_offset=38), Assign([Name('placeholder_16', Store(), lineno=80, col_offset=8, end_lineno=80, end_col_offset=23)], BinOp(Name('self', Load(), lineno=80, col_offset=26, end_lineno=80, end_col_offset=30), Mult(), Name('placeholder_15', Load(), lineno=80, col_offset=33, end_lineno=80, end_col_offset=44), lineno=80, col_offset=26, end_lineno=80, end_col_offset=44), lineno=80, col_offset=8, end_lineno=80, end_col_offset=44), Assign([Name('placeholder_17', Store(), lineno=81, col_offset=8, end_lineno=81, end_col_offset=19)], Call(Name('float', Load(), lineno=81, col_offset=22, end_lineno=81, end_col_offset=27), [Attribute(Name('placeholder_16', Load(), lineno=81, col_offset=28, end_lineno=81, end_col_offset=43), 'placeholder_2', Load(), lineno=81, col_offset=28, end_lineno=81, end_col_offset=48)], [], lineno=81, col_offset=22, end_lineno=81, end_col_offset=49), lineno=81, col_offset=8, end_lineno=81, end_col_offset=49), Assign([Name('placeholder_18', Store(), lineno=82, col_offset=8, end_lineno=82, end_col_offset=17)], BinOp(Name('placeholder_5', Load(), lineno=82, col_offset=20, end_lineno=82, end_col_offset=25), Mult(), Name('placeholder_15', Load(), lineno=82, col_offset=28, end_lineno=82, end_col_offset=39), lineno=82, col_offset=20, end_lineno=82, end_col_offset=39), lineno=82, col_offset=8, end_lineno=82, end_col_offset=39), Return(Call(Name('placeholder_0', Load(), lineno=84, col_offset=15, end_lineno=84, end_col_offset=28), [BinOp(Attribute(Name('placeholder_18', Load(), lineno=84, col_offset=30, end_lineno=84, end_col_offset=39), 'placeholder_2', Load(), lineno=84, col_offset=30, end_lineno=84, end_col_offset=44), Div(), Name('placeholder_17', Load(), lineno=84, col_offset=47, end_lineno=84, end_col_offset=58), lineno=84, col_offset=30, end_lineno=84, end_col_offset=58), BinOp(Attribute(Name('placeholder_18', Load(), lineno=84, col_offset=62, end_lineno=84, end_col_offset=71), 'placeholder_3', Load(), lineno=84, col_offset=62, end_lineno=84, end_col_offset=81), Div(), Name('placeholder_17', Load(), lineno=84, col_offset=84, end_lineno=84, end_col_offset=95), lineno=84, col_offset=62, end_lineno=84, end_col_offset=95)], [], lineno=84, col_offset=15, end_lineno=84, end_col_offset=97), lineno=84, col_offset=8, end_lineno=84, end_col_offset=97)], [], lineno=75, col_offset=4, end_lineno=84, end_col_offset=97), FunctionDef('placeholder_20', arguments([], [arg('self', lineno=86, col_offset=16, end_lineno=86, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_21', Store(), lineno=87, col_offset=8, end_lineno=87, end_col_offset=18)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=87, col_offset=21, end_lineno=87, end_col_offset=25), 'placeholder_2', Load(), lineno=87, col_offset=21, end_lineno=87, end_col_offset=30), Mult(), Attribute(Name('self', Load(), lineno=87, col_offset=33, end_lineno=87, end_col_offset=37), 'placeholder_2', Load(), lineno=87, col_offset=33, end_lineno=87, end_col_offset=42), lineno=87, col_offset=21, end_lineno=87, end_col_offset=42), Add(), BinOp(Attribute(Name('self', Load(), lineno=87, col_offset=45, end_lineno=87, end_col_offset=49), 'placeholder_3', Load(), lineno=87, col_offset=45, end_lineno=87, end_col_offset=59), Mult(), Attribute(Name('self', Load(), lineno=87, col_offset=62, end_lineno=87, end_col_offset=66), 'placeholder_3', Load(), lineno=87, col_offset=62, end_lineno=87, end_col_offset=76), lineno=87, col_offset=45, end_lineno=87, end_col_offset=76), lineno=87, col_offset=21, end_lineno=87, end_col_offset=76), lineno=87, col_offset=8, end_lineno=87, end_col_offset=76), Return(Call(Attribute(Name('math', Load(), lineno=88, col_offset=15, end_lineno=88, end_col_offset=19), 'sqrt', Load(), lineno=88, col_offset=15, end_lineno=88, end_col_offset=24), [Name('placeholder_21', Load(), lineno=88, col_offset=25, end_lineno=88, end_col_offset=35)], [], lineno=88, col_offset=15, end_lineno=88, end_col_offset=36), lineno=88, col_offset=8, end_lineno=88, end_col_offset=36)], [], lineno=86, col_offset=4, end_lineno=88, end_col_offset=36), FunctionDef('placeholder_22', arguments([], [arg('self', lineno=90, col_offset=18, end_lineno=90, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=91, col_offset=15, end_lineno=91, end_col_offset=28), [Attribute(Name('self', Load(), lineno=91, col_offset=29, end_lineno=91, end_col_offset=33), 'placeholder_2', Load(), lineno=91, col_offset=29, end_lineno=91, end_col_offset=38), BinOp(UnaryOp(USub(), Constant(1, lineno=91, col_offset=41, end_lineno=91, end_col_offset=42), lineno=91, col_offset=40, end_lineno=91, end_col_offset=42), Mult(), Attribute(Name('self', Load(), lineno=91, col_offset=45, end_lineno=91, end_col_offset=49), 'placeholder_3', Load(), lineno=91, col_offset=45, end_lineno=91, end_col_offset=59), lineno=91, col_offset=40, end_lineno=91, end_col_offset=59)], [], lineno=91, col_offset=15, end_lineno=91, end_col_offset=60), lineno=91, col_offset=8, end_lineno=91, end_col_offset=60)], [], lineno=90, col_offset=4, end_lineno=91, end_col_offset=60), FunctionDef('placeholder_23', arguments([], [arg('self', lineno=93, col_offset=12, end_lineno=93, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=94, col_offset=8, end_lineno=94, end_col_offset=17)], BinOp(Call(Attribute(Name('math', Load(), lineno=94, col_offset=20, end_lineno=94, end_col_offset=24), 'cos', Load(), lineno=94, col_offset=20, end_lineno=94, end_col_offset=28), [Attribute(Name('self', Load(), lineno=94, col_offset=29, end_lineno=94, end_col_offset=33), 'placeholder_3', Load(), lineno=94, col_offset=29, end_lineno=94, end_col_offset=43)], [], lineno=94, col_offset=20, end_lineno=94, end_col_offset=44), Mult(), Call(Attribute(Name('math', Load(), lineno=94, col_offset=47, end_lineno=94, end_col_offset=51), 'placeholder_23', Load(), lineno=94, col_offset=47, end_lineno=94, end_col_offset=55), [Attribute(Name('self', Load(), lineno=94, col_offset=56, end_lineno=94, end_col_offset=60), 'placeholder_2', Load(), lineno=94, col_offset=56, end_lineno=94, end_col_offset=65)], [], lineno=94, col_offset=47, end_lineno=94, end_col_offset=66), lineno=94, col_offset=20, end_lineno=94, end_col_offset=66), lineno=94, col_offset=8, end_lineno=94, end_col_offset=66), Assign([Name('placeholder_8', Store(), lineno=95, col_offset=8, end_lineno=95, end_col_offset=22)], BinOp(Call(Attribute(Name('math', Load(), lineno=95, col_offset=25, end_lineno=95, end_col_offset=29), 'sin', Load(), lineno=95, col_offset=25, end_lineno=95, end_col_offset=33), [Attribute(Name('self', Load(), lineno=95, col_offset=34, end_lineno=95, end_col_offset=38), 'placeholder_3', Load(), lineno=95, col_offset=34, end_lineno=95, end_col_offset=48)], [], lineno=95, col_offset=25, end_lineno=95, end_col_offset=49), Mult(), Call(Attribute(Name('math', Load(), lineno=95, col_offset=52, end_lineno=95, end_col_offset=56), 'placeholder_23', Load(), lineno=95, col_offset=52, end_lineno=95, end_col_offset=60), [Attribute(Name('self', Load(), lineno=95, col_offset=61, end_lineno=95, end_col_offset=65), 'placeholder_2', Load(), lineno=95, col_offset=61, end_lineno=95, end_col_offset=70)], [], lineno=95, col_offset=52, end_lineno=95, end_col_offset=71), lineno=95, col_offset=25, end_lineno=95, end_col_offset=71), lineno=95, col_offset=8, end_lineno=95, end_col_offset=71), Return(Call(Name('placeholder_0', Load(), lineno=96, col_offset=15, end_lineno=96, end_col_offset=28), [Name('placeholder_7', Load(), lineno=96, col_offset=29, end_lineno=96, end_col_offset=38), Name('placeholder_8', Load(), lineno=96, col_offset=40, end_lineno=96, end_col_offset=54)], [], lineno=96, col_offset=15, end_lineno=96, end_col_offset=55), lineno=96, col_offset=8, end_lineno=96, end_col_offset=55)], [], lineno=93, col_offset=4, end_lineno=96, end_col_offset=55)], [], lineno=3, col_offset=0, end_lineno=96, end_col_offset=55)], []) \ No newline at end of file diff --git a/test/practice-connect/.meta/config.json b/test/practice-connect/.meta/config.json new file mode 100644 index 0000000..dcabaa7 --- /dev/null +++ b/test/practice-connect/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "yunchih" + ], + "contributors": [ + "cmccandless", + "Dog", + "dvermd", + "N-Parsons", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "connect.py" + ], + "test": [ + "connect_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Compute the result for a game of Hex / Polygon." +} diff --git a/test/practice-connect/connect.py b/test/practice-connect/connect.py new file mode 100644 index 0000000..0cb0033 --- /dev/null +++ b/test/practice-connect/connect.py @@ -0,0 +1,66 @@ + +class ConnectGame: + + DIRECTIONS = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, -1), (-1, 1)] + WHITE = 'O' + BLACK = 'X' + + def __init__(self, lines): + self.board = ConnectGame.make_board(lines) + assert len(self.board) > 0 + + self.width = len(self.board[0]) + self.height = len(self.board) + assert self.width > 0 and self.height > 0 + + for line in self.board: + assert len(line) == self.width + + def valid(self, width, height): + return 0 <= width < self.width and 0 <= height < self.height + + @staticmethod + def make_board(lines): + return [''.join(cur_line.split()) for cur_line in lines.splitlines()] + + def player_reach_dest(self, player, width, height): + if player == self.BLACK: + return width == self.width - 1 + if player == self.WHITE: + return height == self.height - 1 + return None + + def walk_board(self, player, width, height, visited=None): + if not visited: + visited = [] + if (width, height) in visited: + return False + + if (not self.valid(width, height)) or self.board[height][width] != player: + return False + + if self.player_reach_dest(player, width, height): + return True + + for vector in self.DIRECTIONS: + if self.walk_board(player, width + vector[0], height + vector[1], visited + [(width, height)]): + return True + return None + + def check_player_is_winner(self, player): + if player == self.BLACK: + for height in range(self.height): + if self.walk_board(player, 0, height): + return True + if player == self.WHITE: + for width in range(self.width): + if self.walk_board(player, width, 0): + return True + return None + + def get_winner(self): + if self.check_player_is_winner(self.BLACK): + return self.BLACK + if self.check_player_is_winner(self.WHITE): + return self.WHITE + return '' diff --git a/test/practice-connect/mapping.json b/test/practice-connect/mapping.json new file mode 100644 index 0000000..480cd40 --- /dev/null +++ b/test/practice-connect/mapping.json @@ -0,0 +1,22 @@ +{ + "placeholder_0": "ConnectGame", + "placeholder_1": "DIRECTIONS", + "placeholder_2": "WHITE", + "placeholder_3": "BLACK", + "placeholder_4": "__init__", + "placeholder_5": "lines", + "placeholder_6": "board", + "placeholder_7": "width", + "placeholder_8": "height", + "placeholder_9": "line", + "placeholder_10": "valid", + "placeholder_11": "make_board", + "placeholder_12": "cur_line", + "placeholder_13": "player_reach_dest", + "placeholder_14": "player", + "placeholder_15": "walk_board", + "placeholder_16": "visited", + "placeholder_17": "vector", + "placeholder_18": "check_player_is_winner", + "placeholder_19": "get_winner" +} \ No newline at end of file diff --git a/test/practice-connect/representation.json b/test/practice-connect/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-connect/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-connect/representation.out b/test/practice-connect/representation.out new file mode 100644 index 0000000..98c46d7 --- /dev/null +++ b/test/practice-connect/representation.out @@ -0,0 +1,4084 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + placeholder_1 = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, -1), (-1, 1)] + placeholder_2 = "O" + placeholder_3 = "X" + + def placeholder_4(self, placeholder_5): + self.placeholder_6 = placeholder_0.make_board(placeholder_5) + assert len(self.placeholder_6) > 0 + self.placeholder_7 = len(self.placeholder_6[0]) + self.placeholder_8 = len(self.placeholder_6) + assert self.placeholder_7 > 0 and self.placeholder_8 > 0 + for placeholder_9 in self.placeholder_6: + assert len(placeholder_9) == self.placeholder_7 + + def placeholder_10(self, placeholder_7, placeholder_8): + return ( + 0 <= placeholder_7 < self.placeholder_7 + and 0 <= placeholder_8 < self.placeholder_8 + ) + + @staticmethod + def placeholder_11(placeholder_5): + return [ + "".join(placeholder_12.split()) + for placeholder_12 in placeholder_5.splitlines() + ] + + def placeholder_13(self, placeholder_14, placeholder_7, placeholder_8): + if placeholder_14 == self.placeholder_3: + return placeholder_7 == self.placeholder_7 - 1 + if placeholder_14 == self.placeholder_2: + return placeholder_8 == self.placeholder_8 - 1 + return None + + def placeholder_15( + self, placeholder_14, placeholder_7, placeholder_8, placeholder_16=None + ): + if not placeholder_16: + placeholder_16 = [] + if (placeholder_7, placeholder_8) in placeholder_16: + return False + if ( + not self.placeholder_10(placeholder_7, placeholder_8) + or self.placeholder_6[placeholder_8][placeholder_7] != placeholder_14 + ): + return False + if self.placeholder_13(placeholder_14, placeholder_7, placeholder_8): + return True + for placeholder_17 in self.placeholder_1: + if self.placeholder_15( + placeholder_14, + placeholder_7 + placeholder_17[0], + placeholder_8 + placeholder_17[1], + placeholder_16 + [(placeholder_7, placeholder_8)], + ): + return True + return None + + def placeholder_18(self, placeholder_14): + if placeholder_14 == self.placeholder_3: + for placeholder_8 in range(self.placeholder_8): + if self.placeholder_15(placeholder_14, 0, placeholder_8): + return True + if placeholder_14 == self.placeholder_2: + for placeholder_7 in range(self.placeholder_7): + if self.placeholder_15(placeholder_14, placeholder_7, 0): + return True + return None + + def placeholder_19(self): + if self.placeholder_18(self.placeholder_3): + return self.placeholder_3 + if self.placeholder_18(self.placeholder_2): + return self.placeholder_2 + return "" + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'ConnectGame', + [], + [], + [ + Assign( + [ + Name( + 'DIRECTIONS', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=14)], + List( + [ + Tuple( + [ + Constant( + 0, + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=20), + Constant( + 1, + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=23)], + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=24), + Tuple( + [ + Constant( + 0, + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=28), + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=32), + lineno=4, + col_offset=30, + end_lineno=4, + end_col_offset=32)], + Load(), + lineno=4, + col_offset=26, + end_lineno=4, + end_col_offset=33), + Tuple( + [ + Constant( + 1, + lineno=4, + col_offset=36, + end_lineno=4, + end_col_offset=37), + Constant( + 0, + lineno=4, + col_offset=39, + end_lineno=4, + end_col_offset=40)], + Load(), + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=41), + Tuple( + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=45, + end_lineno=4, + end_col_offset=46), + lineno=4, + col_offset=44, + end_lineno=4, + end_col_offset=46), + Constant( + 0, + lineno=4, + col_offset=48, + end_lineno=4, + end_col_offset=49)], + Load(), + lineno=4, + col_offset=43, + end_lineno=4, + end_col_offset=50), + Tuple( + [ + Constant( + 1, + lineno=4, + col_offset=53, + end_lineno=4, + end_col_offset=54), + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=57, + end_lineno=4, + end_col_offset=58), + lineno=4, + col_offset=56, + end_lineno=4, + end_col_offset=58)], + Load(), + lineno=4, + col_offset=52, + end_lineno=4, + end_col_offset=59), + Tuple( + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=63, + end_lineno=4, + end_col_offset=64), + lineno=4, + col_offset=62, + end_lineno=4, + end_col_offset=64), + Constant( + 1, + lineno=4, + col_offset=66, + end_lineno=4, + end_col_offset=67)], + Load(), + lineno=4, + col_offset=61, + end_lineno=4, + end_col_offset=68)], + Load(), + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=69), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=69), + Assign( + [ + Name( + 'WHITE', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=9)], + Constant( + 'O', + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=15), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=15), + Assign( + [ + Name( + 'BLACK', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=9)], + Constant( + 'X', + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=15), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=21), + arg( + 'lines', + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'board', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=18)], + Call( + Attribute( + Name( + 'ConnectGame', + Load(), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=32), + 'make_board', + Load(), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=43), + [ + Name( + 'lines', + Load(), + lineno=9, + col_offset=44, + end_lineno=9, + end_col_offset=49)], + [], + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=50), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=50), + Assert( + Compare( + Call( + Name( + 'len', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=18), + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=23), + 'board', + Load(), + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=29)], + [], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=30), + [ + Gt()], + [ + Constant( + 0, + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=34)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=34), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'width', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=18)], + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=24), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=29), + 'board', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=35), + Constant( + 0, + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=37), + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=38)], + [], + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=39), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'height', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=19)], + Call( + Name( + 'len', + Load(), + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=25), + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=30), + 'board', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=36)], + [], + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=37), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=37), + Assert( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=19), + 'width', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=25), + [ + Gt()], + [ + Constant( + 0, + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=29)], + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=29), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=38), + 'height', + Load(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=45), + [ + Gt()], + [ + Constant( + 0, + lineno=14, + col_offset=48, + end_lineno=14, + end_col_offset=49)], + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=49)], + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=49), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=49), + For( + Name( + 'line', + Store(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=16), + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=24), + 'board', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=30), + [ + Assert( + Compare( + Call( + Name( + 'len', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=22), + [ + Name( + 'line', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=27)], + [], + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=28), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=32, + end_lineno=17, + end_col_offset=36), + 'width', + Load(), + lineno=17, + col_offset=32, + end_lineno=17, + end_col_offset=42)], + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=42)], + [], + lineno=16, + col_offset=8, + end_lineno=17, + end_col_offset=42)], + [], + lineno=8, + col_offset=4, + end_lineno=17, + end_col_offset=42), + FunctionDef( + 'valid', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=14, + end_lineno=19, + end_col_offset=18), + arg( + 'width', + lineno=19, + col_offset=20, + end_lineno=19, + end_col_offset=25), + arg( + 'height', + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Constant( + 0, + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=16), + [ + LtE(), + Lt()], + [ + Name( + 'width', + Load(), + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=25), + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=32), + 'width', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=38)], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=38), + Compare( + Constant( + 0, + lineno=20, + col_offset=43, + end_lineno=20, + end_col_offset=44), + [ + LtE(), + Lt()], + [ + Name( + 'height', + Load(), + lineno=20, + col_offset=48, + end_lineno=20, + end_col_offset=54), + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=57, + end_lineno=20, + end_col_offset=61), + 'height', + Load(), + lineno=20, + col_offset=57, + end_lineno=20, + end_col_offset=68)], + lineno=20, + col_offset=43, + end_lineno=20, + end_col_offset=68)], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=68), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=68)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=68), + FunctionDef( + 'make_board', + arguments( + [], + [ + arg( + 'lines', + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Attribute( + Constant( + '', + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=18), + 'join', + Load(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=23), + [ + Call( + Attribute( + Name( + 'cur_line', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=32), + 'split', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=38), + [], + [], + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=40)], + [], + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=41), + [ + comprehension( + Name( + 'cur_line', + Store(), + lineno=24, + col_offset=46, + end_lineno=24, + end_col_offset=54), + Call( + Attribute( + Name( + 'lines', + Load(), + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=63), + 'splitlines', + Load(), + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=74), + [], + [], + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=76), + [], + 0)], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=77), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=77)], + [ + Name( + 'staticmethod', + Load(), + lineno=22, + col_offset=5, + end_lineno=22, + end_col_offset=17)], + lineno=23, + col_offset=4, + end_lineno=24, + end_col_offset=77), + FunctionDef( + 'player_reach_dest', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=30), + arg( + 'player', + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=38), + arg( + 'width', + lineno=26, + col_offset=40, + end_lineno=26, + end_col_offset=45), + arg( + 'height', + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=53)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'player', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=17), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=25), + 'BLACK', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=31)], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=31), + [ + Return( + Compare( + Name( + 'width', + Load(), + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=24), + [ + Eq()], + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=32), + 'width', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=38), + Sub(), + Constant( + 1, + lineno=28, + col_offset=41, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=42)], + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=42)], + [], + lineno=27, + col_offset=8, + end_lineno=28, + end_col_offset=42), + If( + Compare( + Name( + 'player', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=17), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=25), + 'WHITE', + Load(), + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=31)], + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=31), + [ + Return( + Compare( + Name( + 'height', + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=25), + [ + Eq()], + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=33), + 'height', + Load(), + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=40), + Sub(), + Constant( + 1, + lineno=30, + col_offset=43, + end_lineno=30, + end_col_offset=44), + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=44)], + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=44), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=44)], + [], + lineno=29, + col_offset=8, + end_lineno=30, + end_col_offset=44), + Return( + Constant( + None, + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=19), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=19)], + [], + lineno=26, + col_offset=4, + end_lineno=31, + end_col_offset=19), + FunctionDef( + 'walk_board', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=23), + arg( + 'player', + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=31), + arg( + 'width', + lineno=33, + col_offset=33, + end_lineno=33, + end_col_offset=38), + arg( + 'height', + lineno=33, + col_offset=40, + end_lineno=33, + end_col_offset=46), + arg( + 'visited', + lineno=33, + col_offset=48, + end_lineno=33, + end_col_offset=55)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=33, + col_offset=56, + end_lineno=33, + end_col_offset=60)]), + [ + If( + UnaryOp( + Not(), + Name( + 'visited', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=22), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=22), + [ + Assign( + [ + Name( + 'visited', + Store(), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=19)], + List( + [], + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=24), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=24)], + [], + lineno=34, + col_offset=8, + end_lineno=35, + end_col_offset=24), + If( + Compare( + Tuple( + [ + Name( + 'width', + Load(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=17), + Name( + 'height', + Load(), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=25)], + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=26), + [ + In()], + [ + Name( + 'visited', + Load(), + lineno=36, + col_offset=30, + end_lineno=36, + end_col_offset=37)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=37), + [ + Return( + Constant( + False, + lineno=37, + col_offset=19, + end_lineno=37, + end_col_offset=24), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=24)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=24), + If( + BoolOp( + Or(), + [ + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=20), + 'valid', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=26), + [ + Name( + 'width', + Load(), + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=32), + Name( + 'height', + Load(), + lineno=39, + col_offset=34, + end_lineno=39, + end_col_offset=40)], + [], + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=41), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=41), + Compare( + Subscript( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=50), + 'board', + Load(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=56), + Name( + 'height', + Load(), + lineno=39, + col_offset=57, + end_lineno=39, + end_col_offset=63), + Load(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=64), + Name( + 'width', + Load(), + lineno=39, + col_offset=65, + end_lineno=39, + end_col_offset=70), + Load(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=71), + [ + NotEq()], + [ + Name( + 'player', + Load(), + lineno=39, + col_offset=75, + end_lineno=39, + end_col_offset=81)], + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=81)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=81), + [ + Return( + Constant( + False, + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=24), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=24)], + [], + lineno=39, + col_offset=8, + end_lineno=40, + end_col_offset=24), + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=15), + 'player_reach_dest', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=33), + [ + Name( + 'player', + Load(), + lineno=42, + col_offset=34, + end_lineno=42, + end_col_offset=40), + Name( + 'width', + Load(), + lineno=42, + col_offset=42, + end_lineno=42, + end_col_offset=47), + Name( + 'height', + Load(), + lineno=42, + col_offset=49, + end_lineno=42, + end_col_offset=55)], + [], + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=56), + [ + Return( + Constant( + True, + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=23), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=23)], + [], + lineno=42, + col_offset=8, + end_lineno=43, + end_col_offset=23), + For( + Name( + 'vector', + Store(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=18), + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=26), + 'DIRECTIONS', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=37), + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19), + 'walk_board', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=30), + [ + Name( + 'player', + Load(), + lineno=46, + col_offset=31, + end_lineno=46, + end_col_offset=37), + BinOp( + Name( + 'width', + Load(), + lineno=46, + col_offset=39, + end_lineno=46, + end_col_offset=44), + Add(), + Subscript( + Name( + 'vector', + Load(), + lineno=46, + col_offset=47, + end_lineno=46, + end_col_offset=53), + Constant( + 0, + lineno=46, + col_offset=54, + end_lineno=46, + end_col_offset=55), + Load(), + lineno=46, + col_offset=47, + end_lineno=46, + end_col_offset=56), + lineno=46, + col_offset=39, + end_lineno=46, + end_col_offset=56), + BinOp( + Name( + 'height', + Load(), + lineno=46, + col_offset=58, + end_lineno=46, + end_col_offset=64), + Add(), + Subscript( + Name( + 'vector', + Load(), + lineno=46, + col_offset=67, + end_lineno=46, + end_col_offset=73), + Constant( + 1, + lineno=46, + col_offset=74, + end_lineno=46, + end_col_offset=75), + Load(), + lineno=46, + col_offset=67, + end_lineno=46, + end_col_offset=76), + lineno=46, + col_offset=58, + end_lineno=46, + end_col_offset=76), + BinOp( + Name( + 'visited', + Load(), + lineno=46, + col_offset=78, + end_lineno=46, + end_col_offset=85), + Add(), + List( + [ + Tuple( + [ + Name( + 'width', + Load(), + lineno=46, + col_offset=90, + end_lineno=46, + end_col_offset=95), + Name( + 'height', + Load(), + lineno=46, + col_offset=97, + end_lineno=46, + end_col_offset=103)], + Load(), + lineno=46, + col_offset=89, + end_lineno=46, + end_col_offset=104)], + Load(), + lineno=46, + col_offset=88, + end_lineno=46, + end_col_offset=105), + lineno=46, + col_offset=78, + end_lineno=46, + end_col_offset=105)], + [], + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=106), + [ + Return( + Constant( + True, + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=27), + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=27)], + [], + lineno=46, + col_offset=12, + end_lineno=47, + end_col_offset=27)], + [], + lineno=45, + col_offset=8, + end_lineno=47, + end_col_offset=27), + Return( + Constant( + None, + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=19), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=19)], + [], + lineno=33, + col_offset=4, + end_lineno=48, + end_col_offset=19), + FunctionDef( + 'check_player_is_winner', + arguments( + [], + [ + arg( + 'self', + lineno=50, + col_offset=31, + end_lineno=50, + end_col_offset=35), + arg( + 'player', + lineno=50, + col_offset=37, + end_lineno=50, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'player', + Load(), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=17), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=25), + 'BLACK', + Load(), + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=31)], + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=31), + [ + For( + Name( + 'height', + Store(), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=22), + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=31), + [ + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=36), + 'height', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=43)], + [], + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=44), + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=23), + 'walk_board', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=34), + [ + Name( + 'player', + Load(), + lineno=53, + col_offset=35, + end_lineno=53, + end_col_offset=41), + Constant( + 0, + lineno=53, + col_offset=43, + end_lineno=53, + end_col_offset=44), + Name( + 'height', + Load(), + lineno=53, + col_offset=46, + end_lineno=53, + end_col_offset=52)], + [], + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=53), + [ + Return( + Constant( + True, + lineno=54, + col_offset=27, + end_lineno=54, + end_col_offset=31), + lineno=54, + col_offset=20, + end_lineno=54, + end_col_offset=31)], + [], + lineno=53, + col_offset=16, + end_lineno=54, + end_col_offset=31)], + [], + lineno=52, + col_offset=12, + end_lineno=54, + end_col_offset=31)], + [], + lineno=51, + col_offset=8, + end_lineno=54, + end_col_offset=31), + If( + Compare( + Name( + 'player', + Load(), + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=17), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=21, + end_lineno=55, + end_col_offset=25), + 'WHITE', + Load(), + lineno=55, + col_offset=21, + end_lineno=55, + end_col_offset=31)], + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=31), + [ + For( + Name( + 'width', + Store(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=21), + Call( + Name( + 'range', + Load(), + lineno=56, + col_offset=25, + end_lineno=56, + end_col_offset=30), + [ + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=31, + end_lineno=56, + end_col_offset=35), + 'width', + Load(), + lineno=56, + col_offset=31, + end_lineno=56, + end_col_offset=41)], + [], + lineno=56, + col_offset=25, + end_lineno=56, + end_col_offset=42), + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=23), + 'walk_board', + Load(), + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=34), + [ + Name( + 'player', + Load(), + lineno=57, + col_offset=35, + end_lineno=57, + end_col_offset=41), + Name( + 'width', + Load(), + lineno=57, + col_offset=43, + end_lineno=57, + end_col_offset=48), + Constant( + 0, + lineno=57, + col_offset=50, + end_lineno=57, + end_col_offset=51)], + [], + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=52), + [ + Return( + Constant( + True, + lineno=58, + col_offset=27, + end_lineno=58, + end_col_offset=31), + lineno=58, + col_offset=20, + end_lineno=58, + end_col_offset=31)], + [], + lineno=57, + col_offset=16, + end_lineno=58, + end_col_offset=31)], + [], + lineno=56, + col_offset=12, + end_lineno=58, + end_col_offset=31)], + [], + lineno=55, + col_offset=8, + end_lineno=58, + end_col_offset=31), + Return( + Constant( + None, + lineno=59, + col_offset=15, + end_lineno=59, + end_col_offset=19), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=19)], + [], + lineno=50, + col_offset=4, + end_lineno=59, + end_col_offset=19), + FunctionDef( + 'get_winner', + arguments( + [], + [ + arg( + 'self', + lineno=61, + col_offset=19, + end_lineno=61, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=15), + 'check_player_is_winner', + Load(), + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=38), + [ + Attribute( + Name( + 'self', + Load(), + lineno=62, + col_offset=39, + end_lineno=62, + end_col_offset=43), + 'BLACK', + Load(), + lineno=62, + col_offset=39, + end_lineno=62, + end_col_offset=49)], + [], + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=50), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=23), + 'BLACK', + Load(), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=29), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=29)], + [], + lineno=62, + col_offset=8, + end_lineno=63, + end_col_offset=29), + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=15), + 'check_player_is_winner', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=38), + [ + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=39, + end_lineno=64, + end_col_offset=43), + 'WHITE', + Load(), + lineno=64, + col_offset=39, + end_lineno=64, + end_col_offset=49)], + [], + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=50), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=23), + 'WHITE', + Load(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=29), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=29)], + [], + lineno=64, + col_offset=8, + end_lineno=65, + end_col_offset=29), + Return( + Constant( + '', + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=17), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=17)], + [], + lineno=61, + col_offset=4, + end_lineno=66, + end_col_offset=17)], + [], + lineno=2, + col_offset=0, + end_lineno=66, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=14)], + List( + [ + Tuple( + [ + Constant( + 0, + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=20), + Constant( + 1, + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=23)], + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=24), + Tuple( + [ + Constant( + 0, + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=28), + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=32), + lineno=4, + col_offset=30, + end_lineno=4, + end_col_offset=32)], + Load(), + lineno=4, + col_offset=26, + end_lineno=4, + end_col_offset=33), + Tuple( + [ + Constant( + 1, + lineno=4, + col_offset=36, + end_lineno=4, + end_col_offset=37), + Constant( + 0, + lineno=4, + col_offset=39, + end_lineno=4, + end_col_offset=40)], + Load(), + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=41), + Tuple( + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=45, + end_lineno=4, + end_col_offset=46), + lineno=4, + col_offset=44, + end_lineno=4, + end_col_offset=46), + Constant( + 0, + lineno=4, + col_offset=48, + end_lineno=4, + end_col_offset=49)], + Load(), + lineno=4, + col_offset=43, + end_lineno=4, + end_col_offset=50), + Tuple( + [ + Constant( + 1, + lineno=4, + col_offset=53, + end_lineno=4, + end_col_offset=54), + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=57, + end_lineno=4, + end_col_offset=58), + lineno=4, + col_offset=56, + end_lineno=4, + end_col_offset=58)], + Load(), + lineno=4, + col_offset=52, + end_lineno=4, + end_col_offset=59), + Tuple( + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=63, + end_lineno=4, + end_col_offset=64), + lineno=4, + col_offset=62, + end_lineno=4, + end_col_offset=64), + Constant( + 1, + lineno=4, + col_offset=66, + end_lineno=4, + end_col_offset=67)], + Load(), + lineno=4, + col_offset=61, + end_lineno=4, + end_col_offset=68)], + Load(), + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=69), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=69), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=9)], + Constant( + 'O', + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=15), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=15), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=9)], + Constant( + 'X', + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=15), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=21), + arg( + 'placeholder_5', + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=18)], + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=32), + 'make_board', + Load(), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=43), + [ + Name( + 'placeholder_5', + Load(), + lineno=9, + col_offset=44, + end_lineno=9, + end_col_offset=49)], + [], + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=50), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=50), + Assert( + Compare( + Call( + Name( + 'len', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=18), + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=23), + 'placeholder_6', + Load(), + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=29)], + [], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=30), + [ + Gt()], + [ + Constant( + 0, + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=34)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=34), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=18)], + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=24), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=29), + 'placeholder_6', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=35), + Constant( + 0, + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=37), + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=38)], + [], + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=39), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=19)], + Call( + Name( + 'len', + Load(), + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=25), + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=30), + 'placeholder_6', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=36)], + [], + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=37), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=37), + Assert( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=25), + [ + Gt()], + [ + Constant( + 0, + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=29)], + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=29), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=38), + 'placeholder_8', + Load(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=45), + [ + Gt()], + [ + Constant( + 0, + lineno=14, + col_offset=48, + end_lineno=14, + end_col_offset=49)], + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=49)], + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=49), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=49), + For( + Name( + 'placeholder_9', + Store(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=16), + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=24), + 'placeholder_6', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=30), + [ + Assert( + Compare( + Call( + Name( + 'len', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=22), + [ + Name( + 'placeholder_9', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=27)], + [], + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=28), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=32, + end_lineno=17, + end_col_offset=36), + 'placeholder_7', + Load(), + lineno=17, + col_offset=32, + end_lineno=17, + end_col_offset=42)], + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=42)], + [], + lineno=16, + col_offset=8, + end_lineno=17, + end_col_offset=42)], + [], + lineno=8, + col_offset=4, + end_lineno=17, + end_col_offset=42), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=14, + end_lineno=19, + end_col_offset=18), + arg( + 'placeholder_7', + lineno=19, + col_offset=20, + end_lineno=19, + end_col_offset=25), + arg( + 'placeholder_8', + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Constant( + 0, + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=16), + [ + LtE(), + Lt()], + [ + Name( + 'placeholder_7', + Load(), + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=25), + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=32), + 'placeholder_7', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=38)], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=38), + Compare( + Constant( + 0, + lineno=20, + col_offset=43, + end_lineno=20, + end_col_offset=44), + [ + LtE(), + Lt()], + [ + Name( + 'placeholder_8', + Load(), + lineno=20, + col_offset=48, + end_lineno=20, + end_col_offset=54), + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=57, + end_lineno=20, + end_col_offset=61), + 'placeholder_8', + Load(), + lineno=20, + col_offset=57, + end_lineno=20, + end_col_offset=68)], + lineno=20, + col_offset=43, + end_lineno=20, + end_col_offset=68)], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=68), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=68)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=68), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=23, + col_offset=19, + end_lineno=23, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Attribute( + Constant( + '', + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=18), + 'join', + Load(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=23), + [ + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=32), + 'split', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=38), + [], + [], + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=40)], + [], + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=41), + [ + comprehension( + Name( + 'placeholder_12', + Store(), + lineno=24, + col_offset=46, + end_lineno=24, + end_col_offset=54), + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=63), + 'splitlines', + Load(), + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=74), + [], + [], + lineno=24, + col_offset=58, + end_lineno=24, + end_col_offset=76), + [], + 0)], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=77), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=77)], + [ + Name( + 'staticmethod', + Load(), + lineno=22, + col_offset=5, + end_lineno=22, + end_col_offset=17)], + lineno=23, + col_offset=4, + end_lineno=24, + end_col_offset=77), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=30), + arg( + 'placeholder_14', + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=38), + arg( + 'placeholder_7', + lineno=26, + col_offset=40, + end_lineno=26, + end_col_offset=45), + arg( + 'placeholder_8', + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=53)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=17), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=25), + 'placeholder_3', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=31)], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=31), + [ + Return( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=24), + [ + Eq()], + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=32), + 'placeholder_7', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=38), + Sub(), + Constant( + 1, + lineno=28, + col_offset=41, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=42)], + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=42)], + [], + lineno=27, + col_offset=8, + end_lineno=28, + end_col_offset=42), + If( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=17), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=25), + 'placeholder_2', + Load(), + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=31)], + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=31), + [ + Return( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=25), + [ + Eq()], + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=33), + 'placeholder_8', + Load(), + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=40), + Sub(), + Constant( + 1, + lineno=30, + col_offset=43, + end_lineno=30, + end_col_offset=44), + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=44)], + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=44), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=44)], + [], + lineno=29, + col_offset=8, + end_lineno=30, + end_col_offset=44), + Return( + Constant( + None, + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=19), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=19)], + [], + lineno=26, + col_offset=4, + end_lineno=31, + end_col_offset=19), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=23), + arg( + 'placeholder_14', + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=31), + arg( + 'placeholder_7', + lineno=33, + col_offset=33, + end_lineno=33, + end_col_offset=38), + arg( + 'placeholder_8', + lineno=33, + col_offset=40, + end_lineno=33, + end_col_offset=46), + arg( + 'placeholder_16', + lineno=33, + col_offset=48, + end_lineno=33, + end_col_offset=55)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=33, + col_offset=56, + end_lineno=33, + end_col_offset=60)]), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_16', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=22), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=22), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=19)], + List( + [], + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=24), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=24)], + [], + lineno=34, + col_offset=8, + end_lineno=35, + end_col_offset=24), + If( + Compare( + Tuple( + [ + Name( + 'placeholder_7', + Load(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=17), + Name( + 'placeholder_8', + Load(), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=25)], + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=26), + [ + In()], + [ + Name( + 'placeholder_16', + Load(), + lineno=36, + col_offset=30, + end_lineno=36, + end_col_offset=37)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=37), + [ + Return( + Constant( + False, + lineno=37, + col_offset=19, + end_lineno=37, + end_col_offset=24), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=24)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=24), + If( + BoolOp( + Or(), + [ + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=20), + 'placeholder_10', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=26), + [ + Name( + 'placeholder_7', + Load(), + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=32), + Name( + 'placeholder_8', + Load(), + lineno=39, + col_offset=34, + end_lineno=39, + end_col_offset=40)], + [], + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=41), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=41), + Compare( + Subscript( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=50), + 'placeholder_6', + Load(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=56), + Name( + 'placeholder_8', + Load(), + lineno=39, + col_offset=57, + end_lineno=39, + end_col_offset=63), + Load(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=64), + Name( + 'placeholder_7', + Load(), + lineno=39, + col_offset=65, + end_lineno=39, + end_col_offset=70), + Load(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=71), + [ + NotEq()], + [ + Name( + 'placeholder_14', + Load(), + lineno=39, + col_offset=75, + end_lineno=39, + end_col_offset=81)], + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=81)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=81), + [ + Return( + Constant( + False, + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=24), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=24)], + [], + lineno=39, + col_offset=8, + end_lineno=40, + end_col_offset=24), + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=15), + 'placeholder_13', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=33), + [ + Name( + 'placeholder_14', + Load(), + lineno=42, + col_offset=34, + end_lineno=42, + end_col_offset=40), + Name( + 'placeholder_7', + Load(), + lineno=42, + col_offset=42, + end_lineno=42, + end_col_offset=47), + Name( + 'placeholder_8', + Load(), + lineno=42, + col_offset=49, + end_lineno=42, + end_col_offset=55)], + [], + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=56), + [ + Return( + Constant( + True, + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=23), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=23)], + [], + lineno=42, + col_offset=8, + end_lineno=43, + end_col_offset=23), + For( + Name( + 'placeholder_17', + Store(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=18), + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=26), + 'placeholder_1', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=37), + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19), + 'placeholder_15', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=30), + [ + Name( + 'placeholder_14', + Load(), + lineno=46, + col_offset=31, + end_lineno=46, + end_col_offset=37), + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=46, + col_offset=39, + end_lineno=46, + end_col_offset=44), + Add(), + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=46, + col_offset=47, + end_lineno=46, + end_col_offset=53), + Constant( + 0, + lineno=46, + col_offset=54, + end_lineno=46, + end_col_offset=55), + Load(), + lineno=46, + col_offset=47, + end_lineno=46, + end_col_offset=56), + lineno=46, + col_offset=39, + end_lineno=46, + end_col_offset=56), + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=46, + col_offset=58, + end_lineno=46, + end_col_offset=64), + Add(), + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=46, + col_offset=67, + end_lineno=46, + end_col_offset=73), + Constant( + 1, + lineno=46, + col_offset=74, + end_lineno=46, + end_col_offset=75), + Load(), + lineno=46, + col_offset=67, + end_lineno=46, + end_col_offset=76), + lineno=46, + col_offset=58, + end_lineno=46, + end_col_offset=76), + BinOp( + Name( + 'placeholder_16', + Load(), + lineno=46, + col_offset=78, + end_lineno=46, + end_col_offset=85), + Add(), + List( + [ + Tuple( + [ + Name( + 'placeholder_7', + Load(), + lineno=46, + col_offset=90, + end_lineno=46, + end_col_offset=95), + Name( + 'placeholder_8', + Load(), + lineno=46, + col_offset=97, + end_lineno=46, + end_col_offset=103)], + Load(), + lineno=46, + col_offset=89, + end_lineno=46, + end_col_offset=104)], + Load(), + lineno=46, + col_offset=88, + end_lineno=46, + end_col_offset=105), + lineno=46, + col_offset=78, + end_lineno=46, + end_col_offset=105)], + [], + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=106), + [ + Return( + Constant( + True, + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=27), + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=27)], + [], + lineno=46, + col_offset=12, + end_lineno=47, + end_col_offset=27)], + [], + lineno=45, + col_offset=8, + end_lineno=47, + end_col_offset=27), + Return( + Constant( + None, + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=19), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=19)], + [], + lineno=33, + col_offset=4, + end_lineno=48, + end_col_offset=19), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'self', + lineno=50, + col_offset=31, + end_lineno=50, + end_col_offset=35), + arg( + 'placeholder_14', + lineno=50, + col_offset=37, + end_lineno=50, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=17), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=25), + 'placeholder_3', + Load(), + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=31)], + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=31), + [ + For( + Name( + 'placeholder_8', + Store(), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=22), + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=31), + [ + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=36), + 'placeholder_8', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=43)], + [], + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=44), + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=23), + 'placeholder_15', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=34), + [ + Name( + 'placeholder_14', + Load(), + lineno=53, + col_offset=35, + end_lineno=53, + end_col_offset=41), + Constant( + 0, + lineno=53, + col_offset=43, + end_lineno=53, + end_col_offset=44), + Name( + 'placeholder_8', + Load(), + lineno=53, + col_offset=46, + end_lineno=53, + end_col_offset=52)], + [], + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=53), + [ + Return( + Constant( + True, + lineno=54, + col_offset=27, + end_lineno=54, + end_col_offset=31), + lineno=54, + col_offset=20, + end_lineno=54, + end_col_offset=31)], + [], + lineno=53, + col_offset=16, + end_lineno=54, + end_col_offset=31)], + [], + lineno=52, + col_offset=12, + end_lineno=54, + end_col_offset=31)], + [], + lineno=51, + col_offset=8, + end_lineno=54, + end_col_offset=31), + If( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=17), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=21, + end_lineno=55, + end_col_offset=25), + 'placeholder_2', + Load(), + lineno=55, + col_offset=21, + end_lineno=55, + end_col_offset=31)], + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=31), + [ + For( + Name( + 'placeholder_7', + Store(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=21), + Call( + Name( + 'range', + Load(), + lineno=56, + col_offset=25, + end_lineno=56, + end_col_offset=30), + [ + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=31, + end_lineno=56, + end_col_offset=35), + 'placeholder_7', + Load(), + lineno=56, + col_offset=31, + end_lineno=56, + end_col_offset=41)], + [], + lineno=56, + col_offset=25, + end_lineno=56, + end_col_offset=42), + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=23), + 'placeholder_15', + Load(), + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=34), + [ + Name( + 'placeholder_14', + Load(), + lineno=57, + col_offset=35, + end_lineno=57, + end_col_offset=41), + Name( + 'placeholder_7', + Load(), + lineno=57, + col_offset=43, + end_lineno=57, + end_col_offset=48), + Constant( + 0, + lineno=57, + col_offset=50, + end_lineno=57, + end_col_offset=51)], + [], + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=52), + [ + Return( + Constant( + True, + lineno=58, + col_offset=27, + end_lineno=58, + end_col_offset=31), + lineno=58, + col_offset=20, + end_lineno=58, + end_col_offset=31)], + [], + lineno=57, + col_offset=16, + end_lineno=58, + end_col_offset=31)], + [], + lineno=56, + col_offset=12, + end_lineno=58, + end_col_offset=31)], + [], + lineno=55, + col_offset=8, + end_lineno=58, + end_col_offset=31), + Return( + Constant( + None, + lineno=59, + col_offset=15, + end_lineno=59, + end_col_offset=19), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=19)], + [], + lineno=50, + col_offset=4, + end_lineno=59, + end_col_offset=19), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'self', + lineno=61, + col_offset=19, + end_lineno=61, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=15), + 'placeholder_18', + Load(), + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=38), + [ + Attribute( + Name( + 'self', + Load(), + lineno=62, + col_offset=39, + end_lineno=62, + end_col_offset=43), + 'placeholder_3', + Load(), + lineno=62, + col_offset=39, + end_lineno=62, + end_col_offset=49)], + [], + lineno=62, + col_offset=11, + end_lineno=62, + end_col_offset=50), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=23), + 'placeholder_3', + Load(), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=29), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=29)], + [], + lineno=62, + col_offset=8, + end_lineno=63, + end_col_offset=29), + If( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=15), + 'placeholder_18', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=38), + [ + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=39, + end_lineno=64, + end_col_offset=43), + 'placeholder_2', + Load(), + lineno=64, + col_offset=39, + end_lineno=64, + end_col_offset=49)], + [], + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=50), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=23), + 'placeholder_2', + Load(), + lineno=65, + col_offset=19, + end_lineno=65, + end_col_offset=29), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=29)], + [], + lineno=64, + col_offset=8, + end_lineno=65, + end_col_offset=29), + Return( + Constant( + '', + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=17), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=17)], + [], + lineno=61, + col_offset=4, + end_lineno=66, + end_col_offset=17)], + [], + lineno=2, + col_offset=0, + end_lineno=66, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-connect/representation.txt b/test/practice-connect/representation.txt new file mode 100644 index 0000000..15419ed --- /dev/null +++ b/test/practice-connect/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [Assign([Name('placeholder_1', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=14)], List([Tuple([Constant(0, lineno=4, col_offset=19, end_lineno=4, end_col_offset=20), Constant(1, lineno=4, col_offset=22, end_lineno=4, end_col_offset=23)], Load(), lineno=4, col_offset=18, end_lineno=4, end_col_offset=24), Tuple([Constant(0, lineno=4, col_offset=27, end_lineno=4, end_col_offset=28), UnaryOp(USub(), Constant(1, lineno=4, col_offset=31, end_lineno=4, end_col_offset=32), lineno=4, col_offset=30, end_lineno=4, end_col_offset=32)], Load(), lineno=4, col_offset=26, end_lineno=4, end_col_offset=33), Tuple([Constant(1, lineno=4, col_offset=36, end_lineno=4, end_col_offset=37), Constant(0, lineno=4, col_offset=39, end_lineno=4, end_col_offset=40)], Load(), lineno=4, col_offset=35, end_lineno=4, end_col_offset=41), Tuple([UnaryOp(USub(), Constant(1, lineno=4, col_offset=45, end_lineno=4, end_col_offset=46), lineno=4, col_offset=44, end_lineno=4, end_col_offset=46), Constant(0, lineno=4, col_offset=48, end_lineno=4, end_col_offset=49)], Load(), lineno=4, col_offset=43, end_lineno=4, end_col_offset=50), Tuple([Constant(1, lineno=4, col_offset=53, end_lineno=4, end_col_offset=54), UnaryOp(USub(), Constant(1, lineno=4, col_offset=57, end_lineno=4, end_col_offset=58), lineno=4, col_offset=56, end_lineno=4, end_col_offset=58)], Load(), lineno=4, col_offset=52, end_lineno=4, end_col_offset=59), Tuple([UnaryOp(USub(), Constant(1, lineno=4, col_offset=63, end_lineno=4, end_col_offset=64), lineno=4, col_offset=62, end_lineno=4, end_col_offset=64), Constant(1, lineno=4, col_offset=66, end_lineno=4, end_col_offset=67)], Load(), lineno=4, col_offset=61, end_lineno=4, end_col_offset=68)], Load(), lineno=4, col_offset=17, end_lineno=4, end_col_offset=69), lineno=4, col_offset=4, end_lineno=4, end_col_offset=69), Assign([Name('placeholder_2', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=9)], Constant('O', lineno=5, col_offset=12, end_lineno=5, end_col_offset=15), lineno=5, col_offset=4, end_lineno=5, end_col_offset=15), Assign([Name('placeholder_3', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=9)], Constant('X', lineno=6, col_offset=12, end_lineno=6, end_col_offset=15), lineno=6, col_offset=4, end_lineno=6, end_col_offset=15), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=8, col_offset=17, end_lineno=8, end_col_offset=21), arg('placeholder_5', lineno=8, col_offset=23, end_lineno=8, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), 'placeholder_6', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=18)], Call(Attribute(Name('placeholder_0', Load(), lineno=9, col_offset=21, end_lineno=9, end_col_offset=32), 'make_board', Load(), lineno=9, col_offset=21, end_lineno=9, end_col_offset=43), [Name('placeholder_5', Load(), lineno=9, col_offset=44, end_lineno=9, end_col_offset=49)], [], lineno=9, col_offset=21, end_lineno=9, end_col_offset=50), lineno=9, col_offset=8, end_lineno=9, end_col_offset=50), Assert(Compare(Call(Name('len', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=18), [Attribute(Name('self', Load(), lineno=10, col_offset=19, end_lineno=10, end_col_offset=23), 'placeholder_6', Load(), lineno=10, col_offset=19, end_lineno=10, end_col_offset=29)], [], lineno=10, col_offset=15, end_lineno=10, end_col_offset=30), [Gt()], [Constant(0, lineno=10, col_offset=33, end_lineno=10, end_col_offset=34)], lineno=10, col_offset=15, end_lineno=10, end_col_offset=34), lineno=10, col_offset=8, end_lineno=10, end_col_offset=34), Assign([Attribute(Name('self', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), 'placeholder_7', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=18)], Call(Name('len', Load(), lineno=12, col_offset=21, end_lineno=12, end_col_offset=24), [Subscript(Attribute(Name('self', Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=29), 'placeholder_6', Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=35), Constant(0, lineno=12, col_offset=36, end_lineno=12, end_col_offset=37), Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=38)], [], lineno=12, col_offset=21, end_lineno=12, end_col_offset=39), lineno=12, col_offset=8, end_lineno=12, end_col_offset=39), Assign([Attribute(Name('self', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=12), 'placeholder_8', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=19)], Call(Name('len', Load(), lineno=13, col_offset=22, end_lineno=13, end_col_offset=25), [Attribute(Name('self', Load(), lineno=13, col_offset=26, end_lineno=13, end_col_offset=30), 'placeholder_6', Load(), lineno=13, col_offset=26, end_lineno=13, end_col_offset=36)], [], lineno=13, col_offset=22, end_lineno=13, end_col_offset=37), lineno=13, col_offset=8, end_lineno=13, end_col_offset=37), Assert(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=14, col_offset=15, end_lineno=14, end_col_offset=19), 'placeholder_7', Load(), lineno=14, col_offset=15, end_lineno=14, end_col_offset=25), [Gt()], [Constant(0, lineno=14, col_offset=28, end_lineno=14, end_col_offset=29)], lineno=14, col_offset=15, end_lineno=14, end_col_offset=29), Compare(Attribute(Name('self', Load(), lineno=14, col_offset=34, end_lineno=14, end_col_offset=38), 'placeholder_8', Load(), lineno=14, col_offset=34, end_lineno=14, end_col_offset=45), [Gt()], [Constant(0, lineno=14, col_offset=48, end_lineno=14, end_col_offset=49)], lineno=14, col_offset=34, end_lineno=14, end_col_offset=49)], lineno=14, col_offset=15, end_lineno=14, end_col_offset=49), lineno=14, col_offset=8, end_lineno=14, end_col_offset=49), For(Name('placeholder_9', Store(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=16), Attribute(Name('self', Load(), lineno=16, col_offset=20, end_lineno=16, end_col_offset=24), 'placeholder_6', Load(), lineno=16, col_offset=20, end_lineno=16, end_col_offset=30), [Assert(Compare(Call(Name('len', Load(), lineno=17, col_offset=19, end_lineno=17, end_col_offset=22), [Name('placeholder_9', Load(), lineno=17, col_offset=23, end_lineno=17, end_col_offset=27)], [], lineno=17, col_offset=19, end_lineno=17, end_col_offset=28), [Eq()], [Attribute(Name('self', Load(), lineno=17, col_offset=32, end_lineno=17, end_col_offset=36), 'placeholder_7', Load(), lineno=17, col_offset=32, end_lineno=17, end_col_offset=42)], lineno=17, col_offset=19, end_lineno=17, end_col_offset=42), lineno=17, col_offset=12, end_lineno=17, end_col_offset=42)], [], lineno=16, col_offset=8, end_lineno=17, end_col_offset=42)], [], lineno=8, col_offset=4, end_lineno=17, end_col_offset=42), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=19, col_offset=14, end_lineno=19, end_col_offset=18), arg('placeholder_7', lineno=19, col_offset=20, end_lineno=19, end_col_offset=25), arg('placeholder_8', lineno=19, col_offset=27, end_lineno=19, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Constant(0, lineno=20, col_offset=15, end_lineno=20, end_col_offset=16), [LtE(), Lt()], [Name('placeholder_7', Load(), lineno=20, col_offset=20, end_lineno=20, end_col_offset=25), Attribute(Name('self', Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=32), 'placeholder_7', Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=38)], lineno=20, col_offset=15, end_lineno=20, end_col_offset=38), Compare(Constant(0, lineno=20, col_offset=43, end_lineno=20, end_col_offset=44), [LtE(), Lt()], [Name('placeholder_8', Load(), lineno=20, col_offset=48, end_lineno=20, end_col_offset=54), Attribute(Name('self', Load(), lineno=20, col_offset=57, end_lineno=20, end_col_offset=61), 'placeholder_8', Load(), lineno=20, col_offset=57, end_lineno=20, end_col_offset=68)], lineno=20, col_offset=43, end_lineno=20, end_col_offset=68)], lineno=20, col_offset=15, end_lineno=20, end_col_offset=68), lineno=20, col_offset=8, end_lineno=20, end_col_offset=68)], [], lineno=19, col_offset=4, end_lineno=20, end_col_offset=68), FunctionDef('placeholder_11', arguments([], [arg('placeholder_5', lineno=23, col_offset=19, end_lineno=23, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Call(Attribute(Constant('', lineno=24, col_offset=16, end_lineno=24, end_col_offset=18), 'join', Load(), lineno=24, col_offset=16, end_lineno=24, end_col_offset=23), [Call(Attribute(Name('placeholder_12', Load(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=32), 'split', Load(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=38), [], [], lineno=24, col_offset=24, end_lineno=24, end_col_offset=40)], [], lineno=24, col_offset=16, end_lineno=24, end_col_offset=41), [comprehension(Name('placeholder_12', Store(), lineno=24, col_offset=46, end_lineno=24, end_col_offset=54), Call(Attribute(Name('placeholder_5', Load(), lineno=24, col_offset=58, end_lineno=24, end_col_offset=63), 'splitlines', Load(), lineno=24, col_offset=58, end_lineno=24, end_col_offset=74), [], [], lineno=24, col_offset=58, end_lineno=24, end_col_offset=76), [], 0)], lineno=24, col_offset=15, end_lineno=24, end_col_offset=77), lineno=24, col_offset=8, end_lineno=24, end_col_offset=77)], [Name('staticmethod', Load(), lineno=22, col_offset=5, end_lineno=22, end_col_offset=17)], lineno=23, col_offset=4, end_lineno=24, end_col_offset=77), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=26, col_offset=26, end_lineno=26, end_col_offset=30), arg('placeholder_14', lineno=26, col_offset=32, end_lineno=26, end_col_offset=38), arg('placeholder_7', lineno=26, col_offset=40, end_lineno=26, end_col_offset=45), arg('placeholder_8', lineno=26, col_offset=47, end_lineno=26, end_col_offset=53)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_14', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=17), [Eq()], [Attribute(Name('self', Load(), lineno=27, col_offset=21, end_lineno=27, end_col_offset=25), 'placeholder_3', Load(), lineno=27, col_offset=21, end_lineno=27, end_col_offset=31)], lineno=27, col_offset=11, end_lineno=27, end_col_offset=31), [Return(Compare(Name('placeholder_7', Load(), lineno=28, col_offset=19, end_lineno=28, end_col_offset=24), [Eq()], [BinOp(Attribute(Name('self', Load(), lineno=28, col_offset=28, end_lineno=28, end_col_offset=32), 'placeholder_7', Load(), lineno=28, col_offset=28, end_lineno=28, end_col_offset=38), Sub(), Constant(1, lineno=28, col_offset=41, end_lineno=28, end_col_offset=42), lineno=28, col_offset=28, end_lineno=28, end_col_offset=42)], lineno=28, col_offset=19, end_lineno=28, end_col_offset=42), lineno=28, col_offset=12, end_lineno=28, end_col_offset=42)], [], lineno=27, col_offset=8, end_lineno=28, end_col_offset=42), If(Compare(Name('placeholder_14', Load(), lineno=29, col_offset=11, end_lineno=29, end_col_offset=17), [Eq()], [Attribute(Name('self', Load(), lineno=29, col_offset=21, end_lineno=29, end_col_offset=25), 'placeholder_2', Load(), lineno=29, col_offset=21, end_lineno=29, end_col_offset=31)], lineno=29, col_offset=11, end_lineno=29, end_col_offset=31), [Return(Compare(Name('placeholder_8', Load(), lineno=30, col_offset=19, end_lineno=30, end_col_offset=25), [Eq()], [BinOp(Attribute(Name('self', Load(), lineno=30, col_offset=29, end_lineno=30, end_col_offset=33), 'placeholder_8', Load(), lineno=30, col_offset=29, end_lineno=30, end_col_offset=40), Sub(), Constant(1, lineno=30, col_offset=43, end_lineno=30, end_col_offset=44), lineno=30, col_offset=29, end_lineno=30, end_col_offset=44)], lineno=30, col_offset=19, end_lineno=30, end_col_offset=44), lineno=30, col_offset=12, end_lineno=30, end_col_offset=44)], [], lineno=29, col_offset=8, end_lineno=30, end_col_offset=44), Return(Constant(None, lineno=31, col_offset=15, end_lineno=31, end_col_offset=19), lineno=31, col_offset=8, end_lineno=31, end_col_offset=19)], [], lineno=26, col_offset=4, end_lineno=31, end_col_offset=19), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=33, col_offset=19, end_lineno=33, end_col_offset=23), arg('placeholder_14', lineno=33, col_offset=25, end_lineno=33, end_col_offset=31), arg('placeholder_7', lineno=33, col_offset=33, end_lineno=33, end_col_offset=38), arg('placeholder_8', lineno=33, col_offset=40, end_lineno=33, end_col_offset=46), arg('placeholder_16', lineno=33, col_offset=48, end_lineno=33, end_col_offset=55)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=33, col_offset=56, end_lineno=33, end_col_offset=60)]), [If(UnaryOp(Not(), Name('placeholder_16', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=22), lineno=34, col_offset=11, end_lineno=34, end_col_offset=22), [Assign([Name('placeholder_16', Store(), lineno=35, col_offset=12, end_lineno=35, end_col_offset=19)], List([], Load(), lineno=35, col_offset=22, end_lineno=35, end_col_offset=24), lineno=35, col_offset=12, end_lineno=35, end_col_offset=24)], [], lineno=34, col_offset=8, end_lineno=35, end_col_offset=24), If(Compare(Tuple([Name('placeholder_7', Load(), lineno=36, col_offset=12, end_lineno=36, end_col_offset=17), Name('placeholder_8', Load(), lineno=36, col_offset=19, end_lineno=36, end_col_offset=25)], Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=26), [In()], [Name('placeholder_16', Load(), lineno=36, col_offset=30, end_lineno=36, end_col_offset=37)], lineno=36, col_offset=11, end_lineno=36, end_col_offset=37), [Return(Constant(False, lineno=37, col_offset=19, end_lineno=37, end_col_offset=24), lineno=37, col_offset=12, end_lineno=37, end_col_offset=24)], [], lineno=36, col_offset=8, end_lineno=37, end_col_offset=24), If(BoolOp(Or(), [UnaryOp(Not(), Call(Attribute(Name('self', Load(), lineno=39, col_offset=16, end_lineno=39, end_col_offset=20), 'placeholder_10', Load(), lineno=39, col_offset=16, end_lineno=39, end_col_offset=26), [Name('placeholder_7', Load(), lineno=39, col_offset=27, end_lineno=39, end_col_offset=32), Name('placeholder_8', Load(), lineno=39, col_offset=34, end_lineno=39, end_col_offset=40)], [], lineno=39, col_offset=16, end_lineno=39, end_col_offset=41), lineno=39, col_offset=12, end_lineno=39, end_col_offset=41), Compare(Subscript(Subscript(Attribute(Name('self', Load(), lineno=39, col_offset=46, end_lineno=39, end_col_offset=50), 'placeholder_6', Load(), lineno=39, col_offset=46, end_lineno=39, end_col_offset=56), Name('placeholder_8', Load(), lineno=39, col_offset=57, end_lineno=39, end_col_offset=63), Load(), lineno=39, col_offset=46, end_lineno=39, end_col_offset=64), Name('placeholder_7', Load(), lineno=39, col_offset=65, end_lineno=39, end_col_offset=70), Load(), lineno=39, col_offset=46, end_lineno=39, end_col_offset=71), [NotEq()], [Name('placeholder_14', Load(), lineno=39, col_offset=75, end_lineno=39, end_col_offset=81)], lineno=39, col_offset=46, end_lineno=39, end_col_offset=81)], lineno=39, col_offset=11, end_lineno=39, end_col_offset=81), [Return(Constant(False, lineno=40, col_offset=19, end_lineno=40, end_col_offset=24), lineno=40, col_offset=12, end_lineno=40, end_col_offset=24)], [], lineno=39, col_offset=8, end_lineno=40, end_col_offset=24), If(Call(Attribute(Name('self', Load(), lineno=42, col_offset=11, end_lineno=42, end_col_offset=15), 'placeholder_13', Load(), lineno=42, col_offset=11, end_lineno=42, end_col_offset=33), [Name('placeholder_14', Load(), lineno=42, col_offset=34, end_lineno=42, end_col_offset=40), Name('placeholder_7', Load(), lineno=42, col_offset=42, end_lineno=42, end_col_offset=47), Name('placeholder_8', Load(), lineno=42, col_offset=49, end_lineno=42, end_col_offset=55)], [], lineno=42, col_offset=11, end_lineno=42, end_col_offset=56), [Return(Constant(True, lineno=43, col_offset=19, end_lineno=43, end_col_offset=23), lineno=43, col_offset=12, end_lineno=43, end_col_offset=23)], [], lineno=42, col_offset=8, end_lineno=43, end_col_offset=23), For(Name('placeholder_17', Store(), lineno=45, col_offset=12, end_lineno=45, end_col_offset=18), Attribute(Name('self', Load(), lineno=45, col_offset=22, end_lineno=45, end_col_offset=26), 'placeholder_1', Load(), lineno=45, col_offset=22, end_lineno=45, end_col_offset=37), [If(Call(Attribute(Name('self', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=19), 'placeholder_15', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=30), [Name('placeholder_14', Load(), lineno=46, col_offset=31, end_lineno=46, end_col_offset=37), BinOp(Name('placeholder_7', Load(), lineno=46, col_offset=39, end_lineno=46, end_col_offset=44), Add(), Subscript(Name('placeholder_17', Load(), lineno=46, col_offset=47, end_lineno=46, end_col_offset=53), Constant(0, lineno=46, col_offset=54, end_lineno=46, end_col_offset=55), Load(), lineno=46, col_offset=47, end_lineno=46, end_col_offset=56), lineno=46, col_offset=39, end_lineno=46, end_col_offset=56), BinOp(Name('placeholder_8', Load(), lineno=46, col_offset=58, end_lineno=46, end_col_offset=64), Add(), Subscript(Name('placeholder_17', Load(), lineno=46, col_offset=67, end_lineno=46, end_col_offset=73), Constant(1, lineno=46, col_offset=74, end_lineno=46, end_col_offset=75), Load(), lineno=46, col_offset=67, end_lineno=46, end_col_offset=76), lineno=46, col_offset=58, end_lineno=46, end_col_offset=76), BinOp(Name('placeholder_16', Load(), lineno=46, col_offset=78, end_lineno=46, end_col_offset=85), Add(), List([Tuple([Name('placeholder_7', Load(), lineno=46, col_offset=90, end_lineno=46, end_col_offset=95), Name('placeholder_8', Load(), lineno=46, col_offset=97, end_lineno=46, end_col_offset=103)], Load(), lineno=46, col_offset=89, end_lineno=46, end_col_offset=104)], Load(), lineno=46, col_offset=88, end_lineno=46, end_col_offset=105), lineno=46, col_offset=78, end_lineno=46, end_col_offset=105)], [], lineno=46, col_offset=15, end_lineno=46, end_col_offset=106), [Return(Constant(True, lineno=47, col_offset=23, end_lineno=47, end_col_offset=27), lineno=47, col_offset=16, end_lineno=47, end_col_offset=27)], [], lineno=46, col_offset=12, end_lineno=47, end_col_offset=27)], [], lineno=45, col_offset=8, end_lineno=47, end_col_offset=27), Return(Constant(None, lineno=48, col_offset=15, end_lineno=48, end_col_offset=19), lineno=48, col_offset=8, end_lineno=48, end_col_offset=19)], [], lineno=33, col_offset=4, end_lineno=48, end_col_offset=19), FunctionDef('placeholder_18', arguments([], [arg('self', lineno=50, col_offset=31, end_lineno=50, end_col_offset=35), arg('placeholder_14', lineno=50, col_offset=37, end_lineno=50, end_col_offset=43)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_14', Load(), lineno=51, col_offset=11, end_lineno=51, end_col_offset=17), [Eq()], [Attribute(Name('self', Load(), lineno=51, col_offset=21, end_lineno=51, end_col_offset=25), 'placeholder_3', Load(), lineno=51, col_offset=21, end_lineno=51, end_col_offset=31)], lineno=51, col_offset=11, end_lineno=51, end_col_offset=31), [For(Name('placeholder_8', Store(), lineno=52, col_offset=16, end_lineno=52, end_col_offset=22), Call(Name('range', Load(), lineno=52, col_offset=26, end_lineno=52, end_col_offset=31), [Attribute(Name('self', Load(), lineno=52, col_offset=32, end_lineno=52, end_col_offset=36), 'placeholder_8', Load(), lineno=52, col_offset=32, end_lineno=52, end_col_offset=43)], [], lineno=52, col_offset=26, end_lineno=52, end_col_offset=44), [If(Call(Attribute(Name('self', Load(), lineno=53, col_offset=19, end_lineno=53, end_col_offset=23), 'placeholder_15', Load(), lineno=53, col_offset=19, end_lineno=53, end_col_offset=34), [Name('placeholder_14', Load(), lineno=53, col_offset=35, end_lineno=53, end_col_offset=41), Constant(0, lineno=53, col_offset=43, end_lineno=53, end_col_offset=44), Name('placeholder_8', Load(), lineno=53, col_offset=46, end_lineno=53, end_col_offset=52)], [], lineno=53, col_offset=19, end_lineno=53, end_col_offset=53), [Return(Constant(True, lineno=54, col_offset=27, end_lineno=54, end_col_offset=31), lineno=54, col_offset=20, end_lineno=54, end_col_offset=31)], [], lineno=53, col_offset=16, end_lineno=54, end_col_offset=31)], [], lineno=52, col_offset=12, end_lineno=54, end_col_offset=31)], [], lineno=51, col_offset=8, end_lineno=54, end_col_offset=31), If(Compare(Name('placeholder_14', Load(), lineno=55, col_offset=11, end_lineno=55, end_col_offset=17), [Eq()], [Attribute(Name('self', Load(), lineno=55, col_offset=21, end_lineno=55, end_col_offset=25), 'placeholder_2', Load(), lineno=55, col_offset=21, end_lineno=55, end_col_offset=31)], lineno=55, col_offset=11, end_lineno=55, end_col_offset=31), [For(Name('placeholder_7', Store(), lineno=56, col_offset=16, end_lineno=56, end_col_offset=21), Call(Name('range', Load(), lineno=56, col_offset=25, end_lineno=56, end_col_offset=30), [Attribute(Name('self', Load(), lineno=56, col_offset=31, end_lineno=56, end_col_offset=35), 'placeholder_7', Load(), lineno=56, col_offset=31, end_lineno=56, end_col_offset=41)], [], lineno=56, col_offset=25, end_lineno=56, end_col_offset=42), [If(Call(Attribute(Name('self', Load(), lineno=57, col_offset=19, end_lineno=57, end_col_offset=23), 'placeholder_15', Load(), lineno=57, col_offset=19, end_lineno=57, end_col_offset=34), [Name('placeholder_14', Load(), lineno=57, col_offset=35, end_lineno=57, end_col_offset=41), Name('placeholder_7', Load(), lineno=57, col_offset=43, end_lineno=57, end_col_offset=48), Constant(0, lineno=57, col_offset=50, end_lineno=57, end_col_offset=51)], [], lineno=57, col_offset=19, end_lineno=57, end_col_offset=52), [Return(Constant(True, lineno=58, col_offset=27, end_lineno=58, end_col_offset=31), lineno=58, col_offset=20, end_lineno=58, end_col_offset=31)], [], lineno=57, col_offset=16, end_lineno=58, end_col_offset=31)], [], lineno=56, col_offset=12, end_lineno=58, end_col_offset=31)], [], lineno=55, col_offset=8, end_lineno=58, end_col_offset=31), Return(Constant(None, lineno=59, col_offset=15, end_lineno=59, end_col_offset=19), lineno=59, col_offset=8, end_lineno=59, end_col_offset=19)], [], lineno=50, col_offset=4, end_lineno=59, end_col_offset=19), FunctionDef('placeholder_19', arguments([], [arg('self', lineno=61, col_offset=19, end_lineno=61, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Call(Attribute(Name('self', Load(), lineno=62, col_offset=11, end_lineno=62, end_col_offset=15), 'placeholder_18', Load(), lineno=62, col_offset=11, end_lineno=62, end_col_offset=38), [Attribute(Name('self', Load(), lineno=62, col_offset=39, end_lineno=62, end_col_offset=43), 'placeholder_3', Load(), lineno=62, col_offset=39, end_lineno=62, end_col_offset=49)], [], lineno=62, col_offset=11, end_lineno=62, end_col_offset=50), [Return(Attribute(Name('self', Load(), lineno=63, col_offset=19, end_lineno=63, end_col_offset=23), 'placeholder_3', Load(), lineno=63, col_offset=19, end_lineno=63, end_col_offset=29), lineno=63, col_offset=12, end_lineno=63, end_col_offset=29)], [], lineno=62, col_offset=8, end_lineno=63, end_col_offset=29), If(Call(Attribute(Name('self', Load(), lineno=64, col_offset=11, end_lineno=64, end_col_offset=15), 'placeholder_18', Load(), lineno=64, col_offset=11, end_lineno=64, end_col_offset=38), [Attribute(Name('self', Load(), lineno=64, col_offset=39, end_lineno=64, end_col_offset=43), 'placeholder_2', Load(), lineno=64, col_offset=39, end_lineno=64, end_col_offset=49)], [], lineno=64, col_offset=11, end_lineno=64, end_col_offset=50), [Return(Attribute(Name('self', Load(), lineno=65, col_offset=19, end_lineno=65, end_col_offset=23), 'placeholder_2', Load(), lineno=65, col_offset=19, end_lineno=65, end_col_offset=29), lineno=65, col_offset=12, end_lineno=65, end_col_offset=29)], [], lineno=64, col_offset=8, end_lineno=65, end_col_offset=29), Return(Constant('', lineno=66, col_offset=15, end_lineno=66, end_col_offset=17), lineno=66, col_offset=8, end_lineno=66, end_col_offset=17)], [], lineno=61, col_offset=4, end_lineno=66, end_col_offset=17)], [], lineno=2, col_offset=0, end_lineno=66, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-crypto-square/.meta/config.json b/test/practice-crypto-square/.meta/config.json new file mode 100644 index 0000000..7c7de94 --- /dev/null +++ b/test/practice-crypto-square/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "elyssonmr", + "kytrinyx", + "MrNaif2018", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236", + "yawpitch", + "yo-ga" + ], + "files": { + "solution": [ + "crypto_square.py" + ], + "test": [ + "crypto_square_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement the classic method for composing secret messages called a square code.", + "source": "J Dalbey's Programming Practice problems", + "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" +} diff --git a/test/practice-crypto-square/crypto_square.py b/test/practice-crypto-square/crypto_square.py new file mode 100644 index 0000000..8cfc764 --- /dev/null +++ b/test/practice-crypto-square/crypto_square.py @@ -0,0 +1,23 @@ +from math import ceil, sqrt +from itertools import zip_longest + + +def cipher_text(plain_text): + plain_text = _cleanse(plain_text) + square_size = int(ceil(sqrt(len(plain_text)))) + square = _chunks_of(plain_text, square_size) + return ' '.join([''.join(column) + for column in zip_longest(*square, fillvalue=' ')]) + + +def _cleanse(text): + """Lowercase a string and remove punctuation and whitespace + """ + return ''.join([character for character in text + if character.isalnum()]).lower() + + +def _chunks_of(text, num): + if len(text) <= num: + return [text] + return [text[:num]] + _chunks_of(text[num:], num) diff --git a/test/practice-crypto-square/mapping.json b/test/practice-crypto-square/mapping.json new file mode 100644 index 0000000..5294642 --- /dev/null +++ b/test/practice-crypto-square/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "cipher_text", + "placeholder_1": "plain_text", + "placeholder_2": "square_size", + "placeholder_3": "square", + "placeholder_4": "column", + "placeholder_5": "fillvalue", + "placeholder_6": "_cleanse", + "placeholder_7": "text", + "placeholder_8": "character", + "placeholder_9": "_chunks_of", + "placeholder_10": "num" +} \ No newline at end of file diff --git a/test/practice-crypto-square/representation.json b/test/practice-crypto-square/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-crypto-square/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-crypto-square/representation.out b/test/practice-crypto-square/representation.out new file mode 100644 index 0000000..8dbd692 --- /dev/null +++ b/test/practice-crypto-square/representation.out @@ -0,0 +1,1252 @@ +## BEGIN NORMALIZED CODE ## +from math import ceil, sqrt +from itertools import zip_longest + + +def placeholder_0(placeholder_1): + placeholder_1 = _cleanse(placeholder_1) + placeholder_2 = int(ceil(sqrt(len(placeholder_1)))) + placeholder_3 = _chunks_of(placeholder_1, placeholder_2) + return " ".join( + [ + "".join(placeholder_4) + for placeholder_4 in zip_longest(*placeholder_3, placeholder_5=" ") + ] + ) + + +def placeholder_6(placeholder_7): + return "".join( + [placeholder_8 for placeholder_8 in placeholder_7 if placeholder_8.isalnum()] + ).lower() + + +def placeholder_9(placeholder_7, placeholder_10): + if len(placeholder_7) <= placeholder_10: + return [placeholder_7] + return [placeholder_7[:placeholder_10]] + placeholder_9( + placeholder_7[placeholder_10:], placeholder_10 + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'ceil', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21), + alias( + 'sqrt', + lineno=1, + col_offset=23, + end_lineno=1, + end_col_offset=27)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=27), + ImportFrom( + 'itertools', + [ + alias( + 'zip_longest', + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=33)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=33), + FunctionDef( + 'cipher_text', + arguments( + [], + [ + arg( + 'plain_text', + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'plain_text', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=14)], + Call( + Name( + '_cleanse', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=25), + [ + Name( + 'plain_text', + Load(), + lineno=6, + col_offset=26, + end_lineno=6, + end_col_offset=36)], + [], + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=37), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=37), + Assign( + [ + Name( + 'square_size', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=15)], + Call( + Name( + 'int', + Load(), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=21), + [ + Call( + Name( + 'ceil', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=26), + [ + Call( + Name( + 'sqrt', + Load(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=31), + [ + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=35), + [ + Name( + 'plain_text', + Load(), + lineno=7, + col_offset=36, + end_lineno=7, + end_col_offset=46)], + [], + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=47)], + [], + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=48)], + [], + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=49)], + [], + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=50), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=50), + Assign( + [ + Name( + 'square', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10)], + Call( + Name( + '_chunks_of', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=23), + [ + Name( + 'plain_text', + Load(), + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=34), + Name( + 'square_size', + Load(), + lineno=8, + col_offset=36, + end_lineno=8, + end_col_offset=47)], + [], + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=48), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=48), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=14), + 'join', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=19), + [ + ListComp( + Call( + Attribute( + Constant( + '', + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=23), + 'join', + Load(), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=28), + [ + Name( + 'column', + Load(), + lineno=9, + col_offset=29, + end_lineno=9, + end_col_offset=35)], + [], + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=36), + [ + comprehension( + Name( + 'column', + Store(), + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=31), + Call( + Name( + 'zip_longest', + Load(), + lineno=10, + col_offset=35, + end_lineno=10, + end_col_offset=46), + [ + Starred( + Name( + 'square', + Load(), + lineno=10, + col_offset=48, + end_lineno=10, + end_col_offset=54), + Load(), + lineno=10, + col_offset=47, + end_lineno=10, + end_col_offset=54)], + [ + keyword( + 'fillvalue', + Constant( + ' ', + lineno=10, + col_offset=66, + end_lineno=10, + end_col_offset=69), + lineno=10, + col_offset=56, + end_lineno=10, + end_col_offset=69)], + lineno=10, + col_offset=35, + end_lineno=10, + end_col_offset=70), + [], + 0)], + lineno=9, + col_offset=20, + end_lineno=10, + end_col_offset=71)], + [], + lineno=9, + col_offset=11, + end_lineno=10, + end_col_offset=72), + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=72)], + [], + lineno=5, + col_offset=0, + end_lineno=10, + end_col_offset=72), + FunctionDef( + '_cleanse', + arguments( + [], + [ + arg( + 'text', + lineno=13, + col_offset=13, + end_lineno=13, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Lowercase a string and remove punctuation and whitespace\n ', + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=7), + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=7), + Return( + Call( + Attribute( + Call( + Attribute( + Constant( + '', + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=13), + 'join', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=18), + [ + ListComp( + Name( + 'character', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=29), + [ + comprehension( + Name( + 'character', + Store(), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=43), + Name( + 'text', + Load(), + lineno=16, + col_offset=47, + end_lineno=16, + end_col_offset=51), + [ + Call( + Attribute( + Name( + 'character', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=32), + 'isalnum', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=40), + [], + [], + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=42)], + 0)], + lineno=16, + col_offset=19, + end_lineno=17, + end_col_offset=43)], + [], + lineno=16, + col_offset=11, + end_lineno=17, + end_col_offset=44), + 'lower', + Load(), + lineno=16, + col_offset=11, + end_lineno=17, + end_col_offset=50), + [], + [], + lineno=16, + col_offset=11, + end_lineno=17, + end_col_offset=52), + lineno=16, + col_offset=4, + end_lineno=17, + end_col_offset=52)], + [], + lineno=13, + col_offset=0, + end_lineno=17, + end_col_offset=52), + FunctionDef( + '_chunks_of', + arguments( + [], + [ + arg( + 'text', + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=19), + arg( + 'num', + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=10), + [ + Name( + 'text', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=15)], + [], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=16), + [ + LtE()], + [ + Name( + 'num', + Load(), + lineno=21, + col_offset=20, + end_lineno=21, + end_col_offset=23)], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=23), + [ + Return( + List( + [ + Name( + 'text', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20)], + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=21), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=21)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=21), + Return( + BinOp( + List( + [ + Subscript( + Name( + 'text', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=16), + Slice( + upper=Name( + 'num', + Load(), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=21), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=22)], + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=23), + Add(), + Call( + Name( + '_chunks_of', + Load(), + lineno=23, + col_offset=26, + end_lineno=23, + end_col_offset=36), + [ + Subscript( + Name( + 'text', + Load(), + lineno=23, + col_offset=37, + end_lineno=23, + end_col_offset=41), + Slice( + Name( + 'num', + Load(), + lineno=23, + col_offset=42, + end_lineno=23, + end_col_offset=45), + lineno=23, + col_offset=42, + end_lineno=23, + end_col_offset=46), + Load(), + lineno=23, + col_offset=37, + end_lineno=23, + end_col_offset=47), + Name( + 'num', + Load(), + lineno=23, + col_offset=49, + end_lineno=23, + end_col_offset=52)], + [], + lineno=23, + col_offset=26, + end_lineno=23, + end_col_offset=53), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=53), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=53)], + [], + lineno=20, + col_offset=0, + end_lineno=23, + end_col_offset=53)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'ceil', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21), + alias( + 'sqrt', + lineno=1, + col_offset=23, + end_lineno=1, + end_col_offset=27)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=27), + ImportFrom( + 'itertools', + [ + alias( + 'zip_longest', + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=33)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=33), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=14)], + Call( + Name( + '_cleanse', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=25), + [ + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=26, + end_lineno=6, + end_col_offset=36)], + [], + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=37), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=37), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=15)], + Call( + Name( + 'int', + Load(), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=21), + [ + Call( + Name( + 'ceil', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=26), + [ + Call( + Name( + 'sqrt', + Load(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=31), + [ + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=35), + [ + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=36, + end_lineno=7, + end_col_offset=46)], + [], + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=47)], + [], + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=48)], + [], + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=49)], + [], + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=50), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=50), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10)], + Call( + Name( + '_chunks_of', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=23), + [ + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=34), + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=36, + end_lineno=8, + end_col_offset=47)], + [], + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=48), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=48), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=14), + 'join', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=19), + [ + ListComp( + Call( + Attribute( + Constant( + '', + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=23), + 'join', + Load(), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=28), + [ + Name( + 'placeholder_4', + Load(), + lineno=9, + col_offset=29, + end_lineno=9, + end_col_offset=35)], + [], + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=36), + [ + comprehension( + Name( + 'placeholder_4', + Store(), + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=31), + Call( + Name( + 'zip_longest', + Load(), + lineno=10, + col_offset=35, + end_lineno=10, + end_col_offset=46), + [ + Starred( + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=48, + end_lineno=10, + end_col_offset=54), + Load(), + lineno=10, + col_offset=47, + end_lineno=10, + end_col_offset=54)], + [ + keyword( + 'placeholder_5', + Constant( + ' ', + lineno=10, + col_offset=66, + end_lineno=10, + end_col_offset=69), + lineno=10, + col_offset=56, + end_lineno=10, + end_col_offset=69)], + lineno=10, + col_offset=35, + end_lineno=10, + end_col_offset=70), + [], + 0)], + lineno=9, + col_offset=20, + end_lineno=10, + end_col_offset=71)], + [], + lineno=9, + col_offset=11, + end_lineno=10, + end_col_offset=72), + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=72)], + [], + lineno=5, + col_offset=0, + end_lineno=10, + end_col_offset=72), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=13, + col_offset=13, + end_lineno=13, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Attribute( + Constant( + '', + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=13), + 'join', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=18), + [ + ListComp( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=29), + [ + comprehension( + Name( + 'placeholder_8', + Store(), + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=43), + Name( + 'placeholder_7', + Load(), + lineno=16, + col_offset=47, + end_lineno=16, + end_col_offset=51), + [ + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=32), + 'isalnum', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=40), + [], + [], + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=42)], + 0)], + lineno=16, + col_offset=19, + end_lineno=17, + end_col_offset=43)], + [], + lineno=16, + col_offset=11, + end_lineno=17, + end_col_offset=44), + 'lower', + Load(), + lineno=16, + col_offset=11, + end_lineno=17, + end_col_offset=50), + [], + [], + lineno=16, + col_offset=11, + end_lineno=17, + end_col_offset=52), + lineno=16, + col_offset=4, + end_lineno=17, + end_col_offset=52)], + [], + lineno=13, + col_offset=0, + end_lineno=17, + end_col_offset=52), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=19), + arg( + 'placeholder_10', + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=10), + [ + Name( + 'placeholder_7', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=15)], + [], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=16), + [ + LtE()], + [ + Name( + 'placeholder_10', + Load(), + lineno=21, + col_offset=20, + end_lineno=21, + end_col_offset=23)], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=23), + [ + Return( + List( + [ + Name( + 'placeholder_7', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20)], + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=21), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=21)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=21), + Return( + BinOp( + List( + [ + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=16), + Slice( + upper=Name( + 'placeholder_10', + Load(), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=21), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=22)], + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=23), + Add(), + Call( + Name( + 'placeholder_9', + Load(), + lineno=23, + col_offset=26, + end_lineno=23, + end_col_offset=36), + [ + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=23, + col_offset=37, + end_lineno=23, + end_col_offset=41), + Slice( + Name( + 'placeholder_10', + Load(), + lineno=23, + col_offset=42, + end_lineno=23, + end_col_offset=45), + lineno=23, + col_offset=42, + end_lineno=23, + end_col_offset=46), + Load(), + lineno=23, + col_offset=37, + end_lineno=23, + end_col_offset=47), + Name( + 'placeholder_10', + Load(), + lineno=23, + col_offset=49, + end_lineno=23, + end_col_offset=52)], + [], + lineno=23, + col_offset=26, + end_lineno=23, + end_col_offset=53), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=53), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=53)], + [], + lineno=20, + col_offset=0, + end_lineno=23, + end_col_offset=53)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-crypto-square/representation.txt b/test/practice-crypto-square/representation.txt new file mode 100644 index 0000000..ed3a11e --- /dev/null +++ b/test/practice-crypto-square/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('math', [alias('ceil', lineno=1, col_offset=17, end_lineno=1, end_col_offset=21), alias('sqrt', lineno=1, col_offset=23, end_lineno=1, end_col_offset=27)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=27), ImportFrom('itertools', [alias('zip_longest', lineno=2, col_offset=22, end_lineno=2, end_col_offset=33)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=33), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=16, end_lineno=5, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_1', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=14)], Call(Name('_cleanse', Load(), lineno=6, col_offset=17, end_lineno=6, end_col_offset=25), [Name('placeholder_1', Load(), lineno=6, col_offset=26, end_lineno=6, end_col_offset=36)], [], lineno=6, col_offset=17, end_lineno=6, end_col_offset=37), lineno=6, col_offset=4, end_lineno=6, end_col_offset=37), Assign([Name('placeholder_2', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=15)], Call(Name('int', Load(), lineno=7, col_offset=18, end_lineno=7, end_col_offset=21), [Call(Name('ceil', Load(), lineno=7, col_offset=22, end_lineno=7, end_col_offset=26), [Call(Name('sqrt', Load(), lineno=7, col_offset=27, end_lineno=7, end_col_offset=31), [Call(Name('len', Load(), lineno=7, col_offset=32, end_lineno=7, end_col_offset=35), [Name('placeholder_1', Load(), lineno=7, col_offset=36, end_lineno=7, end_col_offset=46)], [], lineno=7, col_offset=32, end_lineno=7, end_col_offset=47)], [], lineno=7, col_offset=27, end_lineno=7, end_col_offset=48)], [], lineno=7, col_offset=22, end_lineno=7, end_col_offset=49)], [], lineno=7, col_offset=18, end_lineno=7, end_col_offset=50), lineno=7, col_offset=4, end_lineno=7, end_col_offset=50), Assign([Name('placeholder_3', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=10)], Call(Name('_chunks_of', Load(), lineno=8, col_offset=13, end_lineno=8, end_col_offset=23), [Name('placeholder_1', Load(), lineno=8, col_offset=24, end_lineno=8, end_col_offset=34), Name('placeholder_2', Load(), lineno=8, col_offset=36, end_lineno=8, end_col_offset=47)], [], lineno=8, col_offset=13, end_lineno=8, end_col_offset=48), lineno=8, col_offset=4, end_lineno=8, end_col_offset=48), Return(Call(Attribute(Constant(' ', lineno=9, col_offset=11, end_lineno=9, end_col_offset=14), 'join', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=19), [ListComp(Call(Attribute(Constant('', lineno=9, col_offset=21, end_lineno=9, end_col_offset=23), 'join', Load(), lineno=9, col_offset=21, end_lineno=9, end_col_offset=28), [Name('placeholder_4', Load(), lineno=9, col_offset=29, end_lineno=9, end_col_offset=35)], [], lineno=9, col_offset=21, end_lineno=9, end_col_offset=36), [comprehension(Name('placeholder_4', Store(), lineno=10, col_offset=25, end_lineno=10, end_col_offset=31), Call(Name('zip_longest', Load(), lineno=10, col_offset=35, end_lineno=10, end_col_offset=46), [Starred(Name('placeholder_3', Load(), lineno=10, col_offset=48, end_lineno=10, end_col_offset=54), Load(), lineno=10, col_offset=47, end_lineno=10, end_col_offset=54)], [keyword('placeholder_5', Constant(' ', lineno=10, col_offset=66, end_lineno=10, end_col_offset=69), lineno=10, col_offset=56, end_lineno=10, end_col_offset=69)], lineno=10, col_offset=35, end_lineno=10, end_col_offset=70), [], 0)], lineno=9, col_offset=20, end_lineno=10, end_col_offset=71)], [], lineno=9, col_offset=11, end_lineno=10, end_col_offset=72), lineno=9, col_offset=4, end_lineno=10, end_col_offset=72)], [], lineno=5, col_offset=0, end_lineno=10, end_col_offset=72), FunctionDef('placeholder_6', arguments([], [arg('placeholder_7', lineno=13, col_offset=13, end_lineno=13, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Call(Attribute(Constant('', lineno=16, col_offset=11, end_lineno=16, end_col_offset=13), 'join', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=18), [ListComp(Name('placeholder_8', Load(), lineno=16, col_offset=20, end_lineno=16, end_col_offset=29), [comprehension(Name('placeholder_8', Store(), lineno=16, col_offset=34, end_lineno=16, end_col_offset=43), Name('placeholder_7', Load(), lineno=16, col_offset=47, end_lineno=16, end_col_offset=51), [Call(Attribute(Name('placeholder_8', Load(), lineno=17, col_offset=23, end_lineno=17, end_col_offset=32), 'isalnum', Load(), lineno=17, col_offset=23, end_lineno=17, end_col_offset=40), [], [], lineno=17, col_offset=23, end_lineno=17, end_col_offset=42)], 0)], lineno=16, col_offset=19, end_lineno=17, end_col_offset=43)], [], lineno=16, col_offset=11, end_lineno=17, end_col_offset=44), 'lower', Load(), lineno=16, col_offset=11, end_lineno=17, end_col_offset=50), [], [], lineno=16, col_offset=11, end_lineno=17, end_col_offset=52), lineno=16, col_offset=4, end_lineno=17, end_col_offset=52)], [], lineno=13, col_offset=0, end_lineno=17, end_col_offset=52), FunctionDef('placeholder_9', arguments([], [arg('placeholder_7', lineno=20, col_offset=15, end_lineno=20, end_col_offset=19), arg('placeholder_10', lineno=20, col_offset=21, end_lineno=20, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=21, col_offset=7, end_lineno=21, end_col_offset=10), [Name('placeholder_7', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=15)], [], lineno=21, col_offset=7, end_lineno=21, end_col_offset=16), [LtE()], [Name('placeholder_10', Load(), lineno=21, col_offset=20, end_lineno=21, end_col_offset=23)], lineno=21, col_offset=7, end_lineno=21, end_col_offset=23), [Return(List([Name('placeholder_7', Load(), lineno=22, col_offset=16, end_lineno=22, end_col_offset=20)], Load(), lineno=22, col_offset=15, end_lineno=22, end_col_offset=21), lineno=22, col_offset=8, end_lineno=22, end_col_offset=21)], [], lineno=21, col_offset=4, end_lineno=22, end_col_offset=21), Return(BinOp(List([Subscript(Name('placeholder_7', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=16), Slice(upper=Name('placeholder_10', Load(), lineno=23, col_offset=18, end_lineno=23, end_col_offset=21), lineno=23, col_offset=17, end_lineno=23, end_col_offset=21), Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=22)], Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=23), Add(), Call(Name('placeholder_9', Load(), lineno=23, col_offset=26, end_lineno=23, end_col_offset=36), [Subscript(Name('placeholder_7', Load(), lineno=23, col_offset=37, end_lineno=23, end_col_offset=41), Slice(Name('placeholder_10', Load(), lineno=23, col_offset=42, end_lineno=23, end_col_offset=45), lineno=23, col_offset=42, end_lineno=23, end_col_offset=46), Load(), lineno=23, col_offset=37, end_lineno=23, end_col_offset=47), Name('placeholder_10', Load(), lineno=23, col_offset=49, end_lineno=23, end_col_offset=52)], [], lineno=23, col_offset=26, end_lineno=23, end_col_offset=53), lineno=23, col_offset=11, end_lineno=23, end_col_offset=53), lineno=23, col_offset=4, end_lineno=23, end_col_offset=53)], [], lineno=20, col_offset=0, end_lineno=23, end_col_offset=53)], []) \ No newline at end of file diff --git a/test/practice-custom-set/.meta/config.json b/test/practice-custom-set/.meta/config.json new file mode 100644 index 0000000..f3c73c2 --- /dev/null +++ b/test/practice-custom-set/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "Dog", + "tqa236", + "vigneshhari" + ], + "files": { + "solution": [ + "custom_set.py" + ], + "test": [ + "custom_set_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Create a custom set type." +} diff --git a/test/practice-custom-set/custom_set.py b/test/practice-custom-set/custom_set.py new file mode 100644 index 0000000..fed6acb --- /dev/null +++ b/test/practice-custom-set/custom_set.py @@ -0,0 +1,45 @@ +class CustomSet: + def __init__(self, elements=None): + self.elements = list(elements) if elements is not None else list([]) + + def isempty(self): + return not self.elements + + def __iter__(self): + return iter(self.elements) + + def __contains__(self, element): + return element in self.elements + + def issubset(self, other): + return all(idx in other for idx in self) + + def isdisjoint(self, other): + return all(idx not in other for idx in self) + + def __eq__(self, other): + return self.issubset(other) and other.issubset(self) + + def add(self, element): + if element not in self: + self.elements.append(element) + + def intersection(self, other): + result = CustomSet() + for idx in self: + if idx in other: + result.add(idx) + return result + + def __sub__(self, other): + result = CustomSet() + for idx in self: + if idx not in other: + result.add(idx) + return result + + def __add__(self, other): + result = CustomSet(self.elements) + for idx in other: + result.add(idx) + return result diff --git a/test/practice-custom-set/mapping.json b/test/practice-custom-set/mapping.json new file mode 100644 index 0000000..ea6beb2 --- /dev/null +++ b/test/practice-custom-set/mapping.json @@ -0,0 +1,19 @@ +{ + "placeholder_0": "CustomSet", + "placeholder_1": "__init__", + "placeholder_2": "elements", + "placeholder_3": "isempty", + "placeholder_4": "__iter__", + "placeholder_5": "__contains__", + "placeholder_6": "element", + "placeholder_7": "issubset", + "placeholder_8": "other", + "placeholder_9": "idx", + "placeholder_10": "isdisjoint", + "placeholder_11": "__eq__", + "placeholder_12": "add", + "placeholder_13": "intersection", + "placeholder_14": "result", + "placeholder_15": "__sub__", + "placeholder_16": "__add__" +} \ No newline at end of file diff --git a/test/practice-custom-set/representation.json b/test/practice-custom-set/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-custom-set/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-custom-set/representation.out b/test/practice-custom-set/representation.out new file mode 100644 index 0000000..439afde --- /dev/null +++ b/test/practice-custom-set/representation.out @@ -0,0 +1,2234 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2=None): + self.placeholder_2 = ( + list(placeholder_2) if placeholder_2 is not None else list([]) + ) + + def placeholder_3(self): + return not self.placeholder_2 + + def placeholder_4(self): + return iter(self.placeholder_2) + + def placeholder_5(self, placeholder_6): + return placeholder_6 in self.placeholder_2 + + def placeholder_7(self, placeholder_8): + return all((placeholder_9 in placeholder_8 for placeholder_9 in self)) + + def placeholder_10(self, placeholder_8): + return all((placeholder_9 not in placeholder_8 for placeholder_9 in self)) + + def placeholder_11(self, placeholder_8): + return self.placeholder_7(placeholder_8) and placeholder_8.placeholder_7(self) + + def placeholder_12(self, placeholder_6): + if placeholder_6 not in self: + self.placeholder_2.append(placeholder_6) + + def placeholder_13(self, placeholder_8): + placeholder_14 = placeholder_0() + for placeholder_9 in self: + if placeholder_9 in placeholder_8: + placeholder_14.placeholder_12(placeholder_9) + return placeholder_14 + + def placeholder_15(self, placeholder_8): + placeholder_14 = placeholder_0() + for placeholder_9 in self: + if placeholder_9 not in placeholder_8: + placeholder_14.placeholder_12(placeholder_9) + return placeholder_14 + + def placeholder_16(self, placeholder_8): + placeholder_14 = placeholder_0(self.placeholder_2) + for placeholder_9 in placeholder_8: + placeholder_14.placeholder_12(placeholder_9) + return placeholder_14 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'CustomSet', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'elements', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=36)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'elements', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=21)], + IfExp( + Compare( + Name( + 'elements', + Load(), + lineno=3, + col_offset=42, + end_lineno=3, + end_col_offset=50), + [ + IsNot()], + [ + Constant( + None, + lineno=3, + col_offset=58, + end_lineno=3, + end_col_offset=62)], + lineno=3, + col_offset=42, + end_lineno=3, + end_col_offset=62), + Call( + Name( + 'list', + Load(), + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=28), + [ + Name( + 'elements', + Load(), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=37)], + [], + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=38), + Call( + Name( + 'list', + Load(), + lineno=3, + col_offset=68, + end_lineno=3, + end_col_offset=72), + [ + List( + [], + Load(), + lineno=3, + col_offset=73, + end_lineno=3, + end_col_offset=75)], + [], + lineno=3, + col_offset=68, + end_lineno=3, + end_col_offset=76), + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=76), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=76)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=76), + FunctionDef( + 'isempty', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=23), + 'elements', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=32), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=32), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=32)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=32), + FunctionDef( + '__iter__', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'iter', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=19), + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=24), + 'elements', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=33)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=34), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=34)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=34), + FunctionDef( + '__contains__', + arguments( + [], + [ + arg( + 'self', + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=25), + arg( + 'element', + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Name( + 'element', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=22), + [ + In()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=30), + 'elements', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=39)], + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=39), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=39)], + [], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=39), + FunctionDef( + 'issubset', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'other', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'all', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=18), + [ + GeneratorExp( + Compare( + Name( + 'idx', + Load(), + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=22), + [ + In()], + [ + Name( + 'other', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=31)], + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=31), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=15, + col_offset=36, + end_lineno=15, + end_col_offset=39), + Name( + 'self', + Load(), + lineno=15, + col_offset=43, + end_lineno=15, + end_col_offset=47), + [], + 0)], + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=48)], + [], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=48), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=48)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=48), + FunctionDef( + 'isdisjoint', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=23), + arg( + 'other', + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'all', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=18), + [ + GeneratorExp( + Compare( + Name( + 'idx', + Load(), + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=22), + [ + NotIn()], + [ + Name( + 'other', + Load(), + lineno=18, + col_offset=30, + end_lineno=18, + end_col_offset=35)], + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=35), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=18, + col_offset=40, + end_lineno=18, + end_col_offset=43), + Name( + 'self', + Load(), + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=51), + [], + 0)], + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=52)], + [], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=52), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=52)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=52), + FunctionDef( + '__eq__', + arguments( + [], + [ + arg( + 'self', + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=19), + arg( + 'other', + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + 'issubset', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=28), + [ + Name( + 'other', + Load(), + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=34)], + [], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=35), + Call( + Attribute( + Name( + 'other', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=45), + 'issubset', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=54), + [ + Name( + 'self', + Load(), + lineno=21, + col_offset=55, + end_lineno=21, + end_col_offset=59)], + [], + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=60)], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=60), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=60)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=60), + FunctionDef( + 'add', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=16), + arg( + 'element', + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'element', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=18), + [ + NotIn()], + [ + Name( + 'self', + Load(), + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=30)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=30), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=16), + 'elements', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=25), + 'append', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=32), + [ + Name( + 'element', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=40)], + [], + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=41), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=41)], + [], + lineno=24, + col_offset=8, + end_lineno=25, + end_col_offset=41)], + [], + lineno=23, + col_offset=4, + end_lineno=25, + end_col_offset=41), + FunctionDef( + 'intersection', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=25), + arg( + 'other', + lineno=27, + col_offset=27, + end_lineno=27, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=14)], + Call( + Name( + 'CustomSet', + Load(), + lineno=28, + col_offset=17, + end_lineno=28, + end_col_offset=26), + [], + [], + lineno=28, + col_offset=17, + end_lineno=28, + end_col_offset=28), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=28), + For( + Name( + 'idx', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=15), + Name( + 'self', + Load(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=23), + [ + If( + Compare( + Name( + 'idx', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=18), + [ + In()], + [ + Name( + 'other', + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=27)], + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=27), + [ + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=22), + 'add', + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=26), + [ + Name( + 'idx', + Load(), + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=30)], + [], + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=31), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=31)], + [], + lineno=30, + col_offset=12, + end_lineno=31, + end_col_offset=31)], + [], + lineno=29, + col_offset=8, + end_lineno=31, + end_col_offset=31), + Return( + Name( + 'result', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=21), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=21)], + [], + lineno=27, + col_offset=4, + end_lineno=32, + end_col_offset=21), + FunctionDef( + '__sub__', + arguments( + [], + [ + arg( + 'self', + lineno=34, + col_offset=16, + end_lineno=34, + end_col_offset=20), + arg( + 'other', + lineno=34, + col_offset=22, + end_lineno=34, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=14)], + Call( + Name( + 'CustomSet', + Load(), + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=26), + [], + [], + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=28), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=28), + For( + Name( + 'idx', + Store(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=15), + Name( + 'self', + Load(), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=23), + [ + If( + Compare( + Name( + 'idx', + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=18), + [ + NotIn()], + [ + Name( + 'other', + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=31)], + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=22), + 'add', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=26), + [ + Name( + 'idx', + Load(), + lineno=38, + col_offset=27, + end_lineno=38, + end_col_offset=30)], + [], + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=31), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=31)], + [], + lineno=37, + col_offset=12, + end_lineno=38, + end_col_offset=31)], + [], + lineno=36, + col_offset=8, + end_lineno=38, + end_col_offset=31), + Return( + Name( + 'result', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=21), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=21)], + [], + lineno=34, + col_offset=4, + end_lineno=39, + end_col_offset=21), + FunctionDef( + '__add__', + arguments( + [], + [ + arg( + 'self', + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=20), + arg( + 'other', + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=14)], + Call( + Name( + 'CustomSet', + Load(), + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=26), + [ + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=31), + 'elements', + Load(), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=40)], + [], + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=41), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=41), + For( + Name( + 'idx', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=15), + Name( + 'other', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=18), + 'add', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=22), + [ + Name( + 'idx', + Load(), + lineno=44, + col_offset=23, + end_lineno=44, + end_col_offset=26)], + [], + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=27), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=27)], + [], + lineno=43, + col_offset=8, + end_lineno=44, + end_col_offset=27), + Return( + Name( + 'result', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=21), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=21)], + [], + lineno=41, + col_offset=4, + end_lineno=45, + end_col_offset=21)], + [], + lineno=1, + col_offset=0, + end_lineno=45, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=36)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=21)], + IfExp( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=42, + end_lineno=3, + end_col_offset=50), + [ + IsNot()], + [ + Constant( + None, + lineno=3, + col_offset=58, + end_lineno=3, + end_col_offset=62)], + lineno=3, + col_offset=42, + end_lineno=3, + end_col_offset=62), + Call( + Name( + 'list', + Load(), + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=28), + [ + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=37)], + [], + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=38), + Call( + Name( + 'list', + Load(), + lineno=3, + col_offset=68, + end_lineno=3, + end_col_offset=72), + [ + List( + [], + Load(), + lineno=3, + col_offset=73, + end_lineno=3, + end_col_offset=75)], + [], + lineno=3, + col_offset=68, + end_lineno=3, + end_col_offset=76), + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=76), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=76)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=76), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=23), + 'placeholder_2', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=32), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=32), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=32)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=32), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'iter', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=19), + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=33)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=34), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=34)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=34), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=25), + arg( + 'placeholder_6', + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=22), + [ + In()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=30), + 'placeholder_2', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=39)], + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=39), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=39)], + [], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=39), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'placeholder_8', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'all', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=18), + [ + GeneratorExp( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=22), + [ + In()], + [ + Name( + 'placeholder_8', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=31)], + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=31), + [ + comprehension( + Name( + 'placeholder_9', + Store(), + lineno=15, + col_offset=36, + end_lineno=15, + end_col_offset=39), + Name( + 'self', + Load(), + lineno=15, + col_offset=43, + end_lineno=15, + end_col_offset=47), + [], + 0)], + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=48)], + [], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=48), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=48)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=48), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=23), + arg( + 'placeholder_8', + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'all', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=18), + [ + GeneratorExp( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=22), + [ + NotIn()], + [ + Name( + 'placeholder_8', + Load(), + lineno=18, + col_offset=30, + end_lineno=18, + end_col_offset=35)], + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=35), + [ + comprehension( + Name( + 'placeholder_9', + Store(), + lineno=18, + col_offset=40, + end_lineno=18, + end_col_offset=43), + Name( + 'self', + Load(), + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=51), + [], + 0)], + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=52)], + [], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=52), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=52)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=52), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=19), + arg( + 'placeholder_8', + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=28), + [ + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=34)], + [], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=35), + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=45), + 'placeholder_7', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=54), + [ + Name( + 'self', + Load(), + lineno=21, + col_offset=55, + end_lineno=21, + end_col_offset=59)], + [], + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=60)], + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=60), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=60)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=60), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=16), + arg( + 'placeholder_6', + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=18), + [ + NotIn()], + [ + Name( + 'self', + Load(), + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=30)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=30), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=16), + 'placeholder_2', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=25), + 'append', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=32), + [ + Name( + 'placeholder_6', + Load(), + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=40)], + [], + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=41), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=41)], + [], + lineno=24, + col_offset=8, + end_lineno=25, + end_col_offset=41)], + [], + lineno=23, + col_offset=4, + end_lineno=25, + end_col_offset=41), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=25), + arg( + 'placeholder_8', + lineno=27, + col_offset=27, + end_lineno=27, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=14)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=28, + col_offset=17, + end_lineno=28, + end_col_offset=26), + [], + [], + lineno=28, + col_offset=17, + end_lineno=28, + end_col_offset=28), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=28), + For( + Name( + 'placeholder_9', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=15), + Name( + 'self', + Load(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=23), + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=18), + [ + In()], + [ + Name( + 'placeholder_8', + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=27)], + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=27), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_14', + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=22), + 'placeholder_12', + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=26), + [ + Name( + 'placeholder_9', + Load(), + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=30)], + [], + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=31), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=31)], + [], + lineno=30, + col_offset=12, + end_lineno=31, + end_col_offset=31)], + [], + lineno=29, + col_offset=8, + end_lineno=31, + end_col_offset=31), + Return( + Name( + 'placeholder_14', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=21), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=21)], + [], + lineno=27, + col_offset=4, + end_lineno=32, + end_col_offset=21), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=34, + col_offset=16, + end_lineno=34, + end_col_offset=20), + arg( + 'placeholder_8', + lineno=34, + col_offset=22, + end_lineno=34, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=14)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=26), + [], + [], + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=28), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=28), + For( + Name( + 'placeholder_9', + Store(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=15), + Name( + 'self', + Load(), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=23), + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=18), + [ + NotIn()], + [ + Name( + 'placeholder_8', + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=31)], + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_14', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=22), + 'placeholder_12', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=26), + [ + Name( + 'placeholder_9', + Load(), + lineno=38, + col_offset=27, + end_lineno=38, + end_col_offset=30)], + [], + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=31), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=31)], + [], + lineno=37, + col_offset=12, + end_lineno=38, + end_col_offset=31)], + [], + lineno=36, + col_offset=8, + end_lineno=38, + end_col_offset=31), + Return( + Name( + 'placeholder_14', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=21), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=21)], + [], + lineno=34, + col_offset=4, + end_lineno=39, + end_col_offset=21), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'self', + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=20), + arg( + 'placeholder_8', + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=14)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=26), + [ + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=31), + 'placeholder_2', + Load(), + lineno=42, + col_offset=27, + end_lineno=42, + end_col_offset=40)], + [], + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=41), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=41), + For( + Name( + 'placeholder_9', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=15), + Name( + 'placeholder_8', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_14', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=18), + 'placeholder_12', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=22), + [ + Name( + 'placeholder_9', + Load(), + lineno=44, + col_offset=23, + end_lineno=44, + end_col_offset=26)], + [], + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=27), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=27)], + [], + lineno=43, + col_offset=8, + end_lineno=44, + end_col_offset=27), + Return( + Name( + 'placeholder_14', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=21), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=21)], + [], + lineno=41, + col_offset=4, + end_lineno=45, + end_col_offset=21)], + [], + lineno=1, + col_offset=0, + end_lineno=45, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-custom-set/representation.txt b/test/practice-custom-set/representation.txt new file mode 100644 index 0000000..c9f6241 --- /dev/null +++ b/test/practice-custom-set/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=2, col_offset=32, end_lineno=2, end_col_offset=36)]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_2', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=21)], IfExp(Compare(Name('placeholder_2', Load(), lineno=3, col_offset=42, end_lineno=3, end_col_offset=50), [IsNot()], [Constant(None, lineno=3, col_offset=58, end_lineno=3, end_col_offset=62)], lineno=3, col_offset=42, end_lineno=3, end_col_offset=62), Call(Name('list', Load(), lineno=3, col_offset=24, end_lineno=3, end_col_offset=28), [Name('placeholder_2', Load(), lineno=3, col_offset=29, end_lineno=3, end_col_offset=37)], [], lineno=3, col_offset=24, end_lineno=3, end_col_offset=38), Call(Name('list', Load(), lineno=3, col_offset=68, end_lineno=3, end_col_offset=72), [List([], Load(), lineno=3, col_offset=73, end_lineno=3, end_col_offset=75)], [], lineno=3, col_offset=68, end_lineno=3, end_col_offset=76), lineno=3, col_offset=24, end_lineno=3, end_col_offset=76), lineno=3, col_offset=8, end_lineno=3, end_col_offset=76)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=76), FunctionDef('placeholder_3', arguments([], [arg('self', lineno=5, col_offset=16, end_lineno=5, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=23), 'placeholder_2', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=32), lineno=6, col_offset=15, end_lineno=6, end_col_offset=32), lineno=6, col_offset=8, end_lineno=6, end_col_offset=32)], [], lineno=5, col_offset=4, end_lineno=6, end_col_offset=32), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=8, col_offset=17, end_lineno=8, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('iter', Load(), lineno=9, col_offset=15, end_lineno=9, end_col_offset=19), [Attribute(Name('self', Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=24), 'placeholder_2', Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=33)], [], lineno=9, col_offset=15, end_lineno=9, end_col_offset=34), lineno=9, col_offset=8, end_lineno=9, end_col_offset=34)], [], lineno=8, col_offset=4, end_lineno=9, end_col_offset=34), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=11, col_offset=21, end_lineno=11, end_col_offset=25), arg('placeholder_6', lineno=11, col_offset=27, end_lineno=11, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Name('placeholder_6', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=22), [In()], [Attribute(Name('self', Load(), lineno=12, col_offset=26, end_lineno=12, end_col_offset=30), 'placeholder_2', Load(), lineno=12, col_offset=26, end_lineno=12, end_col_offset=39)], lineno=12, col_offset=15, end_lineno=12, end_col_offset=39), lineno=12, col_offset=8, end_lineno=12, end_col_offset=39)], [], lineno=11, col_offset=4, end_lineno=12, end_col_offset=39), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=14, col_offset=17, end_lineno=14, end_col_offset=21), arg('placeholder_8', lineno=14, col_offset=23, end_lineno=14, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('all', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=18), [GeneratorExp(Compare(Name('placeholder_9', Load(), lineno=15, col_offset=19, end_lineno=15, end_col_offset=22), [In()], [Name('placeholder_8', Load(), lineno=15, col_offset=26, end_lineno=15, end_col_offset=31)], lineno=15, col_offset=19, end_lineno=15, end_col_offset=31), [comprehension(Name('placeholder_9', Store(), lineno=15, col_offset=36, end_lineno=15, end_col_offset=39), Name('self', Load(), lineno=15, col_offset=43, end_lineno=15, end_col_offset=47), [], 0)], lineno=15, col_offset=18, end_lineno=15, end_col_offset=48)], [], lineno=15, col_offset=15, end_lineno=15, end_col_offset=48), lineno=15, col_offset=8, end_lineno=15, end_col_offset=48)], [], lineno=14, col_offset=4, end_lineno=15, end_col_offset=48), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=17, col_offset=19, end_lineno=17, end_col_offset=23), arg('placeholder_8', lineno=17, col_offset=25, end_lineno=17, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('all', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=18), [GeneratorExp(Compare(Name('placeholder_9', Load(), lineno=18, col_offset=19, end_lineno=18, end_col_offset=22), [NotIn()], [Name('placeholder_8', Load(), lineno=18, col_offset=30, end_lineno=18, end_col_offset=35)], lineno=18, col_offset=19, end_lineno=18, end_col_offset=35), [comprehension(Name('placeholder_9', Store(), lineno=18, col_offset=40, end_lineno=18, end_col_offset=43), Name('self', Load(), lineno=18, col_offset=47, end_lineno=18, end_col_offset=51), [], 0)], lineno=18, col_offset=18, end_lineno=18, end_col_offset=52)], [], lineno=18, col_offset=15, end_lineno=18, end_col_offset=52), lineno=18, col_offset=8, end_lineno=18, end_col_offset=52)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=52), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=20, col_offset=15, end_lineno=20, end_col_offset=19), arg('placeholder_8', lineno=20, col_offset=21, end_lineno=20, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Call(Attribute(Name('self', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=19), 'placeholder_7', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=28), [Name('placeholder_8', Load(), lineno=21, col_offset=29, end_lineno=21, end_col_offset=34)], [], lineno=21, col_offset=15, end_lineno=21, end_col_offset=35), Call(Attribute(Name('placeholder_8', Load(), lineno=21, col_offset=40, end_lineno=21, end_col_offset=45), 'placeholder_7', Load(), lineno=21, col_offset=40, end_lineno=21, end_col_offset=54), [Name('self', Load(), lineno=21, col_offset=55, end_lineno=21, end_col_offset=59)], [], lineno=21, col_offset=40, end_lineno=21, end_col_offset=60)], lineno=21, col_offset=15, end_lineno=21, end_col_offset=60), lineno=21, col_offset=8, end_lineno=21, end_col_offset=60)], [], lineno=20, col_offset=4, end_lineno=21, end_col_offset=60), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=23, col_offset=12, end_lineno=23, end_col_offset=16), arg('placeholder_6', lineno=23, col_offset=18, end_lineno=23, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_6', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=18), [NotIn()], [Name('self', Load(), lineno=24, col_offset=26, end_lineno=24, end_col_offset=30)], lineno=24, col_offset=11, end_lineno=24, end_col_offset=30), [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=16), 'placeholder_2', Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=25), 'append', Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=32), [Name('placeholder_6', Load(), lineno=25, col_offset=33, end_lineno=25, end_col_offset=40)], [], lineno=25, col_offset=12, end_lineno=25, end_col_offset=41), lineno=25, col_offset=12, end_lineno=25, end_col_offset=41)], [], lineno=24, col_offset=8, end_lineno=25, end_col_offset=41)], [], lineno=23, col_offset=4, end_lineno=25, end_col_offset=41), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=27, col_offset=21, end_lineno=27, end_col_offset=25), arg('placeholder_8', lineno=27, col_offset=27, end_lineno=27, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=14)], Call(Name('placeholder_0', Load(), lineno=28, col_offset=17, end_lineno=28, end_col_offset=26), [], [], lineno=28, col_offset=17, end_lineno=28, end_col_offset=28), lineno=28, col_offset=8, end_lineno=28, end_col_offset=28), For(Name('placeholder_9', Store(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=15), Name('self', Load(), lineno=29, col_offset=19, end_lineno=29, end_col_offset=23), [If(Compare(Name('placeholder_9', Load(), lineno=30, col_offset=15, end_lineno=30, end_col_offset=18), [In()], [Name('placeholder_8', Load(), lineno=30, col_offset=22, end_lineno=30, end_col_offset=27)], lineno=30, col_offset=15, end_lineno=30, end_col_offset=27), [Expr(Call(Attribute(Name('placeholder_14', Load(), lineno=31, col_offset=16, end_lineno=31, end_col_offset=22), 'placeholder_12', Load(), lineno=31, col_offset=16, end_lineno=31, end_col_offset=26), [Name('placeholder_9', Load(), lineno=31, col_offset=27, end_lineno=31, end_col_offset=30)], [], lineno=31, col_offset=16, end_lineno=31, end_col_offset=31), lineno=31, col_offset=16, end_lineno=31, end_col_offset=31)], [], lineno=30, col_offset=12, end_lineno=31, end_col_offset=31)], [], lineno=29, col_offset=8, end_lineno=31, end_col_offset=31), Return(Name('placeholder_14', Load(), lineno=32, col_offset=15, end_lineno=32, end_col_offset=21), lineno=32, col_offset=8, end_lineno=32, end_col_offset=21)], [], lineno=27, col_offset=4, end_lineno=32, end_col_offset=21), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=34, col_offset=16, end_lineno=34, end_col_offset=20), arg('placeholder_8', lineno=34, col_offset=22, end_lineno=34, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=35, col_offset=8, end_lineno=35, end_col_offset=14)], Call(Name('placeholder_0', Load(), lineno=35, col_offset=17, end_lineno=35, end_col_offset=26), [], [], lineno=35, col_offset=17, end_lineno=35, end_col_offset=28), lineno=35, col_offset=8, end_lineno=35, end_col_offset=28), For(Name('placeholder_9', Store(), lineno=36, col_offset=12, end_lineno=36, end_col_offset=15), Name('self', Load(), lineno=36, col_offset=19, end_lineno=36, end_col_offset=23), [If(Compare(Name('placeholder_9', Load(), lineno=37, col_offset=15, end_lineno=37, end_col_offset=18), [NotIn()], [Name('placeholder_8', Load(), lineno=37, col_offset=26, end_lineno=37, end_col_offset=31)], lineno=37, col_offset=15, end_lineno=37, end_col_offset=31), [Expr(Call(Attribute(Name('placeholder_14', Load(), lineno=38, col_offset=16, end_lineno=38, end_col_offset=22), 'placeholder_12', Load(), lineno=38, col_offset=16, end_lineno=38, end_col_offset=26), [Name('placeholder_9', Load(), lineno=38, col_offset=27, end_lineno=38, end_col_offset=30)], [], lineno=38, col_offset=16, end_lineno=38, end_col_offset=31), lineno=38, col_offset=16, end_lineno=38, end_col_offset=31)], [], lineno=37, col_offset=12, end_lineno=38, end_col_offset=31)], [], lineno=36, col_offset=8, end_lineno=38, end_col_offset=31), Return(Name('placeholder_14', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=21), lineno=39, col_offset=8, end_lineno=39, end_col_offset=21)], [], lineno=34, col_offset=4, end_lineno=39, end_col_offset=21), FunctionDef('placeholder_16', arguments([], [arg('self', lineno=41, col_offset=16, end_lineno=41, end_col_offset=20), arg('placeholder_8', lineno=41, col_offset=22, end_lineno=41, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=42, col_offset=8, end_lineno=42, end_col_offset=14)], Call(Name('placeholder_0', Load(), lineno=42, col_offset=17, end_lineno=42, end_col_offset=26), [Attribute(Name('self', Load(), lineno=42, col_offset=27, end_lineno=42, end_col_offset=31), 'placeholder_2', Load(), lineno=42, col_offset=27, end_lineno=42, end_col_offset=40)], [], lineno=42, col_offset=17, end_lineno=42, end_col_offset=41), lineno=42, col_offset=8, end_lineno=42, end_col_offset=41), For(Name('placeholder_9', Store(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=15), Name('placeholder_8', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=24), [Expr(Call(Attribute(Name('placeholder_14', Load(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=18), 'placeholder_12', Load(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=22), [Name('placeholder_9', Load(), lineno=44, col_offset=23, end_lineno=44, end_col_offset=26)], [], lineno=44, col_offset=12, end_lineno=44, end_col_offset=27), lineno=44, col_offset=12, end_lineno=44, end_col_offset=27)], [], lineno=43, col_offset=8, end_lineno=44, end_col_offset=27), Return(Name('placeholder_14', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=21), lineno=45, col_offset=8, end_lineno=45, end_col_offset=21)], [], lineno=41, col_offset=4, end_lineno=45, end_col_offset=21)], [], lineno=1, col_offset=0, end_lineno=45, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-darts/.meta/config.json b/test/practice-darts/.meta/config.json new file mode 100644 index 0000000..a306b38 --- /dev/null +++ b/test/practice-darts/.meta/config.json @@ -0,0 +1,29 @@ +{ + "authors": [ + "GascaK" + ], + "contributors": [ + "alexpjohnson", + "AnAccountForReportingBugs", + "BethanyG", + "cmccandless", + "Dog", + "Grociu", + "tqa236", + "xitanggg", + "yawpitch" + ], + "files": { + "solution": [ + "darts.py" + ], + "test": [ + "darts_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Write a function that returns the earned points in a single toss of a Darts game.", + "source": "Inspired by an exercise created by a professor Della Paolera in Argentina" +} diff --git a/test/practice-darts/darts.py b/test/practice-darts/darts.py new file mode 100644 index 0000000..eed150c --- /dev/null +++ b/test/practice-darts/darts.py @@ -0,0 +1,14 @@ +from math import sqrt + +# X, and Y variable names against [pylint]: C0104, but is the same as the stub, advise not to change this. +def score(x, y): + dart_location = sqrt(x * x + y * y) + + if dart_location <= 1.0: + return 10 + elif dart_location <= 5.0: + return 5 + elif dart_location <= 10.0: + return 1 + else: + return 0 diff --git a/test/practice-darts/mapping.json b/test/practice-darts/mapping.json new file mode 100644 index 0000000..5ee4a9f --- /dev/null +++ b/test/practice-darts/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "score", + "placeholder_1": "x", + "placeholder_2": "y", + "placeholder_3": "dart_location" +} \ No newline at end of file diff --git a/test/practice-darts/representation.json b/test/practice-darts/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-darts/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-darts/representation.out b/test/practice-darts/representation.out new file mode 100644 index 0000000..3eafdda --- /dev/null +++ b/test/practice-darts/representation.out @@ -0,0 +1,510 @@ +## BEGIN NORMALIZED CODE ## +from math import sqrt + + +def placeholder_0(placeholder_1, placeholder_2): + placeholder_3 = sqrt(placeholder_1 * placeholder_1 + placeholder_2 * placeholder_2) + if placeholder_3 <= 1.0: + return 10 + elif placeholder_3 <= 5.0: + return 5 + elif placeholder_3 <= 10.0: + return 1 + else: + return 0 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'sqrt', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=21), + FunctionDef( + 'score', + arguments( + [], + [ + arg( + 'x', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=11), + arg( + 'y', + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'dart_location', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=17)], + Call( + Name( + 'sqrt', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=24), + [ + BinOp( + BinOp( + Name( + 'x', + Load(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=26), + Mult(), + Name( + 'x', + Load(), + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=30), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=30), + Add(), + BinOp( + Name( + 'y', + Load(), + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=34), + Mult(), + Name( + 'y', + Load(), + lineno=5, + col_offset=37, + end_lineno=5, + end_col_offset=38), + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=38), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=38)], + [], + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=39), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=39), + If( + Compare( + Name( + 'dart_location', + Load(), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=20), + [ + LtE()], + [ + Constant( + 1.0, + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=27)], + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=27), + [ + Return( + Constant( + 10, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=17), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=17)], + [ + If( + Compare( + Name( + 'dart_location', + Load(), + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=22), + [ + LtE()], + [ + Constant( + 5.0, + lineno=9, + col_offset=26, + end_lineno=9, + end_col_offset=29)], + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=29), + [ + Return( + Constant( + 5, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=16), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=16)], + [ + If( + Compare( + Name( + 'dart_location', + Load(), + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=22), + [ + LtE()], + [ + Constant( + 10.0, + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=30)], + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=30), + [ + Return( + Constant( + 1, + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=16), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=16)], + [ + Return( + Constant( + 0, + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=16), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=16)], + lineno=11, + col_offset=4, + end_lineno=14, + end_col_offset=16)], + lineno=9, + col_offset=4, + end_lineno=14, + end_col_offset=16)], + lineno=7, + col_offset=4, + end_lineno=14, + end_col_offset=16)], + [], + lineno=4, + col_offset=0, + end_lineno=14, + end_col_offset=16)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'sqrt', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=21), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=11), + arg( + 'placeholder_2', + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=17)], + Call( + Name( + 'sqrt', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=24), + [ + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=26), + Mult(), + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=30), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=30), + Add(), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=34), + Mult(), + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=37, + end_lineno=5, + end_col_offset=38), + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=38), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=38)], + [], + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=39), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=39), + If( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=20), + [ + LtE()], + [ + Constant( + 1.0, + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=27)], + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=27), + [ + Return( + Constant( + 10, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=17), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=17)], + [ + If( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=22), + [ + LtE()], + [ + Constant( + 5.0, + lineno=9, + col_offset=26, + end_lineno=9, + end_col_offset=29)], + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=29), + [ + Return( + Constant( + 5, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=16), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=16)], + [ + If( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=22), + [ + LtE()], + [ + Constant( + 10.0, + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=30)], + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=30), + [ + Return( + Constant( + 1, + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=16), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=16)], + [ + Return( + Constant( + 0, + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=16), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=16)], + lineno=11, + col_offset=4, + end_lineno=14, + end_col_offset=16)], + lineno=9, + col_offset=4, + end_lineno=14, + end_col_offset=16)], + lineno=7, + col_offset=4, + end_lineno=14, + end_col_offset=16)], + [], + lineno=4, + col_offset=0, + end_lineno=14, + end_col_offset=16)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-darts/representation.txt b/test/practice-darts/representation.txt new file mode 100644 index 0000000..623b88d --- /dev/null +++ b/test/practice-darts/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('math', [alias('sqrt', lineno=1, col_offset=17, end_lineno=1, end_col_offset=21)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=21), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=10, end_lineno=4, end_col_offset=11), arg('placeholder_2', lineno=4, col_offset=13, end_lineno=4, end_col_offset=14)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=17)], Call(Name('sqrt', Load(), lineno=5, col_offset=20, end_lineno=5, end_col_offset=24), [BinOp(BinOp(Name('placeholder_1', Load(), lineno=5, col_offset=25, end_lineno=5, end_col_offset=26), Mult(), Name('placeholder_1', Load(), lineno=5, col_offset=29, end_lineno=5, end_col_offset=30), lineno=5, col_offset=25, end_lineno=5, end_col_offset=30), Add(), BinOp(Name('placeholder_2', Load(), lineno=5, col_offset=33, end_lineno=5, end_col_offset=34), Mult(), Name('placeholder_2', Load(), lineno=5, col_offset=37, end_lineno=5, end_col_offset=38), lineno=5, col_offset=33, end_lineno=5, end_col_offset=38), lineno=5, col_offset=25, end_lineno=5, end_col_offset=38)], [], lineno=5, col_offset=20, end_lineno=5, end_col_offset=39), lineno=5, col_offset=4, end_lineno=5, end_col_offset=39), If(Compare(Name('placeholder_3', Load(), lineno=7, col_offset=7, end_lineno=7, end_col_offset=20), [LtE()], [Constant(1.0, lineno=7, col_offset=24, end_lineno=7, end_col_offset=27)], lineno=7, col_offset=7, end_lineno=7, end_col_offset=27), [Return(Constant(10, lineno=8, col_offset=15, end_lineno=8, end_col_offset=17), lineno=8, col_offset=8, end_lineno=8, end_col_offset=17)], [If(Compare(Name('placeholder_3', Load(), lineno=9, col_offset=9, end_lineno=9, end_col_offset=22), [LtE()], [Constant(5.0, lineno=9, col_offset=26, end_lineno=9, end_col_offset=29)], lineno=9, col_offset=9, end_lineno=9, end_col_offset=29), [Return(Constant(5, lineno=10, col_offset=15, end_lineno=10, end_col_offset=16), lineno=10, col_offset=8, end_lineno=10, end_col_offset=16)], [If(Compare(Name('placeholder_3', Load(), lineno=11, col_offset=9, end_lineno=11, end_col_offset=22), [LtE()], [Constant(10.0, lineno=11, col_offset=26, end_lineno=11, end_col_offset=30)], lineno=11, col_offset=9, end_lineno=11, end_col_offset=30), [Return(Constant(1, lineno=12, col_offset=15, end_lineno=12, end_col_offset=16), lineno=12, col_offset=8, end_lineno=12, end_col_offset=16)], [Return(Constant(0, lineno=14, col_offset=15, end_lineno=14, end_col_offset=16), lineno=14, col_offset=8, end_lineno=14, end_col_offset=16)], lineno=11, col_offset=4, end_lineno=14, end_col_offset=16)], lineno=9, col_offset=4, end_lineno=14, end_col_offset=16)], lineno=7, col_offset=4, end_lineno=14, end_col_offset=16)], [], lineno=4, col_offset=0, end_lineno=14, end_col_offset=16)], []) \ No newline at end of file diff --git a/test/practice-diamond/.meta/config.json b/test/practice-diamond/.meta/config.json new file mode 100644 index 0000000..f349d65 --- /dev/null +++ b/test/practice-diamond/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "ikhadykin", + "lucasdpau", + "N-Parsons", + "pheanex", + "rjsabatini", + "tqa236" + ], + "files": { + "solution": [ + "diamond.py" + ], + "test": [ + "diamond_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.", + "source": "Seb Rose", + "source_url": "https://web.archive.org/web/20220807163751/http://claysnow.co.uk/recycling-tests-in-tdd/" +} diff --git a/test/practice-diamond/diamond.py b/test/practice-diamond/diamond.py new file mode 100644 index 0000000..bd99247 --- /dev/null +++ b/test/practice-diamond/diamond.py @@ -0,0 +1,15 @@ +def rows(letter): + lines = ord(letter) - 64 + columns = lines * 2 - 1 + half = make_half(lines, columns) + return half + half[-2::-1] + + +def make_half(lines, columns): + diamond_half = [] + for number in range(lines): + row = [' '] * columns + row[lines - 1 - number] = chr(number + 65) + row[lines - 1 + number] = chr(number + 65) + diamond_half.append(''.join(row)) + return diamond_half diff --git a/test/practice-diamond/mapping.json b/test/practice-diamond/mapping.json new file mode 100644 index 0000000..e9baf45 --- /dev/null +++ b/test/practice-diamond/mapping.json @@ -0,0 +1,11 @@ +{ + "placeholder_0": "rows", + "placeholder_1": "letter", + "placeholder_2": "lines", + "placeholder_3": "columns", + "placeholder_4": "half", + "placeholder_5": "make_half", + "placeholder_6": "diamond_half", + "placeholder_7": "number", + "placeholder_8": "row" +} \ No newline at end of file diff --git a/test/practice-diamond/representation.json b/test/practice-diamond/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-diamond/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-diamond/representation.out b/test/practice-diamond/representation.out new file mode 100644 index 0000000..1e6f6c2 --- /dev/null +++ b/test/practice-diamond/representation.out @@ -0,0 +1,1158 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = ord(placeholder_1) - 64 + placeholder_3 = placeholder_2 * 2 - 1 + placeholder_4 = make_half(placeholder_2, placeholder_3) + return placeholder_4 + placeholder_4[-2::-1] + + +def placeholder_5(placeholder_2, placeholder_3): + placeholder_6 = [] + for placeholder_7 in range(placeholder_2): + placeholder_8 = [" "] * placeholder_3 + placeholder_8[placeholder_2 - 1 - placeholder_7] = chr(placeholder_7 + 65) + placeholder_8[placeholder_2 - 1 + placeholder_7] = chr(placeholder_7 + 65) + placeholder_6.append("".join(placeholder_8)) + return placeholder_6 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'rows', + arguments( + [], + [ + arg( + 'letter', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'lines', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9)], + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=15), + [ + Name( + 'letter', + Load(), + lineno=2, + col_offset=16, + end_lineno=2, + end_col_offset=22)], + [], + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=23), + Sub(), + Constant( + 64, + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=28), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=28), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=28), + Assign( + [ + Name( + 'columns', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11)], + BinOp( + BinOp( + Name( + 'lines', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=19), + Mult(), + Constant( + 2, + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=23), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=23), + Sub(), + Constant( + 1, + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=27), + Assign( + [ + Name( + 'half', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=8)], + Call( + Name( + 'make_half', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=20), + [ + Name( + 'lines', + Load(), + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=26), + Name( + 'columns', + Load(), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=35)], + [], + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=36), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=36), + Return( + BinOp( + Name( + 'half', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=15), + Add(), + Subscript( + Name( + 'half', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=22), + Slice( + UnaryOp( + USub(), + Constant( + 2, + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=25), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=25), + step=UnaryOp( + USub(), + Constant( + 1, + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=29), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=29), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=29), + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=30), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=30), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=30)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=30), + FunctionDef( + 'make_half', + arguments( + [], + [ + arg( + 'lines', + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=19), + arg( + 'columns', + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'diamond_half', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=16)], + List( + [], + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=21), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=21), + For( + Name( + 'number', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14), + Call( + Name( + 'range', + Load(), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=23), + [ + Name( + 'lines', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=29)], + [], + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=30), + [ + Assign( + [ + Name( + 'row', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=11)], + BinOp( + List( + [ + Constant( + ' ', + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=18)], + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=19), + Mult(), + Name( + 'columns', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=29), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=29), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=29), + Assign( + [ + Subscript( + Name( + 'row', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=11), + BinOp( + BinOp( + Name( + 'lines', + Load(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=17), + Sub(), + Constant( + 1, + lineno=12, + col_offset=20, + end_lineno=12, + end_col_offset=21), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=21), + Sub(), + Name( + 'number', + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=30), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=30), + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=31)], + Call( + Name( + 'chr', + Load(), + lineno=12, + col_offset=34, + end_lineno=12, + end_col_offset=37), + [ + BinOp( + Name( + 'number', + Load(), + lineno=12, + col_offset=38, + end_lineno=12, + end_col_offset=44), + Add(), + Constant( + 65, + lineno=12, + col_offset=47, + end_lineno=12, + end_col_offset=49), + lineno=12, + col_offset=38, + end_lineno=12, + end_col_offset=49)], + [], + lineno=12, + col_offset=34, + end_lineno=12, + end_col_offset=50), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=50), + Assign( + [ + Subscript( + Name( + 'row', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=11), + BinOp( + BinOp( + Name( + 'lines', + Load(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=17), + Sub(), + Constant( + 1, + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=21), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=21), + Add(), + Name( + 'number', + Load(), + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=30), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=30), + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=31)], + Call( + Name( + 'chr', + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=37), + [ + BinOp( + Name( + 'number', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=44), + Add(), + Constant( + 65, + lineno=13, + col_offset=47, + end_lineno=13, + end_col_offset=49), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=49)], + [], + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=50), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=50), + Expr( + Call( + Attribute( + Name( + 'diamond_half', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=20), + 'append', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=27), + [ + Call( + Attribute( + Constant( + '', + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=30), + 'join', + Load(), + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=35), + [ + Name( + 'row', + Load(), + lineno=14, + col_offset=36, + end_lineno=14, + end_col_offset=39)], + [], + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=40)], + [], + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=41), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=41)], + [], + lineno=10, + col_offset=4, + end_lineno=14, + end_col_offset=41), + Return( + Name( + 'diamond_half', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=23), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=23)], + [], + lineno=8, + col_offset=0, + end_lineno=15, + end_col_offset=23)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9)], + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=15), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=16, + end_lineno=2, + end_col_offset=22)], + [], + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=23), + Sub(), + Constant( + 64, + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=28), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=28), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11)], + BinOp( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=19), + Mult(), + Constant( + 2, + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=23), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=23), + Sub(), + Constant( + 1, + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=8)], + Call( + Name( + 'make_half', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=20), + [ + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=26), + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=35)], + [], + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=36), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=36), + Return( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=15), + Add(), + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=22), + Slice( + UnaryOp( + USub(), + Constant( + 2, + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=25), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=25), + step=UnaryOp( + USub(), + Constant( + 1, + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=29), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=29), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=29), + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=30), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=30), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=30)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=30), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=19), + arg( + 'placeholder_3', + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=16)], + List( + [], + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=21), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=21), + For( + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14), + Call( + Name( + 'range', + Load(), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=23), + [ + Name( + 'placeholder_2', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=29)], + [], + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=30), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=11)], + BinOp( + List( + [ + Constant( + ' ', + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=18)], + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=19), + Mult(), + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=29), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=29), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=29), + Assign( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=11), + BinOp( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=17), + Sub(), + Constant( + 1, + lineno=12, + col_offset=20, + end_lineno=12, + end_col_offset=21), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=21), + Sub(), + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=30), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=30), + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=31)], + Call( + Name( + 'chr', + Load(), + lineno=12, + col_offset=34, + end_lineno=12, + end_col_offset=37), + [ + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=38, + end_lineno=12, + end_col_offset=44), + Add(), + Constant( + 65, + lineno=12, + col_offset=47, + end_lineno=12, + end_col_offset=49), + lineno=12, + col_offset=38, + end_lineno=12, + end_col_offset=49)], + [], + lineno=12, + col_offset=34, + end_lineno=12, + end_col_offset=50), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=50), + Assign( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=11), + BinOp( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=17), + Sub(), + Constant( + 1, + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=21), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=21), + Add(), + Name( + 'placeholder_7', + Load(), + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=30), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=30), + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=31)], + Call( + Name( + 'chr', + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=37), + [ + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=44), + Add(), + Constant( + 65, + lineno=13, + col_offset=47, + end_lineno=13, + end_col_offset=49), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=49)], + [], + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=50), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=50), + Expr( + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=20), + 'append', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=27), + [ + Call( + Attribute( + Constant( + '', + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=30), + 'join', + Load(), + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=35), + [ + Name( + 'placeholder_8', + Load(), + lineno=14, + col_offset=36, + end_lineno=14, + end_col_offset=39)], + [], + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=40)], + [], + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=41), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=41)], + [], + lineno=10, + col_offset=4, + end_lineno=14, + end_col_offset=41), + Return( + Name( + 'placeholder_6', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=23), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=23)], + [], + lineno=8, + col_offset=0, + end_lineno=15, + end_col_offset=23)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-diamond/representation.txt b/test/practice-diamond/representation.txt new file mode 100644 index 0000000..ec636a5 --- /dev/null +++ b/test/practice-diamond/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=9, end_lineno=1, end_col_offset=15)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=9)], BinOp(Call(Name('ord', Load(), lineno=2, col_offset=12, end_lineno=2, end_col_offset=15), [Name('placeholder_1', Load(), lineno=2, col_offset=16, end_lineno=2, end_col_offset=22)], [], lineno=2, col_offset=12, end_lineno=2, end_col_offset=23), Sub(), Constant(64, lineno=2, col_offset=26, end_lineno=2, end_col_offset=28), lineno=2, col_offset=12, end_lineno=2, end_col_offset=28), lineno=2, col_offset=4, end_lineno=2, end_col_offset=28), Assign([Name('placeholder_3', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=11)], BinOp(BinOp(Name('placeholder_2', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=19), Mult(), Constant(2, lineno=3, col_offset=22, end_lineno=3, end_col_offset=23), lineno=3, col_offset=14, end_lineno=3, end_col_offset=23), Sub(), Constant(1, lineno=3, col_offset=26, end_lineno=3, end_col_offset=27), lineno=3, col_offset=14, end_lineno=3, end_col_offset=27), lineno=3, col_offset=4, end_lineno=3, end_col_offset=27), Assign([Name('placeholder_4', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=8)], Call(Name('make_half', Load(), lineno=4, col_offset=11, end_lineno=4, end_col_offset=20), [Name('placeholder_2', Load(), lineno=4, col_offset=21, end_lineno=4, end_col_offset=26), Name('placeholder_3', Load(), lineno=4, col_offset=28, end_lineno=4, end_col_offset=35)], [], lineno=4, col_offset=11, end_lineno=4, end_col_offset=36), lineno=4, col_offset=4, end_lineno=4, end_col_offset=36), Return(BinOp(Name('placeholder_4', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=15), Add(), Subscript(Name('placeholder_4', Load(), lineno=5, col_offset=18, end_lineno=5, end_col_offset=22), Slice(UnaryOp(USub(), Constant(2, lineno=5, col_offset=24, end_lineno=5, end_col_offset=25), lineno=5, col_offset=23, end_lineno=5, end_col_offset=25), step=UnaryOp(USub(), Constant(1, lineno=5, col_offset=28, end_lineno=5, end_col_offset=29), lineno=5, col_offset=27, end_lineno=5, end_col_offset=29), lineno=5, col_offset=23, end_lineno=5, end_col_offset=29), Load(), lineno=5, col_offset=18, end_lineno=5, end_col_offset=30), lineno=5, col_offset=11, end_lineno=5, end_col_offset=30), lineno=5, col_offset=4, end_lineno=5, end_col_offset=30)], [], lineno=1, col_offset=0, end_lineno=5, end_col_offset=30), FunctionDef('placeholder_5', arguments([], [arg('placeholder_2', lineno=8, col_offset=14, end_lineno=8, end_col_offset=19), arg('placeholder_3', lineno=8, col_offset=21, end_lineno=8, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=9, col_offset=4, end_lineno=9, end_col_offset=16)], List([], Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=21), lineno=9, col_offset=4, end_lineno=9, end_col_offset=21), For(Name('placeholder_7', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=14), Call(Name('range', Load(), lineno=10, col_offset=18, end_lineno=10, end_col_offset=23), [Name('placeholder_2', Load(), lineno=10, col_offset=24, end_lineno=10, end_col_offset=29)], [], lineno=10, col_offset=18, end_lineno=10, end_col_offset=30), [Assign([Name('placeholder_8', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=11)], BinOp(List([Constant(' ', lineno=11, col_offset=15, end_lineno=11, end_col_offset=18)], Load(), lineno=11, col_offset=14, end_lineno=11, end_col_offset=19), Mult(), Name('placeholder_3', Load(), lineno=11, col_offset=22, end_lineno=11, end_col_offset=29), lineno=11, col_offset=14, end_lineno=11, end_col_offset=29), lineno=11, col_offset=8, end_lineno=11, end_col_offset=29), Assign([Subscript(Name('placeholder_8', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=11), BinOp(BinOp(Name('placeholder_2', Load(), lineno=12, col_offset=12, end_lineno=12, end_col_offset=17), Sub(), Constant(1, lineno=12, col_offset=20, end_lineno=12, end_col_offset=21), lineno=12, col_offset=12, end_lineno=12, end_col_offset=21), Sub(), Name('placeholder_7', Load(), lineno=12, col_offset=24, end_lineno=12, end_col_offset=30), lineno=12, col_offset=12, end_lineno=12, end_col_offset=30), Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=31)], Call(Name('chr', Load(), lineno=12, col_offset=34, end_lineno=12, end_col_offset=37), [BinOp(Name('placeholder_7', Load(), lineno=12, col_offset=38, end_lineno=12, end_col_offset=44), Add(), Constant(65, lineno=12, col_offset=47, end_lineno=12, end_col_offset=49), lineno=12, col_offset=38, end_lineno=12, end_col_offset=49)], [], lineno=12, col_offset=34, end_lineno=12, end_col_offset=50), lineno=12, col_offset=8, end_lineno=12, end_col_offset=50), Assign([Subscript(Name('placeholder_8', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=11), BinOp(BinOp(Name('placeholder_2', Load(), lineno=13, col_offset=12, end_lineno=13, end_col_offset=17), Sub(), Constant(1, lineno=13, col_offset=20, end_lineno=13, end_col_offset=21), lineno=13, col_offset=12, end_lineno=13, end_col_offset=21), Add(), Name('placeholder_7', Load(), lineno=13, col_offset=24, end_lineno=13, end_col_offset=30), lineno=13, col_offset=12, end_lineno=13, end_col_offset=30), Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=31)], Call(Name('chr', Load(), lineno=13, col_offset=34, end_lineno=13, end_col_offset=37), [BinOp(Name('placeholder_7', Load(), lineno=13, col_offset=38, end_lineno=13, end_col_offset=44), Add(), Constant(65, lineno=13, col_offset=47, end_lineno=13, end_col_offset=49), lineno=13, col_offset=38, end_lineno=13, end_col_offset=49)], [], lineno=13, col_offset=34, end_lineno=13, end_col_offset=50), lineno=13, col_offset=8, end_lineno=13, end_col_offset=50), Expr(Call(Attribute(Name('placeholder_6', Load(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=20), 'append', Load(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=27), [Call(Attribute(Constant('', lineno=14, col_offset=28, end_lineno=14, end_col_offset=30), 'join', Load(), lineno=14, col_offset=28, end_lineno=14, end_col_offset=35), [Name('placeholder_8', Load(), lineno=14, col_offset=36, end_lineno=14, end_col_offset=39)], [], lineno=14, col_offset=28, end_lineno=14, end_col_offset=40)], [], lineno=14, col_offset=8, end_lineno=14, end_col_offset=41), lineno=14, col_offset=8, end_lineno=14, end_col_offset=41)], [], lineno=10, col_offset=4, end_lineno=14, end_col_offset=41), Return(Name('placeholder_6', Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=23), lineno=15, col_offset=4, end_lineno=15, end_col_offset=23)], [], lineno=8, col_offset=0, end_lineno=15, end_col_offset=23)], []) \ No newline at end of file diff --git a/test/practice-difference-of-squares/.meta/config.json b/test/practice-difference-of-squares/.meta/config.json new file mode 100644 index 0000000..fe714d4 --- /dev/null +++ b/test/practice-difference-of-squares/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "akashsara", + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "pheanex", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "difference_of_squares.py" + ], + "test": [ + "difference_of_squares_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.", + "source": "Problem 6 at Project Euler", + "source_url": "https://projecteuler.net/problem=6" +} diff --git a/test/practice-difference-of-squares/difference_of_squares.py b/test/practice-difference-of-squares/difference_of_squares.py new file mode 100644 index 0000000..5879a75 --- /dev/null +++ b/test/practice-difference-of-squares/difference_of_squares.py @@ -0,0 +1,12 @@ +def square_of_sum(number): + sum_ = number * (number + 1) / 2 + return sum_ * sum_ + + +def sum_of_squares(number): + numerator = number * (number + 1) * (2 * number + 1) + return numerator / 6 + + +def difference_of_squares(number): + return square_of_sum(number) - sum_of_squares(number) diff --git a/test/practice-difference-of-squares/mapping.json b/test/practice-difference-of-squares/mapping.json new file mode 100644 index 0000000..8654a49 --- /dev/null +++ b/test/practice-difference-of-squares/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "square_of_sum", + "placeholder_1": "number", + "placeholder_2": "sum_", + "placeholder_3": "sum_of_squares", + "placeholder_4": "numerator", + "placeholder_5": "difference_of_squares" +} \ No newline at end of file diff --git a/test/practice-difference-of-squares/representation.json b/test/practice-difference-of-squares/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-difference-of-squares/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-difference-of-squares/representation.out b/test/practice-difference-of-squares/representation.out new file mode 100644 index 0000000..bcfa77b --- /dev/null +++ b/test/practice-difference-of-squares/representation.out @@ -0,0 +1,629 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = placeholder_1 * (placeholder_1 + 1) / 2 + return placeholder_2 * placeholder_2 + + +def placeholder_3(placeholder_1): + placeholder_4 = placeholder_1 * (placeholder_1 + 1) * (2 * placeholder_1 + 1) + return placeholder_4 / 6 + + +def placeholder_5(placeholder_1): + return placeholder_0(placeholder_1) - placeholder_3(placeholder_1) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'square_of_sum', + arguments( + [], + [ + arg( + 'number', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'sum_', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=8)], + BinOp( + BinOp( + Name( + 'number', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + Mult(), + BinOp( + Name( + 'number', + Load(), + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=27), + Add(), + Constant( + 1, + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=32), + Div(), + Constant( + 2, + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=36), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=36), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=36), + Return( + BinOp( + Name( + 'sum_', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=15), + Mult(), + Name( + 'sum_', + Load(), + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=22), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=22), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=22)], + [], + lineno=1, + col_offset=0, + end_lineno=3, + end_col_offset=22), + FunctionDef( + 'sum_of_squares', + arguments( + [], + [ + arg( + 'number', + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'numerator', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=13)], + BinOp( + BinOp( + Name( + 'number', + Load(), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=22), + Mult(), + BinOp( + Name( + 'number', + Load(), + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=32), + Add(), + Constant( + 1, + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=36), + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=36), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=37), + Mult(), + BinOp( + BinOp( + Constant( + 2, + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=42), + Mult(), + Name( + 'number', + Load(), + lineno=7, + col_offset=45, + end_lineno=7, + end_col_offset=51), + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=51), + Add(), + Constant( + 1, + lineno=7, + col_offset=54, + end_lineno=7, + end_col_offset=55), + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=55), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=56), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=56), + Return( + BinOp( + Name( + 'numerator', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=20), + Div(), + Constant( + 6, + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=24), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=24), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=24)], + [], + lineno=6, + col_offset=0, + end_lineno=8, + end_col_offset=24), + FunctionDef( + 'difference_of_squares', + arguments( + [], + [ + arg( + 'number', + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Call( + Name( + 'square_of_sum', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=24), + [ + Name( + 'number', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=31)], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=32), + Sub(), + Call( + Name( + 'sum_of_squares', + Load(), + lineno=12, + col_offset=35, + end_lineno=12, + end_col_offset=49), + [ + Name( + 'number', + Load(), + lineno=12, + col_offset=50, + end_lineno=12, + end_col_offset=56)], + [], + lineno=12, + col_offset=35, + end_lineno=12, + end_col_offset=57), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=57), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=57)], + [], + lineno=11, + col_offset=0, + end_lineno=12, + end_col_offset=57)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=8)], + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + Mult(), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=27), + Add(), + Constant( + 1, + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=32), + Div(), + Constant( + 2, + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=36), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=36), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=36), + Return( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=15), + Mult(), + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=22), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=22), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=22)], + [], + lineno=1, + col_offset=0, + end_lineno=3, + end_col_offset=22), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=13)], + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=22), + Mult(), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=32), + Add(), + Constant( + 1, + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=36), + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=36), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=37), + Mult(), + BinOp( + BinOp( + Constant( + 2, + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=42), + Mult(), + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=45, + end_lineno=7, + end_col_offset=51), + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=51), + Add(), + Constant( + 1, + lineno=7, + col_offset=54, + end_lineno=7, + end_col_offset=55), + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=55), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=56), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=56), + Return( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=20), + Div(), + Constant( + 6, + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=24), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=24), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=24)], + [], + lineno=6, + col_offset=0, + end_lineno=8, + end_col_offset=24), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=24), + [ + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=31)], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=32), + Sub(), + Call( + Name( + 'placeholder_3', + Load(), + lineno=12, + col_offset=35, + end_lineno=12, + end_col_offset=49), + [ + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=50, + end_lineno=12, + end_col_offset=56)], + [], + lineno=12, + col_offset=35, + end_lineno=12, + end_col_offset=57), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=57), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=57)], + [], + lineno=11, + col_offset=0, + end_lineno=12, + end_col_offset=57)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-difference-of-squares/representation.txt b/test/practice-difference-of-squares/representation.txt new file mode 100644 index 0000000..b5ea788 --- /dev/null +++ b/test/practice-difference-of-squares/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=18, end_lineno=1, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=8)], BinOp(BinOp(Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=17), Mult(), BinOp(Name('placeholder_1', Load(), lineno=2, col_offset=21, end_lineno=2, end_col_offset=27), Add(), Constant(1, lineno=2, col_offset=30, end_lineno=2, end_col_offset=31), lineno=2, col_offset=21, end_lineno=2, end_col_offset=31), lineno=2, col_offset=11, end_lineno=2, end_col_offset=32), Div(), Constant(2, lineno=2, col_offset=35, end_lineno=2, end_col_offset=36), lineno=2, col_offset=11, end_lineno=2, end_col_offset=36), lineno=2, col_offset=4, end_lineno=2, end_col_offset=36), Return(BinOp(Name('placeholder_2', Load(), lineno=3, col_offset=11, end_lineno=3, end_col_offset=15), Mult(), Name('placeholder_2', Load(), lineno=3, col_offset=18, end_lineno=3, end_col_offset=22), lineno=3, col_offset=11, end_lineno=3, end_col_offset=22), lineno=3, col_offset=4, end_lineno=3, end_col_offset=22)], [], lineno=1, col_offset=0, end_lineno=3, end_col_offset=22), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=6, col_offset=19, end_lineno=6, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=13)], BinOp(BinOp(Name('placeholder_1', Load(), lineno=7, col_offset=16, end_lineno=7, end_col_offset=22), Mult(), BinOp(Name('placeholder_1', Load(), lineno=7, col_offset=26, end_lineno=7, end_col_offset=32), Add(), Constant(1, lineno=7, col_offset=35, end_lineno=7, end_col_offset=36), lineno=7, col_offset=26, end_lineno=7, end_col_offset=36), lineno=7, col_offset=16, end_lineno=7, end_col_offset=37), Mult(), BinOp(BinOp(Constant(2, lineno=7, col_offset=41, end_lineno=7, end_col_offset=42), Mult(), Name('placeholder_1', Load(), lineno=7, col_offset=45, end_lineno=7, end_col_offset=51), lineno=7, col_offset=41, end_lineno=7, end_col_offset=51), Add(), Constant(1, lineno=7, col_offset=54, end_lineno=7, end_col_offset=55), lineno=7, col_offset=41, end_lineno=7, end_col_offset=55), lineno=7, col_offset=16, end_lineno=7, end_col_offset=56), lineno=7, col_offset=4, end_lineno=7, end_col_offset=56), Return(BinOp(Name('placeholder_4', Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=20), Div(), Constant(6, lineno=8, col_offset=23, end_lineno=8, end_col_offset=24), lineno=8, col_offset=11, end_lineno=8, end_col_offset=24), lineno=8, col_offset=4, end_lineno=8, end_col_offset=24)], [], lineno=6, col_offset=0, end_lineno=8, end_col_offset=24), FunctionDef('placeholder_5', arguments([], [arg('placeholder_1', lineno=11, col_offset=26, end_lineno=11, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Call(Name('placeholder_0', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=24), [Name('placeholder_1', Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=31)], [], lineno=12, col_offset=11, end_lineno=12, end_col_offset=32), Sub(), Call(Name('placeholder_3', Load(), lineno=12, col_offset=35, end_lineno=12, end_col_offset=49), [Name('placeholder_1', Load(), lineno=12, col_offset=50, end_lineno=12, end_col_offset=56)], [], lineno=12, col_offset=35, end_lineno=12, end_col_offset=57), lineno=12, col_offset=11, end_lineno=12, end_col_offset=57), lineno=12, col_offset=4, end_lineno=12, end_col_offset=57)], [], lineno=11, col_offset=0, end_lineno=12, end_col_offset=57)], []) \ No newline at end of file diff --git a/test/practice-diffie-hellman/.meta/config.json b/test/practice-diffie-hellman/.meta/config.json new file mode 100644 index 0000000..81e8cb8 --- /dev/null +++ b/test/practice-diffie-hellman/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [], + "contributors": [ + "cmccandless", + "Dog", + "lucasloisp", + "N-Parsons", + "pyropy", + "tqa236" + ], + "files": { + "solution": [ + "diffie_hellman.py" + ], + "test": [ + "diffie_hellman_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Diffie-Hellman key exchange.", + "source": "Wikipedia, 1024 bit key from www.cryptopp.com/wiki.", + "source_url": "https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange" +} diff --git a/test/practice-diffie-hellman/diffie_hellman.py b/test/practice-diffie-hellman/diffie_hellman.py new file mode 100644 index 0000000..45a547b --- /dev/null +++ b/test/practice-diffie-hellman/diffie_hellman.py @@ -0,0 +1,13 @@ +import random + + +def private_key(p): + return random.randint(2, p-1) + + +def public_key(p, g, private): + return pow(g, private, p) + + +def secret(p, public, private): + return pow(public, private, p) diff --git a/test/practice-diffie-hellman/mapping.json b/test/practice-diffie-hellman/mapping.json new file mode 100644 index 0000000..c11ee07 --- /dev/null +++ b/test/practice-diffie-hellman/mapping.json @@ -0,0 +1,9 @@ +{ + "placeholder_0": "private_key", + "placeholder_1": "p", + "placeholder_2": "public_key", + "placeholder_3": "g", + "placeholder_4": "private", + "placeholder_5": "secret", + "placeholder_6": "public" +} \ No newline at end of file diff --git a/test/practice-diffie-hellman/representation.json b/test/practice-diffie-hellman/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-diffie-hellman/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-diffie-hellman/representation.out b/test/practice-diffie-hellman/representation.out new file mode 100644 index 0000000..bb9b171 --- /dev/null +++ b/test/practice-diffie-hellman/representation.out @@ -0,0 +1,482 @@ +## BEGIN NORMALIZED CODE ## +import random + + +def placeholder_0(placeholder_1): + return random.randint(2, placeholder_1 - 1) + + +def placeholder_2(placeholder_1, placeholder_3, placeholder_4): + return pow(placeholder_3, placeholder_4, placeholder_1) + + +def placeholder_5(placeholder_1, placeholder_6, placeholder_4): + return pow(placeholder_6, placeholder_4, placeholder_1) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'random', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=13)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=13), + FunctionDef( + 'private_key', + arguments( + [], + [ + arg( + 'p', + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17), + 'randint', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=25), + [ + Constant( + 2, + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=27), + BinOp( + Name( + 'p', + Load(), + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=30), + Sub(), + Constant( + 1, + lineno=5, + col_offset=31, + end_lineno=5, + end_col_offset=32), + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=32)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=33)], + [], + lineno=4, + col_offset=0, + end_lineno=5, + end_col_offset=33), + FunctionDef( + 'public_key', + arguments( + [], + [ + arg( + 'p', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=16), + arg( + 'g', + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=19), + arg( + 'private', + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'pow', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=14), + [ + Name( + 'g', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16), + Name( + 'private', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=25), + Name( + 'p', + Load(), + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=28)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=29), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=29)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=29), + FunctionDef( + 'secret', + arguments( + [], + [ + arg( + 'p', + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=12), + arg( + 'public', + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=20), + arg( + 'private', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'pow', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=14), + [ + Name( + 'public', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=21), + Name( + 'private', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=30), + Name( + 'p', + Load(), + lineno=13, + col_offset=32, + end_lineno=13, + end_col_offset=33)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=34), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=34)], + [], + lineno=12, + col_offset=0, + end_lineno=13, + end_col_offset=34)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'random', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=13)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=13), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17), + 'randint', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=25), + [ + Constant( + 2, + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=27), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=30), + Sub(), + Constant( + 1, + lineno=5, + col_offset=31, + end_lineno=5, + end_col_offset=32), + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=32)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=33)], + [], + lineno=4, + col_offset=0, + end_lineno=5, + end_col_offset=33), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=16), + arg( + 'placeholder_3', + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=19), + arg( + 'placeholder_4', + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'pow', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=14), + [ + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16), + Name( + 'placeholder_4', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=25), + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=28)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=29), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=29)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=29), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=12), + arg( + 'placeholder_6', + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=20), + arg( + 'placeholder_4', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'pow', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=14), + [ + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=21), + Name( + 'placeholder_4', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=30), + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=32, + end_lineno=13, + end_col_offset=33)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=34), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=34)], + [], + lineno=12, + col_offset=0, + end_lineno=13, + end_col_offset=34)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-diffie-hellman/representation.txt b/test/practice-diffie-hellman/representation.txt new file mode 100644 index 0000000..5b951e7 --- /dev/null +++ b/test/practice-diffie-hellman/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('random', lineno=1, col_offset=7, end_lineno=1, end_col_offset=13)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=13), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=16, end_lineno=4, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('random', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=17), 'randint', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=25), [Constant(2, lineno=5, col_offset=26, end_lineno=5, end_col_offset=27), BinOp(Name('placeholder_1', Load(), lineno=5, col_offset=29, end_lineno=5, end_col_offset=30), Sub(), Constant(1, lineno=5, col_offset=31, end_lineno=5, end_col_offset=32), lineno=5, col_offset=29, end_lineno=5, end_col_offset=32)], [], lineno=5, col_offset=11, end_lineno=5, end_col_offset=33), lineno=5, col_offset=4, end_lineno=5, end_col_offset=33)], [], lineno=4, col_offset=0, end_lineno=5, end_col_offset=33), FunctionDef('placeholder_2', arguments([], [arg('placeholder_1', lineno=8, col_offset=15, end_lineno=8, end_col_offset=16), arg('placeholder_3', lineno=8, col_offset=18, end_lineno=8, end_col_offset=19), arg('placeholder_4', lineno=8, col_offset=21, end_lineno=8, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('pow', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=14), [Name('placeholder_3', Load(), lineno=9, col_offset=15, end_lineno=9, end_col_offset=16), Name('placeholder_4', Load(), lineno=9, col_offset=18, end_lineno=9, end_col_offset=25), Name('placeholder_1', Load(), lineno=9, col_offset=27, end_lineno=9, end_col_offset=28)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=29), lineno=9, col_offset=4, end_lineno=9, end_col_offset=29)], [], lineno=8, col_offset=0, end_lineno=9, end_col_offset=29), FunctionDef('placeholder_5', arguments([], [arg('placeholder_1', lineno=12, col_offset=11, end_lineno=12, end_col_offset=12), arg('placeholder_6', lineno=12, col_offset=14, end_lineno=12, end_col_offset=20), arg('placeholder_4', lineno=12, col_offset=22, end_lineno=12, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('pow', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=14), [Name('placeholder_6', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=21), Name('placeholder_4', Load(), lineno=13, col_offset=23, end_lineno=13, end_col_offset=30), Name('placeholder_1', Load(), lineno=13, col_offset=32, end_lineno=13, end_col_offset=33)], [], lineno=13, col_offset=11, end_lineno=13, end_col_offset=34), lineno=13, col_offset=4, end_lineno=13, end_col_offset=34)], [], lineno=12, col_offset=0, end_lineno=13, end_col_offset=34)], []) \ No newline at end of file diff --git a/test/practice-dnd-character/.meta/config.json b/test/practice-dnd-character/.meta/config.json new file mode 100644 index 0000000..8f2c310 --- /dev/null +++ b/test/practice-dnd-character/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "GascaK" + ], + "contributors": [ + "cmccandless", + "Dog", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "dnd_character.py" + ], + "test": [ + "dnd_character_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Randomly generate Dungeons & Dragons characters.", + "source": "Simon Shine, Erik Schierboom", + "source_url": "https://github.com/exercism/problem-specifications/issues/616#issuecomment-437358945" +} diff --git a/test/practice-dnd-character/dnd_character.py b/test/practice-dnd-character/dnd_character.py new file mode 100644 index 0000000..fad3dfe --- /dev/null +++ b/test/practice-dnd-character/dnd_character.py @@ -0,0 +1,21 @@ +import random +import math + + +class Character: + def __init__(self): + self.strength = self.ability() + self.dexterity = self.ability() + self.constitution = self.ability() + self.intelligence = self.ability() + self.wisdom = self.ability() + self.charisma = self.ability() + self.hitpoints = 10 + modifier(self.constitution) + + def ability(self): + dice_rolls = sorted(random.randint(1, 6) for _ in range(4)) + return sum(dice_rolls[1:]) + + +def modifier(value): + return math.floor((value-10)/2) diff --git a/test/practice-dnd-character/mapping.json b/test/practice-dnd-character/mapping.json new file mode 100644 index 0000000..6e18de4 --- /dev/null +++ b/test/practice-dnd-character/mapping.json @@ -0,0 +1,16 @@ +{ + "placeholder_0": "Character", + "placeholder_1": "__init__", + "placeholder_2": "strength", + "placeholder_3": "dexterity", + "placeholder_4": "constitution", + "placeholder_5": "intelligence", + "placeholder_6": "wisdom", + "placeholder_7": "charisma", + "placeholder_8": "hitpoints", + "placeholder_9": "ability", + "placeholder_10": "dice_rolls", + "placeholder_11": "_", + "placeholder_12": "modifier", + "placeholder_13": "value" +} \ No newline at end of file diff --git a/test/practice-dnd-character/representation.json b/test/practice-dnd-character/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-dnd-character/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-dnd-character/representation.out b/test/practice-dnd-character/representation.out new file mode 100644 index 0000000..bd40ae3 --- /dev/null +++ b/test/practice-dnd-character/representation.out @@ -0,0 +1,1228 @@ +## BEGIN NORMALIZED CODE ## +import random +import math + + +class placeholder_0: + def placeholder_1(self): + self.placeholder_2 = self.ability() + self.placeholder_3 = self.ability() + self.placeholder_4 = self.ability() + self.placeholder_5 = self.ability() + self.placeholder_6 = self.ability() + self.placeholder_7 = self.ability() + self.placeholder_8 = 10 + modifier(self.placeholder_4) + + def placeholder_9(self): + placeholder_10 = sorted((random.randint(1, 6) for placeholder_11 in range(4))) + return sum(placeholder_10[1:]) + + +def placeholder_12(placeholder_13): + return math.floor((placeholder_13 - 10) / 2) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'random', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=13)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=13), + Import( + [ + alias( + 'math', + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=11)], + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=11), + ClassDef( + 'Character', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'strength', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=21)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=28), + 'ability', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=36), + [], + [], + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=38), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=38), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'dexterity', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=29), + 'ability', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=37), + [], + [], + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'constitution', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=25)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=32), + 'ability', + Load(), + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=40), + [], + [], + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=42), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=42), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'intelligence', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=25)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=32), + 'ability', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=40), + [], + [], + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=42), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=42), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'wisdom', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=19)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=26), + 'ability', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=34), + [], + [], + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=36), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'charisma', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=21)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=28), + 'ability', + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=36), + [], + [], + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=38), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=38), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'hitpoints', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + BinOp( + Constant( + 10, + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=27), + Add(), + Call( + Name( + 'modifier', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=38), + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=43), + 'constitution', + Load(), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=56)], + [], + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=57), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=57), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=57)], + [], + lineno=6, + col_offset=4, + end_lineno=13, + end_col_offset=57), + FunctionDef( + 'ability', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'dice_rolls', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18)], + Call( + Name( + 'sorted', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=27), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=34), + 'randint', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=42), + [ + Constant( + 1, + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=44), + Constant( + 6, + lineno=16, + col_offset=46, + end_lineno=16, + end_col_offset=47)], + [], + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=48), + [ + comprehension( + Name( + '_', + Store(), + lineno=16, + col_offset=53, + end_lineno=16, + end_col_offset=54), + Call( + Name( + 'range', + Load(), + lineno=16, + col_offset=58, + end_lineno=16, + end_col_offset=63), + [ + Constant( + 4, + lineno=16, + col_offset=64, + end_lineno=16, + end_col_offset=65)], + [], + lineno=16, + col_offset=58, + end_lineno=16, + end_col_offset=66), + [], + 0)], + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=67)], + [], + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=67), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=67), + Return( + Call( + Name( + 'sum', + Load(), + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=18), + [ + Subscript( + Name( + 'dice_rolls', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=29), + Slice( + Constant( + 1, + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=31), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=32), + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=33)], + [], + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=34), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=34)], + [], + lineno=15, + col_offset=4, + end_lineno=17, + end_col_offset=34)], + [], + lineno=5, + col_offset=0, + end_lineno=17, + end_col_offset=34), + FunctionDef( + 'modifier', + arguments( + [], + [ + arg( + 'value', + lineno=20, + col_offset=13, + end_lineno=20, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'math', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=15), + 'floor', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=21), + [ + BinOp( + BinOp( + Name( + 'value', + Load(), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=28), + Sub(), + Constant( + 10, + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=31), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=31), + Div(), + Constant( + 2, + lineno=21, + col_offset=33, + end_lineno=21, + end_col_offset=34), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=34)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=35), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=35)], + [], + lineno=20, + col_offset=0, + end_lineno=21, + end_col_offset=35)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'random', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=13)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=13), + Import( + [ + alias( + 'math', + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=11)], + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=11), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=21)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=28), + 'ability', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=36), + [], + [], + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=38), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=38), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=29), + 'ability', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=37), + [], + [], + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=25)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=32), + 'ability', + Load(), + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=40), + [], + [], + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=42), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=42), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=25)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=32), + 'ability', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=40), + [], + [], + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=42), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=42), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=19)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=26), + 'ability', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=34), + [], + [], + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=36), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=21)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=28), + 'ability', + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=36), + [], + [], + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=38), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=38), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + BinOp( + Constant( + 10, + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=27), + Add(), + Call( + Name( + 'modifier', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=38), + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=43), + 'placeholder_4', + Load(), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=56)], + [], + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=57), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=57), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=57)], + [], + lineno=6, + col_offset=4, + end_lineno=13, + end_col_offset=57), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18)], + Call( + Name( + 'sorted', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=27), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=34), + 'randint', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=42), + [ + Constant( + 1, + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=44), + Constant( + 6, + lineno=16, + col_offset=46, + end_lineno=16, + end_col_offset=47)], + [], + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=48), + [ + comprehension( + Name( + 'placeholder_11', + Store(), + lineno=16, + col_offset=53, + end_lineno=16, + end_col_offset=54), + Call( + Name( + 'range', + Load(), + lineno=16, + col_offset=58, + end_lineno=16, + end_col_offset=63), + [ + Constant( + 4, + lineno=16, + col_offset=64, + end_lineno=16, + end_col_offset=65)], + [], + lineno=16, + col_offset=58, + end_lineno=16, + end_col_offset=66), + [], + 0)], + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=67)], + [], + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=67), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=67), + Return( + Call( + Name( + 'sum', + Load(), + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=18), + [ + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=29), + Slice( + Constant( + 1, + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=31), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=32), + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=33)], + [], + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=34), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=34)], + [], + lineno=15, + col_offset=4, + end_lineno=17, + end_col_offset=34)], + [], + lineno=5, + col_offset=0, + end_lineno=17, + end_col_offset=34), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=20, + col_offset=13, + end_lineno=20, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'math', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=15), + 'floor', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=21), + [ + BinOp( + BinOp( + Name( + 'placeholder_13', + Load(), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=28), + Sub(), + Constant( + 10, + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=31), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=31), + Div(), + Constant( + 2, + lineno=21, + col_offset=33, + end_lineno=21, + end_col_offset=34), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=34)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=35), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=35)], + [], + lineno=20, + col_offset=0, + end_lineno=21, + end_col_offset=35)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-dnd-character/representation.txt b/test/practice-dnd-character/representation.txt new file mode 100644 index 0000000..494bbd0 --- /dev/null +++ b/test/practice-dnd-character/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('random', lineno=1, col_offset=7, end_lineno=1, end_col_offset=13)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=13), Import([alias('math', lineno=2, col_offset=7, end_lineno=2, end_col_offset=11)], lineno=2, col_offset=0, end_lineno=2, end_col_offset=11), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=6, col_offset=17, end_lineno=6, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_2', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=21)], Call(Attribute(Name('self', Load(), lineno=7, col_offset=24, end_lineno=7, end_col_offset=28), 'ability', Load(), lineno=7, col_offset=24, end_lineno=7, end_col_offset=36), [], [], lineno=7, col_offset=24, end_lineno=7, end_col_offset=38), lineno=7, col_offset=8, end_lineno=7, end_col_offset=38), Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_3', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=22)], Call(Attribute(Name('self', Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=29), 'ability', Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=37), [], [], lineno=8, col_offset=25, end_lineno=8, end_col_offset=39), lineno=8, col_offset=8, end_lineno=8, end_col_offset=39), Assign([Attribute(Name('self', Load(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), 'placeholder_4', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=25)], Call(Attribute(Name('self', Load(), lineno=9, col_offset=28, end_lineno=9, end_col_offset=32), 'ability', Load(), lineno=9, col_offset=28, end_lineno=9, end_col_offset=40), [], [], lineno=9, col_offset=28, end_lineno=9, end_col_offset=42), lineno=9, col_offset=8, end_lineno=9, end_col_offset=42), Assign([Attribute(Name('self', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=12), 'placeholder_5', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=25)], Call(Attribute(Name('self', Load(), lineno=10, col_offset=28, end_lineno=10, end_col_offset=32), 'ability', Load(), lineno=10, col_offset=28, end_lineno=10, end_col_offset=40), [], [], lineno=10, col_offset=28, end_lineno=10, end_col_offset=42), lineno=10, col_offset=8, end_lineno=10, end_col_offset=42), Assign([Attribute(Name('self', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), 'placeholder_6', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=19)], Call(Attribute(Name('self', Load(), lineno=11, col_offset=22, end_lineno=11, end_col_offset=26), 'ability', Load(), lineno=11, col_offset=22, end_lineno=11, end_col_offset=34), [], [], lineno=11, col_offset=22, end_lineno=11, end_col_offset=36), lineno=11, col_offset=8, end_lineno=11, end_col_offset=36), Assign([Attribute(Name('self', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), 'placeholder_7', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=21)], Call(Attribute(Name('self', Load(), lineno=12, col_offset=24, end_lineno=12, end_col_offset=28), 'ability', Load(), lineno=12, col_offset=24, end_lineno=12, end_col_offset=36), [], [], lineno=12, col_offset=24, end_lineno=12, end_col_offset=38), lineno=12, col_offset=8, end_lineno=12, end_col_offset=38), Assign([Attribute(Name('self', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=12), 'placeholder_8', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=22)], BinOp(Constant(10, lineno=13, col_offset=25, end_lineno=13, end_col_offset=27), Add(), Call(Name('modifier', Load(), lineno=13, col_offset=30, end_lineno=13, end_col_offset=38), [Attribute(Name('self', Load(), lineno=13, col_offset=39, end_lineno=13, end_col_offset=43), 'placeholder_4', Load(), lineno=13, col_offset=39, end_lineno=13, end_col_offset=56)], [], lineno=13, col_offset=30, end_lineno=13, end_col_offset=57), lineno=13, col_offset=25, end_lineno=13, end_col_offset=57), lineno=13, col_offset=8, end_lineno=13, end_col_offset=57)], [], lineno=6, col_offset=4, end_lineno=13, end_col_offset=57), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=15, col_offset=16, end_lineno=15, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_10', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=18)], Call(Name('sorted', Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=27), [GeneratorExp(Call(Attribute(Name('random', Load(), lineno=16, col_offset=28, end_lineno=16, end_col_offset=34), 'randint', Load(), lineno=16, col_offset=28, end_lineno=16, end_col_offset=42), [Constant(1, lineno=16, col_offset=43, end_lineno=16, end_col_offset=44), Constant(6, lineno=16, col_offset=46, end_lineno=16, end_col_offset=47)], [], lineno=16, col_offset=28, end_lineno=16, end_col_offset=48), [comprehension(Name('placeholder_11', Store(), lineno=16, col_offset=53, end_lineno=16, end_col_offset=54), Call(Name('range', Load(), lineno=16, col_offset=58, end_lineno=16, end_col_offset=63), [Constant(4, lineno=16, col_offset=64, end_lineno=16, end_col_offset=65)], [], lineno=16, col_offset=58, end_lineno=16, end_col_offset=66), [], 0)], lineno=16, col_offset=27, end_lineno=16, end_col_offset=67)], [], lineno=16, col_offset=21, end_lineno=16, end_col_offset=67), lineno=16, col_offset=8, end_lineno=16, end_col_offset=67), Return(Call(Name('sum', Load(), lineno=17, col_offset=15, end_lineno=17, end_col_offset=18), [Subscript(Name('placeholder_10', Load(), lineno=17, col_offset=19, end_lineno=17, end_col_offset=29), Slice(Constant(1, lineno=17, col_offset=30, end_lineno=17, end_col_offset=31), lineno=17, col_offset=30, end_lineno=17, end_col_offset=32), Load(), lineno=17, col_offset=19, end_lineno=17, end_col_offset=33)], [], lineno=17, col_offset=15, end_lineno=17, end_col_offset=34), lineno=17, col_offset=8, end_lineno=17, end_col_offset=34)], [], lineno=15, col_offset=4, end_lineno=17, end_col_offset=34)], [], lineno=5, col_offset=0, end_lineno=17, end_col_offset=34), FunctionDef('placeholder_12', arguments([], [arg('placeholder_13', lineno=20, col_offset=13, end_lineno=20, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('math', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=15), 'floor', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=21), [BinOp(BinOp(Name('placeholder_13', Load(), lineno=21, col_offset=23, end_lineno=21, end_col_offset=28), Sub(), Constant(10, lineno=21, col_offset=29, end_lineno=21, end_col_offset=31), lineno=21, col_offset=23, end_lineno=21, end_col_offset=31), Div(), Constant(2, lineno=21, col_offset=33, end_lineno=21, end_col_offset=34), lineno=21, col_offset=22, end_lineno=21, end_col_offset=34)], [], lineno=21, col_offset=11, end_lineno=21, end_col_offset=35), lineno=21, col_offset=4, end_lineno=21, end_col_offset=35)], [], lineno=20, col_offset=0, end_lineno=21, end_col_offset=35)], []) \ No newline at end of file diff --git a/test/practice-dominoes/.meta/config.json b/test/practice-dominoes/.meta/config.json new file mode 100644 index 0000000..2b7746f --- /dev/null +++ b/test/practice-dominoes/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "BethanyG", + "Dog", + "dvermd", + "N-Parsons", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "dominoes.py" + ], + "test": [ + "dominoes_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Make a chain of dominoes." +} diff --git a/test/practice-dominoes/dominoes.py b/test/practice-dominoes/dominoes.py new file mode 100644 index 0000000..2490525 --- /dev/null +++ b/test/practice-dominoes/dominoes.py @@ -0,0 +1,30 @@ +from itertools import permutations +from functools import reduce + + +def swap(item_1, item_2): + return (item_2, item_1) + + +def build_chain(chain, domino): + if chain is not None: + last = chain[-1] + if len(chain) == 1 and last[0] == domino[0]: + return [swap(*last), domino] + elif len(chain) == 1 and last[0] == domino[1]: + return [swap(*last), swap(*domino)] + elif last[1] == domino[0]: + return chain + [domino] + elif last[1] == domino[1]: + return chain + [swap(*domino)] + return None + + +def can_chain(dominoes): + if not any(dominoes): + return [] + for perm in permutations(dominoes): + chain = reduce(build_chain, perm[1:], [perm[0]]) + if chain is not None and chain[0][0] == chain[-1][1]: + return chain + return None diff --git a/test/practice-dominoes/mapping.json b/test/practice-dominoes/mapping.json new file mode 100644 index 0000000..e11462b --- /dev/null +++ b/test/practice-dominoes/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "swap", + "placeholder_1": "item_1", + "placeholder_2": "item_2", + "placeholder_3": "build_chain", + "placeholder_4": "chain", + "placeholder_5": "domino", + "placeholder_6": "last", + "placeholder_7": "can_chain", + "placeholder_8": "dominoes", + "placeholder_9": "perm" +} \ No newline at end of file diff --git a/test/practice-dominoes/representation.json b/test/practice-dominoes/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-dominoes/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-dominoes/representation.out b/test/practice-dominoes/representation.out new file mode 100644 index 0000000..0a5bede --- /dev/null +++ b/test/practice-dominoes/representation.out @@ -0,0 +1,2033 @@ +## BEGIN NORMALIZED CODE ## +from itertools import permutations +from functools import reduce + + +def placeholder_0(placeholder_1, placeholder_2): + return (placeholder_2, placeholder_1) + + +def placeholder_3(placeholder_4, placeholder_5): + if placeholder_4 is not None: + placeholder_6 = placeholder_4[-1] + if len(placeholder_4) == 1 and placeholder_6[0] == placeholder_5[0]: + return [placeholder_0(*placeholder_6), placeholder_5] + elif len(placeholder_4) == 1 and placeholder_6[0] == placeholder_5[1]: + return [placeholder_0(*placeholder_6), placeholder_0(*placeholder_5)] + elif placeholder_6[1] == placeholder_5[0]: + return placeholder_4 + [placeholder_5] + elif placeholder_6[1] == placeholder_5[1]: + return placeholder_4 + [placeholder_0(*placeholder_5)] + return None + + +def placeholder_7(placeholder_8): + if not any(placeholder_8): + return [] + for placeholder_9 in permutations(placeholder_8): + placeholder_4 = reduce(placeholder_3, placeholder_9[1:], [placeholder_9[0]]) + if placeholder_4 is not None and placeholder_4[0][0] == placeholder_4[-1][1]: + return placeholder_4 + return None + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'permutations', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + ImportFrom( + 'functools', + [ + alias( + 'reduce', + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=28)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=28), + FunctionDef( + 'swap', + arguments( + [], + [ + arg( + 'item_1', + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=15), + arg( + 'item_2', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Tuple( + [ + Name( + 'item_2', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=18), + Name( + 'item_1', + Load(), + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=26)], + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=27), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=27)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=27), + FunctionDef( + 'build_chain', + arguments( + [], + [ + arg( + 'chain', + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=21), + arg( + 'domino', + lineno=9, + col_offset=23, + end_lineno=9, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'chain', + Load(), + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=12), + [ + IsNot()], + [ + Constant( + None, + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=24)], + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=24), + [ + Assign( + [ + Name( + 'last', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12)], + Subscript( + Name( + 'chain', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=20), + UnaryOp( + USub(), + Constant( + 1, + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=23), + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=23), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=24), + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=14), + [ + Name( + 'chain', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=20)], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 1, + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=26)], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=26), + Compare( + Subscript( + Name( + 'last', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=35), + Constant( + 0, + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=37), + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=38), + [ + Eq()], + [ + Subscript( + Name( + 'domino', + Load(), + lineno=12, + col_offset=42, + end_lineno=12, + end_col_offset=48), + Constant( + 0, + lineno=12, + col_offset=49, + end_lineno=12, + end_col_offset=50), + Load(), + lineno=12, + col_offset=42, + end_lineno=12, + end_col_offset=51)], + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=51)], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=51), + [ + Return( + List( + [ + Call( + Name( + 'swap', + Load(), + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=24), + [ + Starred( + Name( + 'last', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=30), + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=30)], + [], + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=31), + Name( + 'domino', + Load(), + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=39)], + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=40), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=40)], + [ + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=16), + [ + Name( + 'chain', + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=22)], + [], + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=23), + [ + Eq()], + [ + Constant( + 1, + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=28)], + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=28), + Compare( + Subscript( + Name( + 'last', + Load(), + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=37), + Constant( + 0, + lineno=14, + col_offset=38, + end_lineno=14, + end_col_offset=39), + Load(), + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=40), + [ + Eq()], + [ + Subscript( + Name( + 'domino', + Load(), + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=50), + Constant( + 1, + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=52), + Load(), + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=53)], + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=53)], + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=53), + [ + Return( + List( + [ + Call( + Name( + 'swap', + Load(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=24), + [ + Starred( + Name( + 'last', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=30), + Load(), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=30)], + [], + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=31), + Call( + Name( + 'swap', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=37), + [ + Starred( + Name( + 'domino', + Load(), + lineno=15, + col_offset=39, + end_lineno=15, + end_col_offset=45), + Load(), + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=45)], + [], + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=46)], + Load(), + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=47), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=47)], + [ + If( + Compare( + Subscript( + Name( + 'last', + Load(), + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=17), + Constant( + 1, + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=19), + Load(), + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=20), + [ + Eq()], + [ + Subscript( + Name( + 'domino', + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=30), + Constant( + 0, + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=32), + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=33)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=33), + [ + Return( + BinOp( + Name( + 'chain', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=24), + Add(), + List( + [ + Name( + 'domino', + Load(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=34)], + Load(), + lineno=17, + col_offset=27, + end_lineno=17, + end_col_offset=35), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=35), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=35)], + [ + If( + Compare( + Subscript( + Name( + 'last', + Load(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=17), + Constant( + 1, + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=19), + Load(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=20), + [ + Eq()], + [ + Subscript( + Name( + 'domino', + Load(), + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=30), + Constant( + 1, + lineno=18, + col_offset=31, + end_lineno=18, + end_col_offset=32), + Load(), + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=33)], + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=33), + [ + Return( + BinOp( + Name( + 'chain', + Load(), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=24), + Add(), + List( + [ + Call( + Name( + 'swap', + Load(), + lineno=19, + col_offset=28, + end_lineno=19, + end_col_offset=32), + [ + Starred( + Name( + 'domino', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=40), + Load(), + lineno=19, + col_offset=33, + end_lineno=19, + end_col_offset=40)], + [], + lineno=19, + col_offset=28, + end_lineno=19, + end_col_offset=41)], + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=42), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=42), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=42)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=42)], + lineno=16, + col_offset=8, + end_lineno=19, + end_col_offset=42)], + lineno=14, + col_offset=8, + end_lineno=19, + end_col_offset=42)], + lineno=12, + col_offset=8, + end_lineno=19, + end_col_offset=42)], + [], + lineno=10, + col_offset=4, + end_lineno=19, + end_col_offset=42), + Return( + Constant( + None, + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=15), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=15)], + [], + lineno=9, + col_offset=0, + end_lineno=20, + end_col_offset=15), + FunctionDef( + 'can_chain', + arguments( + [], + [ + arg( + 'dominoes', + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'any', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=14), + [ + Name( + 'dominoes', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=23)], + [], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=24), + lineno=24, + col_offset=7, + end_lineno=24, + end_col_offset=24), + [ + Return( + List( + [], + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=17), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=17)], + [], + lineno=24, + col_offset=4, + end_lineno=25, + end_col_offset=17), + For( + Name( + 'perm', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=12), + Call( + Name( + 'permutations', + Load(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=28), + [ + Name( + 'dominoes', + Load(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=37)], + [], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=38), + [ + Assign( + [ + Name( + 'chain', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=13)], + Call( + Name( + 'reduce', + Load(), + lineno=27, + col_offset=16, + end_lineno=27, + end_col_offset=22), + [ + Name( + 'build_chain', + Load(), + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=34), + Subscript( + Name( + 'perm', + Load(), + lineno=27, + col_offset=36, + end_lineno=27, + end_col_offset=40), + Slice( + Constant( + 1, + lineno=27, + col_offset=41, + end_lineno=27, + end_col_offset=42), + lineno=27, + col_offset=41, + end_lineno=27, + end_col_offset=43), + Load(), + lineno=27, + col_offset=36, + end_lineno=27, + end_col_offset=44), + List( + [ + Subscript( + Name( + 'perm', + Load(), + lineno=27, + col_offset=47, + end_lineno=27, + end_col_offset=51), + Constant( + 0, + lineno=27, + col_offset=52, + end_lineno=27, + end_col_offset=53), + Load(), + lineno=27, + col_offset=47, + end_lineno=27, + end_col_offset=54)], + Load(), + lineno=27, + col_offset=46, + end_lineno=27, + end_col_offset=55)], + [], + lineno=27, + col_offset=16, + end_lineno=27, + end_col_offset=56), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=56), + If( + BoolOp( + And(), + [ + Compare( + Name( + 'chain', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=16), + [ + IsNot()], + [ + Constant( + None, + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=28)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=28), + Compare( + Subscript( + Subscript( + Name( + 'chain', + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=38), + Constant( + 0, + lineno=28, + col_offset=39, + end_lineno=28, + end_col_offset=40), + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=41), + Constant( + 0, + lineno=28, + col_offset=42, + end_lineno=28, + end_col_offset=43), + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=44), + [ + Eq()], + [ + Subscript( + Subscript( + Name( + 'chain', + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=53), + UnaryOp( + USub(), + Constant( + 1, + lineno=28, + col_offset=55, + end_lineno=28, + end_col_offset=56), + lineno=28, + col_offset=54, + end_lineno=28, + end_col_offset=56), + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=57), + Constant( + 1, + lineno=28, + col_offset=58, + end_lineno=28, + end_col_offset=59), + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=60)], + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=60)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=60), + [ + Return( + Name( + 'chain', + Load(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=24), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=24)], + [], + lineno=28, + col_offset=8, + end_lineno=29, + end_col_offset=24)], + [], + lineno=26, + col_offset=4, + end_lineno=29, + end_col_offset=24), + Return( + Constant( + None, + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=15), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=15)], + [], + lineno=23, + col_offset=0, + end_lineno=30, + end_col_offset=15)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'permutations', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + ImportFrom( + 'functools', + [ + alias( + 'reduce', + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=28)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=28), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=15), + arg( + 'placeholder_2', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Tuple( + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=18), + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=26)], + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=27), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=27)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=27), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=21), + arg( + 'placeholder_5', + lineno=9, + col_offset=23, + end_lineno=9, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=12), + [ + IsNot()], + [ + Constant( + None, + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=24)], + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=24), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12)], + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=20), + UnaryOp( + USub(), + Constant( + 1, + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=23), + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=23), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=24), + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=14), + [ + Name( + 'placeholder_4', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=20)], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 1, + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=26)], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=26), + Compare( + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=35), + Constant( + 0, + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=37), + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=38), + [ + Eq()], + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=42, + end_lineno=12, + end_col_offset=48), + Constant( + 0, + lineno=12, + col_offset=49, + end_lineno=12, + end_col_offset=50), + Load(), + lineno=12, + col_offset=42, + end_lineno=12, + end_col_offset=51)], + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=51)], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=51), + [ + Return( + List( + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=24), + [ + Starred( + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=30), + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=30)], + [], + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=31), + Name( + 'placeholder_5', + Load(), + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=39)], + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=40), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=40)], + [ + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=16), + [ + Name( + 'placeholder_4', + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=22)], + [], + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=23), + [ + Eq()], + [ + Constant( + 1, + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=28)], + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=28), + Compare( + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=37), + Constant( + 0, + lineno=14, + col_offset=38, + end_lineno=14, + end_col_offset=39), + Load(), + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=40), + [ + Eq()], + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=50), + Constant( + 1, + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=52), + Load(), + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=53)], + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=53)], + lineno=14, + col_offset=13, + end_lineno=14, + end_col_offset=53), + [ + Return( + List( + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=24), + [ + Starred( + Name( + 'placeholder_6', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=30), + Load(), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=30)], + [], + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=31), + Call( + Name( + 'placeholder_0', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=37), + [ + Starred( + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=39, + end_lineno=15, + end_col_offset=45), + Load(), + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=45)], + [], + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=46)], + Load(), + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=47), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=47)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=17), + Constant( + 1, + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=19), + Load(), + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=20), + [ + Eq()], + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=30), + Constant( + 0, + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=32), + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=33)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=33), + [ + Return( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=24), + Add(), + List( + [ + Name( + 'placeholder_5', + Load(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=34)], + Load(), + lineno=17, + col_offset=27, + end_lineno=17, + end_col_offset=35), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=35), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=35)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=17), + Constant( + 1, + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=19), + Load(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=20), + [ + Eq()], + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=30), + Constant( + 1, + lineno=18, + col_offset=31, + end_lineno=18, + end_col_offset=32), + Load(), + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=33)], + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=33), + [ + Return( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=24), + Add(), + List( + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=19, + col_offset=28, + end_lineno=19, + end_col_offset=32), + [ + Starred( + Name( + 'placeholder_5', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=40), + Load(), + lineno=19, + col_offset=33, + end_lineno=19, + end_col_offset=40)], + [], + lineno=19, + col_offset=28, + end_lineno=19, + end_col_offset=41)], + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=42), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=42), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=42)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=42)], + lineno=16, + col_offset=8, + end_lineno=19, + end_col_offset=42)], + lineno=14, + col_offset=8, + end_lineno=19, + end_col_offset=42)], + lineno=12, + col_offset=8, + end_lineno=19, + end_col_offset=42)], + [], + lineno=10, + col_offset=4, + end_lineno=19, + end_col_offset=42), + Return( + Constant( + None, + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=15), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=15)], + [], + lineno=9, + col_offset=0, + end_lineno=20, + end_col_offset=15), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'any', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=14), + [ + Name( + 'placeholder_8', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=23)], + [], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=24), + lineno=24, + col_offset=7, + end_lineno=24, + end_col_offset=24), + [ + Return( + List( + [], + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=17), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=17)], + [], + lineno=24, + col_offset=4, + end_lineno=25, + end_col_offset=17), + For( + Name( + 'placeholder_9', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=12), + Call( + Name( + 'permutations', + Load(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=28), + [ + Name( + 'placeholder_8', + Load(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=37)], + [], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=38), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=13)], + Call( + Name( + 'reduce', + Load(), + lineno=27, + col_offset=16, + end_lineno=27, + end_col_offset=22), + [ + Name( + 'placeholder_3', + Load(), + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=34), + Subscript( + Name( + 'placeholder_9', + Load(), + lineno=27, + col_offset=36, + end_lineno=27, + end_col_offset=40), + Slice( + Constant( + 1, + lineno=27, + col_offset=41, + end_lineno=27, + end_col_offset=42), + lineno=27, + col_offset=41, + end_lineno=27, + end_col_offset=43), + Load(), + lineno=27, + col_offset=36, + end_lineno=27, + end_col_offset=44), + List( + [ + Subscript( + Name( + 'placeholder_9', + Load(), + lineno=27, + col_offset=47, + end_lineno=27, + end_col_offset=51), + Constant( + 0, + lineno=27, + col_offset=52, + end_lineno=27, + end_col_offset=53), + Load(), + lineno=27, + col_offset=47, + end_lineno=27, + end_col_offset=54)], + Load(), + lineno=27, + col_offset=46, + end_lineno=27, + end_col_offset=55)], + [], + lineno=27, + col_offset=16, + end_lineno=27, + end_col_offset=56), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=56), + If( + BoolOp( + And(), + [ + Compare( + Name( + 'placeholder_4', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=16), + [ + IsNot()], + [ + Constant( + None, + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=28)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=28), + Compare( + Subscript( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=38), + Constant( + 0, + lineno=28, + col_offset=39, + end_lineno=28, + end_col_offset=40), + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=41), + Constant( + 0, + lineno=28, + col_offset=42, + end_lineno=28, + end_col_offset=43), + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=44), + [ + Eq()], + [ + Subscript( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=53), + UnaryOp( + USub(), + Constant( + 1, + lineno=28, + col_offset=55, + end_lineno=28, + end_col_offset=56), + lineno=28, + col_offset=54, + end_lineno=28, + end_col_offset=56), + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=57), + Constant( + 1, + lineno=28, + col_offset=58, + end_lineno=28, + end_col_offset=59), + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=60)], + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=60)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=60), + [ + Return( + Name( + 'placeholder_4', + Load(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=24), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=24)], + [], + lineno=28, + col_offset=8, + end_lineno=29, + end_col_offset=24)], + [], + lineno=26, + col_offset=4, + end_lineno=29, + end_col_offset=24), + Return( + Constant( + None, + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=15), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=15)], + [], + lineno=23, + col_offset=0, + end_lineno=30, + end_col_offset=15)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-dominoes/representation.txt b/test/practice-dominoes/representation.txt new file mode 100644 index 0000000..338bb4f --- /dev/null +++ b/test/practice-dominoes/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('itertools', [alias('permutations', lineno=1, col_offset=22, end_lineno=1, end_col_offset=34)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=34), ImportFrom('functools', [alias('reduce', lineno=2, col_offset=22, end_lineno=2, end_col_offset=28)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=28), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=9, end_lineno=5, end_col_offset=15), arg('placeholder_2', lineno=5, col_offset=17, end_lineno=5, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Tuple([Name('placeholder_2', Load(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=18), Name('placeholder_1', Load(), lineno=6, col_offset=20, end_lineno=6, end_col_offset=26)], Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=27), lineno=6, col_offset=4, end_lineno=6, end_col_offset=27)], [], lineno=5, col_offset=0, end_lineno=6, end_col_offset=27), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=9, col_offset=16, end_lineno=9, end_col_offset=21), arg('placeholder_5', lineno=9, col_offset=23, end_lineno=9, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_4', Load(), lineno=10, col_offset=7, end_lineno=10, end_col_offset=12), [IsNot()], [Constant(None, lineno=10, col_offset=20, end_lineno=10, end_col_offset=24)], lineno=10, col_offset=7, end_lineno=10, end_col_offset=24), [Assign([Name('placeholder_6', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12)], Subscript(Name('placeholder_4', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=20), UnaryOp(USub(), Constant(1, lineno=11, col_offset=22, end_lineno=11, end_col_offset=23), lineno=11, col_offset=21, end_lineno=11, end_col_offset=23), Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=24), lineno=11, col_offset=8, end_lineno=11, end_col_offset=24), If(BoolOp(And(), [Compare(Call(Name('len', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=14), [Name('placeholder_4', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=20)], [], lineno=12, col_offset=11, end_lineno=12, end_col_offset=21), [Eq()], [Constant(1, lineno=12, col_offset=25, end_lineno=12, end_col_offset=26)], lineno=12, col_offset=11, end_lineno=12, end_col_offset=26), Compare(Subscript(Name('placeholder_6', Load(), lineno=12, col_offset=31, end_lineno=12, end_col_offset=35), Constant(0, lineno=12, col_offset=36, end_lineno=12, end_col_offset=37), Load(), lineno=12, col_offset=31, end_lineno=12, end_col_offset=38), [Eq()], [Subscript(Name('placeholder_5', Load(), lineno=12, col_offset=42, end_lineno=12, end_col_offset=48), Constant(0, lineno=12, col_offset=49, end_lineno=12, end_col_offset=50), Load(), lineno=12, col_offset=42, end_lineno=12, end_col_offset=51)], lineno=12, col_offset=31, end_lineno=12, end_col_offset=51)], lineno=12, col_offset=11, end_lineno=12, end_col_offset=51), [Return(List([Call(Name('placeholder_0', Load(), lineno=13, col_offset=20, end_lineno=13, end_col_offset=24), [Starred(Name('placeholder_6', Load(), lineno=13, col_offset=26, end_lineno=13, end_col_offset=30), Load(), lineno=13, col_offset=25, end_lineno=13, end_col_offset=30)], [], lineno=13, col_offset=20, end_lineno=13, end_col_offset=31), Name('placeholder_5', Load(), lineno=13, col_offset=33, end_lineno=13, end_col_offset=39)], Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=40), lineno=13, col_offset=12, end_lineno=13, end_col_offset=40)], [If(BoolOp(And(), [Compare(Call(Name('len', Load(), lineno=14, col_offset=13, end_lineno=14, end_col_offset=16), [Name('placeholder_4', Load(), lineno=14, col_offset=17, end_lineno=14, end_col_offset=22)], [], lineno=14, col_offset=13, end_lineno=14, end_col_offset=23), [Eq()], [Constant(1, lineno=14, col_offset=27, end_lineno=14, end_col_offset=28)], lineno=14, col_offset=13, end_lineno=14, end_col_offset=28), Compare(Subscript(Name('placeholder_6', Load(), lineno=14, col_offset=33, end_lineno=14, end_col_offset=37), Constant(0, lineno=14, col_offset=38, end_lineno=14, end_col_offset=39), Load(), lineno=14, col_offset=33, end_lineno=14, end_col_offset=40), [Eq()], [Subscript(Name('placeholder_5', Load(), lineno=14, col_offset=44, end_lineno=14, end_col_offset=50), Constant(1, lineno=14, col_offset=51, end_lineno=14, end_col_offset=52), Load(), lineno=14, col_offset=44, end_lineno=14, end_col_offset=53)], lineno=14, col_offset=33, end_lineno=14, end_col_offset=53)], lineno=14, col_offset=13, end_lineno=14, end_col_offset=53), [Return(List([Call(Name('placeholder_0', Load(), lineno=15, col_offset=20, end_lineno=15, end_col_offset=24), [Starred(Name('placeholder_6', Load(), lineno=15, col_offset=26, end_lineno=15, end_col_offset=30), Load(), lineno=15, col_offset=25, end_lineno=15, end_col_offset=30)], [], lineno=15, col_offset=20, end_lineno=15, end_col_offset=31), Call(Name('placeholder_0', Load(), lineno=15, col_offset=33, end_lineno=15, end_col_offset=37), [Starred(Name('placeholder_5', Load(), lineno=15, col_offset=39, end_lineno=15, end_col_offset=45), Load(), lineno=15, col_offset=38, end_lineno=15, end_col_offset=45)], [], lineno=15, col_offset=33, end_lineno=15, end_col_offset=46)], Load(), lineno=15, col_offset=19, end_lineno=15, end_col_offset=47), lineno=15, col_offset=12, end_lineno=15, end_col_offset=47)], [If(Compare(Subscript(Name('placeholder_6', Load(), lineno=16, col_offset=13, end_lineno=16, end_col_offset=17), Constant(1, lineno=16, col_offset=18, end_lineno=16, end_col_offset=19), Load(), lineno=16, col_offset=13, end_lineno=16, end_col_offset=20), [Eq()], [Subscript(Name('placeholder_5', Load(), lineno=16, col_offset=24, end_lineno=16, end_col_offset=30), Constant(0, lineno=16, col_offset=31, end_lineno=16, end_col_offset=32), Load(), lineno=16, col_offset=24, end_lineno=16, end_col_offset=33)], lineno=16, col_offset=13, end_lineno=16, end_col_offset=33), [Return(BinOp(Name('placeholder_4', Load(), lineno=17, col_offset=19, end_lineno=17, end_col_offset=24), Add(), List([Name('placeholder_5', Load(), lineno=17, col_offset=28, end_lineno=17, end_col_offset=34)], Load(), lineno=17, col_offset=27, end_lineno=17, end_col_offset=35), lineno=17, col_offset=19, end_lineno=17, end_col_offset=35), lineno=17, col_offset=12, end_lineno=17, end_col_offset=35)], [If(Compare(Subscript(Name('placeholder_6', Load(), lineno=18, col_offset=13, end_lineno=18, end_col_offset=17), Constant(1, lineno=18, col_offset=18, end_lineno=18, end_col_offset=19), Load(), lineno=18, col_offset=13, end_lineno=18, end_col_offset=20), [Eq()], [Subscript(Name('placeholder_5', Load(), lineno=18, col_offset=24, end_lineno=18, end_col_offset=30), Constant(1, lineno=18, col_offset=31, end_lineno=18, end_col_offset=32), Load(), lineno=18, col_offset=24, end_lineno=18, end_col_offset=33)], lineno=18, col_offset=13, end_lineno=18, end_col_offset=33), [Return(BinOp(Name('placeholder_4', Load(), lineno=19, col_offset=19, end_lineno=19, end_col_offset=24), Add(), List([Call(Name('placeholder_0', Load(), lineno=19, col_offset=28, end_lineno=19, end_col_offset=32), [Starred(Name('placeholder_5', Load(), lineno=19, col_offset=34, end_lineno=19, end_col_offset=40), Load(), lineno=19, col_offset=33, end_lineno=19, end_col_offset=40)], [], lineno=19, col_offset=28, end_lineno=19, end_col_offset=41)], Load(), lineno=19, col_offset=27, end_lineno=19, end_col_offset=42), lineno=19, col_offset=19, end_lineno=19, end_col_offset=42), lineno=19, col_offset=12, end_lineno=19, end_col_offset=42)], [], lineno=18, col_offset=8, end_lineno=19, end_col_offset=42)], lineno=16, col_offset=8, end_lineno=19, end_col_offset=42)], lineno=14, col_offset=8, end_lineno=19, end_col_offset=42)], lineno=12, col_offset=8, end_lineno=19, end_col_offset=42)], [], lineno=10, col_offset=4, end_lineno=19, end_col_offset=42), Return(Constant(None, lineno=20, col_offset=11, end_lineno=20, end_col_offset=15), lineno=20, col_offset=4, end_lineno=20, end_col_offset=15)], [], lineno=9, col_offset=0, end_lineno=20, end_col_offset=15), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=23, col_offset=14, end_lineno=23, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('any', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=14), [Name('placeholder_8', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=23)], [], lineno=24, col_offset=11, end_lineno=24, end_col_offset=24), lineno=24, col_offset=7, end_lineno=24, end_col_offset=24), [Return(List([], Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=17), lineno=25, col_offset=8, end_lineno=25, end_col_offset=17)], [], lineno=24, col_offset=4, end_lineno=25, end_col_offset=17), For(Name('placeholder_9', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=12), Call(Name('permutations', Load(), lineno=26, col_offset=16, end_lineno=26, end_col_offset=28), [Name('placeholder_8', Load(), lineno=26, col_offset=29, end_lineno=26, end_col_offset=37)], [], lineno=26, col_offset=16, end_lineno=26, end_col_offset=38), [Assign([Name('placeholder_4', Store(), lineno=27, col_offset=8, end_lineno=27, end_col_offset=13)], Call(Name('reduce', Load(), lineno=27, col_offset=16, end_lineno=27, end_col_offset=22), [Name('placeholder_3', Load(), lineno=27, col_offset=23, end_lineno=27, end_col_offset=34), Subscript(Name('placeholder_9', Load(), lineno=27, col_offset=36, end_lineno=27, end_col_offset=40), Slice(Constant(1, lineno=27, col_offset=41, end_lineno=27, end_col_offset=42), lineno=27, col_offset=41, end_lineno=27, end_col_offset=43), Load(), lineno=27, col_offset=36, end_lineno=27, end_col_offset=44), List([Subscript(Name('placeholder_9', Load(), lineno=27, col_offset=47, end_lineno=27, end_col_offset=51), Constant(0, lineno=27, col_offset=52, end_lineno=27, end_col_offset=53), Load(), lineno=27, col_offset=47, end_lineno=27, end_col_offset=54)], Load(), lineno=27, col_offset=46, end_lineno=27, end_col_offset=55)], [], lineno=27, col_offset=16, end_lineno=27, end_col_offset=56), lineno=27, col_offset=8, end_lineno=27, end_col_offset=56), If(BoolOp(And(), [Compare(Name('placeholder_4', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=16), [IsNot()], [Constant(None, lineno=28, col_offset=24, end_lineno=28, end_col_offset=28)], lineno=28, col_offset=11, end_lineno=28, end_col_offset=28), Compare(Subscript(Subscript(Name('placeholder_4', Load(), lineno=28, col_offset=33, end_lineno=28, end_col_offset=38), Constant(0, lineno=28, col_offset=39, end_lineno=28, end_col_offset=40), Load(), lineno=28, col_offset=33, end_lineno=28, end_col_offset=41), Constant(0, lineno=28, col_offset=42, end_lineno=28, end_col_offset=43), Load(), lineno=28, col_offset=33, end_lineno=28, end_col_offset=44), [Eq()], [Subscript(Subscript(Name('placeholder_4', Load(), lineno=28, col_offset=48, end_lineno=28, end_col_offset=53), UnaryOp(USub(), Constant(1, lineno=28, col_offset=55, end_lineno=28, end_col_offset=56), lineno=28, col_offset=54, end_lineno=28, end_col_offset=56), Load(), lineno=28, col_offset=48, end_lineno=28, end_col_offset=57), Constant(1, lineno=28, col_offset=58, end_lineno=28, end_col_offset=59), Load(), lineno=28, col_offset=48, end_lineno=28, end_col_offset=60)], lineno=28, col_offset=33, end_lineno=28, end_col_offset=60)], lineno=28, col_offset=11, end_lineno=28, end_col_offset=60), [Return(Name('placeholder_4', Load(), lineno=29, col_offset=19, end_lineno=29, end_col_offset=24), lineno=29, col_offset=12, end_lineno=29, end_col_offset=24)], [], lineno=28, col_offset=8, end_lineno=29, end_col_offset=24)], [], lineno=26, col_offset=4, end_lineno=29, end_col_offset=24), Return(Constant(None, lineno=30, col_offset=11, end_lineno=30, end_col_offset=15), lineno=30, col_offset=4, end_lineno=30, end_col_offset=15)], [], lineno=23, col_offset=0, end_lineno=30, end_col_offset=15)], []) \ No newline at end of file diff --git a/test/practice-dot-dsl/.meta/config.json b/test/practice-dot-dsl/.meta/config.json new file mode 100644 index 0000000..928e8b2 --- /dev/null +++ b/test/practice-dot-dsl/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "ackerleytng" + ], + "contributors": [ + "cmccandless", + "Dog", + "N-Parsons", + "pranasziaukas", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "dot_dsl.py" + ], + "test": [ + "dot_dsl_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Write a Domain Specific Language similar to the Graphviz dot language.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/DOT_(graph_description_language)" +} diff --git a/test/practice-dot-dsl/dot_dsl.py b/test/practice-dot-dsl/dot_dsl.py new file mode 100644 index 0000000..9229cc4 --- /dev/null +++ b/test/practice-dot-dsl/dot_dsl.py @@ -0,0 +1,55 @@ +NODE, EDGE, ATTR = range(3) + + +class Node: + def __init__(self, name, attrs): + self.name = name + self.attrs = attrs + + def __eq__(self, other): + return self.name == other.name and self.attrs == other.attrs + + +class Edge: + def __init__(self, src, dst, attrs): + self.src = src + self.dst = dst + self.attrs = attrs + + def __eq__(self, other): + return (self.src == other.src and + self.dst == other.dst and + self.attrs == other.attrs) + + +class Graph: + def __init__(self, data=None): + self.nodes = [] + self.edges = [] + self.attrs = {} + + if data is None: + data = [] + + if not isinstance(data, list): + raise TypeError('Graph data malformed') + + for item in data: + if len(item) < 3: + raise TypeError('Graph item incomplete') + + type_ = item[0] + if type_ == ATTR: + if len(item) != 3: + raise ValueError('Attribute is malformed') + self.attrs[item[1]] = item[2] + elif type_ == NODE: + if len(item) != 3: + raise ValueError('Node is malformed') + self.nodes.append(Node(item[1], item[2])) + elif type_ == EDGE: + if len(item) != 4: + raise ValueError('Edge is malformed') + self.edges.append(Edge(item[1], item[2], item[3])) + else: + raise ValueError('Unknown item') diff --git a/test/practice-dot-dsl/mapping.json b/test/practice-dot-dsl/mapping.json new file mode 100644 index 0000000..1eac458 --- /dev/null +++ b/test/practice-dot-dsl/mapping.json @@ -0,0 +1,20 @@ +{ + "placeholder_0": "NODE", + "placeholder_1": "EDGE", + "placeholder_2": "ATTR", + "placeholder_3": "Node", + "placeholder_4": "__init__", + "placeholder_5": "name", + "placeholder_6": "attrs", + "placeholder_7": "__eq__", + "placeholder_8": "other", + "placeholder_9": "Edge", + "placeholder_10": "src", + "placeholder_11": "dst", + "placeholder_12": "Graph", + "placeholder_13": "data", + "placeholder_14": "nodes", + "placeholder_15": "edges", + "placeholder_16": "item", + "placeholder_17": "type_" +} \ No newline at end of file diff --git a/test/practice-dot-dsl/representation.json b/test/practice-dot-dsl/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-dot-dsl/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-dot-dsl/representation.out b/test/practice-dot-dsl/representation.out new file mode 100644 index 0000000..3e687c7 --- /dev/null +++ b/test/practice-dot-dsl/representation.out @@ -0,0 +1,2993 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0, placeholder_1, placeholder_2 = range(3) + + +class placeholder_3: + def placeholder_4(self, placeholder_5, placeholder_6): + self.placeholder_5 = placeholder_5 + self.placeholder_6 = placeholder_6 + + def placeholder_7(self, placeholder_8): + return ( + self.placeholder_5 == placeholder_8.placeholder_5 + and self.placeholder_6 == placeholder_8.placeholder_6 + ) + + +class placeholder_9: + def placeholder_4(self, placeholder_10, placeholder_11, placeholder_6): + self.placeholder_10 = placeholder_10 + self.placeholder_11 = placeholder_11 + self.placeholder_6 = placeholder_6 + + def placeholder_7(self, placeholder_8): + return ( + self.placeholder_10 == placeholder_8.placeholder_10 + and self.placeholder_11 == placeholder_8.placeholder_11 + and (self.placeholder_6 == placeholder_8.placeholder_6) + ) + + +class placeholder_12: + def placeholder_4(self, placeholder_13=None): + self.placeholder_14 = [] + self.placeholder_15 = [] + self.placeholder_6 = {} + if placeholder_13 is None: + placeholder_13 = [] + if not isinstance(placeholder_13, list): + raise TypeError("Graph data malformed") + for placeholder_16 in placeholder_13: + if len(placeholder_16) < 3: + raise TypeError("Graph item incomplete") + placeholder_17 = placeholder_16[0] + if placeholder_17 == placeholder_2: + if len(placeholder_16) != 3: + raise ValueError("Attribute is malformed") + self.placeholder_6[placeholder_16[1]] = placeholder_16[2] + elif placeholder_17 == placeholder_0: + if len(placeholder_16) != 3: + raise ValueError("Node is malformed") + self.placeholder_14.append( + placeholder_3(placeholder_16[1], placeholder_16[2]) + ) + elif placeholder_17 == placeholder_1: + if len(placeholder_16) != 4: + raise ValueError("Edge is malformed") + self.placeholder_15.append( + placeholder_9( + placeholder_16[1], placeholder_16[2], placeholder_16[3] + ) + ) + else: + raise ValueError("Unknown item") + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Tuple( + [ + Name( + 'NODE', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=4), + Name( + 'EDGE', + Store(), + lineno=1, + col_offset=6, + end_lineno=1, + end_col_offset=10), + Name( + 'ATTR', + Store(), + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=16)], + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16)], + Call( + Name( + 'range', + Load(), + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=24), + [ + Constant( + 3, + lineno=1, + col_offset=25, + end_lineno=1, + end_col_offset=26)], + [], + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=27), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=27), + ClassDef( + 'Node', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'name', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=27), + arg( + 'attrs', + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'name', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=17)], + Name( + 'name', + Load(), + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=24), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'attrs', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=18)], + Name( + 'attrs', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=26)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=26), + FunctionDef( + '__eq__', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=19), + arg( + 'other', + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=19), + 'name', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=33), + 'name', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=38)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=38), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=47), + 'attrs', + Load(), + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=53), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=10, + col_offset=57, + end_lineno=10, + end_col_offset=62), + 'attrs', + Load(), + lineno=10, + col_offset=57, + end_lineno=10, + end_col_offset=68)], + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=68)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=68), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=68)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=68)], + [], + lineno=4, + col_offset=0, + end_lineno=10, + end_col_offset=68), + ClassDef( + 'Edge', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'src', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=26), + arg( + 'dst', + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=31), + arg( + 'attrs', + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + 'src', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=16)], + Name( + 'src', + Load(), + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=22), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=12), + 'dst', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=16)], + Name( + 'dst', + Load(), + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=22), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=12), + 'attrs', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=18)], + Name( + 'attrs', + Load(), + lineno=17, + col_offset=21, + end_lineno=17, + end_col_offset=26), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=26)], + [], + lineno=14, + col_offset=4, + end_lineno=17, + end_col_offset=26), + FunctionDef( + '__eq__', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + arg( + 'other', + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=20), + 'src', + Load(), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=33), + 'src', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=37)], + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=37), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=20), + 'dst', + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=21, + col_offset=28, + end_lineno=21, + end_col_offset=33), + 'dst', + Load(), + lineno=21, + col_offset=28, + end_lineno=21, + end_col_offset=37)], + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=37), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20), + 'attrs', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=26), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=22, + col_offset=30, + end_lineno=22, + end_col_offset=35), + 'attrs', + Load(), + lineno=22, + col_offset=30, + end_lineno=22, + end_col_offset=41)], + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=41)], + lineno=20, + col_offset=16, + end_lineno=22, + end_col_offset=41), + lineno=20, + col_offset=8, + end_lineno=22, + end_col_offset=42)], + [], + lineno=19, + col_offset=4, + end_lineno=22, + end_col_offset=42)], + [], + lineno=13, + col_offset=0, + end_lineno=22, + end_col_offset=42), + ClassDef( + 'Graph', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=21), + arg( + 'data', + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=32)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=12), + 'nodes', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=18)], + List( + [], + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=23), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=23), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=12), + 'edges', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=18)], + List( + [], + Load(), + lineno=28, + col_offset=21, + end_lineno=28, + end_col_offset=23), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=23), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=12), + 'attrs', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=18)], + Dict( + [], + [], + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=23), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=23), + If( + Compare( + Name( + 'data', + Load(), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=15), + [ + Is()], + [ + Constant( + None, + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=23)], + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=23), + [ + Assign( + [ + Name( + 'data', + Store(), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=16)], + List( + [], + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=21), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=21)], + [], + lineno=31, + col_offset=8, + end_lineno=32, + end_col_offset=21), + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=25), + [ + Name( + 'data', + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=30), + Name( + 'list', + Load(), + lineno=34, + col_offset=32, + end_lineno=34, + end_col_offset=36)], + [], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=37), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=37), + [ + Raise( + Call( + Name( + 'TypeError', + Load(), + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=27), + [ + Constant( + 'Graph data malformed', + lineno=35, + col_offset=28, + end_lineno=35, + end_col_offset=50)], + [], + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=51), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=51)], + [], + lineno=34, + col_offset=8, + end_lineno=35, + end_col_offset=51), + For( + Name( + 'item', + Store(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=16), + Name( + 'data', + Load(), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=24), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=18), + [ + Name( + 'item', + Load(), + lineno=38, + col_offset=19, + end_lineno=38, + end_col_offset=23)], + [], + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=24), + [ + Lt()], + [ + Constant( + 3, + lineno=38, + col_offset=27, + end_lineno=38, + end_col_offset=28)], + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=28), + [ + Raise( + Call( + Name( + 'TypeError', + Load(), + lineno=39, + col_offset=22, + end_lineno=39, + end_col_offset=31), + [ + Constant( + 'Graph item incomplete', + lineno=39, + col_offset=32, + end_lineno=39, + end_col_offset=55)], + [], + lineno=39, + col_offset=22, + end_lineno=39, + end_col_offset=56), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=56)], + [], + lineno=38, + col_offset=12, + end_lineno=39, + end_col_offset=56), + Assign( + [ + Name( + 'type_', + Store(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=17)], + Subscript( + Name( + 'item', + Load(), + lineno=41, + col_offset=20, + end_lineno=41, + end_col_offset=24), + Constant( + 0, + lineno=41, + col_offset=25, + end_lineno=41, + end_col_offset=26), + Load(), + lineno=41, + col_offset=20, + end_lineno=41, + end_col_offset=27), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=27), + If( + Compare( + Name( + 'type_', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=20), + [ + Eq()], + [ + Name( + 'ATTR', + Load(), + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=28)], + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=28), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=22), + [ + Name( + 'item', + Load(), + lineno=43, + col_offset=23, + end_lineno=43, + end_col_offset=27)], + [], + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=28), + [ + NotEq()], + [ + Constant( + 3, + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=33)], + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=36), + [ + Constant( + 'Attribute is malformed', + lineno=44, + col_offset=37, + end_lineno=44, + end_col_offset=61)], + [], + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=62), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=62)], + [], + lineno=43, + col_offset=16, + end_lineno=44, + end_col_offset=62), + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=20), + 'attrs', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=26), + Subscript( + Name( + 'item', + Load(), + lineno=45, + col_offset=27, + end_lineno=45, + end_col_offset=31), + Constant( + 1, + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=33), + Load(), + lineno=45, + col_offset=27, + end_lineno=45, + end_col_offset=34), + Store(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=35)], + Subscript( + Name( + 'item', + Load(), + lineno=45, + col_offset=38, + end_lineno=45, + end_col_offset=42), + Constant( + 2, + lineno=45, + col_offset=43, + end_lineno=45, + end_col_offset=44), + Load(), + lineno=45, + col_offset=38, + end_lineno=45, + end_col_offset=45), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=45)], + [ + If( + Compare( + Name( + 'type_', + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=22), + [ + Eq()], + [ + Name( + 'NODE', + Load(), + lineno=46, + col_offset=26, + end_lineno=46, + end_col_offset=30)], + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=30), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=22), + [ + Name( + 'item', + Load(), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=27)], + [], + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=28), + [ + NotEq()], + [ + Constant( + 3, + lineno=47, + col_offset=32, + end_lineno=47, + end_col_offset=33)], + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=36), + [ + Constant( + 'Node is malformed', + lineno=48, + col_offset=37, + end_lineno=48, + end_col_offset=56)], + [], + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=57), + lineno=48, + col_offset=20, + end_lineno=48, + end_col_offset=57)], + [], + lineno=47, + col_offset=16, + end_lineno=48, + end_col_offset=57), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=20), + 'nodes', + Load(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=26), + 'append', + Load(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=33), + [ + Call( + Name( + 'Node', + Load(), + lineno=49, + col_offset=34, + end_lineno=49, + end_col_offset=38), + [ + Subscript( + Name( + 'item', + Load(), + lineno=49, + col_offset=39, + end_lineno=49, + end_col_offset=43), + Constant( + 1, + lineno=49, + col_offset=44, + end_lineno=49, + end_col_offset=45), + Load(), + lineno=49, + col_offset=39, + end_lineno=49, + end_col_offset=46), + Subscript( + Name( + 'item', + Load(), + lineno=49, + col_offset=48, + end_lineno=49, + end_col_offset=52), + Constant( + 2, + lineno=49, + col_offset=53, + end_lineno=49, + end_col_offset=54), + Load(), + lineno=49, + col_offset=48, + end_lineno=49, + end_col_offset=55)], + [], + lineno=49, + col_offset=34, + end_lineno=49, + end_col_offset=56)], + [], + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=57), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=57)], + [ + If( + Compare( + Name( + 'type_', + Load(), + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=22), + [ + Eq()], + [ + Name( + 'EDGE', + Load(), + lineno=50, + col_offset=26, + end_lineno=50, + end_col_offset=30)], + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=30), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=22), + [ + Name( + 'item', + Load(), + lineno=51, + col_offset=23, + end_lineno=51, + end_col_offset=27)], + [], + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=28), + [ + NotEq()], + [ + Constant( + 4, + lineno=51, + col_offset=32, + end_lineno=51, + end_col_offset=33)], + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=36), + [ + Constant( + 'Edge is malformed', + lineno=52, + col_offset=37, + end_lineno=52, + end_col_offset=56)], + [], + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=57), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=57)], + [], + lineno=51, + col_offset=16, + end_lineno=52, + end_col_offset=57), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=20), + 'edges', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=26), + 'append', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=33), + [ + Call( + Name( + 'Edge', + Load(), + lineno=53, + col_offset=34, + end_lineno=53, + end_col_offset=38), + [ + Subscript( + Name( + 'item', + Load(), + lineno=53, + col_offset=39, + end_lineno=53, + end_col_offset=43), + Constant( + 1, + lineno=53, + col_offset=44, + end_lineno=53, + end_col_offset=45), + Load(), + lineno=53, + col_offset=39, + end_lineno=53, + end_col_offset=46), + Subscript( + Name( + 'item', + Load(), + lineno=53, + col_offset=48, + end_lineno=53, + end_col_offset=52), + Constant( + 2, + lineno=53, + col_offset=53, + end_lineno=53, + end_col_offset=54), + Load(), + lineno=53, + col_offset=48, + end_lineno=53, + end_col_offset=55), + Subscript( + Name( + 'item', + Load(), + lineno=53, + col_offset=57, + end_lineno=53, + end_col_offset=61), + Constant( + 3, + lineno=53, + col_offset=62, + end_lineno=53, + end_col_offset=63), + Load(), + lineno=53, + col_offset=57, + end_lineno=53, + end_col_offset=64)], + [], + lineno=53, + col_offset=34, + end_lineno=53, + end_col_offset=65)], + [], + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=66), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=66)], + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=55, + col_offset=22, + end_lineno=55, + end_col_offset=32), + [ + Constant( + 'Unknown item', + lineno=55, + col_offset=33, + end_lineno=55, + end_col_offset=47)], + [], + lineno=55, + col_offset=22, + end_lineno=55, + end_col_offset=48), + lineno=55, + col_offset=16, + end_lineno=55, + end_col_offset=48)], + lineno=50, + col_offset=12, + end_lineno=55, + end_col_offset=48)], + lineno=46, + col_offset=12, + end_lineno=55, + end_col_offset=48)], + lineno=42, + col_offset=12, + end_lineno=55, + end_col_offset=48)], + [], + lineno=37, + col_offset=8, + end_lineno=55, + end_col_offset=48)], + [], + lineno=26, + col_offset=4, + end_lineno=55, + end_col_offset=48)], + [], + lineno=25, + col_offset=0, + end_lineno=55, + end_col_offset=48)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=4), + Name( + 'placeholder_1', + Store(), + lineno=1, + col_offset=6, + end_lineno=1, + end_col_offset=10), + Name( + 'placeholder_2', + Store(), + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=16)], + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16)], + Call( + Name( + 'range', + Load(), + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=24), + [ + Constant( + 3, + lineno=1, + col_offset=25, + end_lineno=1, + end_col_offset=26)], + [], + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=27), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=27), + ClassDef( + 'placeholder_3', + [], + [], + [ + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'placeholder_5', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=27), + arg( + 'placeholder_6', + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=17)], + Name( + 'placeholder_5', + Load(), + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=24), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=18)], + Name( + 'placeholder_6', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=26)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=26), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=19), + arg( + 'placeholder_8', + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=19), + 'placeholder_5', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=33), + 'placeholder_5', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=38)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=38), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=47), + 'placeholder_6', + Load(), + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=53), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=10, + col_offset=57, + end_lineno=10, + end_col_offset=62), + 'placeholder_6', + Load(), + lineno=10, + col_offset=57, + end_lineno=10, + end_col_offset=68)], + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=68)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=68), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=68)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=68)], + [], + lineno=4, + col_offset=0, + end_lineno=10, + end_col_offset=68), + ClassDef( + 'placeholder_9', + [], + [], + [ + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'placeholder_10', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=26), + arg( + 'placeholder_11', + lineno=14, + col_offset=28, + end_lineno=14, + end_col_offset=31), + arg( + 'placeholder_6', + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + 'placeholder_10', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=16)], + Name( + 'placeholder_10', + Load(), + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=22), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=12), + 'placeholder_11', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=16)], + Name( + 'placeholder_11', + Load(), + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=22), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=18)], + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=21, + end_lineno=17, + end_col_offset=26), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=26)], + [], + lineno=14, + col_offset=4, + end_lineno=17, + end_col_offset=26), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + arg( + 'placeholder_8', + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=20), + 'placeholder_10', + Load(), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=33), + 'placeholder_10', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=37)], + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=37), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=20), + 'placeholder_11', + Load(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=28, + end_lineno=21, + end_col_offset=33), + 'placeholder_11', + Load(), + lineno=21, + col_offset=28, + end_lineno=21, + end_col_offset=37)], + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=37), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20), + 'placeholder_6', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=26), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=22, + col_offset=30, + end_lineno=22, + end_col_offset=35), + 'placeholder_6', + Load(), + lineno=22, + col_offset=30, + end_lineno=22, + end_col_offset=41)], + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=41)], + lineno=20, + col_offset=16, + end_lineno=22, + end_col_offset=41), + lineno=20, + col_offset=8, + end_lineno=22, + end_col_offset=42)], + [], + lineno=19, + col_offset=4, + end_lineno=22, + end_col_offset=42)], + [], + lineno=13, + col_offset=0, + end_lineno=22, + end_col_offset=42), + ClassDef( + 'placeholder_12', + [], + [], + [ + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=21), + arg( + 'placeholder_13', + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=32)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=12), + 'placeholder_14', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=18)], + List( + [], + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=23), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=23), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=12), + 'placeholder_15', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=18)], + List( + [], + Load(), + lineno=28, + col_offset=21, + end_lineno=28, + end_col_offset=23), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=23), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=18)], + Dict( + [], + [], + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=23), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=23), + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=15), + [ + Is()], + [ + Constant( + None, + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=23)], + lineno=31, + col_offset=11, + end_lineno=31, + end_col_offset=23), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=16)], + List( + [], + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=21), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=21)], + [], + lineno=31, + col_offset=8, + end_lineno=32, + end_col_offset=21), + If( + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=25), + [ + Name( + 'placeholder_13', + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=30), + Name( + 'list', + Load(), + lineno=34, + col_offset=32, + end_lineno=34, + end_col_offset=36)], + [], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=37), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=37), + [ + Raise( + Call( + Name( + 'TypeError', + Load(), + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=27), + [ + Constant( + 'Graph data malformed', + lineno=35, + col_offset=28, + end_lineno=35, + end_col_offset=50)], + [], + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=51), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=51)], + [], + lineno=34, + col_offset=8, + end_lineno=35, + end_col_offset=51), + For( + Name( + 'placeholder_16', + Store(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=16), + Name( + 'placeholder_13', + Load(), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=24), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=18), + [ + Name( + 'placeholder_16', + Load(), + lineno=38, + col_offset=19, + end_lineno=38, + end_col_offset=23)], + [], + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=24), + [ + Lt()], + [ + Constant( + 3, + lineno=38, + col_offset=27, + end_lineno=38, + end_col_offset=28)], + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=28), + [ + Raise( + Call( + Name( + 'TypeError', + Load(), + lineno=39, + col_offset=22, + end_lineno=39, + end_col_offset=31), + [ + Constant( + 'Graph item incomplete', + lineno=39, + col_offset=32, + end_lineno=39, + end_col_offset=55)], + [], + lineno=39, + col_offset=22, + end_lineno=39, + end_col_offset=56), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=56)], + [], + lineno=38, + col_offset=12, + end_lineno=39, + end_col_offset=56), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=17)], + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=41, + col_offset=20, + end_lineno=41, + end_col_offset=24), + Constant( + 0, + lineno=41, + col_offset=25, + end_lineno=41, + end_col_offset=26), + Load(), + lineno=41, + col_offset=20, + end_lineno=41, + end_col_offset=27), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=27), + If( + Compare( + Name( + 'placeholder_17', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=20), + [ + Eq()], + [ + Name( + 'placeholder_2', + Load(), + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=28)], + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=28), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=22), + [ + Name( + 'placeholder_16', + Load(), + lineno=43, + col_offset=23, + end_lineno=43, + end_col_offset=27)], + [], + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=28), + [ + NotEq()], + [ + Constant( + 3, + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=33)], + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=36), + [ + Constant( + 'Attribute is malformed', + lineno=44, + col_offset=37, + end_lineno=44, + end_col_offset=61)], + [], + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=62), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=62)], + [], + lineno=43, + col_offset=16, + end_lineno=44, + end_col_offset=62), + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=20), + 'placeholder_6', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=26), + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=45, + col_offset=27, + end_lineno=45, + end_col_offset=31), + Constant( + 1, + lineno=45, + col_offset=32, + end_lineno=45, + end_col_offset=33), + Load(), + lineno=45, + col_offset=27, + end_lineno=45, + end_col_offset=34), + Store(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=35)], + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=45, + col_offset=38, + end_lineno=45, + end_col_offset=42), + Constant( + 2, + lineno=45, + col_offset=43, + end_lineno=45, + end_col_offset=44), + Load(), + lineno=45, + col_offset=38, + end_lineno=45, + end_col_offset=45), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=45)], + [ + If( + Compare( + Name( + 'placeholder_17', + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=22), + [ + Eq()], + [ + Name( + 'placeholder_0', + Load(), + lineno=46, + col_offset=26, + end_lineno=46, + end_col_offset=30)], + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=30), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=22), + [ + Name( + 'placeholder_16', + Load(), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=27)], + [], + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=28), + [ + NotEq()], + [ + Constant( + 3, + lineno=47, + col_offset=32, + end_lineno=47, + end_col_offset=33)], + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=36), + [ + Constant( + 'Node is malformed', + lineno=48, + col_offset=37, + end_lineno=48, + end_col_offset=56)], + [], + lineno=48, + col_offset=26, + end_lineno=48, + end_col_offset=57), + lineno=48, + col_offset=20, + end_lineno=48, + end_col_offset=57)], + [], + lineno=47, + col_offset=16, + end_lineno=48, + end_col_offset=57), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=20), + 'placeholder_14', + Load(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=26), + 'append', + Load(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=33), + [ + Call( + Name( + 'placeholder_3', + Load(), + lineno=49, + col_offset=34, + end_lineno=49, + end_col_offset=38), + [ + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=49, + col_offset=39, + end_lineno=49, + end_col_offset=43), + Constant( + 1, + lineno=49, + col_offset=44, + end_lineno=49, + end_col_offset=45), + Load(), + lineno=49, + col_offset=39, + end_lineno=49, + end_col_offset=46), + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=49, + col_offset=48, + end_lineno=49, + end_col_offset=52), + Constant( + 2, + lineno=49, + col_offset=53, + end_lineno=49, + end_col_offset=54), + Load(), + lineno=49, + col_offset=48, + end_lineno=49, + end_col_offset=55)], + [], + lineno=49, + col_offset=34, + end_lineno=49, + end_col_offset=56)], + [], + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=57), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=57)], + [ + If( + Compare( + Name( + 'placeholder_17', + Load(), + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=22), + [ + Eq()], + [ + Name( + 'placeholder_1', + Load(), + lineno=50, + col_offset=26, + end_lineno=50, + end_col_offset=30)], + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=30), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=22), + [ + Name( + 'placeholder_16', + Load(), + lineno=51, + col_offset=23, + end_lineno=51, + end_col_offset=27)], + [], + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=28), + [ + NotEq()], + [ + Constant( + 4, + lineno=51, + col_offset=32, + end_lineno=51, + end_col_offset=33)], + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=36), + [ + Constant( + 'Edge is malformed', + lineno=52, + col_offset=37, + end_lineno=52, + end_col_offset=56)], + [], + lineno=52, + col_offset=26, + end_lineno=52, + end_col_offset=57), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=57)], + [], + lineno=51, + col_offset=16, + end_lineno=52, + end_col_offset=57), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=20), + 'placeholder_15', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=26), + 'append', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=33), + [ + Call( + Name( + 'placeholder_9', + Load(), + lineno=53, + col_offset=34, + end_lineno=53, + end_col_offset=38), + [ + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=53, + col_offset=39, + end_lineno=53, + end_col_offset=43), + Constant( + 1, + lineno=53, + col_offset=44, + end_lineno=53, + end_col_offset=45), + Load(), + lineno=53, + col_offset=39, + end_lineno=53, + end_col_offset=46), + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=53, + col_offset=48, + end_lineno=53, + end_col_offset=52), + Constant( + 2, + lineno=53, + col_offset=53, + end_lineno=53, + end_col_offset=54), + Load(), + lineno=53, + col_offset=48, + end_lineno=53, + end_col_offset=55), + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=53, + col_offset=57, + end_lineno=53, + end_col_offset=61), + Constant( + 3, + lineno=53, + col_offset=62, + end_lineno=53, + end_col_offset=63), + Load(), + lineno=53, + col_offset=57, + end_lineno=53, + end_col_offset=64)], + [], + lineno=53, + col_offset=34, + end_lineno=53, + end_col_offset=65)], + [], + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=66), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=66)], + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=55, + col_offset=22, + end_lineno=55, + end_col_offset=32), + [ + Constant( + 'Unknown item', + lineno=55, + col_offset=33, + end_lineno=55, + end_col_offset=47)], + [], + lineno=55, + col_offset=22, + end_lineno=55, + end_col_offset=48), + lineno=55, + col_offset=16, + end_lineno=55, + end_col_offset=48)], + lineno=50, + col_offset=12, + end_lineno=55, + end_col_offset=48)], + lineno=46, + col_offset=12, + end_lineno=55, + end_col_offset=48)], + lineno=42, + col_offset=12, + end_lineno=55, + end_col_offset=48)], + [], + lineno=37, + col_offset=8, + end_lineno=55, + end_col_offset=48)], + [], + lineno=26, + col_offset=4, + end_lineno=55, + end_col_offset=48)], + [], + lineno=25, + col_offset=0, + end_lineno=55, + end_col_offset=48)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-dot-dsl/representation.txt b/test/practice-dot-dsl/representation.txt new file mode 100644 index 0000000..d968cbf --- /dev/null +++ b/test/practice-dot-dsl/representation.txt @@ -0,0 +1 @@ +Module([Assign([Tuple([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=4), Name('placeholder_1', Store(), lineno=1, col_offset=6, end_lineno=1, end_col_offset=10), Name('placeholder_2', Store(), lineno=1, col_offset=12, end_lineno=1, end_col_offset=16)], Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=16)], Call(Name('range', Load(), lineno=1, col_offset=19, end_lineno=1, end_col_offset=24), [Constant(3, lineno=1, col_offset=25, end_lineno=1, end_col_offset=26)], [], lineno=1, col_offset=19, end_lineno=1, end_col_offset=27), lineno=1, col_offset=0, end_lineno=1, end_col_offset=27), ClassDef('placeholder_3', [], [], [FunctionDef('placeholder_4', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21), arg('placeholder_5', lineno=5, col_offset=23, end_lineno=5, end_col_offset=27), arg('placeholder_6', lineno=5, col_offset=29, end_lineno=5, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_5', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=17)], Name('placeholder_5', Load(), lineno=6, col_offset=20, end_lineno=6, end_col_offset=24), lineno=6, col_offset=8, end_lineno=6, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_6', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=18)], Name('placeholder_6', Load(), lineno=7, col_offset=21, end_lineno=7, end_col_offset=26), lineno=7, col_offset=8, end_lineno=7, end_col_offset=26)], [], lineno=5, col_offset=4, end_lineno=7, end_col_offset=26), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=9, col_offset=15, end_lineno=9, end_col_offset=19), arg('placeholder_8', lineno=9, col_offset=21, end_lineno=9, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=19), 'placeholder_5', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=24), [Eq()], [Attribute(Name('placeholder_8', Load(), lineno=10, col_offset=28, end_lineno=10, end_col_offset=33), 'placeholder_5', Load(), lineno=10, col_offset=28, end_lineno=10, end_col_offset=38)], lineno=10, col_offset=15, end_lineno=10, end_col_offset=38), Compare(Attribute(Name('self', Load(), lineno=10, col_offset=43, end_lineno=10, end_col_offset=47), 'placeholder_6', Load(), lineno=10, col_offset=43, end_lineno=10, end_col_offset=53), [Eq()], [Attribute(Name('placeholder_8', Load(), lineno=10, col_offset=57, end_lineno=10, end_col_offset=62), 'placeholder_6', Load(), lineno=10, col_offset=57, end_lineno=10, end_col_offset=68)], lineno=10, col_offset=43, end_lineno=10, end_col_offset=68)], lineno=10, col_offset=15, end_lineno=10, end_col_offset=68), lineno=10, col_offset=8, end_lineno=10, end_col_offset=68)], [], lineno=9, col_offset=4, end_lineno=10, end_col_offset=68)], [], lineno=4, col_offset=0, end_lineno=10, end_col_offset=68), ClassDef('placeholder_9', [], [], [FunctionDef('placeholder_4', arguments([], [arg('self', lineno=14, col_offset=17, end_lineno=14, end_col_offset=21), arg('placeholder_10', lineno=14, col_offset=23, end_lineno=14, end_col_offset=26), arg('placeholder_11', lineno=14, col_offset=28, end_lineno=14, end_col_offset=31), arg('placeholder_6', lineno=14, col_offset=33, end_lineno=14, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=12), 'placeholder_10', Store(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=16)], Name('placeholder_10', Load(), lineno=15, col_offset=19, end_lineno=15, end_col_offset=22), lineno=15, col_offset=8, end_lineno=15, end_col_offset=22), Assign([Attribute(Name('self', Load(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=12), 'placeholder_11', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=16)], Name('placeholder_11', Load(), lineno=16, col_offset=19, end_lineno=16, end_col_offset=22), lineno=16, col_offset=8, end_lineno=16, end_col_offset=22), Assign([Attribute(Name('self', Load(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=12), 'placeholder_6', Store(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=18)], Name('placeholder_6', Load(), lineno=17, col_offset=21, end_lineno=17, end_col_offset=26), lineno=17, col_offset=8, end_lineno=17, end_col_offset=26)], [], lineno=14, col_offset=4, end_lineno=17, end_col_offset=26), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=19, col_offset=15, end_lineno=19, end_col_offset=19), arg('placeholder_8', lineno=19, col_offset=21, end_lineno=19, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=20, col_offset=16, end_lineno=20, end_col_offset=20), 'placeholder_10', Load(), lineno=20, col_offset=16, end_lineno=20, end_col_offset=24), [Eq()], [Attribute(Name('placeholder_8', Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=33), 'placeholder_10', Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=37)], lineno=20, col_offset=16, end_lineno=20, end_col_offset=37), Compare(Attribute(Name('self', Load(), lineno=21, col_offset=16, end_lineno=21, end_col_offset=20), 'placeholder_11', Load(), lineno=21, col_offset=16, end_lineno=21, end_col_offset=24), [Eq()], [Attribute(Name('placeholder_8', Load(), lineno=21, col_offset=28, end_lineno=21, end_col_offset=33), 'placeholder_11', Load(), lineno=21, col_offset=28, end_lineno=21, end_col_offset=37)], lineno=21, col_offset=16, end_lineno=21, end_col_offset=37), Compare(Attribute(Name('self', Load(), lineno=22, col_offset=16, end_lineno=22, end_col_offset=20), 'placeholder_6', Load(), lineno=22, col_offset=16, end_lineno=22, end_col_offset=26), [Eq()], [Attribute(Name('placeholder_8', Load(), lineno=22, col_offset=30, end_lineno=22, end_col_offset=35), 'placeholder_6', Load(), lineno=22, col_offset=30, end_lineno=22, end_col_offset=41)], lineno=22, col_offset=16, end_lineno=22, end_col_offset=41)], lineno=20, col_offset=16, end_lineno=22, end_col_offset=41), lineno=20, col_offset=8, end_lineno=22, end_col_offset=42)], [], lineno=19, col_offset=4, end_lineno=22, end_col_offset=42)], [], lineno=13, col_offset=0, end_lineno=22, end_col_offset=42), ClassDef('placeholder_12', [], [], [FunctionDef('placeholder_4', arguments([], [arg('self', lineno=26, col_offset=17, end_lineno=26, end_col_offset=21), arg('placeholder_13', lineno=26, col_offset=23, end_lineno=26, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=26, col_offset=28, end_lineno=26, end_col_offset=32)]), [Assign([Attribute(Name('self', Load(), lineno=27, col_offset=8, end_lineno=27, end_col_offset=12), 'placeholder_14', Store(), lineno=27, col_offset=8, end_lineno=27, end_col_offset=18)], List([], Load(), lineno=27, col_offset=21, end_lineno=27, end_col_offset=23), lineno=27, col_offset=8, end_lineno=27, end_col_offset=23), Assign([Attribute(Name('self', Load(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=12), 'placeholder_15', Store(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=18)], List([], Load(), lineno=28, col_offset=21, end_lineno=28, end_col_offset=23), lineno=28, col_offset=8, end_lineno=28, end_col_offset=23), Assign([Attribute(Name('self', Load(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=12), 'placeholder_6', Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=18)], Dict([], [], lineno=29, col_offset=21, end_lineno=29, end_col_offset=23), lineno=29, col_offset=8, end_lineno=29, end_col_offset=23), If(Compare(Name('placeholder_13', Load(), lineno=31, col_offset=11, end_lineno=31, end_col_offset=15), [Is()], [Constant(None, lineno=31, col_offset=19, end_lineno=31, end_col_offset=23)], lineno=31, col_offset=11, end_lineno=31, end_col_offset=23), [Assign([Name('placeholder_13', Store(), lineno=32, col_offset=12, end_lineno=32, end_col_offset=16)], List([], Load(), lineno=32, col_offset=19, end_lineno=32, end_col_offset=21), lineno=32, col_offset=12, end_lineno=32, end_col_offset=21)], [], lineno=31, col_offset=8, end_lineno=32, end_col_offset=21), If(UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=25), [Name('placeholder_13', Load(), lineno=34, col_offset=26, end_lineno=34, end_col_offset=30), Name('list', Load(), lineno=34, col_offset=32, end_lineno=34, end_col_offset=36)], [], lineno=34, col_offset=15, end_lineno=34, end_col_offset=37), lineno=34, col_offset=11, end_lineno=34, end_col_offset=37), [Raise(Call(Name('TypeError', Load(), lineno=35, col_offset=18, end_lineno=35, end_col_offset=27), [Constant('Graph data malformed', lineno=35, col_offset=28, end_lineno=35, end_col_offset=50)], [], lineno=35, col_offset=18, end_lineno=35, end_col_offset=51), lineno=35, col_offset=12, end_lineno=35, end_col_offset=51)], [], lineno=34, col_offset=8, end_lineno=35, end_col_offset=51), For(Name('placeholder_16', Store(), lineno=37, col_offset=12, end_lineno=37, end_col_offset=16), Name('placeholder_13', Load(), lineno=37, col_offset=20, end_lineno=37, end_col_offset=24), [If(Compare(Call(Name('len', Load(), lineno=38, col_offset=15, end_lineno=38, end_col_offset=18), [Name('placeholder_16', Load(), lineno=38, col_offset=19, end_lineno=38, end_col_offset=23)], [], lineno=38, col_offset=15, end_lineno=38, end_col_offset=24), [Lt()], [Constant(3, lineno=38, col_offset=27, end_lineno=38, end_col_offset=28)], lineno=38, col_offset=15, end_lineno=38, end_col_offset=28), [Raise(Call(Name('TypeError', Load(), lineno=39, col_offset=22, end_lineno=39, end_col_offset=31), [Constant('Graph item incomplete', lineno=39, col_offset=32, end_lineno=39, end_col_offset=55)], [], lineno=39, col_offset=22, end_lineno=39, end_col_offset=56), lineno=39, col_offset=16, end_lineno=39, end_col_offset=56)], [], lineno=38, col_offset=12, end_lineno=39, end_col_offset=56), Assign([Name('placeholder_17', Store(), lineno=41, col_offset=12, end_lineno=41, end_col_offset=17)], Subscript(Name('placeholder_16', Load(), lineno=41, col_offset=20, end_lineno=41, end_col_offset=24), Constant(0, lineno=41, col_offset=25, end_lineno=41, end_col_offset=26), Load(), lineno=41, col_offset=20, end_lineno=41, end_col_offset=27), lineno=41, col_offset=12, end_lineno=41, end_col_offset=27), If(Compare(Name('placeholder_17', Load(), lineno=42, col_offset=15, end_lineno=42, end_col_offset=20), [Eq()], [Name('placeholder_2', Load(), lineno=42, col_offset=24, end_lineno=42, end_col_offset=28)], lineno=42, col_offset=15, end_lineno=42, end_col_offset=28), [If(Compare(Call(Name('len', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=22), [Name('placeholder_16', Load(), lineno=43, col_offset=23, end_lineno=43, end_col_offset=27)], [], lineno=43, col_offset=19, end_lineno=43, end_col_offset=28), [NotEq()], [Constant(3, lineno=43, col_offset=32, end_lineno=43, end_col_offset=33)], lineno=43, col_offset=19, end_lineno=43, end_col_offset=33), [Raise(Call(Name('ValueError', Load(), lineno=44, col_offset=26, end_lineno=44, end_col_offset=36), [Constant('Attribute is malformed', lineno=44, col_offset=37, end_lineno=44, end_col_offset=61)], [], lineno=44, col_offset=26, end_lineno=44, end_col_offset=62), lineno=44, col_offset=20, end_lineno=44, end_col_offset=62)], [], lineno=43, col_offset=16, end_lineno=44, end_col_offset=62), Assign([Subscript(Attribute(Name('self', Load(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=20), 'placeholder_6', Load(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=26), Subscript(Name('placeholder_16', Load(), lineno=45, col_offset=27, end_lineno=45, end_col_offset=31), Constant(1, lineno=45, col_offset=32, end_lineno=45, end_col_offset=33), Load(), lineno=45, col_offset=27, end_lineno=45, end_col_offset=34), Store(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=35)], Subscript(Name('placeholder_16', Load(), lineno=45, col_offset=38, end_lineno=45, end_col_offset=42), Constant(2, lineno=45, col_offset=43, end_lineno=45, end_col_offset=44), Load(), lineno=45, col_offset=38, end_lineno=45, end_col_offset=45), lineno=45, col_offset=16, end_lineno=45, end_col_offset=45)], [If(Compare(Name('placeholder_17', Load(), lineno=46, col_offset=17, end_lineno=46, end_col_offset=22), [Eq()], [Name('placeholder_0', Load(), lineno=46, col_offset=26, end_lineno=46, end_col_offset=30)], lineno=46, col_offset=17, end_lineno=46, end_col_offset=30), [If(Compare(Call(Name('len', Load(), lineno=47, col_offset=19, end_lineno=47, end_col_offset=22), [Name('placeholder_16', Load(), lineno=47, col_offset=23, end_lineno=47, end_col_offset=27)], [], lineno=47, col_offset=19, end_lineno=47, end_col_offset=28), [NotEq()], [Constant(3, lineno=47, col_offset=32, end_lineno=47, end_col_offset=33)], lineno=47, col_offset=19, end_lineno=47, end_col_offset=33), [Raise(Call(Name('ValueError', Load(), lineno=48, col_offset=26, end_lineno=48, end_col_offset=36), [Constant('Node is malformed', lineno=48, col_offset=37, end_lineno=48, end_col_offset=56)], [], lineno=48, col_offset=26, end_lineno=48, end_col_offset=57), lineno=48, col_offset=20, end_lineno=48, end_col_offset=57)], [], lineno=47, col_offset=16, end_lineno=48, end_col_offset=57), Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=49, col_offset=16, end_lineno=49, end_col_offset=20), 'placeholder_14', Load(), lineno=49, col_offset=16, end_lineno=49, end_col_offset=26), 'append', Load(), lineno=49, col_offset=16, end_lineno=49, end_col_offset=33), [Call(Name('placeholder_3', Load(), lineno=49, col_offset=34, end_lineno=49, end_col_offset=38), [Subscript(Name('placeholder_16', Load(), lineno=49, col_offset=39, end_lineno=49, end_col_offset=43), Constant(1, lineno=49, col_offset=44, end_lineno=49, end_col_offset=45), Load(), lineno=49, col_offset=39, end_lineno=49, end_col_offset=46), Subscript(Name('placeholder_16', Load(), lineno=49, col_offset=48, end_lineno=49, end_col_offset=52), Constant(2, lineno=49, col_offset=53, end_lineno=49, end_col_offset=54), Load(), lineno=49, col_offset=48, end_lineno=49, end_col_offset=55)], [], lineno=49, col_offset=34, end_lineno=49, end_col_offset=56)], [], lineno=49, col_offset=16, end_lineno=49, end_col_offset=57), lineno=49, col_offset=16, end_lineno=49, end_col_offset=57)], [If(Compare(Name('placeholder_17', Load(), lineno=50, col_offset=17, end_lineno=50, end_col_offset=22), [Eq()], [Name('placeholder_1', Load(), lineno=50, col_offset=26, end_lineno=50, end_col_offset=30)], lineno=50, col_offset=17, end_lineno=50, end_col_offset=30), [If(Compare(Call(Name('len', Load(), lineno=51, col_offset=19, end_lineno=51, end_col_offset=22), [Name('placeholder_16', Load(), lineno=51, col_offset=23, end_lineno=51, end_col_offset=27)], [], lineno=51, col_offset=19, end_lineno=51, end_col_offset=28), [NotEq()], [Constant(4, lineno=51, col_offset=32, end_lineno=51, end_col_offset=33)], lineno=51, col_offset=19, end_lineno=51, end_col_offset=33), [Raise(Call(Name('ValueError', Load(), lineno=52, col_offset=26, end_lineno=52, end_col_offset=36), [Constant('Edge is malformed', lineno=52, col_offset=37, end_lineno=52, end_col_offset=56)], [], lineno=52, col_offset=26, end_lineno=52, end_col_offset=57), lineno=52, col_offset=20, end_lineno=52, end_col_offset=57)], [], lineno=51, col_offset=16, end_lineno=52, end_col_offset=57), Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=53, col_offset=16, end_lineno=53, end_col_offset=20), 'placeholder_15', Load(), lineno=53, col_offset=16, end_lineno=53, end_col_offset=26), 'append', Load(), lineno=53, col_offset=16, end_lineno=53, end_col_offset=33), [Call(Name('placeholder_9', Load(), lineno=53, col_offset=34, end_lineno=53, end_col_offset=38), [Subscript(Name('placeholder_16', Load(), lineno=53, col_offset=39, end_lineno=53, end_col_offset=43), Constant(1, lineno=53, col_offset=44, end_lineno=53, end_col_offset=45), Load(), lineno=53, col_offset=39, end_lineno=53, end_col_offset=46), Subscript(Name('placeholder_16', Load(), lineno=53, col_offset=48, end_lineno=53, end_col_offset=52), Constant(2, lineno=53, col_offset=53, end_lineno=53, end_col_offset=54), Load(), lineno=53, col_offset=48, end_lineno=53, end_col_offset=55), Subscript(Name('placeholder_16', Load(), lineno=53, col_offset=57, end_lineno=53, end_col_offset=61), Constant(3, lineno=53, col_offset=62, end_lineno=53, end_col_offset=63), Load(), lineno=53, col_offset=57, end_lineno=53, end_col_offset=64)], [], lineno=53, col_offset=34, end_lineno=53, end_col_offset=65)], [], lineno=53, col_offset=16, end_lineno=53, end_col_offset=66), lineno=53, col_offset=16, end_lineno=53, end_col_offset=66)], [Raise(Call(Name('ValueError', Load(), lineno=55, col_offset=22, end_lineno=55, end_col_offset=32), [Constant('Unknown item', lineno=55, col_offset=33, end_lineno=55, end_col_offset=47)], [], lineno=55, col_offset=22, end_lineno=55, end_col_offset=48), lineno=55, col_offset=16, end_lineno=55, end_col_offset=48)], lineno=50, col_offset=12, end_lineno=55, end_col_offset=48)], lineno=46, col_offset=12, end_lineno=55, end_col_offset=48)], lineno=42, col_offset=12, end_lineno=55, end_col_offset=48)], [], lineno=37, col_offset=8, end_lineno=55, end_col_offset=48)], [], lineno=26, col_offset=4, end_lineno=55, end_col_offset=48)], [], lineno=25, col_offset=0, end_lineno=55, end_col_offset=48)], []) \ No newline at end of file diff --git a/test/practice-error-handling/.meta/config.json b/test/practice-error-handling/.meta/config.json new file mode 100644 index 0000000..5664886 --- /dev/null +++ b/test/practice-error-handling/.meta/config.json @@ -0,0 +1,23 @@ +{ + "blurb": "Implement various kinds of error handling and resource management.", + "authors": [ + "cmccandless" + ], + "contributors": [ + "BethanyG", + "Dog", + "N-Parsons", + "tqa236" + ], + "files": { + "solution": [ + "error_handling.py" + ], + "test": [ + "error_handling_test.py" + ], + "example": [ + ".meta/example.py" + ] + } +} diff --git a/test/practice-error-handling/error_handling.py b/test/practice-error-handling/error_handling.py new file mode 100644 index 0000000..1dba190 --- /dev/null +++ b/test/practice-error-handling/error_handling.py @@ -0,0 +1,21 @@ +def handle_error_by_throwing_exception(): + raise Exception('Meaningful message describing the source of the error') + + +def handle_error_by_returning_none(input_data): + try: + return int(input_data) + except ValueError: + return None + + +def handle_error_by_returning_tuple(input_data): + try: + return (True, int(input_data)) + except ValueError: + return (False, None) + + +def filelike_objects_are_closed_on_exception(filelike_object): + with filelike_object as file_obj: + file_obj.do_something() diff --git a/test/practice-error-handling/mapping.json b/test/practice-error-handling/mapping.json new file mode 100644 index 0000000..9dc9557 --- /dev/null +++ b/test/practice-error-handling/mapping.json @@ -0,0 +1,9 @@ +{ + "placeholder_0": "handle_error_by_throwing_exception", + "placeholder_1": "handle_error_by_returning_none", + "placeholder_2": "input_data", + "placeholder_3": "handle_error_by_returning_tuple", + "placeholder_4": "filelike_objects_are_closed_on_exception", + "placeholder_5": "filelike_object", + "placeholder_6": "file_obj" +} \ No newline at end of file diff --git a/test/practice-error-handling/representation.json b/test/practice-error-handling/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-error-handling/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-error-handling/representation.out b/test/practice-error-handling/representation.out new file mode 100644 index 0000000..7d13562 --- /dev/null +++ b/test/practice-error-handling/representation.out @@ -0,0 +1,618 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(): + raise Exception("Meaningful message describing the source of the error") + + +def placeholder_1(placeholder_2): + try: + return int(placeholder_2) + except ValueError: + return None + + +def placeholder_3(placeholder_2): + try: + return (True, int(placeholder_2)) + except ValueError: + return (False, None) + + +def placeholder_4(placeholder_5): + with placeholder_5 as placeholder_6: + placeholder_6.do_something() + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'handle_error_by_throwing_exception', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Raise( + Call( + Name( + 'Exception', + Load(), + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=19), + [ + Constant( + 'Meaningful message describing the source of the error', + lineno=2, + col_offset=20, + end_lineno=2, + end_col_offset=75)], + [], + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=76), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=76)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=76), + FunctionDef( + 'handle_error_by_returning_none', + arguments( + [], + [ + arg( + 'input_data', + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Return( + Call( + Name( + 'int', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=18), + [ + Name( + 'input_data', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=29)], + [], + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=30), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=30)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=21), + body=[ + Return( + Constant( + None, + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=19), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=19)], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=19)], + [], + [], + lineno=6, + col_offset=4, + end_lineno=9, + end_col_offset=19)], + [], + lineno=5, + col_offset=0, + end_lineno=9, + end_col_offset=19), + FunctionDef( + 'handle_error_by_returning_tuple', + arguments( + [], + [ + arg( + 'input_data', + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Return( + Tuple( + [ + Constant( + True, + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=20), + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=25), + [ + Name( + 'input_data', + Load(), + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=36)], + [], + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=37)], + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=38), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=38)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=21), + body=[ + Return( + Tuple( + [ + Constant( + False, + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=21), + Constant( + None, + lineno=16, + col_offset=23, + end_lineno=16, + end_col_offset=27)], + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=28), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=28)], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=28)], + [], + [], + lineno=13, + col_offset=4, + end_lineno=16, + end_col_offset=28)], + [], + lineno=12, + col_offset=0, + end_lineno=16, + end_col_offset=28), + FunctionDef( + 'filelike_objects_are_closed_on_exception', + arguments( + [], + [ + arg( + 'filelike_object', + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=60)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + With( + [ + withitem( + Name( + 'filelike_object', + Load(), + lineno=20, + col_offset=9, + end_lineno=20, + end_col_offset=24), + Name( + 'file_obj', + Store(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=36))], + [ + Expr( + Call( + Attribute( + Name( + 'file_obj', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=16), + 'do_something', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=29), + [], + [], + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=31), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=31)], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=31)], + [], + lineno=19, + col_offset=0, + end_lineno=21, + end_col_offset=31)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Raise( + Call( + Name( + 'Exception', + Load(), + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=19), + [ + Constant( + 'Meaningful message describing the source of the error', + lineno=2, + col_offset=20, + end_lineno=2, + end_col_offset=75)], + [], + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=76), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=76)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=76), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Return( + Call( + Name( + 'int', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=18), + [ + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=29)], + [], + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=30), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=30)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=21), + body=[ + Return( + Constant( + None, + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=19), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=19)], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=19)], + [], + [], + lineno=6, + col_offset=4, + end_lineno=9, + end_col_offset=19)], + [], + lineno=5, + col_offset=0, + end_lineno=9, + end_col_offset=19), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Return( + Tuple( + [ + Constant( + True, + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=20), + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=25), + [ + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=36)], + [], + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=37)], + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=38), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=38)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=21), + body=[ + Return( + Tuple( + [ + Constant( + False, + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=21), + Constant( + None, + lineno=16, + col_offset=23, + end_lineno=16, + end_col_offset=27)], + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=28), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=28)], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=28)], + [], + [], + lineno=13, + col_offset=4, + end_lineno=16, + end_col_offset=28)], + [], + lineno=12, + col_offset=0, + end_lineno=16, + end_col_offset=28), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=60)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + With( + [ + withitem( + Name( + 'placeholder_5', + Load(), + lineno=20, + col_offset=9, + end_lineno=20, + end_col_offset=24), + Name( + 'placeholder_6', + Store(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=36))], + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=16), + 'do_something', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=29), + [], + [], + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=31), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=31)], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=31)], + [], + lineno=19, + col_offset=0, + end_lineno=21, + end_col_offset=31)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-error-handling/representation.txt b/test/practice-error-handling/representation.txt new file mode 100644 index 0000000..bb22856 --- /dev/null +++ b/test/practice-error-handling/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Raise(Call(Name('Exception', Load(), lineno=2, col_offset=10, end_lineno=2, end_col_offset=19), [Constant('Meaningful message describing the source of the error', lineno=2, col_offset=20, end_lineno=2, end_col_offset=75)], [], lineno=2, col_offset=10, end_lineno=2, end_col_offset=76), lineno=2, col_offset=4, end_lineno=2, end_col_offset=76)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=76), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=5, col_offset=35, end_lineno=5, end_col_offset=45)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Try([Return(Call(Name('int', Load(), lineno=7, col_offset=15, end_lineno=7, end_col_offset=18), [Name('placeholder_2', Load(), lineno=7, col_offset=19, end_lineno=7, end_col_offset=29)], [], lineno=7, col_offset=15, end_lineno=7, end_col_offset=30), lineno=7, col_offset=8, end_lineno=7, end_col_offset=30)], [ExceptHandler(Name('ValueError', Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=21), body=[Return(Constant(None, lineno=9, col_offset=15, end_lineno=9, end_col_offset=19), lineno=9, col_offset=8, end_lineno=9, end_col_offset=19)], lineno=8, col_offset=4, end_lineno=9, end_col_offset=19)], [], [], lineno=6, col_offset=4, end_lineno=9, end_col_offset=19)], [], lineno=5, col_offset=0, end_lineno=9, end_col_offset=19), FunctionDef('placeholder_3', arguments([], [arg('placeholder_2', lineno=12, col_offset=36, end_lineno=12, end_col_offset=46)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Try([Return(Tuple([Constant(True, lineno=14, col_offset=16, end_lineno=14, end_col_offset=20), Call(Name('int', Load(), lineno=14, col_offset=22, end_lineno=14, end_col_offset=25), [Name('placeholder_2', Load(), lineno=14, col_offset=26, end_lineno=14, end_col_offset=36)], [], lineno=14, col_offset=22, end_lineno=14, end_col_offset=37)], Load(), lineno=14, col_offset=15, end_lineno=14, end_col_offset=38), lineno=14, col_offset=8, end_lineno=14, end_col_offset=38)], [ExceptHandler(Name('ValueError', Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=21), body=[Return(Tuple([Constant(False, lineno=16, col_offset=16, end_lineno=16, end_col_offset=21), Constant(None, lineno=16, col_offset=23, end_lineno=16, end_col_offset=27)], Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=28), lineno=16, col_offset=8, end_lineno=16, end_col_offset=28)], lineno=15, col_offset=4, end_lineno=16, end_col_offset=28)], [], [], lineno=13, col_offset=4, end_lineno=16, end_col_offset=28)], [], lineno=12, col_offset=0, end_lineno=16, end_col_offset=28), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=19, col_offset=45, end_lineno=19, end_col_offset=60)], kwonlyargs=[], kw_defaults=[], defaults=[]), [With([withitem(Name('placeholder_5', Load(), lineno=20, col_offset=9, end_lineno=20, end_col_offset=24), Name('placeholder_6', Store(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=36))], [Expr(Call(Attribute(Name('placeholder_6', Load(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=16), 'do_something', Load(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=29), [], [], lineno=21, col_offset=8, end_lineno=21, end_col_offset=31), lineno=21, col_offset=8, end_lineno=21, end_col_offset=31)], lineno=20, col_offset=4, end_lineno=21, end_col_offset=31)], [], lineno=19, col_offset=0, end_lineno=21, end_col_offset=31)], []) \ No newline at end of file diff --git a/test/practice-etl/.meta/config.json b/test/practice-etl/.meta/config.json new file mode 100644 index 0000000..32aab8b --- /dev/null +++ b/test/practice-etl/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [], + "contributors": [ + "alirezaghey", + "behrtam", + "cmccandless", + "Dog", + "etrepum", + "ikhadykin", + "kytrinyx", + "lowks", + "Mofeywalker", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "etl.py" + ], + "test": [ + "etl_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Change the data format for scoring a game to more easily add other languages.", + "source": "Based on an exercise by the JumpstartLab team for students at The Turing School of Software and Design.", + "source_url": "https://turing.edu" +} diff --git a/test/practice-etl/etl.py b/test/practice-etl/etl.py new file mode 100644 index 0000000..0e2b658 --- /dev/null +++ b/test/practice-etl/etl.py @@ -0,0 +1,6 @@ +def transform(legacy_data): + return { + letter.lower(): points + for points, letters in legacy_data.items() + for letter in letters + } diff --git a/test/practice-etl/mapping.json b/test/practice-etl/mapping.json new file mode 100644 index 0000000..11e01f0 --- /dev/null +++ b/test/practice-etl/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "transform", + "placeholder_1": "legacy_data", + "placeholder_2": "points", + "placeholder_3": "letters", + "placeholder_4": "letter" +} \ No newline at end of file diff --git a/test/practice-etl/representation.json b/test/practice-etl/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-etl/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-etl/representation.out b/test/practice-etl/representation.out new file mode 100644 index 0000000..6463518 --- /dev/null +++ b/test/practice-etl/representation.out @@ -0,0 +1,263 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return { + placeholder_4.lower(): placeholder_2 + for placeholder_2, placeholder_3 in placeholder_1.items() + for placeholder_4 in placeholder_3 + } + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'transform', + arguments( + [], + [ + arg( + 'legacy_data', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + DictComp( + Call( + Attribute( + Name( + 'letter', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=14), + 'lower', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=20), + [], + [], + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=22), + Name( + 'points', + Load(), + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=30), + [ + comprehension( + Tuple( + [ + Name( + 'points', + Store(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=18), + Name( + 'letters', + Store(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=27)], + Store(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=27), + Call( + Attribute( + Name( + 'legacy_data', + Load(), + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=42), + 'items', + Load(), + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=48), + [], + [], + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=50), + [], + 0), + comprehension( + Name( + 'letter', + Store(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=18), + Name( + 'letters', + Load(), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=29), + [], + 0)], + lineno=2, + col_offset=11, + end_lineno=6, + end_col_offset=5), + lineno=2, + col_offset=4, + end_lineno=6, + end_col_offset=5)], + [], + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=5)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + DictComp( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=14), + 'lower', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=20), + [], + [], + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=22), + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=30), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_2', + Store(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=18), + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=27)], + Store(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=27), + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=42), + 'items', + Load(), + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=48), + [], + [], + lineno=4, + col_offset=31, + end_lineno=4, + end_col_offset=50), + [], + 0), + comprehension( + Name( + 'placeholder_4', + Store(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=18), + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=29), + [], + 0)], + lineno=2, + col_offset=11, + end_lineno=6, + end_col_offset=5), + lineno=2, + col_offset=4, + end_lineno=6, + end_col_offset=5)], + [], + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=5)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-etl/representation.txt b/test/practice-etl/representation.txt new file mode 100644 index 0000000..b3582dd --- /dev/null +++ b/test/practice-etl/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=14, end_lineno=1, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(DictComp(Call(Attribute(Name('placeholder_4', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=14), 'lower', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=20), [], [], lineno=3, col_offset=8, end_lineno=3, end_col_offset=22), Name('placeholder_2', Load(), lineno=3, col_offset=24, end_lineno=3, end_col_offset=30), [comprehension(Tuple([Name('placeholder_2', Store(), lineno=4, col_offset=12, end_lineno=4, end_col_offset=18), Name('placeholder_3', Store(), lineno=4, col_offset=20, end_lineno=4, end_col_offset=27)], Store(), lineno=4, col_offset=12, end_lineno=4, end_col_offset=27), Call(Attribute(Name('placeholder_1', Load(), lineno=4, col_offset=31, end_lineno=4, end_col_offset=42), 'items', Load(), lineno=4, col_offset=31, end_lineno=4, end_col_offset=48), [], [], lineno=4, col_offset=31, end_lineno=4, end_col_offset=50), [], 0), comprehension(Name('placeholder_4', Store(), lineno=5, col_offset=12, end_lineno=5, end_col_offset=18), Name('placeholder_3', Load(), lineno=5, col_offset=22, end_lineno=5, end_col_offset=29), [], 0)], lineno=2, col_offset=11, end_lineno=6, end_col_offset=5), lineno=2, col_offset=4, end_lineno=6, end_col_offset=5)], [], lineno=1, col_offset=0, end_lineno=6, end_col_offset=5)], []) \ No newline at end of file diff --git a/test/practice-flatten-array/.meta/config.json b/test/practice-flatten-array/.meta/config.json new file mode 100644 index 0000000..bd0ec35 --- /dev/null +++ b/test/practice-flatten-array/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "treyhunner" + ], + "contributors": [ + "AiryShift", + "alexpjohnson", + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "N-Parsons", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "flatten_array.py" + ], + "test": [ + "flatten_array_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Take a nested list and return a single list with all values except nil/null.", + "source": "Interview Question", + "source_url": "https://reference.wolfram.com/language/ref/Flatten.html" +} diff --git a/test/practice-flatten-array/flatten_array.py b/test/practice-flatten-array/flatten_array.py new file mode 100644 index 0000000..424f01e --- /dev/null +++ b/test/practice-flatten-array/flatten_array.py @@ -0,0 +1,18 @@ +def is_iterable(thing): + try: + iter(thing) + except TypeError: + return False + else: + return True + + +def flatten(iterable): + """Flatten a list of lists.""" + flattened = [] + for item in iterable: + if is_iterable(item) and not isinstance(item, (str, bytes)): + flattened += flatten(item) + elif item is not None: + flattened.append(item) + return flattened diff --git a/test/practice-flatten-array/mapping.json b/test/practice-flatten-array/mapping.json new file mode 100644 index 0000000..446b67b --- /dev/null +++ b/test/practice-flatten-array/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "is_iterable", + "placeholder_1": "thing", + "placeholder_2": "flatten", + "placeholder_3": "iterable", + "placeholder_4": "flattened", + "placeholder_5": "item" +} \ No newline at end of file diff --git a/test/practice-flatten-array/representation.json b/test/practice-flatten-array/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-flatten-array/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-flatten-array/representation.out b/test/practice-flatten-array/representation.out new file mode 100644 index 0000000..98bf4ad --- /dev/null +++ b/test/practice-flatten-array/representation.out @@ -0,0 +1,727 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + try: + iter(placeholder_1) + except TypeError: + return False + else: + return True + + +def placeholder_2(placeholder_3): + placeholder_4 = [] + for placeholder_5 in placeholder_3: + if placeholder_0(placeholder_5) and ( + not isinstance(placeholder_5, (str, bytes)) + ): + placeholder_4 += placeholder_2(placeholder_5) + elif placeholder_5 is not None: + placeholder_4.append(placeholder_5) + return placeholder_4 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'is_iterable', + arguments( + [], + [ + arg( + 'thing', + lineno=1, + col_offset=16, + end_lineno=1, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Expr( + Call( + Name( + 'iter', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + [ + Name( + 'thing', + Load(), + lineno=3, + col_offset=13, + end_lineno=3, + end_col_offset=18)], + [], + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=19), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=19)], + [ + ExceptHandler( + Name( + 'TypeError', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=20), + body=[ + Return( + Constant( + False, + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=20), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=20)], + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=20)], + [ + Return( + Constant( + True, + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=19), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=19)], + [], + lineno=2, + col_offset=4, + end_lineno=7, + end_col_offset=19)], + [], + lineno=1, + col_offset=0, + end_lineno=7, + end_col_offset=19), + FunctionDef( + 'flatten', + arguments( + [], + [ + arg( + 'iterable', + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Flatten a list of lists.', + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=34), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=34), + Assign( + [ + Name( + 'flattened', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=13)], + List( + [], + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=18), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=18), + For( + Name( + 'item', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + Name( + 'iterable', + Load(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=24), + [ + If( + BoolOp( + And(), + [ + Call( + Name( + 'is_iterable', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=22), + [ + Name( + 'item', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=27)], + [], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=28), + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=14, + col_offset=37, + end_lineno=14, + end_col_offset=47), + [ + Name( + 'item', + Load(), + lineno=14, + col_offset=48, + end_lineno=14, + end_col_offset=52), + Tuple( + [ + Name( + 'str', + Load(), + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=58), + Name( + 'bytes', + Load(), + lineno=14, + col_offset=60, + end_lineno=14, + end_col_offset=65)], + Load(), + lineno=14, + col_offset=54, + end_lineno=14, + end_col_offset=66)], + [], + lineno=14, + col_offset=37, + end_lineno=14, + end_col_offset=67), + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=67)], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=67), + [ + AugAssign( + Name( + 'flattened', + Store(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=21), + Add(), + Call( + Name( + 'flatten', + Load(), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=32), + [ + Name( + 'item', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=37)], + [], + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=38), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=38)], + [ + If( + Compare( + Name( + 'item', + Load(), + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=17), + [ + IsNot()], + [ + Constant( + None, + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=29)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'flattened', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=21), + 'append', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=28), + [ + Name( + 'item', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=33)], + [], + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=34), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=34)], + [], + lineno=16, + col_offset=8, + end_lineno=17, + end_col_offset=34)], + lineno=14, + col_offset=8, + end_lineno=17, + end_col_offset=34)], + [], + lineno=13, + col_offset=4, + end_lineno=17, + end_col_offset=34), + Return( + Name( + 'flattened', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=20), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=20)], + [], + lineno=10, + col_offset=0, + end_lineno=18, + end_col_offset=20)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=16, + end_lineno=1, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Expr( + Call( + Name( + 'iter', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + [ + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=13, + end_lineno=3, + end_col_offset=18)], + [], + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=19), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=19)], + [ + ExceptHandler( + Name( + 'TypeError', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=20), + body=[ + Return( + Constant( + False, + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=20), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=20)], + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=20)], + [ + Return( + Constant( + True, + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=19), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=19)], + [], + lineno=2, + col_offset=4, + end_lineno=7, + end_col_offset=19)], + [], + lineno=1, + col_offset=0, + end_lineno=7, + end_col_offset=19), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=13)], + List( + [], + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=18), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=18), + For( + Name( + 'placeholder_5', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + Name( + 'placeholder_3', + Load(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=24), + [ + If( + BoolOp( + And(), + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=22), + [ + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=27)], + [], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=28), + UnaryOp( + Not(), + Call( + Name( + 'isinstance', + Load(), + lineno=14, + col_offset=37, + end_lineno=14, + end_col_offset=47), + [ + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=48, + end_lineno=14, + end_col_offset=52), + Tuple( + [ + Name( + 'str', + Load(), + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=58), + Name( + 'bytes', + Load(), + lineno=14, + col_offset=60, + end_lineno=14, + end_col_offset=65)], + Load(), + lineno=14, + col_offset=54, + end_lineno=14, + end_col_offset=66)], + [], + lineno=14, + col_offset=37, + end_lineno=14, + end_col_offset=67), + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=67)], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=67), + [ + AugAssign( + Name( + 'placeholder_4', + Store(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=21), + Add(), + Call( + Name( + 'placeholder_2', + Load(), + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=32), + [ + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=37)], + [], + lineno=15, + col_offset=25, + end_lineno=15, + end_col_offset=38), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=38)], + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=17), + [ + IsNot()], + [ + Constant( + None, + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=29)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=21), + 'append', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=28), + [ + Name( + 'placeholder_5', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=33)], + [], + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=34), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=34)], + [], + lineno=16, + col_offset=8, + end_lineno=17, + end_col_offset=34)], + lineno=14, + col_offset=8, + end_lineno=17, + end_col_offset=34)], + [], + lineno=13, + col_offset=4, + end_lineno=17, + end_col_offset=34), + Return( + Name( + 'placeholder_4', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=20), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=20)], + [], + lineno=10, + col_offset=0, + end_lineno=18, + end_col_offset=20)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-flatten-array/representation.txt b/test/practice-flatten-array/representation.txt new file mode 100644 index 0000000..021e1ac --- /dev/null +++ b/test/practice-flatten-array/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=16, end_lineno=1, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Try([Expr(Call(Name('iter', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), [Name('placeholder_1', Load(), lineno=3, col_offset=13, end_lineno=3, end_col_offset=18)], [], lineno=3, col_offset=8, end_lineno=3, end_col_offset=19), lineno=3, col_offset=8, end_lineno=3, end_col_offset=19)], [ExceptHandler(Name('TypeError', Load(), lineno=4, col_offset=11, end_lineno=4, end_col_offset=20), body=[Return(Constant(False, lineno=5, col_offset=15, end_lineno=5, end_col_offset=20), lineno=5, col_offset=8, end_lineno=5, end_col_offset=20)], lineno=4, col_offset=4, end_lineno=5, end_col_offset=20)], [Return(Constant(True, lineno=7, col_offset=15, end_lineno=7, end_col_offset=19), lineno=7, col_offset=8, end_lineno=7, end_col_offset=19)], [], lineno=2, col_offset=4, end_lineno=7, end_col_offset=19)], [], lineno=1, col_offset=0, end_lineno=7, end_col_offset=19), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=10, col_offset=12, end_lineno=10, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=12, col_offset=4, end_lineno=12, end_col_offset=13)], List([], Load(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=18), lineno=12, col_offset=4, end_lineno=12, end_col_offset=18), For(Name('placeholder_5', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=12), Name('placeholder_3', Load(), lineno=13, col_offset=16, end_lineno=13, end_col_offset=24), [If(BoolOp(And(), [Call(Name('placeholder_0', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=22), [Name('placeholder_5', Load(), lineno=14, col_offset=23, end_lineno=14, end_col_offset=27)], [], lineno=14, col_offset=11, end_lineno=14, end_col_offset=28), UnaryOp(Not(), Call(Name('isinstance', Load(), lineno=14, col_offset=37, end_lineno=14, end_col_offset=47), [Name('placeholder_5', Load(), lineno=14, col_offset=48, end_lineno=14, end_col_offset=52), Tuple([Name('str', Load(), lineno=14, col_offset=55, end_lineno=14, end_col_offset=58), Name('bytes', Load(), lineno=14, col_offset=60, end_lineno=14, end_col_offset=65)], Load(), lineno=14, col_offset=54, end_lineno=14, end_col_offset=66)], [], lineno=14, col_offset=37, end_lineno=14, end_col_offset=67), lineno=14, col_offset=33, end_lineno=14, end_col_offset=67)], lineno=14, col_offset=11, end_lineno=14, end_col_offset=67), [AugAssign(Name('placeholder_4', Store(), lineno=15, col_offset=12, end_lineno=15, end_col_offset=21), Add(), Call(Name('placeholder_2', Load(), lineno=15, col_offset=25, end_lineno=15, end_col_offset=32), [Name('placeholder_5', Load(), lineno=15, col_offset=33, end_lineno=15, end_col_offset=37)], [], lineno=15, col_offset=25, end_lineno=15, end_col_offset=38), lineno=15, col_offset=12, end_lineno=15, end_col_offset=38)], [If(Compare(Name('placeholder_5', Load(), lineno=16, col_offset=13, end_lineno=16, end_col_offset=17), [IsNot()], [Constant(None, lineno=16, col_offset=25, end_lineno=16, end_col_offset=29)], lineno=16, col_offset=13, end_lineno=16, end_col_offset=29), [Expr(Call(Attribute(Name('placeholder_4', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=21), 'append', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=28), [Name('placeholder_5', Load(), lineno=17, col_offset=29, end_lineno=17, end_col_offset=33)], [], lineno=17, col_offset=12, end_lineno=17, end_col_offset=34), lineno=17, col_offset=12, end_lineno=17, end_col_offset=34)], [], lineno=16, col_offset=8, end_lineno=17, end_col_offset=34)], lineno=14, col_offset=8, end_lineno=17, end_col_offset=34)], [], lineno=13, col_offset=4, end_lineno=17, end_col_offset=34), Return(Name('placeholder_4', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=20), lineno=18, col_offset=4, end_lineno=18, end_col_offset=20)], [], lineno=10, col_offset=0, end_lineno=18, end_col_offset=20)], []) \ No newline at end of file diff --git a/test/practice-food-chain/.meta/config.json b/test/practice-food-chain/.meta/config.json new file mode 100644 index 0000000..4a42e70 --- /dev/null +++ b/test/practice-food-chain/.meta/config.json @@ -0,0 +1,26 @@ +{ + "authors": [ + "luanjpb" + ], + "contributors": [ + "cmccandless", + "Dog", + "kylecjo", + "N-Parsons", + "tqa236" + ], + "files": { + "solution": [ + "food_chain.py" + ], + "test": [ + "food_chain_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/There_Was_an_Old_Lady_Who_Swallowed_a_Fly" +} diff --git a/test/practice-food-chain/food_chain.py b/test/practice-food-chain/food_chain.py new file mode 100644 index 0000000..075f83f --- /dev/null +++ b/test/practice-food-chain/food_chain.py @@ -0,0 +1,63 @@ +def get_song(): + + animals = ['fly', 'spider', 'bird', 'cat', 'dog', 'goat', 'cow', 'horse'] + + phrases = [' wriggled and jiggled and tickled inside her.', + 'How absurd to swallow a bird!', + 'Imagine that, to swallow a cat!', + 'What a hog, to swallow a dog!', + 'Just opened her throat and swallowed a goat!', + "I don't know how she swallowed a cow!", + "She's dead, of course!"] + + old_lady = 'I know an old lady who swallowed a ' + swallowed = 'She swallowed the to catch the ' + die = "I don't know why she swallowed the fly. Perhaps she'll die." + + song = '' + verse = '' + chain = '' + + for number, animal in enumerate(animals): + verse = old_lady + animal + '.\n' + + if number == 7: + verse += phrases[6] + else: + if number == 0: + chain = swallowed + animal + '.\n' + elif number == 1: + verse += 'It' + phrases[0] + '\n' + chain = chain.replace('', animal) + verse += chain + chain = swallowed + animal + ' that' + phrases[0] + '\n' + chain + else: + verse += phrases[number-1] + '\n' + chain = chain.replace('', animal) + verse += chain + chain = swallowed + animal + '.\n' + chain + + verse += die + '\n' + + verse += '\n' + song += verse + + return song + + +def verses(letter): + return letter.replace('die.', 'die.slice').split('slice') + + +def recite(start_verse, end_verse): + generated = [verse.strip().split('\n') for verse in verses(get_song())] + if start_verse == end_verse: + return generated[start_verse - 1] + else: + result = [] + for idx in range(start_verse - 1, end_verse): + result += generated[idx] + [''] + + # Pop out the last empty string + result.pop() + return result diff --git a/test/practice-food-chain/mapping.json b/test/practice-food-chain/mapping.json new file mode 100644 index 0000000..f8bb51d --- /dev/null +++ b/test/practice-food-chain/mapping.json @@ -0,0 +1,21 @@ +{ + "placeholder_0": "get_song", + "placeholder_1": "animals", + "placeholder_2": "phrases", + "placeholder_3": "old_lady", + "placeholder_4": "swallowed", + "placeholder_5": "die", + "placeholder_6": "song", + "placeholder_7": "verse", + "placeholder_8": "chain", + "placeholder_9": "number", + "placeholder_10": "animal", + "placeholder_11": "verses", + "placeholder_12": "letter", + "placeholder_13": "recite", + "placeholder_14": "start_verse", + "placeholder_15": "end_verse", + "placeholder_16": "generated", + "placeholder_17": "result", + "placeholder_18": "idx" +} \ No newline at end of file diff --git a/test/practice-food-chain/representation.json b/test/practice-food-chain/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-food-chain/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-food-chain/representation.out b/test/practice-food-chain/representation.out new file mode 100644 index 0000000..0a83c0c --- /dev/null +++ b/test/practice-food-chain/representation.out @@ -0,0 +1,2935 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(): + placeholder_1 = ["fly", "spider", "bird", "cat", "dog", "goat", "cow", "horse"] + placeholder_2 = [ + " wriggled and jiggled and tickled inside her.", + "How absurd to swallow a bird!", + "Imagine that, to swallow a cat!", + "What a hog, to swallow a dog!", + "Just opened her throat and swallowed a goat!", + "I don't know how she swallowed a cow!", + "She's dead, of course!", + ] + placeholder_3 = "I know an old lady who swallowed a " + placeholder_4 = "She swallowed the to catch the " + placeholder_5 = "I don't know why she swallowed the fly. Perhaps she'll die." + placeholder_6 = "" + placeholder_7 = "" + placeholder_8 = "" + for placeholder_9, placeholder_10 in enumerate(placeholder_1): + placeholder_7 = placeholder_3 + placeholder_10 + ".\n" + if placeholder_9 == 7: + placeholder_7 += placeholder_2[6] + else: + if placeholder_9 == 0: + placeholder_8 = placeholder_4 + placeholder_10 + ".\n" + elif placeholder_9 == 1: + placeholder_7 += "It" + placeholder_2[0] + "\n" + placeholder_8 = placeholder_8.replace("", placeholder_10) + placeholder_7 += placeholder_8 + placeholder_8 = ( + placeholder_4 + + placeholder_10 + + " that" + + placeholder_2[0] + + "\n" + + placeholder_8 + ) + else: + placeholder_7 += placeholder_2[placeholder_9 - 1] + "\n" + placeholder_8 = placeholder_8.replace("", placeholder_10) + placeholder_7 += placeholder_8 + placeholder_8 = placeholder_4 + placeholder_10 + ".\n" + placeholder_8 + placeholder_7 += placeholder_5 + "\n" + placeholder_7 += "\n" + placeholder_6 += placeholder_7 + return placeholder_6 + + +def placeholder_11(placeholder_12): + return placeholder_12.replace("die.", "die.slice").split("slice") + + +def placeholder_13(placeholder_14, placeholder_15): + placeholder_16 = [ + placeholder_7.strip().split("\n") + for placeholder_7 in placeholder_11(placeholder_0()) + ] + if placeholder_14 == placeholder_15: + return placeholder_16[placeholder_14 - 1] + else: + placeholder_17 = [] + for placeholder_18 in range(placeholder_14 - 1, placeholder_15): + placeholder_17 += placeholder_16[placeholder_18] + [""] + placeholder_17.pop() + return placeholder_17 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'get_song', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'animals', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11)], + List( + [ + Constant( + 'fly', + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + Constant( + 'spider', + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=30), + Constant( + 'bird', + lineno=3, + col_offset=32, + end_lineno=3, + end_col_offset=38), + Constant( + 'cat', + lineno=3, + col_offset=40, + end_lineno=3, + end_col_offset=45), + Constant( + 'dog', + lineno=3, + col_offset=47, + end_lineno=3, + end_col_offset=52), + Constant( + 'goat', + lineno=3, + col_offset=54, + end_lineno=3, + end_col_offset=60), + Constant( + 'cow', + lineno=3, + col_offset=62, + end_lineno=3, + end_col_offset=67), + Constant( + 'horse', + lineno=3, + col_offset=69, + end_lineno=3, + end_col_offset=76)], + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=77), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=77), + Assign( + [ + Name( + 'phrases', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + List( + [ + Constant( + ' wriggled and jiggled and tickled inside her.', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=62), + Constant( + 'How absurd to swallow a bird!', + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=46), + Constant( + 'Imagine that, to swallow a cat!', + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=48), + Constant( + 'What a hog, to swallow a dog!', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=46), + Constant( + 'Just opened her throat and swallowed a goat!', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=61), + Constant( + "I don't know how she swallowed a cow!", + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=54), + Constant( + "She's dead, of course!", + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=39)], + Load(), + lineno=5, + col_offset=14, + end_lineno=11, + end_col_offset=40), + lineno=5, + col_offset=4, + end_lineno=11, + end_col_offset=40), + Assign( + [ + Name( + 'old_lady', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=12)], + Constant( + 'I know an old lady who swallowed a ', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=52), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=52), + Assign( + [ + Name( + 'swallowed', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=13)], + Constant( + 'She swallowed the to catch the ', + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=58), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=58), + Assign( + [ + Name( + 'die', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=7)], + Constant( + "I don't know why she swallowed the fly. Perhaps she'll die.", + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=71), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=71), + Assign( + [ + Name( + 'song', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=8)], + Constant( + '', + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=13), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=13), + Assign( + [ + Name( + 'verse', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=9)], + Constant( + '', + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=14), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=14), + Assign( + [ + Name( + 'chain', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=9)], + Constant( + '', + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=14), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=14), + For( + Tuple( + [ + Name( + 'number', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=14), + Name( + 'animal', + Store(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=22)], + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=22), + Call( + Name( + 'enumerate', + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=35), + [ + Name( + 'animals', + Load(), + lineno=21, + col_offset=36, + end_lineno=21, + end_col_offset=43)], + [], + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=44), + [ + Assign( + [ + Name( + 'verse', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=13)], + BinOp( + BinOp( + Name( + 'old_lady', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=24), + Add(), + Name( + 'animal', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=33), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=33), + Add(), + Constant( + '.\n', + lineno=22, + col_offset=36, + end_lineno=22, + end_col_offset=41), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=41), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=41), + If( + Compare( + Name( + 'number', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 7, + lineno=24, + col_offset=21, + end_lineno=24, + end_col_offset=22)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=22), + [ + AugAssign( + Name( + 'verse', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=17), + Add(), + Subscript( + Name( + 'phrases', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=28), + Constant( + 6, + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=30), + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=31), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=31)], + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 0, + lineno=27, + col_offset=25, + end_lineno=27, + end_col_offset=26)], + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=26), + [ + Assign( + [ + Name( + 'chain', + Store(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=21)], + BinOp( + BinOp( + Name( + 'swallowed', + Load(), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=33), + Add(), + Name( + 'animal', + Load(), + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=42), + Add(), + Constant( + '.\n', + lineno=28, + col_offset=45, + end_lineno=28, + end_col_offset=50), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=50), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=50)], + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=23), + [ + Eq()], + [ + Constant( + 1, + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=28)], + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=28), + [ + AugAssign( + Name( + 'verse', + Store(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=21), + Add(), + BinOp( + BinOp( + Constant( + 'It', + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=29), + Add(), + Subscript( + Name( + 'phrases', + Load(), + lineno=30, + col_offset=32, + end_lineno=30, + end_col_offset=39), + Constant( + 0, + lineno=30, + col_offset=40, + end_lineno=30, + end_col_offset=41), + Load(), + lineno=30, + col_offset=32, + end_lineno=30, + end_col_offset=42), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=42), + Add(), + Constant( + '\n', + lineno=30, + col_offset=45, + end_lineno=30, + end_col_offset=49), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=49), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=49), + Assign( + [ + Name( + 'chain', + Store(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=21)], + Call( + Attribute( + Name( + 'chain', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=29), + 'replace', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=37), + [ + Constant( + '', + lineno=31, + col_offset=38, + end_lineno=31, + end_col_offset=48), + Name( + 'animal', + Load(), + lineno=31, + col_offset=50, + end_lineno=31, + end_col_offset=56)], + [], + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=57), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=57), + AugAssign( + Name( + 'verse', + Store(), + lineno=32, + col_offset=16, + end_lineno=32, + end_col_offset=21), + Add(), + Name( + 'chain', + Load(), + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=30), + lineno=32, + col_offset=16, + end_lineno=32, + end_col_offset=30), + Assign( + [ + Name( + 'chain', + Store(), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=21)], + BinOp( + BinOp( + BinOp( + BinOp( + BinOp( + Name( + 'swallowed', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=33), + Add(), + Name( + 'animal', + Load(), + lineno=33, + col_offset=36, + end_lineno=33, + end_col_offset=42), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=42), + Add(), + Constant( + ' that', + lineno=33, + col_offset=45, + end_lineno=33, + end_col_offset=52), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=52), + Add(), + Subscript( + Name( + 'phrases', + Load(), + lineno=33, + col_offset=55, + end_lineno=33, + end_col_offset=62), + Constant( + 0, + lineno=33, + col_offset=63, + end_lineno=33, + end_col_offset=64), + Load(), + lineno=33, + col_offset=55, + end_lineno=33, + end_col_offset=65), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=65), + Add(), + Constant( + '\n', + lineno=33, + col_offset=68, + end_lineno=33, + end_col_offset=72), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=72), + Add(), + Name( + 'chain', + Load(), + lineno=33, + col_offset=75, + end_lineno=33, + end_col_offset=80), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=80), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=80)], + [ + AugAssign( + Name( + 'verse', + Store(), + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=21), + Add(), + BinOp( + Subscript( + Name( + 'phrases', + Load(), + lineno=35, + col_offset=25, + end_lineno=35, + end_col_offset=32), + BinOp( + Name( + 'number', + Load(), + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=39), + Sub(), + Constant( + 1, + lineno=35, + col_offset=40, + end_lineno=35, + end_col_offset=41), + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=41), + Load(), + lineno=35, + col_offset=25, + end_lineno=35, + end_col_offset=42), + Add(), + Constant( + '\n', + lineno=35, + col_offset=45, + end_lineno=35, + end_col_offset=49), + lineno=35, + col_offset=25, + end_lineno=35, + end_col_offset=49), + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=49), + Assign( + [ + Name( + 'chain', + Store(), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=21)], + Call( + Attribute( + Name( + 'chain', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=29), + 'replace', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=37), + [ + Constant( + '', + lineno=36, + col_offset=38, + end_lineno=36, + end_col_offset=48), + Name( + 'animal', + Load(), + lineno=36, + col_offset=50, + end_lineno=36, + end_col_offset=56)], + [], + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=57), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=57), + AugAssign( + Name( + 'verse', + Store(), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=21), + Add(), + Name( + 'chain', + Load(), + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=30), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=30), + Assign( + [ + Name( + 'chain', + Store(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=21)], + BinOp( + BinOp( + BinOp( + Name( + 'swallowed', + Load(), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=33), + Add(), + Name( + 'animal', + Load(), + lineno=38, + col_offset=36, + end_lineno=38, + end_col_offset=42), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=42), + Add(), + Constant( + '.\n', + lineno=38, + col_offset=45, + end_lineno=38, + end_col_offset=50), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=50), + Add(), + Name( + 'chain', + Load(), + lineno=38, + col_offset=53, + end_lineno=38, + end_col_offset=58), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=58), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=58)], + lineno=29, + col_offset=12, + end_lineno=38, + end_col_offset=58)], + lineno=27, + col_offset=12, + end_lineno=38, + end_col_offset=58), + AugAssign( + Name( + 'verse', + Store(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=17), + Add(), + BinOp( + Name( + 'die', + Load(), + lineno=40, + col_offset=21, + end_lineno=40, + end_col_offset=24), + Add(), + Constant( + '\n', + lineno=40, + col_offset=27, + end_lineno=40, + end_col_offset=31), + lineno=40, + col_offset=21, + end_lineno=40, + end_col_offset=31), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=31)], + lineno=24, + col_offset=8, + end_lineno=40, + end_col_offset=31), + AugAssign( + Name( + 'verse', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=13), + Add(), + Constant( + '\n', + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=21), + AugAssign( + Name( + 'song', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=12), + Add(), + Name( + 'verse', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=21), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=21)], + [], + lineno=21, + col_offset=4, + end_lineno=43, + end_col_offset=21), + Return( + Name( + 'song', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=15), + lineno=45, + col_offset=4, + end_lineno=45, + end_col_offset=15)], + [], + lineno=1, + col_offset=0, + end_lineno=45, + end_col_offset=15), + FunctionDef( + 'verses', + arguments( + [], + [ + arg( + 'letter', + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Attribute( + Name( + 'letter', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=17), + 'replace', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=25), + [ + Constant( + 'die.', + lineno=49, + col_offset=26, + end_lineno=49, + end_col_offset=32), + Constant( + 'die.slice', + lineno=49, + col_offset=34, + end_lineno=49, + end_col_offset=45)], + [], + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=46), + 'split', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=52), + [ + Constant( + 'slice', + lineno=49, + col_offset=53, + end_lineno=49, + end_col_offset=60)], + [], + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=61), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=61)], + [], + lineno=48, + col_offset=0, + end_lineno=49, + end_col_offset=61), + FunctionDef( + 'recite', + arguments( + [], + [ + arg( + 'start_verse', + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=22), + arg( + 'end_verse', + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'generated', + Store(), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=13)], + ListComp( + Call( + Attribute( + Call( + Attribute( + Name( + 'verse', + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=22), + 'strip', + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=28), + [], + [], + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=30), + 'split', + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=36), + [ + Constant( + '\n', + lineno=53, + col_offset=37, + end_lineno=53, + end_col_offset=41)], + [], + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=42), + [ + comprehension( + Name( + 'verse', + Store(), + lineno=53, + col_offset=47, + end_lineno=53, + end_col_offset=52), + Call( + Name( + 'verses', + Load(), + lineno=53, + col_offset=56, + end_lineno=53, + end_col_offset=62), + [ + Call( + Name( + 'get_song', + Load(), + lineno=53, + col_offset=63, + end_lineno=53, + end_col_offset=71), + [], + [], + lineno=53, + col_offset=63, + end_lineno=53, + end_col_offset=73)], + [], + lineno=53, + col_offset=56, + end_lineno=53, + end_col_offset=74), + [], + 0)], + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=75), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=75), + If( + Compare( + Name( + 'start_verse', + Load(), + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=18), + [ + Eq()], + [ + Name( + 'end_verse', + Load(), + lineno=54, + col_offset=22, + end_lineno=54, + end_col_offset=31)], + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=31), + [ + Return( + Subscript( + Name( + 'generated', + Load(), + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=24), + BinOp( + Name( + 'start_verse', + Load(), + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=36), + Sub(), + Constant( + 1, + lineno=55, + col_offset=39, + end_lineno=55, + end_col_offset=40), + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=40), + Load(), + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=41), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=41)], + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=14)], + List( + [], + Load(), + lineno=57, + col_offset=17, + end_lineno=57, + end_col_offset=19), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=19), + For( + Name( + 'idx', + Store(), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=58, + col_offset=19, + end_lineno=58, + end_col_offset=24), + [ + BinOp( + Name( + 'start_verse', + Load(), + lineno=58, + col_offset=25, + end_lineno=58, + end_col_offset=36), + Sub(), + Constant( + 1, + lineno=58, + col_offset=39, + end_lineno=58, + end_col_offset=40), + lineno=58, + col_offset=25, + end_lineno=58, + end_col_offset=40), + Name( + 'end_verse', + Load(), + lineno=58, + col_offset=42, + end_lineno=58, + end_col_offset=51)], + [], + lineno=58, + col_offset=19, + end_lineno=58, + end_col_offset=52), + [ + AugAssign( + Name( + 'result', + Store(), + lineno=59, + col_offset=12, + end_lineno=59, + end_col_offset=18), + Add(), + BinOp( + Subscript( + Name( + 'generated', + Load(), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=31), + Name( + 'idx', + Load(), + lineno=59, + col_offset=32, + end_lineno=59, + end_col_offset=35), + Load(), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=36), + Add(), + List( + [ + Constant( + '', + lineno=59, + col_offset=40, + end_lineno=59, + end_col_offset=42)], + Load(), + lineno=59, + col_offset=39, + end_lineno=59, + end_col_offset=43), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=43), + lineno=59, + col_offset=12, + end_lineno=59, + end_col_offset=43)], + [], + lineno=58, + col_offset=8, + end_lineno=59, + end_col_offset=43), + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=14), + 'pop', + Load(), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=18), + [], + [], + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=20), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=20), + Return( + Name( + 'result', + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=21), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=21)], + lineno=54, + col_offset=4, + end_lineno=63, + end_col_offset=21)], + [], + lineno=52, + col_offset=0, + end_lineno=63, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11)], + List( + [ + Constant( + 'fly', + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + Constant( + 'spider', + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=30), + Constant( + 'bird', + lineno=3, + col_offset=32, + end_lineno=3, + end_col_offset=38), + Constant( + 'cat', + lineno=3, + col_offset=40, + end_lineno=3, + end_col_offset=45), + Constant( + 'dog', + lineno=3, + col_offset=47, + end_lineno=3, + end_col_offset=52), + Constant( + 'goat', + lineno=3, + col_offset=54, + end_lineno=3, + end_col_offset=60), + Constant( + 'cow', + lineno=3, + col_offset=62, + end_lineno=3, + end_col_offset=67), + Constant( + 'horse', + lineno=3, + col_offset=69, + end_lineno=3, + end_col_offset=76)], + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=77), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=77), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + List( + [ + Constant( + ' wriggled and jiggled and tickled inside her.', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=62), + Constant( + 'How absurd to swallow a bird!', + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=46), + Constant( + 'Imagine that, to swallow a cat!', + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=48), + Constant( + 'What a hog, to swallow a dog!', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=46), + Constant( + 'Just opened her throat and swallowed a goat!', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=61), + Constant( + "I don't know how she swallowed a cow!", + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=54), + Constant( + "She's dead, of course!", + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=39)], + Load(), + lineno=5, + col_offset=14, + end_lineno=11, + end_col_offset=40), + lineno=5, + col_offset=4, + end_lineno=11, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=12)], + Constant( + 'I know an old lady who swallowed a ', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=52), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=13)], + Constant( + 'She swallowed the to catch the ', + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=58), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=58), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=7)], + Constant( + "I don't know why she swallowed the fly. Perhaps she'll die.", + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=71), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=71), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=8)], + Constant( + '', + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=13), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=9)], + Constant( + '', + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=14), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=9)], + Constant( + '', + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=14), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=14), + For( + Tuple( + [ + Name( + 'placeholder_9', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=14), + Name( + 'placeholder_10', + Store(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=22)], + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=22), + Call( + Name( + 'enumerate', + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=35), + [ + Name( + 'placeholder_1', + Load(), + lineno=21, + col_offset=36, + end_lineno=21, + end_col_offset=43)], + [], + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=44), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=13)], + BinOp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=24), + Add(), + Name( + 'placeholder_10', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=33), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=33), + Add(), + Constant( + '.\n', + lineno=22, + col_offset=36, + end_lineno=22, + end_col_offset=41), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=41), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=41), + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 7, + lineno=24, + col_offset=21, + end_lineno=24, + end_col_offset=22)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=22), + [ + AugAssign( + Name( + 'placeholder_7', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=17), + Add(), + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=28), + Constant( + 6, + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=30), + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=31), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=31)], + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 0, + lineno=27, + col_offset=25, + end_lineno=27, + end_col_offset=26)], + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=26), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=21)], + BinOp( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=33), + Add(), + Name( + 'placeholder_10', + Load(), + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=42), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=42), + Add(), + Constant( + '.\n', + lineno=28, + col_offset=45, + end_lineno=28, + end_col_offset=50), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=50), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=50)], + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=23), + [ + Eq()], + [ + Constant( + 1, + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=28)], + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=28), + [ + AugAssign( + Name( + 'placeholder_7', + Store(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=21), + Add(), + BinOp( + BinOp( + Constant( + 'It', + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=29), + Add(), + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=30, + col_offset=32, + end_lineno=30, + end_col_offset=39), + Constant( + 0, + lineno=30, + col_offset=40, + end_lineno=30, + end_col_offset=41), + Load(), + lineno=30, + col_offset=32, + end_lineno=30, + end_col_offset=42), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=42), + Add(), + Constant( + '\n', + lineno=30, + col_offset=45, + end_lineno=30, + end_col_offset=49), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=49), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=49), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=21)], + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=29), + 'replace', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=37), + [ + Constant( + '', + lineno=31, + col_offset=38, + end_lineno=31, + end_col_offset=48), + Name( + 'placeholder_10', + Load(), + lineno=31, + col_offset=50, + end_lineno=31, + end_col_offset=56)], + [], + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=57), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=57), + AugAssign( + Name( + 'placeholder_7', + Store(), + lineno=32, + col_offset=16, + end_lineno=32, + end_col_offset=21), + Add(), + Name( + 'placeholder_8', + Load(), + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=30), + lineno=32, + col_offset=16, + end_lineno=32, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=21)], + BinOp( + BinOp( + BinOp( + BinOp( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=33), + Add(), + Name( + 'placeholder_10', + Load(), + lineno=33, + col_offset=36, + end_lineno=33, + end_col_offset=42), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=42), + Add(), + Constant( + ' that', + lineno=33, + col_offset=45, + end_lineno=33, + end_col_offset=52), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=52), + Add(), + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=33, + col_offset=55, + end_lineno=33, + end_col_offset=62), + Constant( + 0, + lineno=33, + col_offset=63, + end_lineno=33, + end_col_offset=64), + Load(), + lineno=33, + col_offset=55, + end_lineno=33, + end_col_offset=65), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=65), + Add(), + Constant( + '\n', + lineno=33, + col_offset=68, + end_lineno=33, + end_col_offset=72), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=72), + Add(), + Name( + 'placeholder_8', + Load(), + lineno=33, + col_offset=75, + end_lineno=33, + end_col_offset=80), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=80), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=80)], + [ + AugAssign( + Name( + 'placeholder_7', + Store(), + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=21), + Add(), + BinOp( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=35, + col_offset=25, + end_lineno=35, + end_col_offset=32), + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=39), + Sub(), + Constant( + 1, + lineno=35, + col_offset=40, + end_lineno=35, + end_col_offset=41), + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=41), + Load(), + lineno=35, + col_offset=25, + end_lineno=35, + end_col_offset=42), + Add(), + Constant( + '\n', + lineno=35, + col_offset=45, + end_lineno=35, + end_col_offset=49), + lineno=35, + col_offset=25, + end_lineno=35, + end_col_offset=49), + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=49), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=21)], + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=29), + 'replace', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=37), + [ + Constant( + '', + lineno=36, + col_offset=38, + end_lineno=36, + end_col_offset=48), + Name( + 'placeholder_10', + Load(), + lineno=36, + col_offset=50, + end_lineno=36, + end_col_offset=56)], + [], + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=57), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=57), + AugAssign( + Name( + 'placeholder_7', + Store(), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=21), + Add(), + Name( + 'placeholder_8', + Load(), + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=30), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=21)], + BinOp( + BinOp( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=33), + Add(), + Name( + 'placeholder_10', + Load(), + lineno=38, + col_offset=36, + end_lineno=38, + end_col_offset=42), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=42), + Add(), + Constant( + '.\n', + lineno=38, + col_offset=45, + end_lineno=38, + end_col_offset=50), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=50), + Add(), + Name( + 'placeholder_8', + Load(), + lineno=38, + col_offset=53, + end_lineno=38, + end_col_offset=58), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=58), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=58)], + lineno=29, + col_offset=12, + end_lineno=38, + end_col_offset=58)], + lineno=27, + col_offset=12, + end_lineno=38, + end_col_offset=58), + AugAssign( + Name( + 'placeholder_7', + Store(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=17), + Add(), + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=40, + col_offset=21, + end_lineno=40, + end_col_offset=24), + Add(), + Constant( + '\n', + lineno=40, + col_offset=27, + end_lineno=40, + end_col_offset=31), + lineno=40, + col_offset=21, + end_lineno=40, + end_col_offset=31), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=31)], + lineno=24, + col_offset=8, + end_lineno=40, + end_col_offset=31), + AugAssign( + Name( + 'placeholder_7', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=13), + Add(), + Constant( + '\n', + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=21), + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=12), + Add(), + Name( + 'placeholder_7', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=21), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=21)], + [], + lineno=21, + col_offset=4, + end_lineno=43, + end_col_offset=21), + Return( + Name( + 'placeholder_6', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=15), + lineno=45, + col_offset=4, + end_lineno=45, + end_col_offset=15)], + [], + lineno=1, + col_offset=0, + end_lineno=45, + end_col_offset=15), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_12', + lineno=48, + col_offset=11, + end_lineno=48, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=17), + 'replace', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=25), + [ + Constant( + 'die.', + lineno=49, + col_offset=26, + end_lineno=49, + end_col_offset=32), + Constant( + 'die.slice', + lineno=49, + col_offset=34, + end_lineno=49, + end_col_offset=45)], + [], + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=46), + 'split', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=52), + [ + Constant( + 'slice', + lineno=49, + col_offset=53, + end_lineno=49, + end_col_offset=60)], + [], + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=61), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=61)], + [], + lineno=48, + col_offset=0, + end_lineno=49, + end_col_offset=61), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=22), + arg( + 'placeholder_15', + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=13)], + ListComp( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=22), + 'strip', + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=28), + [], + [], + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=30), + 'split', + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=36), + [ + Constant( + '\n', + lineno=53, + col_offset=37, + end_lineno=53, + end_col_offset=41)], + [], + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=42), + [ + comprehension( + Name( + 'placeholder_7', + Store(), + lineno=53, + col_offset=47, + end_lineno=53, + end_col_offset=52), + Call( + Name( + 'placeholder_11', + Load(), + lineno=53, + col_offset=56, + end_lineno=53, + end_col_offset=62), + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=53, + col_offset=63, + end_lineno=53, + end_col_offset=71), + [], + [], + lineno=53, + col_offset=63, + end_lineno=53, + end_col_offset=73)], + [], + lineno=53, + col_offset=56, + end_lineno=53, + end_col_offset=74), + [], + 0)], + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=75), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=75), + If( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=18), + [ + Eq()], + [ + Name( + 'placeholder_15', + Load(), + lineno=54, + col_offset=22, + end_lineno=54, + end_col_offset=31)], + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=31), + [ + Return( + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=24), + BinOp( + Name( + 'placeholder_14', + Load(), + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=36), + Sub(), + Constant( + 1, + lineno=55, + col_offset=39, + end_lineno=55, + end_col_offset=40), + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=40), + Load(), + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=41), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=41)], + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=14)], + List( + [], + Load(), + lineno=57, + col_offset=17, + end_lineno=57, + end_col_offset=19), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=19), + For( + Name( + 'placeholder_18', + Store(), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=58, + col_offset=19, + end_lineno=58, + end_col_offset=24), + [ + BinOp( + Name( + 'placeholder_14', + Load(), + lineno=58, + col_offset=25, + end_lineno=58, + end_col_offset=36), + Sub(), + Constant( + 1, + lineno=58, + col_offset=39, + end_lineno=58, + end_col_offset=40), + lineno=58, + col_offset=25, + end_lineno=58, + end_col_offset=40), + Name( + 'placeholder_15', + Load(), + lineno=58, + col_offset=42, + end_lineno=58, + end_col_offset=51)], + [], + lineno=58, + col_offset=19, + end_lineno=58, + end_col_offset=52), + [ + AugAssign( + Name( + 'placeholder_17', + Store(), + lineno=59, + col_offset=12, + end_lineno=59, + end_col_offset=18), + Add(), + BinOp( + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=31), + Name( + 'placeholder_18', + Load(), + lineno=59, + col_offset=32, + end_lineno=59, + end_col_offset=35), + Load(), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=36), + Add(), + List( + [ + Constant( + '', + lineno=59, + col_offset=40, + end_lineno=59, + end_col_offset=42)], + Load(), + lineno=59, + col_offset=39, + end_lineno=59, + end_col_offset=43), + lineno=59, + col_offset=22, + end_lineno=59, + end_col_offset=43), + lineno=59, + col_offset=12, + end_lineno=59, + end_col_offset=43)], + [], + lineno=58, + col_offset=8, + end_lineno=59, + end_col_offset=43), + Expr( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=14), + 'pop', + Load(), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=18), + [], + [], + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=20), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=20), + Return( + Name( + 'placeholder_17', + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=21), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=21)], + lineno=54, + col_offset=4, + end_lineno=63, + end_col_offset=21)], + [], + lineno=52, + col_offset=0, + end_lineno=63, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-food-chain/representation.txt b/test/practice-food-chain/representation.txt new file mode 100644 index 0000000..29efec6 --- /dev/null +++ b/test/practice-food-chain/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_1', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=11)], List([Constant('fly', lineno=3, col_offset=15, end_lineno=3, end_col_offset=20), Constant('spider', lineno=3, col_offset=22, end_lineno=3, end_col_offset=30), Constant('bird', lineno=3, col_offset=32, end_lineno=3, end_col_offset=38), Constant('cat', lineno=3, col_offset=40, end_lineno=3, end_col_offset=45), Constant('dog', lineno=3, col_offset=47, end_lineno=3, end_col_offset=52), Constant('goat', lineno=3, col_offset=54, end_lineno=3, end_col_offset=60), Constant('cow', lineno=3, col_offset=62, end_lineno=3, end_col_offset=67), Constant('horse', lineno=3, col_offset=69, end_lineno=3, end_col_offset=76)], Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=77), lineno=3, col_offset=4, end_lineno=3, end_col_offset=77), Assign([Name('placeholder_2', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=11)], List([Constant(' wriggled and jiggled and tickled inside her.', lineno=5, col_offset=15, end_lineno=5, end_col_offset=62), Constant('How absurd to swallow a bird!', lineno=6, col_offset=15, end_lineno=6, end_col_offset=46), Constant('Imagine that, to swallow a cat!', lineno=7, col_offset=15, end_lineno=7, end_col_offset=48), Constant('What a hog, to swallow a dog!', lineno=8, col_offset=15, end_lineno=8, end_col_offset=46), Constant('Just opened her throat and swallowed a goat!', lineno=9, col_offset=15, end_lineno=9, end_col_offset=61), Constant("I don't know how she swallowed a cow!", lineno=10, col_offset=15, end_lineno=10, end_col_offset=54), Constant("She's dead, of course!", lineno=11, col_offset=15, end_lineno=11, end_col_offset=39)], Load(), lineno=5, col_offset=14, end_lineno=11, end_col_offset=40), lineno=5, col_offset=4, end_lineno=11, end_col_offset=40), Assign([Name('placeholder_3', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=12)], Constant('I know an old lady who swallowed a ', lineno=13, col_offset=15, end_lineno=13, end_col_offset=52), lineno=13, col_offset=4, end_lineno=13, end_col_offset=52), Assign([Name('placeholder_4', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=13)], Constant('She swallowed the to catch the ', lineno=14, col_offset=16, end_lineno=14, end_col_offset=58), lineno=14, col_offset=4, end_lineno=14, end_col_offset=58), Assign([Name('placeholder_5', Store(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=7)], Constant("I don't know why she swallowed the fly. Perhaps she'll die.", lineno=15, col_offset=10, end_lineno=15, end_col_offset=71), lineno=15, col_offset=4, end_lineno=15, end_col_offset=71), Assign([Name('placeholder_6', Store(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=8)], Constant('', lineno=17, col_offset=11, end_lineno=17, end_col_offset=13), lineno=17, col_offset=4, end_lineno=17, end_col_offset=13), Assign([Name('placeholder_7', Store(), lineno=18, col_offset=4, end_lineno=18, end_col_offset=9)], Constant('', lineno=18, col_offset=12, end_lineno=18, end_col_offset=14), lineno=18, col_offset=4, end_lineno=18, end_col_offset=14), Assign([Name('placeholder_8', Store(), lineno=19, col_offset=4, end_lineno=19, end_col_offset=9)], Constant('', lineno=19, col_offset=12, end_lineno=19, end_col_offset=14), lineno=19, col_offset=4, end_lineno=19, end_col_offset=14), For(Tuple([Name('placeholder_9', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=14), Name('placeholder_10', Store(), lineno=21, col_offset=16, end_lineno=21, end_col_offset=22)], Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=22), Call(Name('enumerate', Load(), lineno=21, col_offset=26, end_lineno=21, end_col_offset=35), [Name('placeholder_1', Load(), lineno=21, col_offset=36, end_lineno=21, end_col_offset=43)], [], lineno=21, col_offset=26, end_lineno=21, end_col_offset=44), [Assign([Name('placeholder_7', Store(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=13)], BinOp(BinOp(Name('placeholder_3', Load(), lineno=22, col_offset=16, end_lineno=22, end_col_offset=24), Add(), Name('placeholder_10', Load(), lineno=22, col_offset=27, end_lineno=22, end_col_offset=33), lineno=22, col_offset=16, end_lineno=22, end_col_offset=33), Add(), Constant('.\n', lineno=22, col_offset=36, end_lineno=22, end_col_offset=41), lineno=22, col_offset=16, end_lineno=22, end_col_offset=41), lineno=22, col_offset=8, end_lineno=22, end_col_offset=41), If(Compare(Name('placeholder_9', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=17), [Eq()], [Constant(7, lineno=24, col_offset=21, end_lineno=24, end_col_offset=22)], lineno=24, col_offset=11, end_lineno=24, end_col_offset=22), [AugAssign(Name('placeholder_7', Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=17), Add(), Subscript(Name('placeholder_2', Load(), lineno=25, col_offset=21, end_lineno=25, end_col_offset=28), Constant(6, lineno=25, col_offset=29, end_lineno=25, end_col_offset=30), Load(), lineno=25, col_offset=21, end_lineno=25, end_col_offset=31), lineno=25, col_offset=12, end_lineno=25, end_col_offset=31)], [If(Compare(Name('placeholder_9', Load(), lineno=27, col_offset=15, end_lineno=27, end_col_offset=21), [Eq()], [Constant(0, lineno=27, col_offset=25, end_lineno=27, end_col_offset=26)], lineno=27, col_offset=15, end_lineno=27, end_col_offset=26), [Assign([Name('placeholder_8', Store(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=21)], BinOp(BinOp(Name('placeholder_4', Load(), lineno=28, col_offset=24, end_lineno=28, end_col_offset=33), Add(), Name('placeholder_10', Load(), lineno=28, col_offset=36, end_lineno=28, end_col_offset=42), lineno=28, col_offset=24, end_lineno=28, end_col_offset=42), Add(), Constant('.\n', lineno=28, col_offset=45, end_lineno=28, end_col_offset=50), lineno=28, col_offset=24, end_lineno=28, end_col_offset=50), lineno=28, col_offset=16, end_lineno=28, end_col_offset=50)], [If(Compare(Name('placeholder_9', Load(), lineno=29, col_offset=17, end_lineno=29, end_col_offset=23), [Eq()], [Constant(1, lineno=29, col_offset=27, end_lineno=29, end_col_offset=28)], lineno=29, col_offset=17, end_lineno=29, end_col_offset=28), [AugAssign(Name('placeholder_7', Store(), lineno=30, col_offset=16, end_lineno=30, end_col_offset=21), Add(), BinOp(BinOp(Constant('It', lineno=30, col_offset=25, end_lineno=30, end_col_offset=29), Add(), Subscript(Name('placeholder_2', Load(), lineno=30, col_offset=32, end_lineno=30, end_col_offset=39), Constant(0, lineno=30, col_offset=40, end_lineno=30, end_col_offset=41), Load(), lineno=30, col_offset=32, end_lineno=30, end_col_offset=42), lineno=30, col_offset=25, end_lineno=30, end_col_offset=42), Add(), Constant('\n', lineno=30, col_offset=45, end_lineno=30, end_col_offset=49), lineno=30, col_offset=25, end_lineno=30, end_col_offset=49), lineno=30, col_offset=16, end_lineno=30, end_col_offset=49), Assign([Name('placeholder_8', Store(), lineno=31, col_offset=16, end_lineno=31, end_col_offset=21)], Call(Attribute(Name('placeholder_8', Load(), lineno=31, col_offset=24, end_lineno=31, end_col_offset=29), 'replace', Load(), lineno=31, col_offset=24, end_lineno=31, end_col_offset=37), [Constant('', lineno=31, col_offset=38, end_lineno=31, end_col_offset=48), Name('placeholder_10', Load(), lineno=31, col_offset=50, end_lineno=31, end_col_offset=56)], [], lineno=31, col_offset=24, end_lineno=31, end_col_offset=57), lineno=31, col_offset=16, end_lineno=31, end_col_offset=57), AugAssign(Name('placeholder_7', Store(), lineno=32, col_offset=16, end_lineno=32, end_col_offset=21), Add(), Name('placeholder_8', Load(), lineno=32, col_offset=25, end_lineno=32, end_col_offset=30), lineno=32, col_offset=16, end_lineno=32, end_col_offset=30), Assign([Name('placeholder_8', Store(), lineno=33, col_offset=16, end_lineno=33, end_col_offset=21)], BinOp(BinOp(BinOp(BinOp(BinOp(Name('placeholder_4', Load(), lineno=33, col_offset=24, end_lineno=33, end_col_offset=33), Add(), Name('placeholder_10', Load(), lineno=33, col_offset=36, end_lineno=33, end_col_offset=42), lineno=33, col_offset=24, end_lineno=33, end_col_offset=42), Add(), Constant(' that', lineno=33, col_offset=45, end_lineno=33, end_col_offset=52), lineno=33, col_offset=24, end_lineno=33, end_col_offset=52), Add(), Subscript(Name('placeholder_2', Load(), lineno=33, col_offset=55, end_lineno=33, end_col_offset=62), Constant(0, lineno=33, col_offset=63, end_lineno=33, end_col_offset=64), Load(), lineno=33, col_offset=55, end_lineno=33, end_col_offset=65), lineno=33, col_offset=24, end_lineno=33, end_col_offset=65), Add(), Constant('\n', lineno=33, col_offset=68, end_lineno=33, end_col_offset=72), lineno=33, col_offset=24, end_lineno=33, end_col_offset=72), Add(), Name('placeholder_8', Load(), lineno=33, col_offset=75, end_lineno=33, end_col_offset=80), lineno=33, col_offset=24, end_lineno=33, end_col_offset=80), lineno=33, col_offset=16, end_lineno=33, end_col_offset=80)], [AugAssign(Name('placeholder_7', Store(), lineno=35, col_offset=16, end_lineno=35, end_col_offset=21), Add(), BinOp(Subscript(Name('placeholder_2', Load(), lineno=35, col_offset=25, end_lineno=35, end_col_offset=32), BinOp(Name('placeholder_9', Load(), lineno=35, col_offset=33, end_lineno=35, end_col_offset=39), Sub(), Constant(1, lineno=35, col_offset=40, end_lineno=35, end_col_offset=41), lineno=35, col_offset=33, end_lineno=35, end_col_offset=41), Load(), lineno=35, col_offset=25, end_lineno=35, end_col_offset=42), Add(), Constant('\n', lineno=35, col_offset=45, end_lineno=35, end_col_offset=49), lineno=35, col_offset=25, end_lineno=35, end_col_offset=49), lineno=35, col_offset=16, end_lineno=35, end_col_offset=49), Assign([Name('placeholder_8', Store(), lineno=36, col_offset=16, end_lineno=36, end_col_offset=21)], Call(Attribute(Name('placeholder_8', Load(), lineno=36, col_offset=24, end_lineno=36, end_col_offset=29), 'replace', Load(), lineno=36, col_offset=24, end_lineno=36, end_col_offset=37), [Constant('', lineno=36, col_offset=38, end_lineno=36, end_col_offset=48), Name('placeholder_10', Load(), lineno=36, col_offset=50, end_lineno=36, end_col_offset=56)], [], lineno=36, col_offset=24, end_lineno=36, end_col_offset=57), lineno=36, col_offset=16, end_lineno=36, end_col_offset=57), AugAssign(Name('placeholder_7', Store(), lineno=37, col_offset=16, end_lineno=37, end_col_offset=21), Add(), Name('placeholder_8', Load(), lineno=37, col_offset=25, end_lineno=37, end_col_offset=30), lineno=37, col_offset=16, end_lineno=37, end_col_offset=30), Assign([Name('placeholder_8', Store(), lineno=38, col_offset=16, end_lineno=38, end_col_offset=21)], BinOp(BinOp(BinOp(Name('placeholder_4', Load(), lineno=38, col_offset=24, end_lineno=38, end_col_offset=33), Add(), Name('placeholder_10', Load(), lineno=38, col_offset=36, end_lineno=38, end_col_offset=42), lineno=38, col_offset=24, end_lineno=38, end_col_offset=42), Add(), Constant('.\n', lineno=38, col_offset=45, end_lineno=38, end_col_offset=50), lineno=38, col_offset=24, end_lineno=38, end_col_offset=50), Add(), Name('placeholder_8', Load(), lineno=38, col_offset=53, end_lineno=38, end_col_offset=58), lineno=38, col_offset=24, end_lineno=38, end_col_offset=58), lineno=38, col_offset=16, end_lineno=38, end_col_offset=58)], lineno=29, col_offset=12, end_lineno=38, end_col_offset=58)], lineno=27, col_offset=12, end_lineno=38, end_col_offset=58), AugAssign(Name('placeholder_7', Store(), lineno=40, col_offset=12, end_lineno=40, end_col_offset=17), Add(), BinOp(Name('placeholder_5', Load(), lineno=40, col_offset=21, end_lineno=40, end_col_offset=24), Add(), Constant('\n', lineno=40, col_offset=27, end_lineno=40, end_col_offset=31), lineno=40, col_offset=21, end_lineno=40, end_col_offset=31), lineno=40, col_offset=12, end_lineno=40, end_col_offset=31)], lineno=24, col_offset=8, end_lineno=40, end_col_offset=31), AugAssign(Name('placeholder_7', Store(), lineno=42, col_offset=8, end_lineno=42, end_col_offset=13), Add(), Constant('\n', lineno=42, col_offset=17, end_lineno=42, end_col_offset=21), lineno=42, col_offset=8, end_lineno=42, end_col_offset=21), AugAssign(Name('placeholder_6', Store(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=12), Add(), Name('placeholder_7', Load(), lineno=43, col_offset=16, end_lineno=43, end_col_offset=21), lineno=43, col_offset=8, end_lineno=43, end_col_offset=21)], [], lineno=21, col_offset=4, end_lineno=43, end_col_offset=21), Return(Name('placeholder_6', Load(), lineno=45, col_offset=11, end_lineno=45, end_col_offset=15), lineno=45, col_offset=4, end_lineno=45, end_col_offset=15)], [], lineno=1, col_offset=0, end_lineno=45, end_col_offset=15), FunctionDef('placeholder_11', arguments([], [arg('placeholder_12', lineno=48, col_offset=11, end_lineno=48, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Call(Attribute(Name('placeholder_12', Load(), lineno=49, col_offset=11, end_lineno=49, end_col_offset=17), 'replace', Load(), lineno=49, col_offset=11, end_lineno=49, end_col_offset=25), [Constant('die.', lineno=49, col_offset=26, end_lineno=49, end_col_offset=32), Constant('die.slice', lineno=49, col_offset=34, end_lineno=49, end_col_offset=45)], [], lineno=49, col_offset=11, end_lineno=49, end_col_offset=46), 'split', Load(), lineno=49, col_offset=11, end_lineno=49, end_col_offset=52), [Constant('slice', lineno=49, col_offset=53, end_lineno=49, end_col_offset=60)], [], lineno=49, col_offset=11, end_lineno=49, end_col_offset=61), lineno=49, col_offset=4, end_lineno=49, end_col_offset=61)], [], lineno=48, col_offset=0, end_lineno=49, end_col_offset=61), FunctionDef('placeholder_13', arguments([], [arg('placeholder_14', lineno=52, col_offset=11, end_lineno=52, end_col_offset=22), arg('placeholder_15', lineno=52, col_offset=24, end_lineno=52, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_16', Store(), lineno=53, col_offset=4, end_lineno=53, end_col_offset=13)], ListComp(Call(Attribute(Call(Attribute(Name('placeholder_7', Load(), lineno=53, col_offset=17, end_lineno=53, end_col_offset=22), 'strip', Load(), lineno=53, col_offset=17, end_lineno=53, end_col_offset=28), [], [], lineno=53, col_offset=17, end_lineno=53, end_col_offset=30), 'split', Load(), lineno=53, col_offset=17, end_lineno=53, end_col_offset=36), [Constant('\n', lineno=53, col_offset=37, end_lineno=53, end_col_offset=41)], [], lineno=53, col_offset=17, end_lineno=53, end_col_offset=42), [comprehension(Name('placeholder_7', Store(), lineno=53, col_offset=47, end_lineno=53, end_col_offset=52), Call(Name('placeholder_11', Load(), lineno=53, col_offset=56, end_lineno=53, end_col_offset=62), [Call(Name('placeholder_0', Load(), lineno=53, col_offset=63, end_lineno=53, end_col_offset=71), [], [], lineno=53, col_offset=63, end_lineno=53, end_col_offset=73)], [], lineno=53, col_offset=56, end_lineno=53, end_col_offset=74), [], 0)], lineno=53, col_offset=16, end_lineno=53, end_col_offset=75), lineno=53, col_offset=4, end_lineno=53, end_col_offset=75), If(Compare(Name('placeholder_14', Load(), lineno=54, col_offset=7, end_lineno=54, end_col_offset=18), [Eq()], [Name('placeholder_15', Load(), lineno=54, col_offset=22, end_lineno=54, end_col_offset=31)], lineno=54, col_offset=7, end_lineno=54, end_col_offset=31), [Return(Subscript(Name('placeholder_16', Load(), lineno=55, col_offset=15, end_lineno=55, end_col_offset=24), BinOp(Name('placeholder_14', Load(), lineno=55, col_offset=25, end_lineno=55, end_col_offset=36), Sub(), Constant(1, lineno=55, col_offset=39, end_lineno=55, end_col_offset=40), lineno=55, col_offset=25, end_lineno=55, end_col_offset=40), Load(), lineno=55, col_offset=15, end_lineno=55, end_col_offset=41), lineno=55, col_offset=8, end_lineno=55, end_col_offset=41)], [Assign([Name('placeholder_17', Store(), lineno=57, col_offset=8, end_lineno=57, end_col_offset=14)], List([], Load(), lineno=57, col_offset=17, end_lineno=57, end_col_offset=19), lineno=57, col_offset=8, end_lineno=57, end_col_offset=19), For(Name('placeholder_18', Store(), lineno=58, col_offset=12, end_lineno=58, end_col_offset=15), Call(Name('range', Load(), lineno=58, col_offset=19, end_lineno=58, end_col_offset=24), [BinOp(Name('placeholder_14', Load(), lineno=58, col_offset=25, end_lineno=58, end_col_offset=36), Sub(), Constant(1, lineno=58, col_offset=39, end_lineno=58, end_col_offset=40), lineno=58, col_offset=25, end_lineno=58, end_col_offset=40), Name('placeholder_15', Load(), lineno=58, col_offset=42, end_lineno=58, end_col_offset=51)], [], lineno=58, col_offset=19, end_lineno=58, end_col_offset=52), [AugAssign(Name('placeholder_17', Store(), lineno=59, col_offset=12, end_lineno=59, end_col_offset=18), Add(), BinOp(Subscript(Name('placeholder_16', Load(), lineno=59, col_offset=22, end_lineno=59, end_col_offset=31), Name('placeholder_18', Load(), lineno=59, col_offset=32, end_lineno=59, end_col_offset=35), Load(), lineno=59, col_offset=22, end_lineno=59, end_col_offset=36), Add(), List([Constant('', lineno=59, col_offset=40, end_lineno=59, end_col_offset=42)], Load(), lineno=59, col_offset=39, end_lineno=59, end_col_offset=43), lineno=59, col_offset=22, end_lineno=59, end_col_offset=43), lineno=59, col_offset=12, end_lineno=59, end_col_offset=43)], [], lineno=58, col_offset=8, end_lineno=59, end_col_offset=43), Expr(Call(Attribute(Name('placeholder_17', Load(), lineno=62, col_offset=8, end_lineno=62, end_col_offset=14), 'pop', Load(), lineno=62, col_offset=8, end_lineno=62, end_col_offset=18), [], [], lineno=62, col_offset=8, end_lineno=62, end_col_offset=20), lineno=62, col_offset=8, end_lineno=62, end_col_offset=20), Return(Name('placeholder_17', Load(), lineno=63, col_offset=15, end_lineno=63, end_col_offset=21), lineno=63, col_offset=8, end_lineno=63, end_col_offset=21)], lineno=54, col_offset=4, end_lineno=63, end_col_offset=21)], [], lineno=52, col_offset=0, end_lineno=63, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-forth/.meta/config.json b/test/practice-forth/.meta/config.json new file mode 100644 index 0000000..569eddd --- /dev/null +++ b/test/practice-forth/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "Dog", + "dvermd", + "ikhadykin", + "N-Parsons", + "omer-g", + "parthsharma2", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "forth.py" + ], + "test": [ + "forth_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement an evaluator for a very simple subset of Forth." +} diff --git a/test/practice-forth/forth.py b/test/practice-forth/forth.py new file mode 100644 index 0000000..5e499ac --- /dev/null +++ b/test/practice-forth/forth.py @@ -0,0 +1,66 @@ +class StackUnderflowError(Exception): + """Exception raised when Stack is not full. + message: explanation of the error. + """ + def __init__(self, message): + self.message = message + + +def is_integer(string): + try: + int(string) + return True + except ValueError: + return False + + +def evaluate(input_data): + if not input_data: + return [] + defines = {} + while input_data[0][:1] == ':': + values = input_data.pop(0).split() + values.pop() + values.pop(0) + key = values.pop(0).lower() + if is_integer(key): + raise ValueError('illegal operation') + defines[key] = [ + idx + for vivaldi in values + for idx in defines.get(vivaldi, [vivaldi]) + ] + stack = [] + input_data = input_data[-1].split() + while any(input_data): + word = input_data.pop(0).lower() + try: + if is_integer(word): + stack.append(int(word)) + elif word in defines: + input_data = defines[word] + input_data + elif word == '+': + stack.append(stack.pop() + stack.pop()) + elif word == '-': + stack.append(-stack.pop() + stack.pop()) + elif word == '*': + stack.append(stack.pop() * stack.pop()) + elif word == '/': + divisor = stack.pop() + if divisor == 0: + raise ZeroDivisionError('divide by zero') + stack.append(int(stack.pop() / divisor)) + elif word == 'dup': + stack.append(stack[-1]) + elif word == 'drop': + stack.pop() + elif word == 'swap': + stack.append(stack[-2]) + del stack[-3] + elif word == 'over': + stack.append(stack[-2]) + else: + raise ValueError('undefined operation') + except IndexError as error: + raise StackUnderflowError('Insufficient number of items in stack') from error + return stack diff --git a/test/practice-forth/mapping.json b/test/practice-forth/mapping.json new file mode 100644 index 0000000..048e42d --- /dev/null +++ b/test/practice-forth/mapping.json @@ -0,0 +1,18 @@ +{ + "placeholder_0": "StackUnderflowError", + "placeholder_1": "__init__", + "placeholder_2": "message", + "placeholder_3": "is_integer", + "placeholder_4": "string", + "placeholder_5": "evaluate", + "placeholder_6": "input_data", + "placeholder_7": "defines", + "placeholder_8": "values", + "placeholder_9": "key", + "placeholder_10": "vivaldi", + "placeholder_11": "idx", + "placeholder_12": "stack", + "placeholder_13": "word", + "placeholder_14": "divisor", + "placeholder_15": "error" +} \ No newline at end of file diff --git a/test/practice-forth/representation.json b/test/practice-forth/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-forth/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-forth/representation.out b/test/practice-forth/representation.out new file mode 100644 index 0000000..57cde76 --- /dev/null +++ b/test/practice-forth/representation.out @@ -0,0 +1,3761 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0(Exception): + def placeholder_1(self, placeholder_2): + self.placeholder_2 = placeholder_2 + + +def placeholder_3(placeholder_4): + try: + int(placeholder_4) + return True + except ValueError: + return False + + +def placeholder_5(placeholder_6): + if not placeholder_6: + return [] + placeholder_7 = {} + while placeholder_6[0][:1] == ":": + placeholder_8 = placeholder_6.pop(0).split() + placeholder_8.pop() + placeholder_8.pop(0) + placeholder_9 = placeholder_8.pop(0).lower() + if placeholder_3(placeholder_9): + raise ValueError("illegal operation") + placeholder_7[placeholder_9] = [ + placeholder_11 + for placeholder_10 in placeholder_8 + for placeholder_11 in placeholder_7.get(placeholder_10, [placeholder_10]) + ] + placeholder_12 = [] + placeholder_6 = placeholder_6[-1].split() + while any(placeholder_6): + placeholder_13 = placeholder_6.pop(0).lower() + try: + if placeholder_3(placeholder_13): + placeholder_12.append(int(placeholder_13)) + elif placeholder_13 in placeholder_7: + placeholder_6 = placeholder_7[placeholder_13] + placeholder_6 + elif placeholder_13 == "+": + placeholder_12.append(placeholder_12.pop() + placeholder_12.pop()) + elif placeholder_13 == "-": + placeholder_12.append(-placeholder_12.pop() + placeholder_12.pop()) + elif placeholder_13 == "*": + placeholder_12.append(placeholder_12.pop() * placeholder_12.pop()) + elif placeholder_13 == "/": + placeholder_14 = placeholder_12.pop() + if placeholder_14 == 0: + raise ZeroDivisionError("divide by zero") + placeholder_12.append(int(placeholder_12.pop() / placeholder_14)) + elif placeholder_13 == "dup": + placeholder_12.append(placeholder_12[-1]) + elif placeholder_13 == "drop": + placeholder_12.pop() + elif placeholder_13 == "swap": + placeholder_12.append(placeholder_12[-2]) + del placeholder_12[-3] + elif placeholder_13 == "over": + placeholder_12.append(placeholder_12[-2]) + else: + raise ValueError("undefined operation") + except IndexError as placeholder_15: + raise placeholder_0( + "Insufficient number of items in stack" + ) from placeholder_15 + return placeholder_12 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'StackUnderflowError', + [ + Name( + 'Exception', + Load(), + lineno=1, + col_offset=26, + end_lineno=1, + end_col_offset=35)], + [], + [ + Expr( + Constant( + 'Exception raised when Stack is not full.\n message: explanation of the error.\n ', + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=7), + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=7), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'message', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'message', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=20)], + Name( + 'message', + Load(), + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=30), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=30)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=30)], + [], + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=30), + FunctionDef( + 'is_integer', + arguments( + [], + [ + arg( + 'string', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Expr( + Call( + Name( + 'int', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=11), + [ + Name( + 'string', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18)], + [], + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=19), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=19), + Return( + Constant( + True, + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=19), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=19)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=21), + body=[ + Return( + Constant( + False, + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=20), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=20)], + lineno=13, + col_offset=4, + end_lineno=14, + end_col_offset=20)], + [], + [], + lineno=10, + col_offset=4, + end_lineno=14, + end_col_offset=20)], + [], + lineno=9, + col_offset=0, + end_lineno=14, + end_col_offset=20), + FunctionDef( + 'evaluate', + arguments( + [], + [ + arg( + 'input_data', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'input_data', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=21), + lineno=18, + col_offset=7, + end_lineno=18, + end_col_offset=21), + [ + Return( + List( + [], + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=17), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=17)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=17), + Assign( + [ + Name( + 'defines', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=11)], + Dict( + [], + [], + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=16), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=16), + While( + Compare( + Subscript( + Subscript( + Name( + 'input_data', + Load(), + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=20), + Constant( + 0, + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=22), + Load(), + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=23), + Slice( + upper=Constant( + 1, + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=26), + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=26), + Load(), + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=27), + [ + Eq()], + [ + Constant( + ':', + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=34)], + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=34), + [ + Assign( + [ + Name( + 'values', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=14)], + Call( + Attribute( + Call( + Attribute( + Name( + 'input_data', + Load(), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=27), + 'pop', + Load(), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=31), + [ + Constant( + 0, + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=33)], + [], + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=34), + 'split', + Load(), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=40), + [], + [], + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=42), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=42), + Expr( + Call( + Attribute( + Name( + 'values', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=14), + 'pop', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=18), + [], + [], + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=20), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=20), + Expr( + Call( + Attribute( + Name( + 'values', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=14), + 'pop', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=18), + [ + Constant( + 0, + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=20)], + [], + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=21), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=21), + Assign( + [ + Name( + 'key', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=11)], + Call( + Attribute( + Call( + Attribute( + Name( + 'values', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=20), + 'pop', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=24), + [ + Constant( + 0, + lineno=25, + col_offset=25, + end_lineno=25, + end_col_offset=26)], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=27), + 'lower', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=33), + [], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=35), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=35), + If( + Call( + Name( + 'is_integer', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=21), + [ + Name( + 'key', + Load(), + lineno=26, + col_offset=22, + end_lineno=26, + end_col_offset=25)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=28), + [ + Constant( + 'illegal operation', + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=48)], + [], + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=49), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=49)], + [], + lineno=26, + col_offset=8, + end_lineno=27, + end_col_offset=49), + Assign( + [ + Subscript( + Name( + 'defines', + Load(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=15), + Name( + 'key', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=19), + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=20)], + ListComp( + Name( + 'idx', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=19), + [ + comprehension( + Name( + 'vivaldi', + Store(), + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=27), + Name( + 'values', + Load(), + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=37), + [], + 0), + comprehension( + Name( + 'idx', + Store(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=23), + Call( + Attribute( + Name( + 'defines', + Load(), + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=34), + 'get', + Load(), + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=38), + [ + Name( + 'vivaldi', + Load(), + lineno=31, + col_offset=39, + end_lineno=31, + end_col_offset=46), + List( + [ + Name( + 'vivaldi', + Load(), + lineno=31, + col_offset=49, + end_lineno=31, + end_col_offset=56)], + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=57)], + [], + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=58), + [], + 0)], + lineno=28, + col_offset=23, + end_lineno=32, + end_col_offset=9), + lineno=28, + col_offset=8, + end_lineno=32, + end_col_offset=9)], + [], + lineno=21, + col_offset=4, + end_lineno=32, + end_col_offset=9), + Assign( + [ + Name( + 'stack', + Store(), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=9)], + List( + [], + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=14), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=14), + Assign( + [ + Name( + 'input_data', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=14)], + Call( + Attribute( + Subscript( + Name( + 'input_data', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=27), + UnaryOp( + USub(), + Constant( + 1, + lineno=34, + col_offset=29, + end_lineno=34, + end_col_offset=30), + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=30), + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=31), + 'split', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=37), + [], + [], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=39), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=39), + While( + Call( + Name( + 'any', + Load(), + lineno=35, + col_offset=10, + end_lineno=35, + end_col_offset=13), + [ + Name( + 'input_data', + Load(), + lineno=35, + col_offset=14, + end_lineno=35, + end_col_offset=24)], + [], + lineno=35, + col_offset=10, + end_lineno=35, + end_col_offset=25), + [ + Assign( + [ + Name( + 'word', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=12)], + Call( + Attribute( + Call( + Attribute( + Name( + 'input_data', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=25), + 'pop', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=29), + [ + Constant( + 0, + lineno=36, + col_offset=30, + end_lineno=36, + end_col_offset=31)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=32), + 'lower', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=38), + [], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=40), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=40), + Try( + [ + If( + Call( + Name( + 'is_integer', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=25), + [ + Name( + 'word', + Load(), + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=30)], + [], + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=21), + 'append', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=28), + [ + Call( + Name( + 'int', + Load(), + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=32), + [ + Name( + 'word', + Load(), + lineno=39, + col_offset=33, + end_lineno=39, + end_col_offset=37)], + [], + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=38)], + [], + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=39), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=39)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=21), + [ + In()], + [ + Name( + 'defines', + Load(), + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=32)], + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=32), + [ + Assign( + [ + Name( + 'input_data', + Store(), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=26)], + BinOp( + Subscript( + Name( + 'defines', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=36), + Name( + 'word', + Load(), + lineno=41, + col_offset=37, + end_lineno=41, + end_col_offset=41), + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=42), + Add(), + Name( + 'input_data', + Load(), + lineno=41, + col_offset=45, + end_lineno=41, + end_col_offset=55), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=55), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=55)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '+', + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=28)], + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=28), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=21), + 'append', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=28), + [ + BinOp( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=43, + col_offset=29, + end_lineno=43, + end_col_offset=34), + 'pop', + Load(), + lineno=43, + col_offset=29, + end_lineno=43, + end_col_offset=38), + [], + [], + lineno=43, + col_offset=29, + end_lineno=43, + end_col_offset=40), + Add(), + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=43, + col_offset=43, + end_lineno=43, + end_col_offset=48), + 'pop', + Load(), + lineno=43, + col_offset=43, + end_lineno=43, + end_col_offset=52), + [], + [], + lineno=43, + col_offset=43, + end_lineno=43, + end_col_offset=54), + lineno=43, + col_offset=29, + end_lineno=43, + end_col_offset=54)], + [], + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=55), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=55)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=44, + col_offset=17, + end_lineno=44, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '-', + lineno=44, + col_offset=25, + end_lineno=44, + end_col_offset=28)], + lineno=44, + col_offset=17, + end_lineno=44, + end_col_offset=28), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=21), + 'append', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=28), + [ + BinOp( + UnaryOp( + USub(), + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=45, + col_offset=30, + end_lineno=45, + end_col_offset=35), + 'pop', + Load(), + lineno=45, + col_offset=30, + end_lineno=45, + end_col_offset=39), + [], + [], + lineno=45, + col_offset=30, + end_lineno=45, + end_col_offset=41), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=41), + Add(), + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=45, + col_offset=44, + end_lineno=45, + end_col_offset=49), + 'pop', + Load(), + lineno=45, + col_offset=44, + end_lineno=45, + end_col_offset=53), + [], + [], + lineno=45, + col_offset=44, + end_lineno=45, + end_col_offset=55), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=55)], + [], + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=56), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=56)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '*', + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=28)], + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=28), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=21), + 'append', + Load(), + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=28), + [ + BinOp( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=34), + 'pop', + Load(), + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=38), + [], + [], + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=40), + Mult(), + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=48), + 'pop', + Load(), + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=52), + [], + [], + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=54), + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=54)], + [], + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=55), + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=55)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '/', + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=28)], + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=28), + [ + Assign( + [ + Name( + 'divisor', + Store(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=23)], + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=49, + col_offset=26, + end_lineno=49, + end_col_offset=31), + 'pop', + Load(), + lineno=49, + col_offset=26, + end_lineno=49, + end_col_offset=35), + [], + [], + lineno=49, + col_offset=26, + end_lineno=49, + end_col_offset=37), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=37), + If( + Compare( + Name( + 'divisor', + Load(), + lineno=50, + col_offset=19, + end_lineno=50, + end_col_offset=26), + [ + Eq()], + [ + Constant( + 0, + lineno=50, + col_offset=30, + end_lineno=50, + end_col_offset=31)], + lineno=50, + col_offset=19, + end_lineno=50, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ZeroDivisionError', + Load(), + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=43), + [ + Constant( + 'divide by zero', + lineno=51, + col_offset=44, + end_lineno=51, + end_col_offset=60)], + [], + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=61), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=61)], + [], + lineno=50, + col_offset=16, + end_lineno=51, + end_col_offset=61), + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=21), + 'append', + Load(), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=28), + [ + Call( + Name( + 'int', + Load(), + lineno=52, + col_offset=29, + end_lineno=52, + end_col_offset=32), + [ + BinOp( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=52, + col_offset=33, + end_lineno=52, + end_col_offset=38), + 'pop', + Load(), + lineno=52, + col_offset=33, + end_lineno=52, + end_col_offset=42), + [], + [], + lineno=52, + col_offset=33, + end_lineno=52, + end_col_offset=44), + Div(), + Name( + 'divisor', + Load(), + lineno=52, + col_offset=47, + end_lineno=52, + end_col_offset=54), + lineno=52, + col_offset=33, + end_lineno=52, + end_col_offset=54)], + [], + lineno=52, + col_offset=29, + end_lineno=52, + end_col_offset=55)], + [], + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=56), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=56)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'dup', + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=30)], + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=30), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=21), + 'append', + Load(), + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=28), + [ + Subscript( + Name( + 'stack', + Load(), + lineno=54, + col_offset=29, + end_lineno=54, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 1, + lineno=54, + col_offset=36, + end_lineno=54, + end_col_offset=37), + lineno=54, + col_offset=35, + end_lineno=54, + end_col_offset=37), + Load(), + lineno=54, + col_offset=29, + end_lineno=54, + end_col_offset=38)], + [], + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=39), + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=39)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'drop', + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=31)], + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=21), + 'pop', + Load(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=25), + [], + [], + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=27), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=27)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=57, + col_offset=17, + end_lineno=57, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'swap', + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=31)], + lineno=57, + col_offset=17, + end_lineno=57, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=21), + 'append', + Load(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=28), + [ + Subscript( + Name( + 'stack', + Load(), + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 2, + lineno=58, + col_offset=36, + end_lineno=58, + end_col_offset=37), + lineno=58, + col_offset=35, + end_lineno=58, + end_col_offset=37), + Load(), + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=38)], + [], + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=39), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=39), + Delete( + [ + Subscript( + Name( + 'stack', + Load(), + lineno=59, + col_offset=20, + end_lineno=59, + end_col_offset=25), + UnaryOp( + USub(), + Constant( + 3, + lineno=59, + col_offset=27, + end_lineno=59, + end_col_offset=28), + lineno=59, + col_offset=26, + end_lineno=59, + end_col_offset=28), + Del(), + lineno=59, + col_offset=20, + end_lineno=59, + end_col_offset=29)], + lineno=59, + col_offset=16, + end_lineno=59, + end_col_offset=29)], + [ + If( + Compare( + Name( + 'word', + Load(), + lineno=60, + col_offset=17, + end_lineno=60, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'over', + lineno=60, + col_offset=25, + end_lineno=60, + end_col_offset=31)], + lineno=60, + col_offset=17, + end_lineno=60, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=21), + 'append', + Load(), + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=28), + [ + Subscript( + Name( + 'stack', + Load(), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 2, + lineno=61, + col_offset=36, + end_lineno=61, + end_col_offset=37), + lineno=61, + col_offset=35, + end_lineno=61, + end_col_offset=37), + Load(), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=38)], + [], + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=39), + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=39)], + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=32), + [ + Constant( + 'undefined operation', + lineno=63, + col_offset=33, + end_lineno=63, + end_col_offset=54)], + [], + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=55), + lineno=63, + col_offset=16, + end_lineno=63, + end_col_offset=55)], + lineno=60, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=57, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=55, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=53, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=48, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=46, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=44, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=42, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=40, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=38, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + [ + ExceptHandler( + Name( + 'IndexError', + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=25), + 'error', + [ + Raise( + Call( + Name( + 'StackUnderflowError', + Load(), + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=37), + [ + Constant( + 'Insufficient number of items in stack', + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=77)], + [], + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=78), + Name( + 'error', + Load(), + lineno=65, + col_offset=84, + end_lineno=65, + end_col_offset=89), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=89)], + lineno=64, + col_offset=8, + end_lineno=65, + end_col_offset=89)], + [], + [], + lineno=37, + col_offset=8, + end_lineno=65, + end_col_offset=89)], + [], + lineno=35, + col_offset=4, + end_lineno=65, + end_col_offset=89), + Return( + Name( + 'stack', + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=16), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=16)], + [], + lineno=17, + col_offset=0, + end_lineno=66, + end_col_offset=16)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [ + Name( + 'Exception', + Load(), + lineno=1, + col_offset=26, + end_lineno=1, + end_col_offset=35)], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=20)], + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=30), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=30)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=30)], + [], + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=30), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Expr( + Call( + Name( + 'int', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=11), + [ + Name( + 'placeholder_4', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18)], + [], + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=19), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=19), + Return( + Constant( + True, + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=19), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=19)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=21), + body=[ + Return( + Constant( + False, + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=20), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=20)], + lineno=13, + col_offset=4, + end_lineno=14, + end_col_offset=20)], + [], + [], + lineno=10, + col_offset=4, + end_lineno=14, + end_col_offset=20)], + [], + lineno=9, + col_offset=0, + end_lineno=14, + end_col_offset=20), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_6', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=21), + lineno=18, + col_offset=7, + end_lineno=18, + end_col_offset=21), + [ + Return( + List( + [], + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=17), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=17)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=11)], + Dict( + [], + [], + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=16), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=16), + While( + Compare( + Subscript( + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=20), + Constant( + 0, + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=22), + Load(), + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=23), + Slice( + upper=Constant( + 1, + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=26), + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=26), + Load(), + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=27), + [ + Eq()], + [ + Constant( + ':', + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=34)], + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=34), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=14)], + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=27), + 'pop', + Load(), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=31), + [ + Constant( + 0, + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=33)], + [], + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=34), + 'split', + Load(), + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=40), + [], + [], + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=42), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=42), + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=14), + 'pop', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=18), + [], + [], + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=20), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=20), + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=14), + 'pop', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=18), + [ + Constant( + 0, + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=20)], + [], + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=21), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=21), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=11)], + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=20), + 'pop', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=24), + [ + Constant( + 0, + lineno=25, + col_offset=25, + end_lineno=25, + end_col_offset=26)], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=27), + 'lower', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=33), + [], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=35), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=35), + If( + Call( + Name( + 'placeholder_3', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=21), + [ + Name( + 'placeholder_9', + Load(), + lineno=26, + col_offset=22, + end_lineno=26, + end_col_offset=25)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=28), + [ + Constant( + 'illegal operation', + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=48)], + [], + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=49), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=49)], + [], + lineno=26, + col_offset=8, + end_lineno=27, + end_col_offset=49), + Assign( + [ + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=15), + Name( + 'placeholder_9', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=19), + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=20)], + ListComp( + Name( + 'placeholder_11', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=19), + [ + comprehension( + Name( + 'placeholder_10', + Store(), + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=27), + Name( + 'placeholder_8', + Load(), + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=37), + [], + 0), + comprehension( + Name( + 'placeholder_11', + Store(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=23), + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=34), + 'get', + Load(), + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=38), + [ + Name( + 'placeholder_10', + Load(), + lineno=31, + col_offset=39, + end_lineno=31, + end_col_offset=46), + List( + [ + Name( + 'placeholder_10', + Load(), + lineno=31, + col_offset=49, + end_lineno=31, + end_col_offset=56)], + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=57)], + [], + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=58), + [], + 0)], + lineno=28, + col_offset=23, + end_lineno=32, + end_col_offset=9), + lineno=28, + col_offset=8, + end_lineno=32, + end_col_offset=9)], + [], + lineno=21, + col_offset=4, + end_lineno=32, + end_col_offset=9), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=9)], + List( + [], + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=14), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=14)], + Call( + Attribute( + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=27), + UnaryOp( + USub(), + Constant( + 1, + lineno=34, + col_offset=29, + end_lineno=34, + end_col_offset=30), + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=30), + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=31), + 'split', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=37), + [], + [], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=39), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=39), + While( + Call( + Name( + 'any', + Load(), + lineno=35, + col_offset=10, + end_lineno=35, + end_col_offset=13), + [ + Name( + 'placeholder_6', + Load(), + lineno=35, + col_offset=14, + end_lineno=35, + end_col_offset=24)], + [], + lineno=35, + col_offset=10, + end_lineno=35, + end_col_offset=25), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=12)], + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=25), + 'pop', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=29), + [ + Constant( + 0, + lineno=36, + col_offset=30, + end_lineno=36, + end_col_offset=31)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=32), + 'lower', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=38), + [], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=40), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=40), + Try( + [ + If( + Call( + Name( + 'placeholder_3', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=25), + [ + Name( + 'placeholder_13', + Load(), + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=30)], + [], + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=21), + 'append', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=28), + [ + Call( + Name( + 'int', + Load(), + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=32), + [ + Name( + 'placeholder_13', + Load(), + lineno=39, + col_offset=33, + end_lineno=39, + end_col_offset=37)], + [], + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=38)], + [], + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=39), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=39)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=21), + [ + In()], + [ + Name( + 'placeholder_7', + Load(), + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=32)], + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=32), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=26)], + BinOp( + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=36), + Name( + 'placeholder_13', + Load(), + lineno=41, + col_offset=37, + end_lineno=41, + end_col_offset=41), + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=42), + Add(), + Name( + 'placeholder_6', + Load(), + lineno=41, + col_offset=45, + end_lineno=41, + end_col_offset=55), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=55), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=55)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '+', + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=28)], + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=28), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=21), + 'append', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=28), + [ + BinOp( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=43, + col_offset=29, + end_lineno=43, + end_col_offset=34), + 'pop', + Load(), + lineno=43, + col_offset=29, + end_lineno=43, + end_col_offset=38), + [], + [], + lineno=43, + col_offset=29, + end_lineno=43, + end_col_offset=40), + Add(), + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=43, + col_offset=43, + end_lineno=43, + end_col_offset=48), + 'pop', + Load(), + lineno=43, + col_offset=43, + end_lineno=43, + end_col_offset=52), + [], + [], + lineno=43, + col_offset=43, + end_lineno=43, + end_col_offset=54), + lineno=43, + col_offset=29, + end_lineno=43, + end_col_offset=54)], + [], + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=55), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=55)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=44, + col_offset=17, + end_lineno=44, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '-', + lineno=44, + col_offset=25, + end_lineno=44, + end_col_offset=28)], + lineno=44, + col_offset=17, + end_lineno=44, + end_col_offset=28), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=21), + 'append', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=28), + [ + BinOp( + UnaryOp( + USub(), + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=45, + col_offset=30, + end_lineno=45, + end_col_offset=35), + 'pop', + Load(), + lineno=45, + col_offset=30, + end_lineno=45, + end_col_offset=39), + [], + [], + lineno=45, + col_offset=30, + end_lineno=45, + end_col_offset=41), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=41), + Add(), + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=45, + col_offset=44, + end_lineno=45, + end_col_offset=49), + 'pop', + Load(), + lineno=45, + col_offset=44, + end_lineno=45, + end_col_offset=53), + [], + [], + lineno=45, + col_offset=44, + end_lineno=45, + end_col_offset=55), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=55)], + [], + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=56), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=56)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '*', + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=28)], + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=28), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=21), + 'append', + Load(), + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=28), + [ + BinOp( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=34), + 'pop', + Load(), + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=38), + [], + [], + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=40), + Mult(), + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=48), + 'pop', + Load(), + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=52), + [], + [], + lineno=47, + col_offset=43, + end_lineno=47, + end_col_offset=54), + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=54)], + [], + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=55), + lineno=47, + col_offset=16, + end_lineno=47, + end_col_offset=55)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '/', + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=28)], + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=28), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=23)], + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=49, + col_offset=26, + end_lineno=49, + end_col_offset=31), + 'pop', + Load(), + lineno=49, + col_offset=26, + end_lineno=49, + end_col_offset=35), + [], + [], + lineno=49, + col_offset=26, + end_lineno=49, + end_col_offset=37), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=37), + If( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=50, + col_offset=19, + end_lineno=50, + end_col_offset=26), + [ + Eq()], + [ + Constant( + 0, + lineno=50, + col_offset=30, + end_lineno=50, + end_col_offset=31)], + lineno=50, + col_offset=19, + end_lineno=50, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ZeroDivisionError', + Load(), + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=43), + [ + Constant( + 'divide by zero', + lineno=51, + col_offset=44, + end_lineno=51, + end_col_offset=60)], + [], + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=61), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=61)], + [], + lineno=50, + col_offset=16, + end_lineno=51, + end_col_offset=61), + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=21), + 'append', + Load(), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=28), + [ + Call( + Name( + 'int', + Load(), + lineno=52, + col_offset=29, + end_lineno=52, + end_col_offset=32), + [ + BinOp( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=52, + col_offset=33, + end_lineno=52, + end_col_offset=38), + 'pop', + Load(), + lineno=52, + col_offset=33, + end_lineno=52, + end_col_offset=42), + [], + [], + lineno=52, + col_offset=33, + end_lineno=52, + end_col_offset=44), + Div(), + Name( + 'placeholder_14', + Load(), + lineno=52, + col_offset=47, + end_lineno=52, + end_col_offset=54), + lineno=52, + col_offset=33, + end_lineno=52, + end_col_offset=54)], + [], + lineno=52, + col_offset=29, + end_lineno=52, + end_col_offset=55)], + [], + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=56), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=56)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'dup', + lineno=53, + col_offset=25, + end_lineno=53, + end_col_offset=30)], + lineno=53, + col_offset=17, + end_lineno=53, + end_col_offset=30), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=21), + 'append', + Load(), + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=28), + [ + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=54, + col_offset=29, + end_lineno=54, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 1, + lineno=54, + col_offset=36, + end_lineno=54, + end_col_offset=37), + lineno=54, + col_offset=35, + end_lineno=54, + end_col_offset=37), + Load(), + lineno=54, + col_offset=29, + end_lineno=54, + end_col_offset=38)], + [], + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=39), + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=39)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'drop', + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=31)], + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=21), + 'pop', + Load(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=25), + [], + [], + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=27), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=27)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=57, + col_offset=17, + end_lineno=57, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'swap', + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=31)], + lineno=57, + col_offset=17, + end_lineno=57, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=21), + 'append', + Load(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=28), + [ + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 2, + lineno=58, + col_offset=36, + end_lineno=58, + end_col_offset=37), + lineno=58, + col_offset=35, + end_lineno=58, + end_col_offset=37), + Load(), + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=38)], + [], + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=39), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=39), + Delete( + [ + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=59, + col_offset=20, + end_lineno=59, + end_col_offset=25), + UnaryOp( + USub(), + Constant( + 3, + lineno=59, + col_offset=27, + end_lineno=59, + end_col_offset=28), + lineno=59, + col_offset=26, + end_lineno=59, + end_col_offset=28), + Del(), + lineno=59, + col_offset=20, + end_lineno=59, + end_col_offset=29)], + lineno=59, + col_offset=16, + end_lineno=59, + end_col_offset=29)], + [ + If( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=60, + col_offset=17, + end_lineno=60, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'over', + lineno=60, + col_offset=25, + end_lineno=60, + end_col_offset=31)], + lineno=60, + col_offset=17, + end_lineno=60, + end_col_offset=31), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=21), + 'append', + Load(), + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=28), + [ + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 2, + lineno=61, + col_offset=36, + end_lineno=61, + end_col_offset=37), + lineno=61, + col_offset=35, + end_lineno=61, + end_col_offset=37), + Load(), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=38)], + [], + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=39), + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=39)], + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=32), + [ + Constant( + 'undefined operation', + lineno=63, + col_offset=33, + end_lineno=63, + end_col_offset=54)], + [], + lineno=63, + col_offset=22, + end_lineno=63, + end_col_offset=55), + lineno=63, + col_offset=16, + end_lineno=63, + end_col_offset=55)], + lineno=60, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=57, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=55, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=53, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=48, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=46, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=44, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=42, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=40, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + lineno=38, + col_offset=12, + end_lineno=63, + end_col_offset=55)], + [ + ExceptHandler( + Name( + 'IndexError', + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=25), + 'placeholder_15', + [ + Raise( + Call( + Name( + 'placeholder_0', + Load(), + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=37), + [ + Constant( + 'Insufficient number of items in stack', + lineno=65, + col_offset=38, + end_lineno=65, + end_col_offset=77)], + [], + lineno=65, + col_offset=18, + end_lineno=65, + end_col_offset=78), + Name( + 'placeholder_15', + Load(), + lineno=65, + col_offset=84, + end_lineno=65, + end_col_offset=89), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=89)], + lineno=64, + col_offset=8, + end_lineno=65, + end_col_offset=89)], + [], + [], + lineno=37, + col_offset=8, + end_lineno=65, + end_col_offset=89)], + [], + lineno=35, + col_offset=4, + end_lineno=65, + end_col_offset=89), + Return( + Name( + 'placeholder_12', + Load(), + lineno=66, + col_offset=11, + end_lineno=66, + end_col_offset=16), + lineno=66, + col_offset=4, + end_lineno=66, + end_col_offset=16)], + [], + lineno=17, + col_offset=0, + end_lineno=66, + end_col_offset=16)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-forth/representation.txt b/test/practice-forth/representation.txt new file mode 100644 index 0000000..0edbb29 --- /dev/null +++ b/test/practice-forth/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [Name('Exception', Load(), lineno=1, col_offset=26, end_lineno=1, end_col_offset=35)], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21), arg('placeholder_2', lineno=5, col_offset=23, end_lineno=5, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_2', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=20)], Name('placeholder_2', Load(), lineno=6, col_offset=23, end_lineno=6, end_col_offset=30), lineno=6, col_offset=8, end_lineno=6, end_col_offset=30)], [], lineno=5, col_offset=4, end_lineno=6, end_col_offset=30)], [], lineno=1, col_offset=0, end_lineno=6, end_col_offset=30), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=9, col_offset=15, end_lineno=9, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Try([Expr(Call(Name('int', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=11), [Name('placeholder_4', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=18)], [], lineno=11, col_offset=8, end_lineno=11, end_col_offset=19), lineno=11, col_offset=8, end_lineno=11, end_col_offset=19), Return(Constant(True, lineno=12, col_offset=15, end_lineno=12, end_col_offset=19), lineno=12, col_offset=8, end_lineno=12, end_col_offset=19)], [ExceptHandler(Name('ValueError', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=21), body=[Return(Constant(False, lineno=14, col_offset=15, end_lineno=14, end_col_offset=20), lineno=14, col_offset=8, end_lineno=14, end_col_offset=20)], lineno=13, col_offset=4, end_lineno=14, end_col_offset=20)], [], [], lineno=10, col_offset=4, end_lineno=14, end_col_offset=20)], [], lineno=9, col_offset=0, end_lineno=14, end_col_offset=20), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=17, col_offset=13, end_lineno=17, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Name('placeholder_6', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=21), lineno=18, col_offset=7, end_lineno=18, end_col_offset=21), [Return(List([], Load(), lineno=19, col_offset=15, end_lineno=19, end_col_offset=17), lineno=19, col_offset=8, end_lineno=19, end_col_offset=17)], [], lineno=18, col_offset=4, end_lineno=19, end_col_offset=17), Assign([Name('placeholder_7', Store(), lineno=20, col_offset=4, end_lineno=20, end_col_offset=11)], Dict([], [], lineno=20, col_offset=14, end_lineno=20, end_col_offset=16), lineno=20, col_offset=4, end_lineno=20, end_col_offset=16), While(Compare(Subscript(Subscript(Name('placeholder_6', Load(), lineno=21, col_offset=10, end_lineno=21, end_col_offset=20), Constant(0, lineno=21, col_offset=21, end_lineno=21, end_col_offset=22), Load(), lineno=21, col_offset=10, end_lineno=21, end_col_offset=23), Slice(upper=Constant(1, lineno=21, col_offset=25, end_lineno=21, end_col_offset=26), lineno=21, col_offset=24, end_lineno=21, end_col_offset=26), Load(), lineno=21, col_offset=10, end_lineno=21, end_col_offset=27), [Eq()], [Constant(':', lineno=21, col_offset=31, end_lineno=21, end_col_offset=34)], lineno=21, col_offset=10, end_lineno=21, end_col_offset=34), [Assign([Name('placeholder_8', Store(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=14)], Call(Attribute(Call(Attribute(Name('placeholder_6', Load(), lineno=22, col_offset=17, end_lineno=22, end_col_offset=27), 'pop', Load(), lineno=22, col_offset=17, end_lineno=22, end_col_offset=31), [Constant(0, lineno=22, col_offset=32, end_lineno=22, end_col_offset=33)], [], lineno=22, col_offset=17, end_lineno=22, end_col_offset=34), 'split', Load(), lineno=22, col_offset=17, end_lineno=22, end_col_offset=40), [], [], lineno=22, col_offset=17, end_lineno=22, end_col_offset=42), lineno=22, col_offset=8, end_lineno=22, end_col_offset=42), Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=14), 'pop', Load(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=18), [], [], lineno=23, col_offset=8, end_lineno=23, end_col_offset=20), lineno=23, col_offset=8, end_lineno=23, end_col_offset=20), Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=14), 'pop', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=18), [Constant(0, lineno=24, col_offset=19, end_lineno=24, end_col_offset=20)], [], lineno=24, col_offset=8, end_lineno=24, end_col_offset=21), lineno=24, col_offset=8, end_lineno=24, end_col_offset=21), Assign([Name('placeholder_9', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=11)], Call(Attribute(Call(Attribute(Name('placeholder_8', Load(), lineno=25, col_offset=14, end_lineno=25, end_col_offset=20), 'pop', Load(), lineno=25, col_offset=14, end_lineno=25, end_col_offset=24), [Constant(0, lineno=25, col_offset=25, end_lineno=25, end_col_offset=26)], [], lineno=25, col_offset=14, end_lineno=25, end_col_offset=27), 'lower', Load(), lineno=25, col_offset=14, end_lineno=25, end_col_offset=33), [], [], lineno=25, col_offset=14, end_lineno=25, end_col_offset=35), lineno=25, col_offset=8, end_lineno=25, end_col_offset=35), If(Call(Name('placeholder_3', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=21), [Name('placeholder_9', Load(), lineno=26, col_offset=22, end_lineno=26, end_col_offset=25)], [], lineno=26, col_offset=11, end_lineno=26, end_col_offset=26), [Raise(Call(Name('ValueError', Load(), lineno=27, col_offset=18, end_lineno=27, end_col_offset=28), [Constant('illegal operation', lineno=27, col_offset=29, end_lineno=27, end_col_offset=48)], [], lineno=27, col_offset=18, end_lineno=27, end_col_offset=49), lineno=27, col_offset=12, end_lineno=27, end_col_offset=49)], [], lineno=26, col_offset=8, end_lineno=27, end_col_offset=49), Assign([Subscript(Name('placeholder_7', Load(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=15), Name('placeholder_9', Load(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=19), Store(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=20)], ListComp(Name('placeholder_11', Load(), lineno=29, col_offset=16, end_lineno=29, end_col_offset=19), [comprehension(Name('placeholder_10', Store(), lineno=30, col_offset=20, end_lineno=30, end_col_offset=27), Name('placeholder_8', Load(), lineno=30, col_offset=31, end_lineno=30, end_col_offset=37), [], 0), comprehension(Name('placeholder_11', Store(), lineno=31, col_offset=20, end_lineno=31, end_col_offset=23), Call(Attribute(Name('placeholder_7', Load(), lineno=31, col_offset=27, end_lineno=31, end_col_offset=34), 'get', Load(), lineno=31, col_offset=27, end_lineno=31, end_col_offset=38), [Name('placeholder_10', Load(), lineno=31, col_offset=39, end_lineno=31, end_col_offset=46), List([Name('placeholder_10', Load(), lineno=31, col_offset=49, end_lineno=31, end_col_offset=56)], Load(), lineno=31, col_offset=48, end_lineno=31, end_col_offset=57)], [], lineno=31, col_offset=27, end_lineno=31, end_col_offset=58), [], 0)], lineno=28, col_offset=23, end_lineno=32, end_col_offset=9), lineno=28, col_offset=8, end_lineno=32, end_col_offset=9)], [], lineno=21, col_offset=4, end_lineno=32, end_col_offset=9), Assign([Name('placeholder_12', Store(), lineno=33, col_offset=4, end_lineno=33, end_col_offset=9)], List([], Load(), lineno=33, col_offset=12, end_lineno=33, end_col_offset=14), lineno=33, col_offset=4, end_lineno=33, end_col_offset=14), Assign([Name('placeholder_6', Store(), lineno=34, col_offset=4, end_lineno=34, end_col_offset=14)], Call(Attribute(Subscript(Name('placeholder_6', Load(), lineno=34, col_offset=17, end_lineno=34, end_col_offset=27), UnaryOp(USub(), Constant(1, lineno=34, col_offset=29, end_lineno=34, end_col_offset=30), lineno=34, col_offset=28, end_lineno=34, end_col_offset=30), Load(), lineno=34, col_offset=17, end_lineno=34, end_col_offset=31), 'split', Load(), lineno=34, col_offset=17, end_lineno=34, end_col_offset=37), [], [], lineno=34, col_offset=17, end_lineno=34, end_col_offset=39), lineno=34, col_offset=4, end_lineno=34, end_col_offset=39), While(Call(Name('any', Load(), lineno=35, col_offset=10, end_lineno=35, end_col_offset=13), [Name('placeholder_6', Load(), lineno=35, col_offset=14, end_lineno=35, end_col_offset=24)], [], lineno=35, col_offset=10, end_lineno=35, end_col_offset=25), [Assign([Name('placeholder_13', Store(), lineno=36, col_offset=8, end_lineno=36, end_col_offset=12)], Call(Attribute(Call(Attribute(Name('placeholder_6', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=25), 'pop', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=29), [Constant(0, lineno=36, col_offset=30, end_lineno=36, end_col_offset=31)], [], lineno=36, col_offset=15, end_lineno=36, end_col_offset=32), 'lower', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=38), [], [], lineno=36, col_offset=15, end_lineno=36, end_col_offset=40), lineno=36, col_offset=8, end_lineno=36, end_col_offset=40), Try([If(Call(Name('placeholder_3', Load(), lineno=38, col_offset=15, end_lineno=38, end_col_offset=25), [Name('placeholder_13', Load(), lineno=38, col_offset=26, end_lineno=38, end_col_offset=30)], [], lineno=38, col_offset=15, end_lineno=38, end_col_offset=31), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=39, col_offset=16, end_lineno=39, end_col_offset=21), 'append', Load(), lineno=39, col_offset=16, end_lineno=39, end_col_offset=28), [Call(Name('int', Load(), lineno=39, col_offset=29, end_lineno=39, end_col_offset=32), [Name('placeholder_13', Load(), lineno=39, col_offset=33, end_lineno=39, end_col_offset=37)], [], lineno=39, col_offset=29, end_lineno=39, end_col_offset=38)], [], lineno=39, col_offset=16, end_lineno=39, end_col_offset=39), lineno=39, col_offset=16, end_lineno=39, end_col_offset=39)], [If(Compare(Name('placeholder_13', Load(), lineno=40, col_offset=17, end_lineno=40, end_col_offset=21), [In()], [Name('placeholder_7', Load(), lineno=40, col_offset=25, end_lineno=40, end_col_offset=32)], lineno=40, col_offset=17, end_lineno=40, end_col_offset=32), [Assign([Name('placeholder_6', Store(), lineno=41, col_offset=16, end_lineno=41, end_col_offset=26)], BinOp(Subscript(Name('placeholder_7', Load(), lineno=41, col_offset=29, end_lineno=41, end_col_offset=36), Name('placeholder_13', Load(), lineno=41, col_offset=37, end_lineno=41, end_col_offset=41), Load(), lineno=41, col_offset=29, end_lineno=41, end_col_offset=42), Add(), Name('placeholder_6', Load(), lineno=41, col_offset=45, end_lineno=41, end_col_offset=55), lineno=41, col_offset=29, end_lineno=41, end_col_offset=55), lineno=41, col_offset=16, end_lineno=41, end_col_offset=55)], [If(Compare(Name('placeholder_13', Load(), lineno=42, col_offset=17, end_lineno=42, end_col_offset=21), [Eq()], [Constant('+', lineno=42, col_offset=25, end_lineno=42, end_col_offset=28)], lineno=42, col_offset=17, end_lineno=42, end_col_offset=28), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=43, col_offset=16, end_lineno=43, end_col_offset=21), 'append', Load(), lineno=43, col_offset=16, end_lineno=43, end_col_offset=28), [BinOp(Call(Attribute(Name('placeholder_12', Load(), lineno=43, col_offset=29, end_lineno=43, end_col_offset=34), 'pop', Load(), lineno=43, col_offset=29, end_lineno=43, end_col_offset=38), [], [], lineno=43, col_offset=29, end_lineno=43, end_col_offset=40), Add(), Call(Attribute(Name('placeholder_12', Load(), lineno=43, col_offset=43, end_lineno=43, end_col_offset=48), 'pop', Load(), lineno=43, col_offset=43, end_lineno=43, end_col_offset=52), [], [], lineno=43, col_offset=43, end_lineno=43, end_col_offset=54), lineno=43, col_offset=29, end_lineno=43, end_col_offset=54)], [], lineno=43, col_offset=16, end_lineno=43, end_col_offset=55), lineno=43, col_offset=16, end_lineno=43, end_col_offset=55)], [If(Compare(Name('placeholder_13', Load(), lineno=44, col_offset=17, end_lineno=44, end_col_offset=21), [Eq()], [Constant('-', lineno=44, col_offset=25, end_lineno=44, end_col_offset=28)], lineno=44, col_offset=17, end_lineno=44, end_col_offset=28), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=21), 'append', Load(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=28), [BinOp(UnaryOp(USub(), Call(Attribute(Name('placeholder_12', Load(), lineno=45, col_offset=30, end_lineno=45, end_col_offset=35), 'pop', Load(), lineno=45, col_offset=30, end_lineno=45, end_col_offset=39), [], [], lineno=45, col_offset=30, end_lineno=45, end_col_offset=41), lineno=45, col_offset=29, end_lineno=45, end_col_offset=41), Add(), Call(Attribute(Name('placeholder_12', Load(), lineno=45, col_offset=44, end_lineno=45, end_col_offset=49), 'pop', Load(), lineno=45, col_offset=44, end_lineno=45, end_col_offset=53), [], [], lineno=45, col_offset=44, end_lineno=45, end_col_offset=55), lineno=45, col_offset=29, end_lineno=45, end_col_offset=55)], [], lineno=45, col_offset=16, end_lineno=45, end_col_offset=56), lineno=45, col_offset=16, end_lineno=45, end_col_offset=56)], [If(Compare(Name('placeholder_13', Load(), lineno=46, col_offset=17, end_lineno=46, end_col_offset=21), [Eq()], [Constant('*', lineno=46, col_offset=25, end_lineno=46, end_col_offset=28)], lineno=46, col_offset=17, end_lineno=46, end_col_offset=28), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=47, col_offset=16, end_lineno=47, end_col_offset=21), 'append', Load(), lineno=47, col_offset=16, end_lineno=47, end_col_offset=28), [BinOp(Call(Attribute(Name('placeholder_12', Load(), lineno=47, col_offset=29, end_lineno=47, end_col_offset=34), 'pop', Load(), lineno=47, col_offset=29, end_lineno=47, end_col_offset=38), [], [], lineno=47, col_offset=29, end_lineno=47, end_col_offset=40), Mult(), Call(Attribute(Name('placeholder_12', Load(), lineno=47, col_offset=43, end_lineno=47, end_col_offset=48), 'pop', Load(), lineno=47, col_offset=43, end_lineno=47, end_col_offset=52), [], [], lineno=47, col_offset=43, end_lineno=47, end_col_offset=54), lineno=47, col_offset=29, end_lineno=47, end_col_offset=54)], [], lineno=47, col_offset=16, end_lineno=47, end_col_offset=55), lineno=47, col_offset=16, end_lineno=47, end_col_offset=55)], [If(Compare(Name('placeholder_13', Load(), lineno=48, col_offset=17, end_lineno=48, end_col_offset=21), [Eq()], [Constant('/', lineno=48, col_offset=25, end_lineno=48, end_col_offset=28)], lineno=48, col_offset=17, end_lineno=48, end_col_offset=28), [Assign([Name('placeholder_14', Store(), lineno=49, col_offset=16, end_lineno=49, end_col_offset=23)], Call(Attribute(Name('placeholder_12', Load(), lineno=49, col_offset=26, end_lineno=49, end_col_offset=31), 'pop', Load(), lineno=49, col_offset=26, end_lineno=49, end_col_offset=35), [], [], lineno=49, col_offset=26, end_lineno=49, end_col_offset=37), lineno=49, col_offset=16, end_lineno=49, end_col_offset=37), If(Compare(Name('placeholder_14', Load(), lineno=50, col_offset=19, end_lineno=50, end_col_offset=26), [Eq()], [Constant(0, lineno=50, col_offset=30, end_lineno=50, end_col_offset=31)], lineno=50, col_offset=19, end_lineno=50, end_col_offset=31), [Raise(Call(Name('ZeroDivisionError', Load(), lineno=51, col_offset=26, end_lineno=51, end_col_offset=43), [Constant('divide by zero', lineno=51, col_offset=44, end_lineno=51, end_col_offset=60)], [], lineno=51, col_offset=26, end_lineno=51, end_col_offset=61), lineno=51, col_offset=20, end_lineno=51, end_col_offset=61)], [], lineno=50, col_offset=16, end_lineno=51, end_col_offset=61), Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=52, col_offset=16, end_lineno=52, end_col_offset=21), 'append', Load(), lineno=52, col_offset=16, end_lineno=52, end_col_offset=28), [Call(Name('int', Load(), lineno=52, col_offset=29, end_lineno=52, end_col_offset=32), [BinOp(Call(Attribute(Name('placeholder_12', Load(), lineno=52, col_offset=33, end_lineno=52, end_col_offset=38), 'pop', Load(), lineno=52, col_offset=33, end_lineno=52, end_col_offset=42), [], [], lineno=52, col_offset=33, end_lineno=52, end_col_offset=44), Div(), Name('placeholder_14', Load(), lineno=52, col_offset=47, end_lineno=52, end_col_offset=54), lineno=52, col_offset=33, end_lineno=52, end_col_offset=54)], [], lineno=52, col_offset=29, end_lineno=52, end_col_offset=55)], [], lineno=52, col_offset=16, end_lineno=52, end_col_offset=56), lineno=52, col_offset=16, end_lineno=52, end_col_offset=56)], [If(Compare(Name('placeholder_13', Load(), lineno=53, col_offset=17, end_lineno=53, end_col_offset=21), [Eq()], [Constant('dup', lineno=53, col_offset=25, end_lineno=53, end_col_offset=30)], lineno=53, col_offset=17, end_lineno=53, end_col_offset=30), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=54, col_offset=16, end_lineno=54, end_col_offset=21), 'append', Load(), lineno=54, col_offset=16, end_lineno=54, end_col_offset=28), [Subscript(Name('placeholder_12', Load(), lineno=54, col_offset=29, end_lineno=54, end_col_offset=34), UnaryOp(USub(), Constant(1, lineno=54, col_offset=36, end_lineno=54, end_col_offset=37), lineno=54, col_offset=35, end_lineno=54, end_col_offset=37), Load(), lineno=54, col_offset=29, end_lineno=54, end_col_offset=38)], [], lineno=54, col_offset=16, end_lineno=54, end_col_offset=39), lineno=54, col_offset=16, end_lineno=54, end_col_offset=39)], [If(Compare(Name('placeholder_13', Load(), lineno=55, col_offset=17, end_lineno=55, end_col_offset=21), [Eq()], [Constant('drop', lineno=55, col_offset=25, end_lineno=55, end_col_offset=31)], lineno=55, col_offset=17, end_lineno=55, end_col_offset=31), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=56, col_offset=16, end_lineno=56, end_col_offset=21), 'pop', Load(), lineno=56, col_offset=16, end_lineno=56, end_col_offset=25), [], [], lineno=56, col_offset=16, end_lineno=56, end_col_offset=27), lineno=56, col_offset=16, end_lineno=56, end_col_offset=27)], [If(Compare(Name('placeholder_13', Load(), lineno=57, col_offset=17, end_lineno=57, end_col_offset=21), [Eq()], [Constant('swap', lineno=57, col_offset=25, end_lineno=57, end_col_offset=31)], lineno=57, col_offset=17, end_lineno=57, end_col_offset=31), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=58, col_offset=16, end_lineno=58, end_col_offset=21), 'append', Load(), lineno=58, col_offset=16, end_lineno=58, end_col_offset=28), [Subscript(Name('placeholder_12', Load(), lineno=58, col_offset=29, end_lineno=58, end_col_offset=34), UnaryOp(USub(), Constant(2, lineno=58, col_offset=36, end_lineno=58, end_col_offset=37), lineno=58, col_offset=35, end_lineno=58, end_col_offset=37), Load(), lineno=58, col_offset=29, end_lineno=58, end_col_offset=38)], [], lineno=58, col_offset=16, end_lineno=58, end_col_offset=39), lineno=58, col_offset=16, end_lineno=58, end_col_offset=39), Delete([Subscript(Name('placeholder_12', Load(), lineno=59, col_offset=20, end_lineno=59, end_col_offset=25), UnaryOp(USub(), Constant(3, lineno=59, col_offset=27, end_lineno=59, end_col_offset=28), lineno=59, col_offset=26, end_lineno=59, end_col_offset=28), Del(), lineno=59, col_offset=20, end_lineno=59, end_col_offset=29)], lineno=59, col_offset=16, end_lineno=59, end_col_offset=29)], [If(Compare(Name('placeholder_13', Load(), lineno=60, col_offset=17, end_lineno=60, end_col_offset=21), [Eq()], [Constant('over', lineno=60, col_offset=25, end_lineno=60, end_col_offset=31)], lineno=60, col_offset=17, end_lineno=60, end_col_offset=31), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=61, col_offset=16, end_lineno=61, end_col_offset=21), 'append', Load(), lineno=61, col_offset=16, end_lineno=61, end_col_offset=28), [Subscript(Name('placeholder_12', Load(), lineno=61, col_offset=29, end_lineno=61, end_col_offset=34), UnaryOp(USub(), Constant(2, lineno=61, col_offset=36, end_lineno=61, end_col_offset=37), lineno=61, col_offset=35, end_lineno=61, end_col_offset=37), Load(), lineno=61, col_offset=29, end_lineno=61, end_col_offset=38)], [], lineno=61, col_offset=16, end_lineno=61, end_col_offset=39), lineno=61, col_offset=16, end_lineno=61, end_col_offset=39)], [Raise(Call(Name('ValueError', Load(), lineno=63, col_offset=22, end_lineno=63, end_col_offset=32), [Constant('undefined operation', lineno=63, col_offset=33, end_lineno=63, end_col_offset=54)], [], lineno=63, col_offset=22, end_lineno=63, end_col_offset=55), lineno=63, col_offset=16, end_lineno=63, end_col_offset=55)], lineno=60, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=57, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=55, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=53, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=48, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=46, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=44, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=42, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=40, col_offset=12, end_lineno=63, end_col_offset=55)], lineno=38, col_offset=12, end_lineno=63, end_col_offset=55)], [ExceptHandler(Name('IndexError', Load(), lineno=64, col_offset=15, end_lineno=64, end_col_offset=25), 'placeholder_15', [Raise(Call(Name('placeholder_0', Load(), lineno=65, col_offset=18, end_lineno=65, end_col_offset=37), [Constant('Insufficient number of items in stack', lineno=65, col_offset=38, end_lineno=65, end_col_offset=77)], [], lineno=65, col_offset=18, end_lineno=65, end_col_offset=78), Name('placeholder_15', Load(), lineno=65, col_offset=84, end_lineno=65, end_col_offset=89), lineno=65, col_offset=12, end_lineno=65, end_col_offset=89)], lineno=64, col_offset=8, end_lineno=65, end_col_offset=89)], [], [], lineno=37, col_offset=8, end_lineno=65, end_col_offset=89)], [], lineno=35, col_offset=4, end_lineno=65, end_col_offset=89), Return(Name('placeholder_12', Load(), lineno=66, col_offset=11, end_lineno=66, end_col_offset=16), lineno=66, col_offset=4, end_lineno=66, end_col_offset=16)], [], lineno=17, col_offset=0, end_lineno=66, end_col_offset=16)], []) \ No newline at end of file diff --git a/test/practice-gigasecond/.meta/config.json b/test/practice-gigasecond/.meta/config.json new file mode 100644 index 0000000..76af3da --- /dev/null +++ b/test/practice-gigasecond/.meta/config.json @@ -0,0 +1,35 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "etrepum", + "GascaK", + "ikhadykin", + "kytrinyx", + "lowks", + "N-Parsons", + "pamtdoh", + "pheanex", + "sjakobi", + "tqa236", + "yawpitch", + "AndrewLawendy" + ], + "files": { + "solution": [ + "gigasecond.py" + ], + "test": [ + "gigasecond_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", + "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", + "source_url": "https://pine.fm/LearnToProgram/?Chapter=09" +} diff --git a/test/practice-gigasecond/gigasecond.py b/test/practice-gigasecond/gigasecond.py new file mode 100644 index 0000000..15bedb0 --- /dev/null +++ b/test/practice-gigasecond/gigasecond.py @@ -0,0 +1,5 @@ +from datetime import timedelta + + +def add(moment): + return moment + timedelta(seconds=1e9) diff --git a/test/practice-gigasecond/mapping.json b/test/practice-gigasecond/mapping.json new file mode 100644 index 0000000..75a674d --- /dev/null +++ b/test/practice-gigasecond/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "add", + "placeholder_1": "moment", + "placeholder_2": "seconds" +} \ No newline at end of file diff --git a/test/practice-gigasecond/representation.json b/test/practice-gigasecond/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-gigasecond/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-gigasecond/representation.out b/test/practice-gigasecond/representation.out new file mode 100644 index 0000000..26a6ead --- /dev/null +++ b/test/practice-gigasecond/representation.out @@ -0,0 +1,176 @@ +## BEGIN NORMALIZED CODE ## +from datetime import timedelta + + +def placeholder_0(placeholder_1): + return placeholder_1 + timedelta(placeholder_2=1000000000.0) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'datetime', + [ + alias( + 'timedelta', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=30)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=30), + FunctionDef( + 'add', + arguments( + [], + [ + arg( + 'moment', + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'moment', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17), + Add(), + Call( + Name( + 'timedelta', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=29), + [], + [ + keyword( + 'seconds', + Constant( + 1000000000.0, + lineno=5, + col_offset=38, + end_lineno=5, + end_col_offset=41), + lineno=5, + col_offset=30, + end_lineno=5, + end_col_offset=41)], + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=42), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=42), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=42)], + [], + lineno=4, + col_offset=0, + end_lineno=5, + end_col_offset=42)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'datetime', + [ + alias( + 'timedelta', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=30)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=30), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17), + Add(), + Call( + Name( + 'timedelta', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=29), + [], + [ + keyword( + 'placeholder_2', + Constant( + 1000000000.0, + lineno=5, + col_offset=38, + end_lineno=5, + end_col_offset=41), + lineno=5, + col_offset=30, + end_lineno=5, + end_col_offset=41)], + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=42), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=42), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=42)], + [], + lineno=4, + col_offset=0, + end_lineno=5, + end_col_offset=42)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-gigasecond/representation.txt b/test/practice-gigasecond/representation.txt new file mode 100644 index 0000000..0b809c8 --- /dev/null +++ b/test/practice-gigasecond/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('datetime', [alias('timedelta', lineno=1, col_offset=21, end_lineno=1, end_col_offset=30)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=30), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=8, end_lineno=4, end_col_offset=14)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_1', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=17), Add(), Call(Name('timedelta', Load(), lineno=5, col_offset=20, end_lineno=5, end_col_offset=29), [], [keyword('placeholder_2', Constant(1000000000.0, lineno=5, col_offset=38, end_lineno=5, end_col_offset=41), lineno=5, col_offset=30, end_lineno=5, end_col_offset=41)], lineno=5, col_offset=20, end_lineno=5, end_col_offset=42), lineno=5, col_offset=11, end_lineno=5, end_col_offset=42), lineno=5, col_offset=4, end_lineno=5, end_col_offset=42)], [], lineno=4, col_offset=0, end_lineno=5, end_col_offset=42)], []) \ No newline at end of file diff --git a/test/practice-go-counting/.meta/config.json b/test/practice-go-counting/.meta/config.json new file mode 100644 index 0000000..0cfd3ff --- /dev/null +++ b/test/practice-go-counting/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "yunchih" + ], + "contributors": [ + "cmccandless", + "Dog", + "dvermd", + "N-Parsons", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "go_counting.py" + ], + "test": [ + "go_counting_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Count the scored points on a Go board." +} diff --git a/test/practice-go-counting/go_counting.py b/test/practice-go-counting/go_counting.py new file mode 100644 index 0000000..c6ccd51 --- /dev/null +++ b/test/practice-go-counting/go_counting.py @@ -0,0 +1,64 @@ + +BLACK = 'B' +WHITE = 'W' +NONE = '' +STONES = [BLACK, WHITE] +DIRECTIONS = [(0, 1), (0, -1), (1, 0), (-1, 0)] + + +class Board: + def __init__(self, board): + self.board = board + self.width = len(self.board[0]) + self.height = len(self.board) + + def valid(self, width, height): + return self.width > width >= 0 and self.height > height >= 0 + + def walk(self, width, height, visited_territory=None, visited_coords=None, visited_stones=None): + # Pylint gives W0102 warning if list used as default argument, because list is mutable. + visited_territory = [] if visited_territory is None else visited_territory + visited_coords = [] if visited_coords is None else visited_coords + visited_stones = [] if visited_stones is None else visited_stones + + if (width, height) not in visited_coords and self.valid(width, height): + stone = self.board[height][width] + if stone in STONES: + if stone not in visited_stones: + return (visited_territory, visited_stones + [stone]) + else: # s is empty + for direction in DIRECTIONS: + visited = self.walk(width + direction[0], height + direction[1], + visited_territory + [(width, height)], + visited_coords + [(width, height)], + visited_stones) + visited_territory = visited[0] + visited_stones = visited[1] + + return (visited_territory, visited_stones) + + def territory(self, x, y): + if not self.valid(x, y): + raise ValueError('Invalid coordinate') + if self.board[y][x] in STONES: + return (NONE, set()) + + visited_territory, visited_stones = self.walk(x, y) + result = set(visited_territory) + + if len(visited_stones) == 1: + return (visited_stones[0], result) + return (NONE, result) + + def territories(self): + owners = STONES + [NONE] + result = {owner:set() for owner in owners} + visited = set() + for row in range(self.height): + for column in range(self.width): + if not (column, row) in visited: + owner, owned_territories = self.territory(column, row) + result[owner].update(owned_territories) + visited.update(owned_territories) + + return result diff --git a/test/practice-go-counting/mapping.json b/test/practice-go-counting/mapping.json new file mode 100644 index 0000000..8b911f2 --- /dev/null +++ b/test/practice-go-counting/mapping.json @@ -0,0 +1,30 @@ +{ + "placeholder_0": "BLACK", + "placeholder_1": "WHITE", + "placeholder_2": "NONE", + "placeholder_3": "STONES", + "placeholder_4": "DIRECTIONS", + "placeholder_5": "Board", + "placeholder_6": "__init__", + "placeholder_7": "board", + "placeholder_8": "width", + "placeholder_9": "height", + "placeholder_10": "valid", + "placeholder_11": "walk", + "placeholder_12": "visited_territory", + "placeholder_13": "visited_coords", + "placeholder_14": "visited_stones", + "placeholder_15": "stone", + "placeholder_16": "direction", + "placeholder_17": "visited", + "placeholder_18": "territory", + "placeholder_19": "x", + "placeholder_20": "y", + "placeholder_21": "result", + "placeholder_22": "territories", + "placeholder_23": "owners", + "placeholder_24": "owner", + "placeholder_25": "row", + "placeholder_26": "column", + "placeholder_27": "owned_territories" +} \ No newline at end of file diff --git a/test/practice-go-counting/representation.json b/test/practice-go-counting/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-go-counting/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-go-counting/representation.out b/test/practice-go-counting/representation.out new file mode 100644 index 0000000..770bdcb --- /dev/null +++ b/test/practice-go-counting/representation.out @@ -0,0 +1,4261 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = "B" +placeholder_1 = "W" +placeholder_2 = "" +placeholder_3 = [placeholder_0, placeholder_1] +placeholder_4 = [(0, 1), (0, -1), (1, 0), (-1, 0)] + + +class placeholder_5: + def placeholder_6(self, placeholder_7): + self.placeholder_7 = placeholder_7 + self.placeholder_8 = len(self.placeholder_7[0]) + self.placeholder_9 = len(self.placeholder_7) + + def placeholder_10(self, placeholder_8, placeholder_9): + return ( + self.placeholder_8 > placeholder_8 >= 0 + and self.placeholder_9 > placeholder_9 >= 0 + ) + + def placeholder_11( + self, + placeholder_8, + placeholder_9, + placeholder_12=None, + placeholder_13=None, + placeholder_14=None, + ): + placeholder_12 = [] if placeholder_12 is None else placeholder_12 + placeholder_13 = [] if placeholder_13 is None else placeholder_13 + placeholder_14 = [] if placeholder_14 is None else placeholder_14 + if (placeholder_8, placeholder_9) not in placeholder_13 and self.placeholder_10( + placeholder_8, placeholder_9 + ): + placeholder_15 = self.placeholder_7[placeholder_9][placeholder_8] + if placeholder_15 in placeholder_3: + if placeholder_15 not in placeholder_14: + return (placeholder_12, placeholder_14 + [placeholder_15]) + else: + for placeholder_16 in placeholder_4: + placeholder_17 = self.placeholder_11( + placeholder_8 + placeholder_16[0], + placeholder_9 + placeholder_16[1], + placeholder_12 + [(placeholder_8, placeholder_9)], + placeholder_13 + [(placeholder_8, placeholder_9)], + placeholder_14, + ) + placeholder_12 = placeholder_17[0] + placeholder_14 = placeholder_17[1] + return (placeholder_12, placeholder_14) + + def placeholder_18(self, placeholder_19, placeholder_20): + if not self.placeholder_10(placeholder_19, placeholder_20): + raise ValueError("Invalid coordinate") + if self.placeholder_7[placeholder_20][placeholder_19] in placeholder_3: + return (placeholder_2, set()) + placeholder_12, placeholder_14 = self.placeholder_11( + placeholder_19, placeholder_20 + ) + placeholder_21 = set(placeholder_12) + if len(placeholder_14) == 1: + return (placeholder_14[0], placeholder_21) + return (placeholder_2, placeholder_21) + + def placeholder_22(self): + placeholder_23 = placeholder_3 + [placeholder_2] + placeholder_21 = {placeholder_24: set() for placeholder_24 in placeholder_23} + placeholder_17 = set() + for placeholder_25 in range(self.placeholder_9): + for placeholder_26 in range(self.placeholder_8): + if not (placeholder_26, placeholder_25) in placeholder_17: + placeholder_24, placeholder_27 = self.placeholder_18( + placeholder_26, placeholder_25 + ) + placeholder_21[placeholder_24].update(placeholder_27) + placeholder_17.update(placeholder_27) + return placeholder_21 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'BLACK', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=5)], + Constant( + 'B', + lineno=2, + col_offset=8, + end_lineno=2, + end_col_offset=11), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=11), + Assign( + [ + Name( + 'WHITE', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=5)], + Constant( + 'W', + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=11), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=11), + Assign( + [ + Name( + 'NONE', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=4)], + Constant( + '', + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=9), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=9), + Assign( + [ + Name( + 'STONES', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=6)], + List( + [ + Name( + 'BLACK', + Load(), + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=15), + Name( + 'WHITE', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=22)], + Load(), + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=23), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=23), + Assign( + [ + Name( + 'DIRECTIONS', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=10)], + List( + [ + Tuple( + [ + Constant( + 0, + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=16), + Constant( + 1, + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=19)], + Load(), + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=20), + Tuple( + [ + Constant( + 0, + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=24), + UnaryOp( + USub(), + Constant( + 1, + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=26, + end_lineno=6, + end_col_offset=28)], + Load(), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=29), + Tuple( + [ + Constant( + 1, + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=33), + Constant( + 0, + lineno=6, + col_offset=35, + end_lineno=6, + end_col_offset=36)], + Load(), + lineno=6, + col_offset=31, + end_lineno=6, + end_col_offset=37), + Tuple( + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=6, + col_offset=41, + end_lineno=6, + end_col_offset=42), + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=42), + Constant( + 0, + lineno=6, + col_offset=44, + end_lineno=6, + end_col_offset=45)], + Load(), + lineno=6, + col_offset=39, + end_lineno=6, + end_col_offset=46)], + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=47), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=47), + ClassDef( + 'Board', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=21), + arg( + 'board', + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'board', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=18)], + Name( + 'board', + Load(), + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=26), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'width', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=18)], + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=24), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=29), + 'board', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=35), + Constant( + 0, + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=37), + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=38)], + [], + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=39), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'height', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=19)], + Call( + Name( + 'len', + Load(), + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=25), + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=30), + 'board', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=36)], + [], + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=37), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=37)], + [], + lineno=10, + col_offset=4, + end_lineno=13, + end_col_offset=37), + FunctionDef( + 'valid', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=18), + arg( + 'width', + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=25), + arg( + 'height', + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + 'width', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=25), + [ + Gt(), + GtE()], + [ + Name( + 'width', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=33), + Constant( + 0, + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=38)], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=38), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=47), + 'height', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=54), + [ + Gt(), + GtE()], + [ + Name( + 'height', + Load(), + lineno=16, + col_offset=57, + end_lineno=16, + end_col_offset=63), + Constant( + 0, + lineno=16, + col_offset=67, + end_lineno=16, + end_col_offset=68)], + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=68)], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=68), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=68)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=68), + FunctionDef( + 'walk', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=17), + arg( + 'width', + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=24), + arg( + 'height', + lineno=18, + col_offset=26, + end_lineno=18, + end_col_offset=32), + arg( + 'visited_territory', + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=51), + arg( + 'visited_coords', + lineno=18, + col_offset=58, + end_lineno=18, + end_col_offset=72), + arg( + 'visited_stones', + lineno=18, + col_offset=79, + end_lineno=18, + end_col_offset=93)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=18, + col_offset=52, + end_lineno=18, + end_col_offset=56), + Constant( + None, + lineno=18, + col_offset=73, + end_lineno=18, + end_col_offset=77), + Constant( + None, + lineno=18, + col_offset=94, + end_lineno=18, + end_col_offset=98)]), + [ + Assign( + [ + Name( + 'visited_territory', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=25)], + IfExp( + Compare( + Name( + 'visited_territory', + Load(), + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=51), + [ + Is()], + [ + Constant( + None, + lineno=20, + col_offset=55, + end_lineno=20, + end_col_offset=59)], + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=59), + List( + [], + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=30), + Name( + 'visited_territory', + Load(), + lineno=20, + col_offset=65, + end_lineno=20, + end_col_offset=82), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=82), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=82), + Assign( + [ + Name( + 'visited_coords', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=22)], + IfExp( + Compare( + Name( + 'visited_coords', + Load(), + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=45), + [ + Is()], + [ + Constant( + None, + lineno=21, + col_offset=49, + end_lineno=21, + end_col_offset=53)], + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=53), + List( + [], + Load(), + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=27), + Name( + 'visited_coords', + Load(), + lineno=21, + col_offset=59, + end_lineno=21, + end_col_offset=73), + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=73), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=73), + Assign( + [ + Name( + 'visited_stones', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=22)], + IfExp( + Compare( + Name( + 'visited_stones', + Load(), + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=45), + [ + Is()], + [ + Constant( + None, + lineno=22, + col_offset=49, + end_lineno=22, + end_col_offset=53)], + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=53), + List( + [], + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=27), + Name( + 'visited_stones', + Load(), + lineno=22, + col_offset=59, + end_lineno=22, + end_col_offset=73), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=73), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=73), + If( + BoolOp( + And(), + [ + Compare( + Tuple( + [ + Name( + 'width', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=17), + Name( + 'height', + Load(), + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=25)], + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=26), + [ + NotIn()], + [ + Name( + 'visited_coords', + Load(), + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=48)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=48), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=53, + end_lineno=24, + end_col_offset=57), + 'valid', + Load(), + lineno=24, + col_offset=53, + end_lineno=24, + end_col_offset=63), + [ + Name( + 'width', + Load(), + lineno=24, + col_offset=64, + end_lineno=24, + end_col_offset=69), + Name( + 'height', + Load(), + lineno=24, + col_offset=71, + end_lineno=24, + end_col_offset=77)], + [], + lineno=24, + col_offset=53, + end_lineno=24, + end_col_offset=78)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=78), + [ + Assign( + [ + Name( + 'stone', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=17)], + Subscript( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=24), + 'board', + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=30), + Name( + 'height', + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=37), + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=38), + Name( + 'width', + Load(), + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=44), + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=45), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=45), + If( + Compare( + Name( + 'stone', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=20), + [ + In()], + [ + Name( + 'STONES', + Load(), + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=30)], + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=30), + [ + If( + Compare( + Name( + 'stone', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=24), + [ + NotIn()], + [ + Name( + 'visited_stones', + Load(), + lineno=27, + col_offset=32, + end_lineno=27, + end_col_offset=46)], + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=46), + [ + Return( + Tuple( + [ + Name( + 'visited_territory', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=45), + BinOp( + Name( + 'visited_stones', + Load(), + lineno=28, + col_offset=47, + end_lineno=28, + end_col_offset=61), + Add(), + List( + [ + Name( + 'stone', + Load(), + lineno=28, + col_offset=65, + end_lineno=28, + end_col_offset=70)], + Load(), + lineno=28, + col_offset=64, + end_lineno=28, + end_col_offset=71), + lineno=28, + col_offset=47, + end_lineno=28, + end_col_offset=71)], + Load(), + lineno=28, + col_offset=27, + end_lineno=28, + end_col_offset=72), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=72)], + [], + lineno=27, + col_offset=16, + end_lineno=28, + end_col_offset=72)], + [ + For( + Name( + 'direction', + Store(), + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=29), + Name( + 'DIRECTIONS', + Load(), + lineno=30, + col_offset=33, + end_lineno=30, + end_col_offset=43), + [ + Assign( + [ + Name( + 'visited', + Store(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=27)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=30, + end_lineno=31, + end_col_offset=34), + 'walk', + Load(), + lineno=31, + col_offset=30, + end_lineno=31, + end_col_offset=39), + [ + BinOp( + Name( + 'width', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=45), + Add(), + Subscript( + Name( + 'direction', + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=57), + Constant( + 0, + lineno=31, + col_offset=58, + end_lineno=31, + end_col_offset=59), + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=60), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=60), + BinOp( + Name( + 'height', + Load(), + lineno=31, + col_offset=62, + end_lineno=31, + end_col_offset=68), + Add(), + Subscript( + Name( + 'direction', + Load(), + lineno=31, + col_offset=71, + end_lineno=31, + end_col_offset=80), + Constant( + 1, + lineno=31, + col_offset=81, + end_lineno=31, + end_col_offset=82), + Load(), + lineno=31, + col_offset=71, + end_lineno=31, + end_col_offset=83), + lineno=31, + col_offset=62, + end_lineno=31, + end_col_offset=83), + BinOp( + Name( + 'visited_territory', + Load(), + lineno=32, + col_offset=40, + end_lineno=32, + end_col_offset=57), + Add(), + List( + [ + Tuple( + [ + Name( + 'width', + Load(), + lineno=32, + col_offset=62, + end_lineno=32, + end_col_offset=67), + Name( + 'height', + Load(), + lineno=32, + col_offset=69, + end_lineno=32, + end_col_offset=75)], + Load(), + lineno=32, + col_offset=61, + end_lineno=32, + end_col_offset=76)], + Load(), + lineno=32, + col_offset=60, + end_lineno=32, + end_col_offset=77), + lineno=32, + col_offset=40, + end_lineno=32, + end_col_offset=77), + BinOp( + Name( + 'visited_coords', + Load(), + lineno=33, + col_offset=40, + end_lineno=33, + end_col_offset=54), + Add(), + List( + [ + Tuple( + [ + Name( + 'width', + Load(), + lineno=33, + col_offset=59, + end_lineno=33, + end_col_offset=64), + Name( + 'height', + Load(), + lineno=33, + col_offset=66, + end_lineno=33, + end_col_offset=72)], + Load(), + lineno=33, + col_offset=58, + end_lineno=33, + end_col_offset=73)], + Load(), + lineno=33, + col_offset=57, + end_lineno=33, + end_col_offset=74), + lineno=33, + col_offset=40, + end_lineno=33, + end_col_offset=74), + Name( + 'visited_stones', + Load(), + lineno=34, + col_offset=40, + end_lineno=34, + end_col_offset=54)], + [], + lineno=31, + col_offset=30, + end_lineno=34, + end_col_offset=55), + lineno=31, + col_offset=20, + end_lineno=34, + end_col_offset=55), + Assign( + [ + Name( + 'visited_territory', + Store(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=37)], + Subscript( + Name( + 'visited', + Load(), + lineno=35, + col_offset=40, + end_lineno=35, + end_col_offset=47), + Constant( + 0, + lineno=35, + col_offset=48, + end_lineno=35, + end_col_offset=49), + Load(), + lineno=35, + col_offset=40, + end_lineno=35, + end_col_offset=50), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=50), + Assign( + [ + Name( + 'visited_stones', + Store(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=34)], + Subscript( + Name( + 'visited', + Load(), + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=44), + Constant( + 1, + lineno=36, + col_offset=45, + end_lineno=36, + end_col_offset=46), + Load(), + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=47), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=47)], + [], + lineno=30, + col_offset=16, + end_lineno=36, + end_col_offset=47)], + lineno=26, + col_offset=12, + end_lineno=36, + end_col_offset=47)], + [], + lineno=24, + col_offset=8, + end_lineno=36, + end_col_offset=47), + Return( + Tuple( + [ + Name( + 'visited_territory', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=33), + Name( + 'visited_stones', + Load(), + lineno=38, + col_offset=35, + end_lineno=38, + end_col_offset=49)], + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=50), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=50)], + [], + lineno=18, + col_offset=4, + end_lineno=38, + end_col_offset=50), + FunctionDef( + 'territory', + arguments( + [], + [ + arg( + 'self', + lineno=40, + col_offset=18, + end_lineno=40, + end_col_offset=22), + arg( + 'x', + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=25), + arg( + 'y', + lineno=40, + col_offset=27, + end_lineno=40, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=19), + 'valid', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=25), + [ + Name( + 'x', + Load(), + lineno=41, + col_offset=26, + end_lineno=41, + end_col_offset=27), + Name( + 'y', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=30)], + [], + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=31), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=28), + [ + Constant( + 'Invalid coordinate', + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=49)], + [], + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=50), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=50)], + [], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=50), + If( + Compare( + Subscript( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=15), + 'board', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=21), + Name( + 'y', + Load(), + lineno=43, + col_offset=22, + end_lineno=43, + end_col_offset=23), + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=24), + Name( + 'x', + Load(), + lineno=43, + col_offset=25, + end_lineno=43, + end_col_offset=26), + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=27), + [ + In()], + [ + Name( + 'STONES', + Load(), + lineno=43, + col_offset=31, + end_lineno=43, + end_col_offset=37)], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=37), + [ + Return( + Tuple( + [ + Name( + 'NONE', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=24), + Call( + Name( + 'set', + Load(), + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=29), + [], + [], + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=31)], + Load(), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=32), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=32)], + [], + lineno=43, + col_offset=8, + end_lineno=44, + end_col_offset=32), + Assign( + [ + Tuple( + [ + Name( + 'visited_territory', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=25), + Name( + 'visited_stones', + Store(), + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=41)], + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=41)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=48), + 'walk', + Load(), + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=53), + [ + Name( + 'x', + Load(), + lineno=46, + col_offset=54, + end_lineno=46, + end_col_offset=55), + Name( + 'y', + Load(), + lineno=46, + col_offset=57, + end_lineno=46, + end_col_offset=58)], + [], + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=59), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=59), + Assign( + [ + Name( + 'result', + Store(), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=14)], + Call( + Name( + 'set', + Load(), + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=20), + [ + Name( + 'visited_territory', + Load(), + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=38)], + [], + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=39), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=39), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=14), + [ + Name( + 'visited_stones', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=29)], + [], + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 1, + lineno=49, + col_offset=34, + end_lineno=49, + end_col_offset=35)], + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=35), + [ + Return( + Tuple( + [ + Subscript( + Name( + 'visited_stones', + Load(), + lineno=50, + col_offset=20, + end_lineno=50, + end_col_offset=34), + Constant( + 0, + lineno=50, + col_offset=35, + end_lineno=50, + end_col_offset=36), + Load(), + lineno=50, + col_offset=20, + end_lineno=50, + end_col_offset=37), + Name( + 'result', + Load(), + lineno=50, + col_offset=39, + end_lineno=50, + end_col_offset=45)], + Load(), + lineno=50, + col_offset=19, + end_lineno=50, + end_col_offset=46), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=46)], + [], + lineno=49, + col_offset=8, + end_lineno=50, + end_col_offset=46), + Return( + Tuple( + [ + Name( + 'NONE', + Load(), + lineno=51, + col_offset=16, + end_lineno=51, + end_col_offset=20), + Name( + 'result', + Load(), + lineno=51, + col_offset=22, + end_lineno=51, + end_col_offset=28)], + Load(), + lineno=51, + col_offset=15, + end_lineno=51, + end_col_offset=29), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=29)], + [], + lineno=40, + col_offset=4, + end_lineno=51, + end_col_offset=29), + FunctionDef( + 'territories', + arguments( + [], + [ + arg( + 'self', + lineno=53, + col_offset=20, + end_lineno=53, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'owners', + Store(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=14)], + BinOp( + Name( + 'STONES', + Load(), + lineno=54, + col_offset=17, + end_lineno=54, + end_col_offset=23), + Add(), + List( + [ + Name( + 'NONE', + Load(), + lineno=54, + col_offset=27, + end_lineno=54, + end_col_offset=31)], + Load(), + lineno=54, + col_offset=26, + end_lineno=54, + end_col_offset=32), + lineno=54, + col_offset=17, + end_lineno=54, + end_col_offset=32), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=32), + Assign( + [ + Name( + 'result', + Store(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=14)], + DictComp( + Name( + 'owner', + Load(), + lineno=55, + col_offset=18, + end_lineno=55, + end_col_offset=23), + Call( + Name( + 'set', + Load(), + lineno=55, + col_offset=24, + end_lineno=55, + end_col_offset=27), + [], + [], + lineno=55, + col_offset=24, + end_lineno=55, + end_col_offset=29), + [ + comprehension( + Name( + 'owner', + Store(), + lineno=55, + col_offset=34, + end_lineno=55, + end_col_offset=39), + Name( + 'owners', + Load(), + lineno=55, + col_offset=43, + end_lineno=55, + end_col_offset=49), + [], + 0)], + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=50), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=50), + Assign( + [ + Name( + 'visited', + Store(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=15)], + Call( + Name( + 'set', + Load(), + lineno=56, + col_offset=18, + end_lineno=56, + end_col_offset=21), + [], + [], + lineno=56, + col_offset=18, + end_lineno=56, + end_col_offset=23), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=23), + For( + Name( + 'row', + Store(), + lineno=57, + col_offset=12, + end_lineno=57, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=24), + [ + Attribute( + Name( + 'self', + Load(), + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=29), + 'height', + Load(), + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=36)], + [], + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=37), + [ + For( + Name( + 'column', + Store(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=22), + Call( + Name( + 'range', + Load(), + lineno=58, + col_offset=26, + end_lineno=58, + end_col_offset=31), + [ + Attribute( + Name( + 'self', + Load(), + lineno=58, + col_offset=32, + end_lineno=58, + end_col_offset=36), + 'width', + Load(), + lineno=58, + col_offset=32, + end_lineno=58, + end_col_offset=42)], + [], + lineno=58, + col_offset=26, + end_lineno=58, + end_col_offset=43), + [ + If( + UnaryOp( + Not(), + Compare( + Tuple( + [ + Name( + 'column', + Load(), + lineno=59, + col_offset=24, + end_lineno=59, + end_col_offset=30), + Name( + 'row', + Load(), + lineno=59, + col_offset=32, + end_lineno=59, + end_col_offset=35)], + Load(), + lineno=59, + col_offset=23, + end_lineno=59, + end_col_offset=36), + [ + In()], + [ + Name( + 'visited', + Load(), + lineno=59, + col_offset=40, + end_lineno=59, + end_col_offset=47)], + lineno=59, + col_offset=23, + end_lineno=59, + end_col_offset=47), + lineno=59, + col_offset=19, + end_lineno=59, + end_col_offset=47), + [ + Assign( + [ + Tuple( + [ + Name( + 'owner', + Store(), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=25), + Name( + 'owned_territories', + Store(), + lineno=60, + col_offset=27, + end_lineno=60, + end_col_offset=44)], + Store(), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=44)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=47, + end_lineno=60, + end_col_offset=51), + 'territory', + Load(), + lineno=60, + col_offset=47, + end_lineno=60, + end_col_offset=61), + [ + Name( + 'column', + Load(), + lineno=60, + col_offset=62, + end_lineno=60, + end_col_offset=68), + Name( + 'row', + Load(), + lineno=60, + col_offset=70, + end_lineno=60, + end_col_offset=73)], + [], + lineno=60, + col_offset=47, + end_lineno=60, + end_col_offset=74), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=74), + Expr( + Call( + Attribute( + Subscript( + Name( + 'result', + Load(), + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=26), + Name( + 'owner', + Load(), + lineno=61, + col_offset=27, + end_lineno=61, + end_col_offset=32), + Load(), + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=33), + 'update', + Load(), + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=40), + [ + Name( + 'owned_territories', + Load(), + lineno=61, + col_offset=41, + end_lineno=61, + end_col_offset=58)], + [], + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=59), + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=59), + Expr( + Call( + Attribute( + Name( + 'visited', + Load(), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=27), + 'update', + Load(), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=34), + [ + Name( + 'owned_territories', + Load(), + lineno=62, + col_offset=35, + end_lineno=62, + end_col_offset=52)], + [], + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=53), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=53)], + [], + lineno=59, + col_offset=16, + end_lineno=62, + end_col_offset=53)], + [], + lineno=58, + col_offset=12, + end_lineno=62, + end_col_offset=53)], + [], + lineno=57, + col_offset=8, + end_lineno=62, + end_col_offset=53), + Return( + Name( + 'result', + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=21), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=21)], + [], + lineno=53, + col_offset=4, + end_lineno=64, + end_col_offset=21)], + [], + lineno=9, + col_offset=0, + end_lineno=64, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=5)], + Constant( + 'B', + lineno=2, + col_offset=8, + end_lineno=2, + end_col_offset=11), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=11), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=5)], + Constant( + 'W', + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=11), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=11), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=4)], + Constant( + '', + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=9), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=9), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=6)], + List( + [ + Name( + 'placeholder_0', + Load(), + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=15), + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=22)], + Load(), + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=23), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=23), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=10)], + List( + [ + Tuple( + [ + Constant( + 0, + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=16), + Constant( + 1, + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=19)], + Load(), + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=20), + Tuple( + [ + Constant( + 0, + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=24), + UnaryOp( + USub(), + Constant( + 1, + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=26, + end_lineno=6, + end_col_offset=28)], + Load(), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=29), + Tuple( + [ + Constant( + 1, + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=33), + Constant( + 0, + lineno=6, + col_offset=35, + end_lineno=6, + end_col_offset=36)], + Load(), + lineno=6, + col_offset=31, + end_lineno=6, + end_col_offset=37), + Tuple( + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=6, + col_offset=41, + end_lineno=6, + end_col_offset=42), + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=42), + Constant( + 0, + lineno=6, + col_offset=44, + end_lineno=6, + end_col_offset=45)], + Load(), + lineno=6, + col_offset=39, + end_lineno=6, + end_col_offset=46)], + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=47), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=47), + ClassDef( + 'placeholder_5', + [], + [], + [ + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=21), + arg( + 'placeholder_7', + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=18)], + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=26), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=18)], + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=24), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=29), + 'placeholder_7', + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=35), + Constant( + 0, + lineno=12, + col_offset=36, + end_lineno=12, + end_col_offset=37), + Load(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=38)], + [], + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=39), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'placeholder_9', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=19)], + Call( + Name( + 'len', + Load(), + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=25), + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=30), + 'placeholder_7', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=36)], + [], + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=37), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=37)], + [], + lineno=10, + col_offset=4, + end_lineno=13, + end_col_offset=37), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=18), + arg( + 'placeholder_8', + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=25), + arg( + 'placeholder_9', + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + 'placeholder_8', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=25), + [ + Gt(), + GtE()], + [ + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=33), + Constant( + 0, + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=38)], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=38), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=47), + 'placeholder_9', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=54), + [ + Gt(), + GtE()], + [ + Name( + 'placeholder_9', + Load(), + lineno=16, + col_offset=57, + end_lineno=16, + end_col_offset=63), + Constant( + 0, + lineno=16, + col_offset=67, + end_lineno=16, + end_col_offset=68)], + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=68)], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=68), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=68)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=68), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=17), + arg( + 'placeholder_8', + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=24), + arg( + 'placeholder_9', + lineno=18, + col_offset=26, + end_lineno=18, + end_col_offset=32), + arg( + 'placeholder_12', + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=51), + arg( + 'placeholder_13', + lineno=18, + col_offset=58, + end_lineno=18, + end_col_offset=72), + arg( + 'placeholder_14', + lineno=18, + col_offset=79, + end_lineno=18, + end_col_offset=93)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=18, + col_offset=52, + end_lineno=18, + end_col_offset=56), + Constant( + None, + lineno=18, + col_offset=73, + end_lineno=18, + end_col_offset=77), + Constant( + None, + lineno=18, + col_offset=94, + end_lineno=18, + end_col_offset=98)]), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=25)], + IfExp( + Compare( + Name( + 'placeholder_12', + Load(), + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=51), + [ + Is()], + [ + Constant( + None, + lineno=20, + col_offset=55, + end_lineno=20, + end_col_offset=59)], + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=59), + List( + [], + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=30), + Name( + 'placeholder_12', + Load(), + lineno=20, + col_offset=65, + end_lineno=20, + end_col_offset=82), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=82), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=82), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=22)], + IfExp( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=45), + [ + Is()], + [ + Constant( + None, + lineno=21, + col_offset=49, + end_lineno=21, + end_col_offset=53)], + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=53), + List( + [], + Load(), + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=27), + Name( + 'placeholder_13', + Load(), + lineno=21, + col_offset=59, + end_lineno=21, + end_col_offset=73), + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=73), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=73), + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=22)], + IfExp( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=45), + [ + Is()], + [ + Constant( + None, + lineno=22, + col_offset=49, + end_lineno=22, + end_col_offset=53)], + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=53), + List( + [], + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=27), + Name( + 'placeholder_14', + Load(), + lineno=22, + col_offset=59, + end_lineno=22, + end_col_offset=73), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=73), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=73), + If( + BoolOp( + And(), + [ + Compare( + Tuple( + [ + Name( + 'placeholder_8', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=17), + Name( + 'placeholder_9', + Load(), + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=25)], + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=26), + [ + NotIn()], + [ + Name( + 'placeholder_13', + Load(), + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=48)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=48), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=53, + end_lineno=24, + end_col_offset=57), + 'placeholder_10', + Load(), + lineno=24, + col_offset=53, + end_lineno=24, + end_col_offset=63), + [ + Name( + 'placeholder_8', + Load(), + lineno=24, + col_offset=64, + end_lineno=24, + end_col_offset=69), + Name( + 'placeholder_9', + Load(), + lineno=24, + col_offset=71, + end_lineno=24, + end_col_offset=77)], + [], + lineno=24, + col_offset=53, + end_lineno=24, + end_col_offset=78)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=78), + [ + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=17)], + Subscript( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=24), + 'placeholder_7', + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=30), + Name( + 'placeholder_9', + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=37), + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=38), + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=44), + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=45), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=45), + If( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=20), + [ + In()], + [ + Name( + 'placeholder_3', + Load(), + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=30)], + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=30), + [ + If( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=24), + [ + NotIn()], + [ + Name( + 'placeholder_14', + Load(), + lineno=27, + col_offset=32, + end_lineno=27, + end_col_offset=46)], + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=46), + [ + Return( + Tuple( + [ + Name( + 'placeholder_12', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=45), + BinOp( + Name( + 'placeholder_14', + Load(), + lineno=28, + col_offset=47, + end_lineno=28, + end_col_offset=61), + Add(), + List( + [ + Name( + 'placeholder_15', + Load(), + lineno=28, + col_offset=65, + end_lineno=28, + end_col_offset=70)], + Load(), + lineno=28, + col_offset=64, + end_lineno=28, + end_col_offset=71), + lineno=28, + col_offset=47, + end_lineno=28, + end_col_offset=71)], + Load(), + lineno=28, + col_offset=27, + end_lineno=28, + end_col_offset=72), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=72)], + [], + lineno=27, + col_offset=16, + end_lineno=28, + end_col_offset=72)], + [ + For( + Name( + 'placeholder_16', + Store(), + lineno=30, + col_offset=20, + end_lineno=30, + end_col_offset=29), + Name( + 'placeholder_4', + Load(), + lineno=30, + col_offset=33, + end_lineno=30, + end_col_offset=43), + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=27)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=30, + end_lineno=31, + end_col_offset=34), + 'placeholder_11', + Load(), + lineno=31, + col_offset=30, + end_lineno=31, + end_col_offset=39), + [ + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=45), + Add(), + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=57), + Constant( + 0, + lineno=31, + col_offset=58, + end_lineno=31, + end_col_offset=59), + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=60), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=60), + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=31, + col_offset=62, + end_lineno=31, + end_col_offset=68), + Add(), + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=31, + col_offset=71, + end_lineno=31, + end_col_offset=80), + Constant( + 1, + lineno=31, + col_offset=81, + end_lineno=31, + end_col_offset=82), + Load(), + lineno=31, + col_offset=71, + end_lineno=31, + end_col_offset=83), + lineno=31, + col_offset=62, + end_lineno=31, + end_col_offset=83), + BinOp( + Name( + 'placeholder_12', + Load(), + lineno=32, + col_offset=40, + end_lineno=32, + end_col_offset=57), + Add(), + List( + [ + Tuple( + [ + Name( + 'placeholder_8', + Load(), + lineno=32, + col_offset=62, + end_lineno=32, + end_col_offset=67), + Name( + 'placeholder_9', + Load(), + lineno=32, + col_offset=69, + end_lineno=32, + end_col_offset=75)], + Load(), + lineno=32, + col_offset=61, + end_lineno=32, + end_col_offset=76)], + Load(), + lineno=32, + col_offset=60, + end_lineno=32, + end_col_offset=77), + lineno=32, + col_offset=40, + end_lineno=32, + end_col_offset=77), + BinOp( + Name( + 'placeholder_13', + Load(), + lineno=33, + col_offset=40, + end_lineno=33, + end_col_offset=54), + Add(), + List( + [ + Tuple( + [ + Name( + 'placeholder_8', + Load(), + lineno=33, + col_offset=59, + end_lineno=33, + end_col_offset=64), + Name( + 'placeholder_9', + Load(), + lineno=33, + col_offset=66, + end_lineno=33, + end_col_offset=72)], + Load(), + lineno=33, + col_offset=58, + end_lineno=33, + end_col_offset=73)], + Load(), + lineno=33, + col_offset=57, + end_lineno=33, + end_col_offset=74), + lineno=33, + col_offset=40, + end_lineno=33, + end_col_offset=74), + Name( + 'placeholder_14', + Load(), + lineno=34, + col_offset=40, + end_lineno=34, + end_col_offset=54)], + [], + lineno=31, + col_offset=30, + end_lineno=34, + end_col_offset=55), + lineno=31, + col_offset=20, + end_lineno=34, + end_col_offset=55), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=37)], + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=35, + col_offset=40, + end_lineno=35, + end_col_offset=47), + Constant( + 0, + lineno=35, + col_offset=48, + end_lineno=35, + end_col_offset=49), + Load(), + lineno=35, + col_offset=40, + end_lineno=35, + end_col_offset=50), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=50), + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=34)], + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=44), + Constant( + 1, + lineno=36, + col_offset=45, + end_lineno=36, + end_col_offset=46), + Load(), + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=47), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=47)], + [], + lineno=30, + col_offset=16, + end_lineno=36, + end_col_offset=47)], + lineno=26, + col_offset=12, + end_lineno=36, + end_col_offset=47)], + [], + lineno=24, + col_offset=8, + end_lineno=36, + end_col_offset=47), + Return( + Tuple( + [ + Name( + 'placeholder_12', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=33), + Name( + 'placeholder_14', + Load(), + lineno=38, + col_offset=35, + end_lineno=38, + end_col_offset=49)], + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=50), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=50)], + [], + lineno=18, + col_offset=4, + end_lineno=38, + end_col_offset=50), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'self', + lineno=40, + col_offset=18, + end_lineno=40, + end_col_offset=22), + arg( + 'placeholder_19', + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=25), + arg( + 'placeholder_20', + lineno=40, + col_offset=27, + end_lineno=40, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=19), + 'placeholder_10', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=25), + [ + Name( + 'placeholder_19', + Load(), + lineno=41, + col_offset=26, + end_lineno=41, + end_col_offset=27), + Name( + 'placeholder_20', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=30)], + [], + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=31), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=28), + [ + Constant( + 'Invalid coordinate', + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=49)], + [], + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=50), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=50)], + [], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=50), + If( + Compare( + Subscript( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=15), + 'placeholder_7', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=21), + Name( + 'placeholder_20', + Load(), + lineno=43, + col_offset=22, + end_lineno=43, + end_col_offset=23), + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=24), + Name( + 'placeholder_19', + Load(), + lineno=43, + col_offset=25, + end_lineno=43, + end_col_offset=26), + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=27), + [ + In()], + [ + Name( + 'placeholder_3', + Load(), + lineno=43, + col_offset=31, + end_lineno=43, + end_col_offset=37)], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=37), + [ + Return( + Tuple( + [ + Name( + 'placeholder_2', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=24), + Call( + Name( + 'set', + Load(), + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=29), + [], + [], + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=31)], + Load(), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=32), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=32)], + [], + lineno=43, + col_offset=8, + end_lineno=44, + end_col_offset=32), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_12', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=25), + Name( + 'placeholder_14', + Store(), + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=41)], + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=41)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=48), + 'placeholder_11', + Load(), + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=53), + [ + Name( + 'placeholder_19', + Load(), + lineno=46, + col_offset=54, + end_lineno=46, + end_col_offset=55), + Name( + 'placeholder_20', + Load(), + lineno=46, + col_offset=57, + end_lineno=46, + end_col_offset=58)], + [], + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=59), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=59), + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=14)], + Call( + Name( + 'set', + Load(), + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=20), + [ + Name( + 'placeholder_12', + Load(), + lineno=47, + col_offset=21, + end_lineno=47, + end_col_offset=38)], + [], + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=39), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=39), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=14), + [ + Name( + 'placeholder_14', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=29)], + [], + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 1, + lineno=49, + col_offset=34, + end_lineno=49, + end_col_offset=35)], + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=35), + [ + Return( + Tuple( + [ + Subscript( + Name( + 'placeholder_14', + Load(), + lineno=50, + col_offset=20, + end_lineno=50, + end_col_offset=34), + Constant( + 0, + lineno=50, + col_offset=35, + end_lineno=50, + end_col_offset=36), + Load(), + lineno=50, + col_offset=20, + end_lineno=50, + end_col_offset=37), + Name( + 'placeholder_21', + Load(), + lineno=50, + col_offset=39, + end_lineno=50, + end_col_offset=45)], + Load(), + lineno=50, + col_offset=19, + end_lineno=50, + end_col_offset=46), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=46)], + [], + lineno=49, + col_offset=8, + end_lineno=50, + end_col_offset=46), + Return( + Tuple( + [ + Name( + 'placeholder_2', + Load(), + lineno=51, + col_offset=16, + end_lineno=51, + end_col_offset=20), + Name( + 'placeholder_21', + Load(), + lineno=51, + col_offset=22, + end_lineno=51, + end_col_offset=28)], + Load(), + lineno=51, + col_offset=15, + end_lineno=51, + end_col_offset=29), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=29)], + [], + lineno=40, + col_offset=4, + end_lineno=51, + end_col_offset=29), + FunctionDef( + 'placeholder_22', + arguments( + [], + [ + arg( + 'self', + lineno=53, + col_offset=20, + end_lineno=53, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_23', + Store(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=14)], + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=54, + col_offset=17, + end_lineno=54, + end_col_offset=23), + Add(), + List( + [ + Name( + 'placeholder_2', + Load(), + lineno=54, + col_offset=27, + end_lineno=54, + end_col_offset=31)], + Load(), + lineno=54, + col_offset=26, + end_lineno=54, + end_col_offset=32), + lineno=54, + col_offset=17, + end_lineno=54, + end_col_offset=32), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=14)], + DictComp( + Name( + 'placeholder_24', + Load(), + lineno=55, + col_offset=18, + end_lineno=55, + end_col_offset=23), + Call( + Name( + 'set', + Load(), + lineno=55, + col_offset=24, + end_lineno=55, + end_col_offset=27), + [], + [], + lineno=55, + col_offset=24, + end_lineno=55, + end_col_offset=29), + [ + comprehension( + Name( + 'placeholder_24', + Store(), + lineno=55, + col_offset=34, + end_lineno=55, + end_col_offset=39), + Name( + 'placeholder_23', + Load(), + lineno=55, + col_offset=43, + end_lineno=55, + end_col_offset=49), + [], + 0)], + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=50), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=50), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=15)], + Call( + Name( + 'set', + Load(), + lineno=56, + col_offset=18, + end_lineno=56, + end_col_offset=21), + [], + [], + lineno=56, + col_offset=18, + end_lineno=56, + end_col_offset=23), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=23), + For( + Name( + 'placeholder_25', + Store(), + lineno=57, + col_offset=12, + end_lineno=57, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=24), + [ + Attribute( + Name( + 'self', + Load(), + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=29), + 'placeholder_9', + Load(), + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=36)], + [], + lineno=57, + col_offset=19, + end_lineno=57, + end_col_offset=37), + [ + For( + Name( + 'placeholder_26', + Store(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=22), + Call( + Name( + 'range', + Load(), + lineno=58, + col_offset=26, + end_lineno=58, + end_col_offset=31), + [ + Attribute( + Name( + 'self', + Load(), + lineno=58, + col_offset=32, + end_lineno=58, + end_col_offset=36), + 'placeholder_8', + Load(), + lineno=58, + col_offset=32, + end_lineno=58, + end_col_offset=42)], + [], + lineno=58, + col_offset=26, + end_lineno=58, + end_col_offset=43), + [ + If( + UnaryOp( + Not(), + Compare( + Tuple( + [ + Name( + 'placeholder_26', + Load(), + lineno=59, + col_offset=24, + end_lineno=59, + end_col_offset=30), + Name( + 'placeholder_25', + Load(), + lineno=59, + col_offset=32, + end_lineno=59, + end_col_offset=35)], + Load(), + lineno=59, + col_offset=23, + end_lineno=59, + end_col_offset=36), + [ + In()], + [ + Name( + 'placeholder_17', + Load(), + lineno=59, + col_offset=40, + end_lineno=59, + end_col_offset=47)], + lineno=59, + col_offset=23, + end_lineno=59, + end_col_offset=47), + lineno=59, + col_offset=19, + end_lineno=59, + end_col_offset=47), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_24', + Store(), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=25), + Name( + 'placeholder_27', + Store(), + lineno=60, + col_offset=27, + end_lineno=60, + end_col_offset=44)], + Store(), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=44)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=47, + end_lineno=60, + end_col_offset=51), + 'placeholder_18', + Load(), + lineno=60, + col_offset=47, + end_lineno=60, + end_col_offset=61), + [ + Name( + 'placeholder_26', + Load(), + lineno=60, + col_offset=62, + end_lineno=60, + end_col_offset=68), + Name( + 'placeholder_25', + Load(), + lineno=60, + col_offset=70, + end_lineno=60, + end_col_offset=73)], + [], + lineno=60, + col_offset=47, + end_lineno=60, + end_col_offset=74), + lineno=60, + col_offset=20, + end_lineno=60, + end_col_offset=74), + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_21', + Load(), + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=26), + Name( + 'placeholder_24', + Load(), + lineno=61, + col_offset=27, + end_lineno=61, + end_col_offset=32), + Load(), + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=33), + 'update', + Load(), + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=40), + [ + Name( + 'placeholder_27', + Load(), + lineno=61, + col_offset=41, + end_lineno=61, + end_col_offset=58)], + [], + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=59), + lineno=61, + col_offset=20, + end_lineno=61, + end_col_offset=59), + Expr( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=27), + 'update', + Load(), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=34), + [ + Name( + 'placeholder_27', + Load(), + lineno=62, + col_offset=35, + end_lineno=62, + end_col_offset=52)], + [], + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=53), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=53)], + [], + lineno=59, + col_offset=16, + end_lineno=62, + end_col_offset=53)], + [], + lineno=58, + col_offset=12, + end_lineno=62, + end_col_offset=53)], + [], + lineno=57, + col_offset=8, + end_lineno=62, + end_col_offset=53), + Return( + Name( + 'placeholder_21', + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=21), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=21)], + [], + lineno=53, + col_offset=4, + end_lineno=64, + end_col_offset=21)], + [], + lineno=9, + col_offset=0, + end_lineno=64, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-go-counting/representation.txt b/test/practice-go-counting/representation.txt new file mode 100644 index 0000000..f67aa2a --- /dev/null +++ b/test/practice-go-counting/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=2, col_offset=0, end_lineno=2, end_col_offset=5)], Constant('B', lineno=2, col_offset=8, end_lineno=2, end_col_offset=11), lineno=2, col_offset=0, end_lineno=2, end_col_offset=11), Assign([Name('placeholder_1', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=5)], Constant('W', lineno=3, col_offset=8, end_lineno=3, end_col_offset=11), lineno=3, col_offset=0, end_lineno=3, end_col_offset=11), Assign([Name('placeholder_2', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=4)], Constant('', lineno=4, col_offset=7, end_lineno=4, end_col_offset=9), lineno=4, col_offset=0, end_lineno=4, end_col_offset=9), Assign([Name('placeholder_3', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=6)], List([Name('placeholder_0', Load(), lineno=5, col_offset=10, end_lineno=5, end_col_offset=15), Name('placeholder_1', Load(), lineno=5, col_offset=17, end_lineno=5, end_col_offset=22)], Load(), lineno=5, col_offset=9, end_lineno=5, end_col_offset=23), lineno=5, col_offset=0, end_lineno=5, end_col_offset=23), Assign([Name('placeholder_4', Store(), lineno=6, col_offset=0, end_lineno=6, end_col_offset=10)], List([Tuple([Constant(0, lineno=6, col_offset=15, end_lineno=6, end_col_offset=16), Constant(1, lineno=6, col_offset=18, end_lineno=6, end_col_offset=19)], Load(), lineno=6, col_offset=14, end_lineno=6, end_col_offset=20), Tuple([Constant(0, lineno=6, col_offset=23, end_lineno=6, end_col_offset=24), UnaryOp(USub(), Constant(1, lineno=6, col_offset=27, end_lineno=6, end_col_offset=28), lineno=6, col_offset=26, end_lineno=6, end_col_offset=28)], Load(), lineno=6, col_offset=22, end_lineno=6, end_col_offset=29), Tuple([Constant(1, lineno=6, col_offset=32, end_lineno=6, end_col_offset=33), Constant(0, lineno=6, col_offset=35, end_lineno=6, end_col_offset=36)], Load(), lineno=6, col_offset=31, end_lineno=6, end_col_offset=37), Tuple([UnaryOp(USub(), Constant(1, lineno=6, col_offset=41, end_lineno=6, end_col_offset=42), lineno=6, col_offset=40, end_lineno=6, end_col_offset=42), Constant(0, lineno=6, col_offset=44, end_lineno=6, end_col_offset=45)], Load(), lineno=6, col_offset=39, end_lineno=6, end_col_offset=46)], Load(), lineno=6, col_offset=13, end_lineno=6, end_col_offset=47), lineno=6, col_offset=0, end_lineno=6, end_col_offset=47), ClassDef('placeholder_5', [], [], [FunctionDef('placeholder_6', arguments([], [arg('self', lineno=10, col_offset=17, end_lineno=10, end_col_offset=21), arg('placeholder_7', lineno=10, col_offset=23, end_lineno=10, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), 'placeholder_7', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=18)], Name('placeholder_7', Load(), lineno=11, col_offset=21, end_lineno=11, end_col_offset=26), lineno=11, col_offset=8, end_lineno=11, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), 'placeholder_8', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=18)], Call(Name('len', Load(), lineno=12, col_offset=21, end_lineno=12, end_col_offset=24), [Subscript(Attribute(Name('self', Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=29), 'placeholder_7', Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=35), Constant(0, lineno=12, col_offset=36, end_lineno=12, end_col_offset=37), Load(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=38)], [], lineno=12, col_offset=21, end_lineno=12, end_col_offset=39), lineno=12, col_offset=8, end_lineno=12, end_col_offset=39), Assign([Attribute(Name('self', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=12), 'placeholder_9', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=19)], Call(Name('len', Load(), lineno=13, col_offset=22, end_lineno=13, end_col_offset=25), [Attribute(Name('self', Load(), lineno=13, col_offset=26, end_lineno=13, end_col_offset=30), 'placeholder_7', Load(), lineno=13, col_offset=26, end_lineno=13, end_col_offset=36)], [], lineno=13, col_offset=22, end_lineno=13, end_col_offset=37), lineno=13, col_offset=8, end_lineno=13, end_col_offset=37)], [], lineno=10, col_offset=4, end_lineno=13, end_col_offset=37), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=15, col_offset=14, end_lineno=15, end_col_offset=18), arg('placeholder_8', lineno=15, col_offset=20, end_lineno=15, end_col_offset=25), arg('placeholder_9', lineno=15, col_offset=27, end_lineno=15, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=19), 'placeholder_8', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=25), [Gt(), GtE()], [Name('placeholder_8', Load(), lineno=16, col_offset=28, end_lineno=16, end_col_offset=33), Constant(0, lineno=16, col_offset=37, end_lineno=16, end_col_offset=38)], lineno=16, col_offset=15, end_lineno=16, end_col_offset=38), Compare(Attribute(Name('self', Load(), lineno=16, col_offset=43, end_lineno=16, end_col_offset=47), 'placeholder_9', Load(), lineno=16, col_offset=43, end_lineno=16, end_col_offset=54), [Gt(), GtE()], [Name('placeholder_9', Load(), lineno=16, col_offset=57, end_lineno=16, end_col_offset=63), Constant(0, lineno=16, col_offset=67, end_lineno=16, end_col_offset=68)], lineno=16, col_offset=43, end_lineno=16, end_col_offset=68)], lineno=16, col_offset=15, end_lineno=16, end_col_offset=68), lineno=16, col_offset=8, end_lineno=16, end_col_offset=68)], [], lineno=15, col_offset=4, end_lineno=16, end_col_offset=68), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=18, col_offset=13, end_lineno=18, end_col_offset=17), arg('placeholder_8', lineno=18, col_offset=19, end_lineno=18, end_col_offset=24), arg('placeholder_9', lineno=18, col_offset=26, end_lineno=18, end_col_offset=32), arg('placeholder_12', lineno=18, col_offset=34, end_lineno=18, end_col_offset=51), arg('placeholder_13', lineno=18, col_offset=58, end_lineno=18, end_col_offset=72), arg('placeholder_14', lineno=18, col_offset=79, end_lineno=18, end_col_offset=93)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=18, col_offset=52, end_lineno=18, end_col_offset=56), Constant(None, lineno=18, col_offset=73, end_lineno=18, end_col_offset=77), Constant(None, lineno=18, col_offset=94, end_lineno=18, end_col_offset=98)]), [Assign([Name('placeholder_12', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=25)], IfExp(Compare(Name('placeholder_12', Load(), lineno=20, col_offset=34, end_lineno=20, end_col_offset=51), [Is()], [Constant(None, lineno=20, col_offset=55, end_lineno=20, end_col_offset=59)], lineno=20, col_offset=34, end_lineno=20, end_col_offset=59), List([], Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=30), Name('placeholder_12', Load(), lineno=20, col_offset=65, end_lineno=20, end_col_offset=82), lineno=20, col_offset=28, end_lineno=20, end_col_offset=82), lineno=20, col_offset=8, end_lineno=20, end_col_offset=82), Assign([Name('placeholder_13', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=22)], IfExp(Compare(Name('placeholder_13', Load(), lineno=21, col_offset=31, end_lineno=21, end_col_offset=45), [Is()], [Constant(None, lineno=21, col_offset=49, end_lineno=21, end_col_offset=53)], lineno=21, col_offset=31, end_lineno=21, end_col_offset=53), List([], Load(), lineno=21, col_offset=25, end_lineno=21, end_col_offset=27), Name('placeholder_13', Load(), lineno=21, col_offset=59, end_lineno=21, end_col_offset=73), lineno=21, col_offset=25, end_lineno=21, end_col_offset=73), lineno=21, col_offset=8, end_lineno=21, end_col_offset=73), Assign([Name('placeholder_14', Store(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=22)], IfExp(Compare(Name('placeholder_14', Load(), lineno=22, col_offset=31, end_lineno=22, end_col_offset=45), [Is()], [Constant(None, lineno=22, col_offset=49, end_lineno=22, end_col_offset=53)], lineno=22, col_offset=31, end_lineno=22, end_col_offset=53), List([], Load(), lineno=22, col_offset=25, end_lineno=22, end_col_offset=27), Name('placeholder_14', Load(), lineno=22, col_offset=59, end_lineno=22, end_col_offset=73), lineno=22, col_offset=25, end_lineno=22, end_col_offset=73), lineno=22, col_offset=8, end_lineno=22, end_col_offset=73), If(BoolOp(And(), [Compare(Tuple([Name('placeholder_8', Load(), lineno=24, col_offset=12, end_lineno=24, end_col_offset=17), Name('placeholder_9', Load(), lineno=24, col_offset=19, end_lineno=24, end_col_offset=25)], Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=26), [NotIn()], [Name('placeholder_13', Load(), lineno=24, col_offset=34, end_lineno=24, end_col_offset=48)], lineno=24, col_offset=11, end_lineno=24, end_col_offset=48), Call(Attribute(Name('self', Load(), lineno=24, col_offset=53, end_lineno=24, end_col_offset=57), 'placeholder_10', Load(), lineno=24, col_offset=53, end_lineno=24, end_col_offset=63), [Name('placeholder_8', Load(), lineno=24, col_offset=64, end_lineno=24, end_col_offset=69), Name('placeholder_9', Load(), lineno=24, col_offset=71, end_lineno=24, end_col_offset=77)], [], lineno=24, col_offset=53, end_lineno=24, end_col_offset=78)], lineno=24, col_offset=11, end_lineno=24, end_col_offset=78), [Assign([Name('placeholder_15', Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=17)], Subscript(Subscript(Attribute(Name('self', Load(), lineno=25, col_offset=20, end_lineno=25, end_col_offset=24), 'placeholder_7', Load(), lineno=25, col_offset=20, end_lineno=25, end_col_offset=30), Name('placeholder_9', Load(), lineno=25, col_offset=31, end_lineno=25, end_col_offset=37), Load(), lineno=25, col_offset=20, end_lineno=25, end_col_offset=38), Name('placeholder_8', Load(), lineno=25, col_offset=39, end_lineno=25, end_col_offset=44), Load(), lineno=25, col_offset=20, end_lineno=25, end_col_offset=45), lineno=25, col_offset=12, end_lineno=25, end_col_offset=45), If(Compare(Name('placeholder_15', Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=20), [In()], [Name('placeholder_3', Load(), lineno=26, col_offset=24, end_lineno=26, end_col_offset=30)], lineno=26, col_offset=15, end_lineno=26, end_col_offset=30), [If(Compare(Name('placeholder_15', Load(), lineno=27, col_offset=19, end_lineno=27, end_col_offset=24), [NotIn()], [Name('placeholder_14', Load(), lineno=27, col_offset=32, end_lineno=27, end_col_offset=46)], lineno=27, col_offset=19, end_lineno=27, end_col_offset=46), [Return(Tuple([Name('placeholder_12', Load(), lineno=28, col_offset=28, end_lineno=28, end_col_offset=45), BinOp(Name('placeholder_14', Load(), lineno=28, col_offset=47, end_lineno=28, end_col_offset=61), Add(), List([Name('placeholder_15', Load(), lineno=28, col_offset=65, end_lineno=28, end_col_offset=70)], Load(), lineno=28, col_offset=64, end_lineno=28, end_col_offset=71), lineno=28, col_offset=47, end_lineno=28, end_col_offset=71)], Load(), lineno=28, col_offset=27, end_lineno=28, end_col_offset=72), lineno=28, col_offset=20, end_lineno=28, end_col_offset=72)], [], lineno=27, col_offset=16, end_lineno=28, end_col_offset=72)], [For(Name('placeholder_16', Store(), lineno=30, col_offset=20, end_lineno=30, end_col_offset=29), Name('placeholder_4', Load(), lineno=30, col_offset=33, end_lineno=30, end_col_offset=43), [Assign([Name('placeholder_17', Store(), lineno=31, col_offset=20, end_lineno=31, end_col_offset=27)], Call(Attribute(Name('self', Load(), lineno=31, col_offset=30, end_lineno=31, end_col_offset=34), 'placeholder_11', Load(), lineno=31, col_offset=30, end_lineno=31, end_col_offset=39), [BinOp(Name('placeholder_8', Load(), lineno=31, col_offset=40, end_lineno=31, end_col_offset=45), Add(), Subscript(Name('placeholder_16', Load(), lineno=31, col_offset=48, end_lineno=31, end_col_offset=57), Constant(0, lineno=31, col_offset=58, end_lineno=31, end_col_offset=59), Load(), lineno=31, col_offset=48, end_lineno=31, end_col_offset=60), lineno=31, col_offset=40, end_lineno=31, end_col_offset=60), BinOp(Name('placeholder_9', Load(), lineno=31, col_offset=62, end_lineno=31, end_col_offset=68), Add(), Subscript(Name('placeholder_16', Load(), lineno=31, col_offset=71, end_lineno=31, end_col_offset=80), Constant(1, lineno=31, col_offset=81, end_lineno=31, end_col_offset=82), Load(), lineno=31, col_offset=71, end_lineno=31, end_col_offset=83), lineno=31, col_offset=62, end_lineno=31, end_col_offset=83), BinOp(Name('placeholder_12', Load(), lineno=32, col_offset=40, end_lineno=32, end_col_offset=57), Add(), List([Tuple([Name('placeholder_8', Load(), lineno=32, col_offset=62, end_lineno=32, end_col_offset=67), Name('placeholder_9', Load(), lineno=32, col_offset=69, end_lineno=32, end_col_offset=75)], Load(), lineno=32, col_offset=61, end_lineno=32, end_col_offset=76)], Load(), lineno=32, col_offset=60, end_lineno=32, end_col_offset=77), lineno=32, col_offset=40, end_lineno=32, end_col_offset=77), BinOp(Name('placeholder_13', Load(), lineno=33, col_offset=40, end_lineno=33, end_col_offset=54), Add(), List([Tuple([Name('placeholder_8', Load(), lineno=33, col_offset=59, end_lineno=33, end_col_offset=64), Name('placeholder_9', Load(), lineno=33, col_offset=66, end_lineno=33, end_col_offset=72)], Load(), lineno=33, col_offset=58, end_lineno=33, end_col_offset=73)], Load(), lineno=33, col_offset=57, end_lineno=33, end_col_offset=74), lineno=33, col_offset=40, end_lineno=33, end_col_offset=74), Name('placeholder_14', Load(), lineno=34, col_offset=40, end_lineno=34, end_col_offset=54)], [], lineno=31, col_offset=30, end_lineno=34, end_col_offset=55), lineno=31, col_offset=20, end_lineno=34, end_col_offset=55), Assign([Name('placeholder_12', Store(), lineno=35, col_offset=20, end_lineno=35, end_col_offset=37)], Subscript(Name('placeholder_17', Load(), lineno=35, col_offset=40, end_lineno=35, end_col_offset=47), Constant(0, lineno=35, col_offset=48, end_lineno=35, end_col_offset=49), Load(), lineno=35, col_offset=40, end_lineno=35, end_col_offset=50), lineno=35, col_offset=20, end_lineno=35, end_col_offset=50), Assign([Name('placeholder_14', Store(), lineno=36, col_offset=20, end_lineno=36, end_col_offset=34)], Subscript(Name('placeholder_17', Load(), lineno=36, col_offset=37, end_lineno=36, end_col_offset=44), Constant(1, lineno=36, col_offset=45, end_lineno=36, end_col_offset=46), Load(), lineno=36, col_offset=37, end_lineno=36, end_col_offset=47), lineno=36, col_offset=20, end_lineno=36, end_col_offset=47)], [], lineno=30, col_offset=16, end_lineno=36, end_col_offset=47)], lineno=26, col_offset=12, end_lineno=36, end_col_offset=47)], [], lineno=24, col_offset=8, end_lineno=36, end_col_offset=47), Return(Tuple([Name('placeholder_12', Load(), lineno=38, col_offset=16, end_lineno=38, end_col_offset=33), Name('placeholder_14', Load(), lineno=38, col_offset=35, end_lineno=38, end_col_offset=49)], Load(), lineno=38, col_offset=15, end_lineno=38, end_col_offset=50), lineno=38, col_offset=8, end_lineno=38, end_col_offset=50)], [], lineno=18, col_offset=4, end_lineno=38, end_col_offset=50), FunctionDef('placeholder_18', arguments([], [arg('self', lineno=40, col_offset=18, end_lineno=40, end_col_offset=22), arg('placeholder_19', lineno=40, col_offset=24, end_lineno=40, end_col_offset=25), arg('placeholder_20', lineno=40, col_offset=27, end_lineno=40, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Attribute(Name('self', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=19), 'placeholder_10', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=25), [Name('placeholder_19', Load(), lineno=41, col_offset=26, end_lineno=41, end_col_offset=27), Name('placeholder_20', Load(), lineno=41, col_offset=29, end_lineno=41, end_col_offset=30)], [], lineno=41, col_offset=15, end_lineno=41, end_col_offset=31), lineno=41, col_offset=11, end_lineno=41, end_col_offset=31), [Raise(Call(Name('ValueError', Load(), lineno=42, col_offset=18, end_lineno=42, end_col_offset=28), [Constant('Invalid coordinate', lineno=42, col_offset=29, end_lineno=42, end_col_offset=49)], [], lineno=42, col_offset=18, end_lineno=42, end_col_offset=50), lineno=42, col_offset=12, end_lineno=42, end_col_offset=50)], [], lineno=41, col_offset=8, end_lineno=42, end_col_offset=50), If(Compare(Subscript(Subscript(Attribute(Name('self', Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=15), 'placeholder_7', Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=21), Name('placeholder_20', Load(), lineno=43, col_offset=22, end_lineno=43, end_col_offset=23), Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=24), Name('placeholder_19', Load(), lineno=43, col_offset=25, end_lineno=43, end_col_offset=26), Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=27), [In()], [Name('placeholder_3', Load(), lineno=43, col_offset=31, end_lineno=43, end_col_offset=37)], lineno=43, col_offset=11, end_lineno=43, end_col_offset=37), [Return(Tuple([Name('placeholder_2', Load(), lineno=44, col_offset=20, end_lineno=44, end_col_offset=24), Call(Name('set', Load(), lineno=44, col_offset=26, end_lineno=44, end_col_offset=29), [], [], lineno=44, col_offset=26, end_lineno=44, end_col_offset=31)], Load(), lineno=44, col_offset=19, end_lineno=44, end_col_offset=32), lineno=44, col_offset=12, end_lineno=44, end_col_offset=32)], [], lineno=43, col_offset=8, end_lineno=44, end_col_offset=32), Assign([Tuple([Name('placeholder_12', Store(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=25), Name('placeholder_14', Store(), lineno=46, col_offset=27, end_lineno=46, end_col_offset=41)], Store(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=41)], Call(Attribute(Name('self', Load(), lineno=46, col_offset=44, end_lineno=46, end_col_offset=48), 'placeholder_11', Load(), lineno=46, col_offset=44, end_lineno=46, end_col_offset=53), [Name('placeholder_19', Load(), lineno=46, col_offset=54, end_lineno=46, end_col_offset=55), Name('placeholder_20', Load(), lineno=46, col_offset=57, end_lineno=46, end_col_offset=58)], [], lineno=46, col_offset=44, end_lineno=46, end_col_offset=59), lineno=46, col_offset=8, end_lineno=46, end_col_offset=59), Assign([Name('placeholder_21', Store(), lineno=47, col_offset=8, end_lineno=47, end_col_offset=14)], Call(Name('set', Load(), lineno=47, col_offset=17, end_lineno=47, end_col_offset=20), [Name('placeholder_12', Load(), lineno=47, col_offset=21, end_lineno=47, end_col_offset=38)], [], lineno=47, col_offset=17, end_lineno=47, end_col_offset=39), lineno=47, col_offset=8, end_lineno=47, end_col_offset=39), If(Compare(Call(Name('len', Load(), lineno=49, col_offset=11, end_lineno=49, end_col_offset=14), [Name('placeholder_14', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=29)], [], lineno=49, col_offset=11, end_lineno=49, end_col_offset=30), [Eq()], [Constant(1, lineno=49, col_offset=34, end_lineno=49, end_col_offset=35)], lineno=49, col_offset=11, end_lineno=49, end_col_offset=35), [Return(Tuple([Subscript(Name('placeholder_14', Load(), lineno=50, col_offset=20, end_lineno=50, end_col_offset=34), Constant(0, lineno=50, col_offset=35, end_lineno=50, end_col_offset=36), Load(), lineno=50, col_offset=20, end_lineno=50, end_col_offset=37), Name('placeholder_21', Load(), lineno=50, col_offset=39, end_lineno=50, end_col_offset=45)], Load(), lineno=50, col_offset=19, end_lineno=50, end_col_offset=46), lineno=50, col_offset=12, end_lineno=50, end_col_offset=46)], [], lineno=49, col_offset=8, end_lineno=50, end_col_offset=46), Return(Tuple([Name('placeholder_2', Load(), lineno=51, col_offset=16, end_lineno=51, end_col_offset=20), Name('placeholder_21', Load(), lineno=51, col_offset=22, end_lineno=51, end_col_offset=28)], Load(), lineno=51, col_offset=15, end_lineno=51, end_col_offset=29), lineno=51, col_offset=8, end_lineno=51, end_col_offset=29)], [], lineno=40, col_offset=4, end_lineno=51, end_col_offset=29), FunctionDef('placeholder_22', arguments([], [arg('self', lineno=53, col_offset=20, end_lineno=53, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_23', Store(), lineno=54, col_offset=8, end_lineno=54, end_col_offset=14)], BinOp(Name('placeholder_3', Load(), lineno=54, col_offset=17, end_lineno=54, end_col_offset=23), Add(), List([Name('placeholder_2', Load(), lineno=54, col_offset=27, end_lineno=54, end_col_offset=31)], Load(), lineno=54, col_offset=26, end_lineno=54, end_col_offset=32), lineno=54, col_offset=17, end_lineno=54, end_col_offset=32), lineno=54, col_offset=8, end_lineno=54, end_col_offset=32), Assign([Name('placeholder_21', Store(), lineno=55, col_offset=8, end_lineno=55, end_col_offset=14)], DictComp(Name('placeholder_24', Load(), lineno=55, col_offset=18, end_lineno=55, end_col_offset=23), Call(Name('set', Load(), lineno=55, col_offset=24, end_lineno=55, end_col_offset=27), [], [], lineno=55, col_offset=24, end_lineno=55, end_col_offset=29), [comprehension(Name('placeholder_24', Store(), lineno=55, col_offset=34, end_lineno=55, end_col_offset=39), Name('placeholder_23', Load(), lineno=55, col_offset=43, end_lineno=55, end_col_offset=49), [], 0)], lineno=55, col_offset=17, end_lineno=55, end_col_offset=50), lineno=55, col_offset=8, end_lineno=55, end_col_offset=50), Assign([Name('placeholder_17', Store(), lineno=56, col_offset=8, end_lineno=56, end_col_offset=15)], Call(Name('set', Load(), lineno=56, col_offset=18, end_lineno=56, end_col_offset=21), [], [], lineno=56, col_offset=18, end_lineno=56, end_col_offset=23), lineno=56, col_offset=8, end_lineno=56, end_col_offset=23), For(Name('placeholder_25', Store(), lineno=57, col_offset=12, end_lineno=57, end_col_offset=15), Call(Name('range', Load(), lineno=57, col_offset=19, end_lineno=57, end_col_offset=24), [Attribute(Name('self', Load(), lineno=57, col_offset=25, end_lineno=57, end_col_offset=29), 'placeholder_9', Load(), lineno=57, col_offset=25, end_lineno=57, end_col_offset=36)], [], lineno=57, col_offset=19, end_lineno=57, end_col_offset=37), [For(Name('placeholder_26', Store(), lineno=58, col_offset=16, end_lineno=58, end_col_offset=22), Call(Name('range', Load(), lineno=58, col_offset=26, end_lineno=58, end_col_offset=31), [Attribute(Name('self', Load(), lineno=58, col_offset=32, end_lineno=58, end_col_offset=36), 'placeholder_8', Load(), lineno=58, col_offset=32, end_lineno=58, end_col_offset=42)], [], lineno=58, col_offset=26, end_lineno=58, end_col_offset=43), [If(UnaryOp(Not(), Compare(Tuple([Name('placeholder_26', Load(), lineno=59, col_offset=24, end_lineno=59, end_col_offset=30), Name('placeholder_25', Load(), lineno=59, col_offset=32, end_lineno=59, end_col_offset=35)], Load(), lineno=59, col_offset=23, end_lineno=59, end_col_offset=36), [In()], [Name('placeholder_17', Load(), lineno=59, col_offset=40, end_lineno=59, end_col_offset=47)], lineno=59, col_offset=23, end_lineno=59, end_col_offset=47), lineno=59, col_offset=19, end_lineno=59, end_col_offset=47), [Assign([Tuple([Name('placeholder_24', Store(), lineno=60, col_offset=20, end_lineno=60, end_col_offset=25), Name('placeholder_27', Store(), lineno=60, col_offset=27, end_lineno=60, end_col_offset=44)], Store(), lineno=60, col_offset=20, end_lineno=60, end_col_offset=44)], Call(Attribute(Name('self', Load(), lineno=60, col_offset=47, end_lineno=60, end_col_offset=51), 'placeholder_18', Load(), lineno=60, col_offset=47, end_lineno=60, end_col_offset=61), [Name('placeholder_26', Load(), lineno=60, col_offset=62, end_lineno=60, end_col_offset=68), Name('placeholder_25', Load(), lineno=60, col_offset=70, end_lineno=60, end_col_offset=73)], [], lineno=60, col_offset=47, end_lineno=60, end_col_offset=74), lineno=60, col_offset=20, end_lineno=60, end_col_offset=74), Expr(Call(Attribute(Subscript(Name('placeholder_21', Load(), lineno=61, col_offset=20, end_lineno=61, end_col_offset=26), Name('placeholder_24', Load(), lineno=61, col_offset=27, end_lineno=61, end_col_offset=32), Load(), lineno=61, col_offset=20, end_lineno=61, end_col_offset=33), 'update', Load(), lineno=61, col_offset=20, end_lineno=61, end_col_offset=40), [Name('placeholder_27', Load(), lineno=61, col_offset=41, end_lineno=61, end_col_offset=58)], [], lineno=61, col_offset=20, end_lineno=61, end_col_offset=59), lineno=61, col_offset=20, end_lineno=61, end_col_offset=59), Expr(Call(Attribute(Name('placeholder_17', Load(), lineno=62, col_offset=20, end_lineno=62, end_col_offset=27), 'update', Load(), lineno=62, col_offset=20, end_lineno=62, end_col_offset=34), [Name('placeholder_27', Load(), lineno=62, col_offset=35, end_lineno=62, end_col_offset=52)], [], lineno=62, col_offset=20, end_lineno=62, end_col_offset=53), lineno=62, col_offset=20, end_lineno=62, end_col_offset=53)], [], lineno=59, col_offset=16, end_lineno=62, end_col_offset=53)], [], lineno=58, col_offset=12, end_lineno=62, end_col_offset=53)], [], lineno=57, col_offset=8, end_lineno=62, end_col_offset=53), Return(Name('placeholder_21', Load(), lineno=64, col_offset=15, end_lineno=64, end_col_offset=21), lineno=64, col_offset=8, end_lineno=64, end_col_offset=21)], [], lineno=53, col_offset=4, end_lineno=64, end_col_offset=21)], [], lineno=9, col_offset=0, end_lineno=64, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-grade-school/.meta/config.json b/test/practice-grade-school/.meta/config.json new file mode 100644 index 0000000..1a93a3e --- /dev/null +++ b/test/practice-grade-school/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "cmccandless", + "de2Zotjes", + "Dog", + "hop", + "ikhadykin", + "kytrinyx", + "lowks", + "mambocab", + "Mofeywalker", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "grade_school.py" + ], + "test": [ + "grade_school_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given students' names along with the grade that they are in, create a roster for the school.", + "source": "A pairing session with Phil Battos at gSchool" +} diff --git a/test/practice-grade-school/grade_school.py b/test/practice-grade-school/grade_school.py new file mode 100644 index 0000000..fc97491 --- /dev/null +++ b/test/practice-grade-school/grade_school.py @@ -0,0 +1,36 @@ +from collections import defaultdict + + +class School: + def __init__(self): + self.db = {} + self.add = [] + + def added(self): + result = self.add[:] + self.add = [] + return result + + def add_student(self, name, grade): + + if not self.db.get(name, 0): + self.db[name] = grade + self.add.append(True) + else: + self.add.append(False) + + + def roster(self, grade=0): + grades_roster = defaultdict(list) + + for key, value in self.db.items(): + grades_roster[value].append(key) + + if grade: + return sorted(grades_roster[grade]) + else: + working_list = (sorted(grades_roster[key]) for key in sorted(grades_roster.keys())) + return [element for item in working_list for element in item] + + def grade(self, grade_number): + return sorted(self.roster(grade_number)) diff --git a/test/practice-grade-school/mapping.json b/test/practice-grade-school/mapping.json new file mode 100644 index 0000000..1d83658 --- /dev/null +++ b/test/practice-grade-school/mapping.json @@ -0,0 +1,19 @@ +{ + "placeholder_0": "School", + "placeholder_1": "__init__", + "placeholder_2": "db", + "placeholder_3": "add", + "placeholder_4": "added", + "placeholder_5": "result", + "placeholder_6": "add_student", + "placeholder_7": "name", + "placeholder_8": "grade", + "placeholder_9": "roster", + "placeholder_10": "grades_roster", + "placeholder_11": "key", + "placeholder_12": "value", + "placeholder_13": "working_list", + "placeholder_14": "item", + "placeholder_15": "element", + "placeholder_16": "grade_number" +} \ No newline at end of file diff --git a/test/practice-grade-school/representation.json b/test/practice-grade-school/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-grade-school/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-grade-school/representation.out b/test/practice-grade-school/representation.out new file mode 100644 index 0000000..e8adb7b --- /dev/null +++ b/test/practice-grade-school/representation.out @@ -0,0 +1,1740 @@ +## BEGIN NORMALIZED CODE ## +from collections import defaultdict + + +class placeholder_0: + def placeholder_1(self): + self.placeholder_2 = {} + self.placeholder_3 = [] + + def placeholder_4(self): + placeholder_5 = self.placeholder_3[:] + self.placeholder_3 = [] + return placeholder_5 + + def placeholder_6(self, placeholder_7, placeholder_8): + if not self.placeholder_2.get(placeholder_7, 0): + self.placeholder_2[placeholder_7] = placeholder_8 + self.placeholder_3.append(True) + else: + self.placeholder_3.append(False) + + def placeholder_9(self, placeholder_8=0): + placeholder_10 = defaultdict(list) + for placeholder_11, placeholder_12 in self.placeholder_2.items(): + placeholder_10[placeholder_12].append(placeholder_11) + if placeholder_8: + return sorted(placeholder_10[placeholder_8]) + else: + placeholder_13 = ( + sorted(placeholder_10[placeholder_11]) + for placeholder_11 in sorted(placeholder_10.keys()) + ) + return [ + placeholder_15 + for placeholder_14 in placeholder_13 + for placeholder_15 in placeholder_14 + ] + + def placeholder_8(self, placeholder_16): + return sorted(self.placeholder_9(placeholder_16)) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'defaultdict', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=35)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=35), + ClassDef( + 'School', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'db', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=15)], + Dict( + [], + [], + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=20), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=20), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'add', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=16)], + List( + [], + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=21), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=21)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=21), + FunctionDef( + 'added', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=14, + end_lineno=9, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=21), + 'add', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=25), + Slice( + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=27), + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=28), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'add', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=16)], + List( + [], + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=21), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=21), + Return( + Name( + 'result', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=21), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=21)], + [], + lineno=9, + col_offset=4, + end_lineno=12, + end_col_offset=21), + FunctionDef( + 'add_student', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=24), + arg( + 'name', + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=30), + arg( + 'grade', + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + 'db', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=22), + 'get', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=26), + [ + Name( + 'name', + Load(), + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=31), + Constant( + 0, + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=34)], + [], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=35), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=35), + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=16), + 'db', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=19), + Name( + 'name', + Load(), + lineno=17, + col_offset=20, + end_lineno=17, + end_col_offset=24), + Store(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=25)], + Name( + 'grade', + Load(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=33), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=33), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=16), + 'add', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=20), + 'append', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=27), + [ + Constant( + True, + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=32)], + [], + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=33), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=33)], + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=16), + 'add', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=20), + 'append', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=27), + [ + Constant( + False, + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=33)], + [], + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=34), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=34)], + lineno=16, + col_offset=8, + end_lineno=20, + end_col_offset=34)], + [], + lineno=14, + col_offset=4, + end_lineno=20, + end_col_offset=34), + FunctionDef( + 'roster', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=19), + arg( + 'grade', + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 0, + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=28)]), + [ + Assign( + [ + Name( + 'grades_roster', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=21)], + Call( + Name( + 'defaultdict', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=35), + [ + Name( + 'list', + Load(), + lineno=24, + col_offset=36, + end_lineno=24, + end_col_offset=40)], + [], + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=41), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=41), + For( + Tuple( + [ + Name( + 'key', + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=15), + Name( + 'value', + Store(), + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=22)], + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=22), + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=30), + 'db', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=33), + 'items', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=39), + [], + [], + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=41), + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'grades_roster', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=25), + Name( + 'value', + Load(), + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=31), + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=32), + 'append', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=39), + [ + Name( + 'key', + Load(), + lineno=27, + col_offset=40, + end_lineno=27, + end_col_offset=43)], + [], + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=44), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=44)], + [], + lineno=26, + col_offset=8, + end_lineno=27, + end_col_offset=44), + If( + Name( + 'grade', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=16), + [ + Return( + Call( + Name( + 'sorted', + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=25), + [ + Subscript( + Name( + 'grades_roster', + Load(), + lineno=30, + col_offset=26, + end_lineno=30, + end_col_offset=39), + Name( + 'grade', + Load(), + lineno=30, + col_offset=40, + end_lineno=30, + end_col_offset=45), + Load(), + lineno=30, + col_offset=26, + end_lineno=30, + end_col_offset=46)], + [], + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=47), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=47)], + [ + Assign( + [ + Name( + 'working_list', + Store(), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=24)], + GeneratorExp( + Call( + Name( + 'sorted', + Load(), + lineno=32, + col_offset=28, + end_lineno=32, + end_col_offset=34), + [ + Subscript( + Name( + 'grades_roster', + Load(), + lineno=32, + col_offset=35, + end_lineno=32, + end_col_offset=48), + Name( + 'key', + Load(), + lineno=32, + col_offset=49, + end_lineno=32, + end_col_offset=52), + Load(), + lineno=32, + col_offset=35, + end_lineno=32, + end_col_offset=53)], + [], + lineno=32, + col_offset=28, + end_lineno=32, + end_col_offset=54), + [ + comprehension( + Name( + 'key', + Store(), + lineno=32, + col_offset=59, + end_lineno=32, + end_col_offset=62), + Call( + Name( + 'sorted', + Load(), + lineno=32, + col_offset=66, + end_lineno=32, + end_col_offset=72), + [ + Call( + Attribute( + Name( + 'grades_roster', + Load(), + lineno=32, + col_offset=73, + end_lineno=32, + end_col_offset=86), + 'keys', + Load(), + lineno=32, + col_offset=73, + end_lineno=32, + end_col_offset=91), + [], + [], + lineno=32, + col_offset=73, + end_lineno=32, + end_col_offset=93)], + [], + lineno=32, + col_offset=66, + end_lineno=32, + end_col_offset=94), + [], + 0)], + lineno=32, + col_offset=27, + end_lineno=32, + end_col_offset=95), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=95), + Return( + ListComp( + Name( + 'element', + Load(), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=27), + [ + comprehension( + Name( + 'item', + Store(), + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=36), + Name( + 'working_list', + Load(), + lineno=33, + col_offset=40, + end_lineno=33, + end_col_offset=52), + [], + 0), + comprehension( + Name( + 'element', + Store(), + lineno=33, + col_offset=57, + end_lineno=33, + end_col_offset=64), + Name( + 'item', + Load(), + lineno=33, + col_offset=68, + end_lineno=33, + end_col_offset=72), + [], + 0)], + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=73), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=73)], + lineno=29, + col_offset=8, + end_lineno=33, + end_col_offset=73)], + [], + lineno=23, + col_offset=4, + end_lineno=33, + end_col_offset=73), + FunctionDef( + 'grade', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=14, + end_lineno=35, + end_col_offset=18), + arg( + 'grade_number', + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sorted', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=21), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=26), + 'roster', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=33), + [ + Name( + 'grade_number', + Load(), + lineno=36, + col_offset=34, + end_lineno=36, + end_col_offset=46)], + [], + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=47)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=48), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=48)], + [], + lineno=35, + col_offset=4, + end_lineno=36, + end_col_offset=48)], + [], + lineno=4, + col_offset=0, + end_lineno=36, + end_col_offset=48)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'defaultdict', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=35)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=35), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=15)], + Dict( + [], + [], + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=20), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=20), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=16)], + List( + [], + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=21), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=21)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=21), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=14, + end_lineno=9, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=21), + 'placeholder_3', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=25), + Slice( + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=27), + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=28), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=16)], + List( + [], + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=21), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=21), + Return( + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=21), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=21)], + [], + lineno=9, + col_offset=4, + end_lineno=12, + end_col_offset=21), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=24), + arg( + 'placeholder_7', + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=30), + arg( + 'placeholder_8', + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=22), + 'get', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=26), + [ + Name( + 'placeholder_7', + Load(), + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=31), + Constant( + 0, + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=34)], + [], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=35), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=35), + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=16), + 'placeholder_2', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=19), + Name( + 'placeholder_7', + Load(), + lineno=17, + col_offset=20, + end_lineno=17, + end_col_offset=24), + Store(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=25)], + Name( + 'placeholder_8', + Load(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=33), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=33), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=16), + 'placeholder_3', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=20), + 'append', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=27), + [ + Constant( + True, + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=32)], + [], + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=33), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=33)], + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=16), + 'placeholder_3', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=20), + 'append', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=27), + [ + Constant( + False, + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=33)], + [], + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=34), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=34)], + lineno=16, + col_offset=8, + end_lineno=20, + end_col_offset=34)], + [], + lineno=14, + col_offset=4, + end_lineno=20, + end_col_offset=34), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=19), + arg( + 'placeholder_8', + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 0, + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=28)]), + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=21)], + Call( + Name( + 'defaultdict', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=35), + [ + Name( + 'list', + Load(), + lineno=24, + col_offset=36, + end_lineno=24, + end_col_offset=40)], + [], + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=41), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=41), + For( + Tuple( + [ + Name( + 'placeholder_11', + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=15), + Name( + 'placeholder_12', + Store(), + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=22)], + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=22), + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=30), + 'placeholder_2', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=33), + 'items', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=39), + [], + [], + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=41), + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=25), + Name( + 'placeholder_12', + Load(), + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=31), + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=32), + 'append', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=39), + [ + Name( + 'placeholder_11', + Load(), + lineno=27, + col_offset=40, + end_lineno=27, + end_col_offset=43)], + [], + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=44), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=44)], + [], + lineno=26, + col_offset=8, + end_lineno=27, + end_col_offset=44), + If( + Name( + 'placeholder_8', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=16), + [ + Return( + Call( + Name( + 'sorted', + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=25), + [ + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=30, + col_offset=26, + end_lineno=30, + end_col_offset=39), + Name( + 'placeholder_8', + Load(), + lineno=30, + col_offset=40, + end_lineno=30, + end_col_offset=45), + Load(), + lineno=30, + col_offset=26, + end_lineno=30, + end_col_offset=46)], + [], + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=47), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=47)], + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=24)], + GeneratorExp( + Call( + Name( + 'sorted', + Load(), + lineno=32, + col_offset=28, + end_lineno=32, + end_col_offset=34), + [ + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=32, + col_offset=35, + end_lineno=32, + end_col_offset=48), + Name( + 'placeholder_11', + Load(), + lineno=32, + col_offset=49, + end_lineno=32, + end_col_offset=52), + Load(), + lineno=32, + col_offset=35, + end_lineno=32, + end_col_offset=53)], + [], + lineno=32, + col_offset=28, + end_lineno=32, + end_col_offset=54), + [ + comprehension( + Name( + 'placeholder_11', + Store(), + lineno=32, + col_offset=59, + end_lineno=32, + end_col_offset=62), + Call( + Name( + 'sorted', + Load(), + lineno=32, + col_offset=66, + end_lineno=32, + end_col_offset=72), + [ + Call( + Attribute( + Name( + 'placeholder_10', + Load(), + lineno=32, + col_offset=73, + end_lineno=32, + end_col_offset=86), + 'keys', + Load(), + lineno=32, + col_offset=73, + end_lineno=32, + end_col_offset=91), + [], + [], + lineno=32, + col_offset=73, + end_lineno=32, + end_col_offset=93)], + [], + lineno=32, + col_offset=66, + end_lineno=32, + end_col_offset=94), + [], + 0)], + lineno=32, + col_offset=27, + end_lineno=32, + end_col_offset=95), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=95), + Return( + ListComp( + Name( + 'placeholder_15', + Load(), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=27), + [ + comprehension( + Name( + 'placeholder_14', + Store(), + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=36), + Name( + 'placeholder_13', + Load(), + lineno=33, + col_offset=40, + end_lineno=33, + end_col_offset=52), + [], + 0), + comprehension( + Name( + 'placeholder_15', + Store(), + lineno=33, + col_offset=57, + end_lineno=33, + end_col_offset=64), + Name( + 'placeholder_14', + Load(), + lineno=33, + col_offset=68, + end_lineno=33, + end_col_offset=72), + [], + 0)], + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=73), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=73)], + lineno=29, + col_offset=8, + end_lineno=33, + end_col_offset=73)], + [], + lineno=23, + col_offset=4, + end_lineno=33, + end_col_offset=73), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=14, + end_lineno=35, + end_col_offset=18), + arg( + 'placeholder_16', + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sorted', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=21), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=26), + 'placeholder_9', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=33), + [ + Name( + 'placeholder_16', + Load(), + lineno=36, + col_offset=34, + end_lineno=36, + end_col_offset=46)], + [], + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=47)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=48), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=48)], + [], + lineno=35, + col_offset=4, + end_lineno=36, + end_col_offset=48)], + [], + lineno=4, + col_offset=0, + end_lineno=36, + end_col_offset=48)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-grade-school/representation.txt b/test/practice-grade-school/representation.txt new file mode 100644 index 0000000..dcf004c --- /dev/null +++ b/test/practice-grade-school/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('collections', [alias('defaultdict', lineno=1, col_offset=24, end_lineno=1, end_col_offset=35)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=35), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_2', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=15)], Dict([], [], lineno=6, col_offset=18, end_lineno=6, end_col_offset=20), lineno=6, col_offset=8, end_lineno=6, end_col_offset=20), Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_3', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=16)], List([], Load(), lineno=7, col_offset=19, end_lineno=7, end_col_offset=21), lineno=7, col_offset=8, end_lineno=7, end_col_offset=21)], [], lineno=5, col_offset=4, end_lineno=7, end_col_offset=21), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=9, col_offset=14, end_lineno=9, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_5', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=14)], Subscript(Attribute(Name('self', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=21), 'placeholder_3', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=25), Slice(lineno=10, col_offset=26, end_lineno=10, end_col_offset=27), Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=28), lineno=10, col_offset=8, end_lineno=10, end_col_offset=28), Assign([Attribute(Name('self', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), 'placeholder_3', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=16)], List([], Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=21), lineno=11, col_offset=8, end_lineno=11, end_col_offset=21), Return(Name('placeholder_5', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=21), lineno=12, col_offset=8, end_lineno=12, end_col_offset=21)], [], lineno=9, col_offset=4, end_lineno=12, end_col_offset=21), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=14, col_offset=20, end_lineno=14, end_col_offset=24), arg('placeholder_7', lineno=14, col_offset=26, end_lineno=14, end_col_offset=30), arg('placeholder_8', lineno=14, col_offset=32, end_lineno=14, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Attribute(Attribute(Name('self', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=19), 'placeholder_2', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=22), 'get', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=26), [Name('placeholder_7', Load(), lineno=16, col_offset=27, end_lineno=16, end_col_offset=31), Constant(0, lineno=16, col_offset=33, end_lineno=16, end_col_offset=34)], [], lineno=16, col_offset=15, end_lineno=16, end_col_offset=35), lineno=16, col_offset=11, end_lineno=16, end_col_offset=35), [Assign([Subscript(Attribute(Name('self', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=16), 'placeholder_2', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=19), Name('placeholder_7', Load(), lineno=17, col_offset=20, end_lineno=17, end_col_offset=24), Store(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=25)], Name('placeholder_8', Load(), lineno=17, col_offset=28, end_lineno=17, end_col_offset=33), lineno=17, col_offset=12, end_lineno=17, end_col_offset=33), Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=18, col_offset=12, end_lineno=18, end_col_offset=16), 'placeholder_3', Load(), lineno=18, col_offset=12, end_lineno=18, end_col_offset=20), 'append', Load(), lineno=18, col_offset=12, end_lineno=18, end_col_offset=27), [Constant(True, lineno=18, col_offset=28, end_lineno=18, end_col_offset=32)], [], lineno=18, col_offset=12, end_lineno=18, end_col_offset=33), lineno=18, col_offset=12, end_lineno=18, end_col_offset=33)], [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=16), 'placeholder_3', Load(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=20), 'append', Load(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=27), [Constant(False, lineno=20, col_offset=28, end_lineno=20, end_col_offset=33)], [], lineno=20, col_offset=12, end_lineno=20, end_col_offset=34), lineno=20, col_offset=12, end_lineno=20, end_col_offset=34)], lineno=16, col_offset=8, end_lineno=20, end_col_offset=34)], [], lineno=14, col_offset=4, end_lineno=20, end_col_offset=34), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=23, col_offset=15, end_lineno=23, end_col_offset=19), arg('placeholder_8', lineno=23, col_offset=21, end_lineno=23, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(0, lineno=23, col_offset=27, end_lineno=23, end_col_offset=28)]), [Assign([Name('placeholder_10', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=21)], Call(Name('defaultdict', Load(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=35), [Name('list', Load(), lineno=24, col_offset=36, end_lineno=24, end_col_offset=40)], [], lineno=24, col_offset=24, end_lineno=24, end_col_offset=41), lineno=24, col_offset=8, end_lineno=24, end_col_offset=41), For(Tuple([Name('placeholder_11', Store(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=15), Name('placeholder_12', Store(), lineno=26, col_offset=17, end_lineno=26, end_col_offset=22)], Store(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=22), Call(Attribute(Attribute(Name('self', Load(), lineno=26, col_offset=26, end_lineno=26, end_col_offset=30), 'placeholder_2', Load(), lineno=26, col_offset=26, end_lineno=26, end_col_offset=33), 'items', Load(), lineno=26, col_offset=26, end_lineno=26, end_col_offset=39), [], [], lineno=26, col_offset=26, end_lineno=26, end_col_offset=41), [Expr(Call(Attribute(Subscript(Name('placeholder_10', Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=25), Name('placeholder_12', Load(), lineno=27, col_offset=26, end_lineno=27, end_col_offset=31), Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=32), 'append', Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=39), [Name('placeholder_11', Load(), lineno=27, col_offset=40, end_lineno=27, end_col_offset=43)], [], lineno=27, col_offset=12, end_lineno=27, end_col_offset=44), lineno=27, col_offset=12, end_lineno=27, end_col_offset=44)], [], lineno=26, col_offset=8, end_lineno=27, end_col_offset=44), If(Name('placeholder_8', Load(), lineno=29, col_offset=11, end_lineno=29, end_col_offset=16), [Return(Call(Name('sorted', Load(), lineno=30, col_offset=19, end_lineno=30, end_col_offset=25), [Subscript(Name('placeholder_10', Load(), lineno=30, col_offset=26, end_lineno=30, end_col_offset=39), Name('placeholder_8', Load(), lineno=30, col_offset=40, end_lineno=30, end_col_offset=45), Load(), lineno=30, col_offset=26, end_lineno=30, end_col_offset=46)], [], lineno=30, col_offset=19, end_lineno=30, end_col_offset=47), lineno=30, col_offset=12, end_lineno=30, end_col_offset=47)], [Assign([Name('placeholder_13', Store(), lineno=32, col_offset=12, end_lineno=32, end_col_offset=24)], GeneratorExp(Call(Name('sorted', Load(), lineno=32, col_offset=28, end_lineno=32, end_col_offset=34), [Subscript(Name('placeholder_10', Load(), lineno=32, col_offset=35, end_lineno=32, end_col_offset=48), Name('placeholder_11', Load(), lineno=32, col_offset=49, end_lineno=32, end_col_offset=52), Load(), lineno=32, col_offset=35, end_lineno=32, end_col_offset=53)], [], lineno=32, col_offset=28, end_lineno=32, end_col_offset=54), [comprehension(Name('placeholder_11', Store(), lineno=32, col_offset=59, end_lineno=32, end_col_offset=62), Call(Name('sorted', Load(), lineno=32, col_offset=66, end_lineno=32, end_col_offset=72), [Call(Attribute(Name('placeholder_10', Load(), lineno=32, col_offset=73, end_lineno=32, end_col_offset=86), 'keys', Load(), lineno=32, col_offset=73, end_lineno=32, end_col_offset=91), [], [], lineno=32, col_offset=73, end_lineno=32, end_col_offset=93)], [], lineno=32, col_offset=66, end_lineno=32, end_col_offset=94), [], 0)], lineno=32, col_offset=27, end_lineno=32, end_col_offset=95), lineno=32, col_offset=12, end_lineno=32, end_col_offset=95), Return(ListComp(Name('placeholder_15', Load(), lineno=33, col_offset=20, end_lineno=33, end_col_offset=27), [comprehension(Name('placeholder_14', Store(), lineno=33, col_offset=32, end_lineno=33, end_col_offset=36), Name('placeholder_13', Load(), lineno=33, col_offset=40, end_lineno=33, end_col_offset=52), [], 0), comprehension(Name('placeholder_15', Store(), lineno=33, col_offset=57, end_lineno=33, end_col_offset=64), Name('placeholder_14', Load(), lineno=33, col_offset=68, end_lineno=33, end_col_offset=72), [], 0)], lineno=33, col_offset=19, end_lineno=33, end_col_offset=73), lineno=33, col_offset=12, end_lineno=33, end_col_offset=73)], lineno=29, col_offset=8, end_lineno=33, end_col_offset=73)], [], lineno=23, col_offset=4, end_lineno=33, end_col_offset=73), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=35, col_offset=14, end_lineno=35, end_col_offset=18), arg('placeholder_16', lineno=35, col_offset=20, end_lineno=35, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sorted', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=21), [Call(Attribute(Name('self', Load(), lineno=36, col_offset=22, end_lineno=36, end_col_offset=26), 'placeholder_9', Load(), lineno=36, col_offset=22, end_lineno=36, end_col_offset=33), [Name('placeholder_16', Load(), lineno=36, col_offset=34, end_lineno=36, end_col_offset=46)], [], lineno=36, col_offset=22, end_lineno=36, end_col_offset=47)], [], lineno=36, col_offset=15, end_lineno=36, end_col_offset=48), lineno=36, col_offset=8, end_lineno=36, end_col_offset=48)], [], lineno=35, col_offset=4, end_lineno=36, end_col_offset=48)], [], lineno=4, col_offset=0, end_lineno=36, end_col_offset=48)], []) \ No newline at end of file diff --git a/test/practice-grains/.meta/config.json b/test/practice-grains/.meta/config.json new file mode 100644 index 0000000..4e59df7 --- /dev/null +++ b/test/practice-grains/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "denislooby", + "Dog", + "kytrinyx", + "lowks", + "MojitoMonday", + "N-Parsons", + "pheanex", + "sdublish", + "sjakobi", + "smalley", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "grains.py" + ], + "test": [ + "grains_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.", + "source": "The CodeRanch Cattle Drive, Assignment 6", + "source_url": "https://coderanch.com/wiki/718824/Grains" +} diff --git a/test/practice-grains/grains.py b/test/practice-grains/grains.py new file mode 100644 index 0000000..8610d32 --- /dev/null +++ b/test/practice-grains/grains.py @@ -0,0 +1,13 @@ +def square(number): + if number == 0: + raise ValueError('square must be between 1 and 64') + elif number < 0: + raise ValueError('square must be between 1 and 64') + elif number > 64: + raise ValueError('square must be between 1 and 64') + + return 2 ** (number - 1) + + +def total(): + return (2 ** 64) - 1 diff --git a/test/practice-grains/mapping.json b/test/practice-grains/mapping.json new file mode 100644 index 0000000..c1e5688 --- /dev/null +++ b/test/practice-grains/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "square", + "placeholder_1": "number", + "placeholder_2": "total" +} \ No newline at end of file diff --git a/test/practice-grains/representation.json b/test/practice-grains/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-grains/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-grains/representation.out b/test/practice-grains/representation.out new file mode 100644 index 0000000..1bc0a68 --- /dev/null +++ b/test/practice-grains/representation.out @@ -0,0 +1,555 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + if placeholder_1 == 0: + raise ValueError("square must be between 1 and 64") + elif placeholder_1 < 0: + raise ValueError("square must be between 1 and 64") + elif placeholder_1 > 64: + raise ValueError("square must be between 1 and 64") + return 2 ** (placeholder_1 - 1) + + +def placeholder_2(): + return 2**64 - 1 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'square', + arguments( + [], + [ + arg( + 'number', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 0, + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=18)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'square must be between 1 and 64', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=58)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=59), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=59)], + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=15), + [ + Lt()], + [ + Constant( + 0, + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=19)], + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=19), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=24), + [ + Constant( + 'square must be between 1 and 64', + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=58)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=59), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=59)], + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=15), + [ + Gt()], + [ + Constant( + 64, + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=20)], + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'square must be between 1 and 64', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=58)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=59), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=59)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=59)], + lineno=4, + col_offset=4, + end_lineno=7, + end_col_offset=59)], + lineno=2, + col_offset=4, + end_lineno=7, + end_col_offset=59), + Return( + BinOp( + Constant( + 2, + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=12), + Pow(), + BinOp( + Name( + 'number', + Load(), + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=23), + Sub(), + Constant( + 1, + lineno=9, + col_offset=26, + end_lineno=9, + end_col_offset=27), + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=27), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=28), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=28)], + [], + lineno=1, + col_offset=0, + end_lineno=9, + end_col_offset=28), + FunctionDef( + 'total', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + Constant( + 2, + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=13), + Pow(), + Constant( + 64, + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=19), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=19), + Sub(), + Constant( + 1, + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=24), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=24), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=24)], + [], + lineno=12, + col_offset=0, + end_lineno=13, + end_col_offset=24)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 0, + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=18)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'square must be between 1 and 64', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=58)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=59), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=59)], + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=15), + [ + Lt()], + [ + Constant( + 0, + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=19)], + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=19), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=24), + [ + Constant( + 'square must be between 1 and 64', + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=58)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=59), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=59)], + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=15), + [ + Gt()], + [ + Constant( + 64, + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=20)], + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'square must be between 1 and 64', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=58)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=59), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=59)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=59)], + lineno=4, + col_offset=4, + end_lineno=7, + end_col_offset=59)], + lineno=2, + col_offset=4, + end_lineno=7, + end_col_offset=59), + Return( + BinOp( + Constant( + 2, + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=12), + Pow(), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=23), + Sub(), + Constant( + 1, + lineno=9, + col_offset=26, + end_lineno=9, + end_col_offset=27), + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=27), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=28), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=28)], + [], + lineno=1, + col_offset=0, + end_lineno=9, + end_col_offset=28), + FunctionDef( + 'placeholder_2', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + Constant( + 2, + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=13), + Pow(), + Constant( + 64, + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=19), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=19), + Sub(), + Constant( + 1, + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=24), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=24), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=24)], + [], + lineno=12, + col_offset=0, + end_lineno=13, + end_col_offset=24)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-grains/representation.txt b/test/practice-grains/representation.txt new file mode 100644 index 0000000..fc0c469 --- /dev/null +++ b/test/practice-grains/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=11, end_lineno=1, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_1', Load(), lineno=2, col_offset=7, end_lineno=2, end_col_offset=13), [Eq()], [Constant(0, lineno=2, col_offset=17, end_lineno=2, end_col_offset=18)], lineno=2, col_offset=7, end_lineno=2, end_col_offset=18), [Raise(Call(Name('ValueError', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=24), [Constant('square must be between 1 and 64', lineno=3, col_offset=25, end_lineno=3, end_col_offset=58)], [], lineno=3, col_offset=14, end_lineno=3, end_col_offset=59), lineno=3, col_offset=8, end_lineno=3, end_col_offset=59)], [If(Compare(Name('placeholder_1', Load(), lineno=4, col_offset=9, end_lineno=4, end_col_offset=15), [Lt()], [Constant(0, lineno=4, col_offset=18, end_lineno=4, end_col_offset=19)], lineno=4, col_offset=9, end_lineno=4, end_col_offset=19), [Raise(Call(Name('ValueError', Load(), lineno=5, col_offset=14, end_lineno=5, end_col_offset=24), [Constant('square must be between 1 and 64', lineno=5, col_offset=25, end_lineno=5, end_col_offset=58)], [], lineno=5, col_offset=14, end_lineno=5, end_col_offset=59), lineno=5, col_offset=8, end_lineno=5, end_col_offset=59)], [If(Compare(Name('placeholder_1', Load(), lineno=6, col_offset=9, end_lineno=6, end_col_offset=15), [Gt()], [Constant(64, lineno=6, col_offset=18, end_lineno=6, end_col_offset=20)], lineno=6, col_offset=9, end_lineno=6, end_col_offset=20), [Raise(Call(Name('ValueError', Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=24), [Constant('square must be between 1 and 64', lineno=7, col_offset=25, end_lineno=7, end_col_offset=58)], [], lineno=7, col_offset=14, end_lineno=7, end_col_offset=59), lineno=7, col_offset=8, end_lineno=7, end_col_offset=59)], [], lineno=6, col_offset=4, end_lineno=7, end_col_offset=59)], lineno=4, col_offset=4, end_lineno=7, end_col_offset=59)], lineno=2, col_offset=4, end_lineno=7, end_col_offset=59), Return(BinOp(Constant(2, lineno=9, col_offset=11, end_lineno=9, end_col_offset=12), Pow(), BinOp(Name('placeholder_1', Load(), lineno=9, col_offset=17, end_lineno=9, end_col_offset=23), Sub(), Constant(1, lineno=9, col_offset=26, end_lineno=9, end_col_offset=27), lineno=9, col_offset=17, end_lineno=9, end_col_offset=27), lineno=9, col_offset=11, end_lineno=9, end_col_offset=28), lineno=9, col_offset=4, end_lineno=9, end_col_offset=28)], [], lineno=1, col_offset=0, end_lineno=9, end_col_offset=28), FunctionDef('placeholder_2', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(BinOp(Constant(2, lineno=13, col_offset=12, end_lineno=13, end_col_offset=13), Pow(), Constant(64, lineno=13, col_offset=17, end_lineno=13, end_col_offset=19), lineno=13, col_offset=12, end_lineno=13, end_col_offset=19), Sub(), Constant(1, lineno=13, col_offset=23, end_lineno=13, end_col_offset=24), lineno=13, col_offset=11, end_lineno=13, end_col_offset=24), lineno=13, col_offset=4, end_lineno=13, end_col_offset=24)], [], lineno=12, col_offset=0, end_lineno=13, end_col_offset=24)], []) \ No newline at end of file diff --git a/test/practice-grep/.meta/config.json b/test/practice-grep/.meta/config.json new file mode 100644 index 0000000..b79d15e --- /dev/null +++ b/test/practice-grep/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "beatorizu", + "BethanyG", + "carloscdias", + "cmccandless", + "Dog", + "ikhadykin", + "N-Parsons", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "grep.py" + ], + "test": [ + "grep_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Search a file for lines matching a regular expression pattern. Return the line number and contents of each matching line.", + "source": "Conversation with Nate Foster.", + "source_url": "https://www.cs.cornell.edu/Courses/cs3110/2014sp/hw/0/ps0.pdf" +} diff --git a/test/practice-grep/.meta/plugins.py b/test/practice-grep/.meta/plugins.py new file mode 100644 index 0000000..c95c718 --- /dev/null +++ b/test/practice-grep/.meta/plugins.py @@ -0,0 +1,15 @@ +import re + +RGX_ILLEGAL_CHARS = re.compile(r"\||-") +RGX_LINEBREAK = re.compile(r"\s*\n\s*") + + +def strip_illegal(s): + return RGX_ILLEGAL_CHARS.sub("", s) + + +def clean_filetext(text): + text = strip_illegal(text) + text = RGX_ILLEGAL_CHARS.sub("", text) + text = RGX_LINEBREAK.sub("\n", text) + return text.strip() diff --git a/test/practice-grep/grep.py b/test/practice-grep/grep.py new file mode 100644 index 0000000..e0ffbfe --- /dev/null +++ b/test/practice-grep/grep.py @@ -0,0 +1,57 @@ +def matches(line, pattern, flags): + if '-i' in flags: # case-insensitive + line = line.lower() + pattern = pattern.lower() + + if '-x' in flags: # match entire lines + if len(pattern) != len(line.rstrip()): + return '-v' in flags + + if '-v' in flags: # invert matching + return pattern not in line + + return pattern in line + + +def format_files(matched_lines): + result = '' + + for file_name, _, _ in matched_lines: + if file_name not in result: + result += file_name + '\n' + + return result + + +def format_lines(matched_lines, flags, files): + result = [] + + for file_name, line_number, line in matched_lines: + line_result = '' + + if len(files) > 1: + line_result += file_name + ':' + + if '-n' in flags: + line_result += str(line_number) + ':' + + line_result += line + + result.append(line_result) + + return ''.join(result) + + +def grep(pattern, flags, files): + matched_lines = [] + + for file_name in files: + with open(file_name, encoding='utf-8') as f: + for line_number, line in enumerate(f.readlines(), start=1): + if matches(line, pattern, flags): + matched_lines.append((file_name, line_number, line)) + + if '-l' in flags: + return format_files(matched_lines) + + return format_lines(matched_lines, flags, files) diff --git a/test/practice-grep/mapping.json b/test/practice-grep/mapping.json new file mode 100644 index 0000000..650aeac --- /dev/null +++ b/test/practice-grep/mapping.json @@ -0,0 +1,19 @@ +{ + "placeholder_0": "matches", + "placeholder_1": "line", + "placeholder_2": "pattern", + "placeholder_3": "flags", + "placeholder_4": "format_files", + "placeholder_5": "matched_lines", + "placeholder_6": "result", + "placeholder_7": "file_name", + "placeholder_8": "_", + "placeholder_9": "format_lines", + "placeholder_10": "files", + "placeholder_11": "line_number", + "placeholder_12": "line_result", + "placeholder_13": "grep", + "placeholder_14": "encoding", + "placeholder_15": "f", + "placeholder_16": "start" +} \ No newline at end of file diff --git a/test/practice-grep/representation.json b/test/practice-grep/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-grep/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-grep/representation.out b/test/practice-grep/representation.out new file mode 100644 index 0000000..d7626be --- /dev/null +++ b/test/practice-grep/representation.out @@ -0,0 +1,2502 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2, placeholder_3): + if "-i" in placeholder_3: + placeholder_1 = placeholder_1.lower() + placeholder_2 = placeholder_2.lower() + if "-x" in placeholder_3: + if len(placeholder_2) != len(placeholder_1.rstrip()): + return "-v" in placeholder_3 + if "-v" in placeholder_3: + return placeholder_2 not in placeholder_1 + return placeholder_2 in placeholder_1 + + +def placeholder_4(placeholder_5): + placeholder_6 = "" + for placeholder_7, placeholder_8, placeholder_8 in placeholder_5: + if placeholder_7 not in placeholder_6: + placeholder_6 += placeholder_7 + "\n" + return placeholder_6 + + +def placeholder_9(placeholder_5, placeholder_3, placeholder_10): + placeholder_6 = [] + for placeholder_7, placeholder_11, placeholder_1 in placeholder_5: + placeholder_12 = "" + if len(placeholder_10) > 1: + placeholder_12 += placeholder_7 + ":" + if "-n" in placeholder_3: + placeholder_12 += str(placeholder_11) + ":" + placeholder_12 += placeholder_1 + placeholder_6.append(placeholder_12) + return "".join(placeholder_6) + + +def placeholder_13(placeholder_2, placeholder_3, placeholder_10): + placeholder_5 = [] + for placeholder_7 in placeholder_10: + with open(placeholder_7, placeholder_14="utf-8") as placeholder_15: + for placeholder_11, placeholder_1 in enumerate( + placeholder_15.readlines(), placeholder_16=1 + ): + if placeholder_0(placeholder_1, placeholder_2, placeholder_3): + placeholder_5.append((placeholder_7, placeholder_11, placeholder_1)) + if "-l" in placeholder_3: + return placeholder_4(placeholder_5) + return placeholder_9(placeholder_5, placeholder_3, placeholder_10) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'matches', + arguments( + [], + [ + arg( + 'line', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=16), + arg( + 'pattern', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=25), + arg( + 'flags', + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Constant( + '-i', + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=11), + [ + In()], + [ + Name( + 'flags', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=20)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + Assign( + [ + Name( + 'line', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12)], + Call( + Attribute( + Name( + 'line', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=19), + 'lower', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=25), + [], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=27), + Assign( + [ + Name( + 'pattern', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=15)], + Call( + Attribute( + Name( + 'pattern', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=25), + 'lower', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=31), + [], + [], + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=33), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=33)], + [], + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=33), + If( + Compare( + Constant( + '-x', + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=11), + [ + In()], + [ + Name( + 'flags', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=20)], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=20), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=14), + [ + Name( + 'pattern', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=22)], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=23), + [ + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=30), + [ + Call( + Attribute( + Name( + 'line', + Load(), + lineno=7, + col_offset=31, + end_lineno=7, + end_col_offset=35), + 'rstrip', + Load(), + lineno=7, + col_offset=31, + end_lineno=7, + end_col_offset=42), + [], + [], + lineno=7, + col_offset=31, + end_lineno=7, + end_col_offset=44)], + [], + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=45)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=45), + [ + Return( + Compare( + Constant( + '-v', + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=23), + [ + In()], + [ + Name( + 'flags', + Load(), + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=32)], + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=32), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=32)], + [], + lineno=7, + col_offset=8, + end_lineno=8, + end_col_offset=32)], + [], + lineno=6, + col_offset=4, + end_lineno=8, + end_col_offset=32), + If( + Compare( + Constant( + '-v', + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=11), + [ + In()], + [ + Name( + 'flags', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=20)], + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=20), + [ + Return( + Compare( + Name( + 'pattern', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=22), + [ + NotIn()], + [ + Name( + 'line', + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=34)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=34), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=34)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=34), + Return( + Compare( + Name( + 'pattern', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=18), + [ + In()], + [ + Name( + 'line', + Load(), + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=26)], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=26), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=13, + end_col_offset=26), + FunctionDef( + 'format_files', + arguments( + [], + [ + arg( + 'matched_lines', + lineno=16, + col_offset=17, + end_lineno=16, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=10)], + Constant( + '', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=15), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'file_name', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=17), + Name( + '_', + Store(), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=20), + Name( + '_', + Store(), + lineno=19, + col_offset=22, + end_lineno=19, + end_col_offset=23)], + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=23), + Name( + 'matched_lines', + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=40), + [ + If( + Compare( + Name( + 'file_name', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=20), + [ + NotIn()], + [ + Name( + 'result', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=34)], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=34), + [ + AugAssign( + Name( + 'result', + Store(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=18), + Add(), + BinOp( + Name( + 'file_name', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=31), + Add(), + Constant( + '\n', + lineno=21, + col_offset=34, + end_lineno=21, + end_col_offset=38), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=38), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=38)], + [], + lineno=20, + col_offset=8, + end_lineno=21, + end_col_offset=38)], + [], + lineno=19, + col_offset=4, + end_lineno=21, + end_col_offset=38), + Return( + Name( + 'result', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=17), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=17)], + [], + lineno=16, + col_offset=0, + end_lineno=23, + end_col_offset=17), + FunctionDef( + 'format_lines', + arguments( + [], + [ + arg( + 'matched_lines', + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=30), + arg( + 'flags', + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=37), + arg( + 'files', + lineno=26, + col_offset=39, + end_lineno=26, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=10)], + List( + [], + Load(), + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=15), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'file_name', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=17), + Name( + 'line_number', + Store(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=30), + Name( + 'line', + Store(), + lineno=29, + col_offset=32, + end_lineno=29, + end_col_offset=36)], + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=36), + Name( + 'matched_lines', + Load(), + lineno=29, + col_offset=40, + end_lineno=29, + end_col_offset=53), + [ + Assign( + [ + Name( + 'line_result', + Store(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=19)], + Constant( + '', + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=24), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=24), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=14), + [ + Name( + 'files', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=20)], + [], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=21), + [ + Gt()], + [ + Constant( + 1, + lineno=32, + col_offset=24, + end_lineno=32, + end_col_offset=25)], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=25), + [ + AugAssign( + Name( + 'line_result', + Store(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=23), + Add(), + BinOp( + Name( + 'file_name', + Load(), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=36), + Add(), + Constant( + ':', + lineno=33, + col_offset=39, + end_lineno=33, + end_col_offset=42), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=42), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=42)], + [], + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=42), + If( + Compare( + Constant( + '-n', + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=15), + [ + In()], + [ + Name( + 'flags', + Load(), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=24)], + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=24), + [ + AugAssign( + Name( + 'line_result', + Store(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=23), + Add(), + BinOp( + Call( + Name( + 'str', + Load(), + lineno=36, + col_offset=27, + end_lineno=36, + end_col_offset=30), + [ + Name( + 'line_number', + Load(), + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=42)], + [], + lineno=36, + col_offset=27, + end_lineno=36, + end_col_offset=43), + Add(), + Constant( + ':', + lineno=36, + col_offset=46, + end_lineno=36, + end_col_offset=49), + lineno=36, + col_offset=27, + end_lineno=36, + end_col_offset=49), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=49)], + [], + lineno=35, + col_offset=8, + end_lineno=36, + end_col_offset=49), + AugAssign( + Name( + 'line_result', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=19), + Add(), + Name( + 'line', + Load(), + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=27), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=27), + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=14), + 'append', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=21), + [ + Name( + 'line_result', + Load(), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=33)], + [], + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=34), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=34)], + [], + lineno=29, + col_offset=4, + end_lineno=40, + end_col_offset=34), + Return( + Call( + Attribute( + Constant( + '', + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=13), + 'join', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=18), + [ + Name( + 'result', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=25)], + [], + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=26), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=26)], + [], + lineno=26, + col_offset=0, + end_lineno=42, + end_col_offset=26), + FunctionDef( + 'grep', + arguments( + [], + [ + arg( + 'pattern', + lineno=45, + col_offset=9, + end_lineno=45, + end_col_offset=16), + arg( + 'flags', + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=23), + arg( + 'files', + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'matched_lines', + Store(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=17)], + List( + [], + Load(), + lineno=46, + col_offset=20, + end_lineno=46, + end_col_offset=22), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=22), + For( + Name( + 'file_name', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=17), + Name( + 'files', + Load(), + lineno=48, + col_offset=21, + end_lineno=48, + end_col_offset=26), + [ + With( + [ + withitem( + Call( + Name( + 'open', + Load(), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=17), + [ + Name( + 'file_name', + Load(), + lineno=49, + col_offset=18, + end_lineno=49, + end_col_offset=27)], + [ + keyword( + 'encoding', + Constant( + 'utf-8', + lineno=49, + col_offset=38, + end_lineno=49, + end_col_offset=45), + lineno=49, + col_offset=29, + end_lineno=49, + end_col_offset=45)], + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=46), + Name( + 'f', + Store(), + lineno=49, + col_offset=50, + end_lineno=49, + end_col_offset=51))], + [ + For( + Tuple( + [ + Name( + 'line_number', + Store(), + lineno=50, + col_offset=16, + end_lineno=50, + end_col_offset=27), + Name( + 'line', + Store(), + lineno=50, + col_offset=29, + end_lineno=50, + end_col_offset=33)], + Store(), + lineno=50, + col_offset=16, + end_lineno=50, + end_col_offset=33), + Call( + Name( + 'enumerate', + Load(), + lineno=50, + col_offset=37, + end_lineno=50, + end_col_offset=46), + [ + Call( + Attribute( + Name( + 'f', + Load(), + lineno=50, + col_offset=47, + end_lineno=50, + end_col_offset=48), + 'readlines', + Load(), + lineno=50, + col_offset=47, + end_lineno=50, + end_col_offset=58), + [], + [], + lineno=50, + col_offset=47, + end_lineno=50, + end_col_offset=60)], + [ + keyword( + 'start', + Constant( + 1, + lineno=50, + col_offset=68, + end_lineno=50, + end_col_offset=69), + lineno=50, + col_offset=62, + end_lineno=50, + end_col_offset=69)], + lineno=50, + col_offset=37, + end_lineno=50, + end_col_offset=70), + [ + If( + Call( + Name( + 'matches', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=26), + [ + Name( + 'line', + Load(), + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=31), + Name( + 'pattern', + Load(), + lineno=51, + col_offset=33, + end_lineno=51, + end_col_offset=40), + Name( + 'flags', + Load(), + lineno=51, + col_offset=42, + end_lineno=51, + end_col_offset=47)], + [], + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=48), + [ + Expr( + Call( + Attribute( + Name( + 'matched_lines', + Load(), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=33), + 'append', + Load(), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=40), + [ + Tuple( + [ + Name( + 'file_name', + Load(), + lineno=52, + col_offset=42, + end_lineno=52, + end_col_offset=51), + Name( + 'line_number', + Load(), + lineno=52, + col_offset=53, + end_lineno=52, + end_col_offset=64), + Name( + 'line', + Load(), + lineno=52, + col_offset=66, + end_lineno=52, + end_col_offset=70)], + Load(), + lineno=52, + col_offset=41, + end_lineno=52, + end_col_offset=71)], + [], + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=72), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=72)], + [], + lineno=51, + col_offset=16, + end_lineno=52, + end_col_offset=72)], + [], + lineno=50, + col_offset=12, + end_lineno=52, + end_col_offset=72)], + lineno=49, + col_offset=8, + end_lineno=52, + end_col_offset=72)], + [], + lineno=48, + col_offset=4, + end_lineno=52, + end_col_offset=72), + If( + Compare( + Constant( + '-l', + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=11), + [ + In()], + [ + Name( + 'flags', + Load(), + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=20)], + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=20), + [ + Return( + Call( + Name( + 'format_files', + Load(), + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=27), + [ + Name( + 'matched_lines', + Load(), + lineno=55, + col_offset=28, + end_lineno=55, + end_col_offset=41)], + [], + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=42), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=42)], + [], + lineno=54, + col_offset=4, + end_lineno=55, + end_col_offset=42), + Return( + Call( + Name( + 'format_lines', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=23), + [ + Name( + 'matched_lines', + Load(), + lineno=57, + col_offset=24, + end_lineno=57, + end_col_offset=37), + Name( + 'flags', + Load(), + lineno=57, + col_offset=39, + end_lineno=57, + end_col_offset=44), + Name( + 'files', + Load(), + lineno=57, + col_offset=46, + end_lineno=57, + end_col_offset=51)], + [], + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=52), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=52)], + [], + lineno=45, + col_offset=0, + end_lineno=57, + end_col_offset=52)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=16), + arg( + 'placeholder_2', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=25), + arg( + 'placeholder_3', + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Constant( + '-i', + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=11), + [ + In()], + [ + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=20)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12)], + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=19), + 'lower', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=25), + [], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=15)], + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=25), + 'lower', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=31), + [], + [], + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=33), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=33)], + [], + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=33), + If( + Compare( + Constant( + '-x', + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=11), + [ + In()], + [ + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=20)], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=20), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=14), + [ + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=22)], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=23), + [ + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=30), + [ + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=31, + end_lineno=7, + end_col_offset=35), + 'rstrip', + Load(), + lineno=7, + col_offset=31, + end_lineno=7, + end_col_offset=42), + [], + [], + lineno=7, + col_offset=31, + end_lineno=7, + end_col_offset=44)], + [], + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=45)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=45), + [ + Return( + Compare( + Constant( + '-v', + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=23), + [ + In()], + [ + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=32)], + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=32), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=32)], + [], + lineno=7, + col_offset=8, + end_lineno=8, + end_col_offset=32)], + [], + lineno=6, + col_offset=4, + end_lineno=8, + end_col_offset=32), + If( + Compare( + Constant( + '-v', + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=11), + [ + In()], + [ + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=20)], + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=20), + [ + Return( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=22), + [ + NotIn()], + [ + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=34)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=34), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=34)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=34), + Return( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=18), + [ + In()], + [ + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=22, + end_lineno=13, + end_col_offset=26)], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=26), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=13, + end_col_offset=26), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=16, + col_offset=17, + end_lineno=16, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=10)], + Constant( + '', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=15), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=17), + Name( + 'placeholder_8', + Store(), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=20), + Name( + 'placeholder_8', + Store(), + lineno=19, + col_offset=22, + end_lineno=19, + end_col_offset=23)], + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=23), + Name( + 'placeholder_5', + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=40), + [ + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=20), + [ + NotIn()], + [ + Name( + 'placeholder_6', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=34)], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=34), + [ + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=18), + Add(), + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=31), + Add(), + Constant( + '\n', + lineno=21, + col_offset=34, + end_lineno=21, + end_col_offset=38), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=38), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=38)], + [], + lineno=20, + col_offset=8, + end_lineno=21, + end_col_offset=38)], + [], + lineno=19, + col_offset=4, + end_lineno=21, + end_col_offset=38), + Return( + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=17), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=17)], + [], + lineno=16, + col_offset=0, + end_lineno=23, + end_col_offset=17), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=30), + arg( + 'placeholder_3', + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=37), + arg( + 'placeholder_10', + lineno=26, + col_offset=39, + end_lineno=26, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=10)], + List( + [], + Load(), + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=15), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=17), + Name( + 'placeholder_11', + Store(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=30), + Name( + 'placeholder_1', + Store(), + lineno=29, + col_offset=32, + end_lineno=29, + end_col_offset=36)], + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=36), + Name( + 'placeholder_5', + Load(), + lineno=29, + col_offset=40, + end_lineno=29, + end_col_offset=53), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=19)], + Constant( + '', + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=24), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=24), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=14), + [ + Name( + 'placeholder_10', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=20)], + [], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=21), + [ + Gt()], + [ + Constant( + 1, + lineno=32, + col_offset=24, + end_lineno=32, + end_col_offset=25)], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=25), + [ + AugAssign( + Name( + 'placeholder_12', + Store(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=23), + Add(), + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=36), + Add(), + Constant( + ':', + lineno=33, + col_offset=39, + end_lineno=33, + end_col_offset=42), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=42), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=42)], + [], + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=42), + If( + Compare( + Constant( + '-n', + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=15), + [ + In()], + [ + Name( + 'placeholder_3', + Load(), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=24)], + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=24), + [ + AugAssign( + Name( + 'placeholder_12', + Store(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=23), + Add(), + BinOp( + Call( + Name( + 'str', + Load(), + lineno=36, + col_offset=27, + end_lineno=36, + end_col_offset=30), + [ + Name( + 'placeholder_11', + Load(), + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=42)], + [], + lineno=36, + col_offset=27, + end_lineno=36, + end_col_offset=43), + Add(), + Constant( + ':', + lineno=36, + col_offset=46, + end_lineno=36, + end_col_offset=49), + lineno=36, + col_offset=27, + end_lineno=36, + end_col_offset=49), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=49)], + [], + lineno=35, + col_offset=8, + end_lineno=36, + end_col_offset=49), + AugAssign( + Name( + 'placeholder_12', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=19), + Add(), + Name( + 'placeholder_1', + Load(), + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=27), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=27), + Expr( + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=14), + 'append', + Load(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=21), + [ + Name( + 'placeholder_12', + Load(), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=33)], + [], + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=34), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=34)], + [], + lineno=29, + col_offset=4, + end_lineno=40, + end_col_offset=34), + Return( + Call( + Attribute( + Constant( + '', + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=13), + 'join', + Load(), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=18), + [ + Name( + 'placeholder_6', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=25)], + [], + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=26), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=26)], + [], + lineno=26, + col_offset=0, + end_lineno=42, + end_col_offset=26), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=45, + col_offset=9, + end_lineno=45, + end_col_offset=16), + arg( + 'placeholder_3', + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=23), + arg( + 'placeholder_10', + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=17)], + List( + [], + Load(), + lineno=46, + col_offset=20, + end_lineno=46, + end_col_offset=22), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=22), + For( + Name( + 'placeholder_7', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=17), + Name( + 'placeholder_10', + Load(), + lineno=48, + col_offset=21, + end_lineno=48, + end_col_offset=26), + [ + With( + [ + withitem( + Call( + Name( + 'open', + Load(), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=17), + [ + Name( + 'placeholder_7', + Load(), + lineno=49, + col_offset=18, + end_lineno=49, + end_col_offset=27)], + [ + keyword( + 'placeholder_14', + Constant( + 'utf-8', + lineno=49, + col_offset=38, + end_lineno=49, + end_col_offset=45), + lineno=49, + col_offset=29, + end_lineno=49, + end_col_offset=45)], + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=46), + Name( + 'placeholder_15', + Store(), + lineno=49, + col_offset=50, + end_lineno=49, + end_col_offset=51))], + [ + For( + Tuple( + [ + Name( + 'placeholder_11', + Store(), + lineno=50, + col_offset=16, + end_lineno=50, + end_col_offset=27), + Name( + 'placeholder_1', + Store(), + lineno=50, + col_offset=29, + end_lineno=50, + end_col_offset=33)], + Store(), + lineno=50, + col_offset=16, + end_lineno=50, + end_col_offset=33), + Call( + Name( + 'enumerate', + Load(), + lineno=50, + col_offset=37, + end_lineno=50, + end_col_offset=46), + [ + Call( + Attribute( + Name( + 'placeholder_15', + Load(), + lineno=50, + col_offset=47, + end_lineno=50, + end_col_offset=48), + 'readlines', + Load(), + lineno=50, + col_offset=47, + end_lineno=50, + end_col_offset=58), + [], + [], + lineno=50, + col_offset=47, + end_lineno=50, + end_col_offset=60)], + [ + keyword( + 'placeholder_16', + Constant( + 1, + lineno=50, + col_offset=68, + end_lineno=50, + end_col_offset=69), + lineno=50, + col_offset=62, + end_lineno=50, + end_col_offset=69)], + lineno=50, + col_offset=37, + end_lineno=50, + end_col_offset=70), + [ + If( + Call( + Name( + 'placeholder_0', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=26), + [ + Name( + 'placeholder_1', + Load(), + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=31), + Name( + 'placeholder_2', + Load(), + lineno=51, + col_offset=33, + end_lineno=51, + end_col_offset=40), + Name( + 'placeholder_3', + Load(), + lineno=51, + col_offset=42, + end_lineno=51, + end_col_offset=47)], + [], + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=48), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=33), + 'append', + Load(), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=40), + [ + Tuple( + [ + Name( + 'placeholder_7', + Load(), + lineno=52, + col_offset=42, + end_lineno=52, + end_col_offset=51), + Name( + 'placeholder_11', + Load(), + lineno=52, + col_offset=53, + end_lineno=52, + end_col_offset=64), + Name( + 'placeholder_1', + Load(), + lineno=52, + col_offset=66, + end_lineno=52, + end_col_offset=70)], + Load(), + lineno=52, + col_offset=41, + end_lineno=52, + end_col_offset=71)], + [], + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=72), + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=72)], + [], + lineno=51, + col_offset=16, + end_lineno=52, + end_col_offset=72)], + [], + lineno=50, + col_offset=12, + end_lineno=52, + end_col_offset=72)], + lineno=49, + col_offset=8, + end_lineno=52, + end_col_offset=72)], + [], + lineno=48, + col_offset=4, + end_lineno=52, + end_col_offset=72), + If( + Compare( + Constant( + '-l', + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=11), + [ + In()], + [ + Name( + 'placeholder_3', + Load(), + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=20)], + lineno=54, + col_offset=7, + end_lineno=54, + end_col_offset=20), + [ + Return( + Call( + Name( + 'placeholder_4', + Load(), + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=27), + [ + Name( + 'placeholder_5', + Load(), + lineno=55, + col_offset=28, + end_lineno=55, + end_col_offset=41)], + [], + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=42), + lineno=55, + col_offset=8, + end_lineno=55, + end_col_offset=42)], + [], + lineno=54, + col_offset=4, + end_lineno=55, + end_col_offset=42), + Return( + Call( + Name( + 'placeholder_9', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=23), + [ + Name( + 'placeholder_5', + Load(), + lineno=57, + col_offset=24, + end_lineno=57, + end_col_offset=37), + Name( + 'placeholder_3', + Load(), + lineno=57, + col_offset=39, + end_lineno=57, + end_col_offset=44), + Name( + 'placeholder_10', + Load(), + lineno=57, + col_offset=46, + end_lineno=57, + end_col_offset=51)], + [], + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=52), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=52)], + [], + lineno=45, + col_offset=0, + end_lineno=57, + end_col_offset=52)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-grep/representation.txt b/test/practice-grep/representation.txt new file mode 100644 index 0000000..4d047b9 --- /dev/null +++ b/test/practice-grep/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=12, end_lineno=1, end_col_offset=16), arg('placeholder_2', lineno=1, col_offset=18, end_lineno=1, end_col_offset=25), arg('placeholder_3', lineno=1, col_offset=27, end_lineno=1, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Constant('-i', lineno=2, col_offset=7, end_lineno=2, end_col_offset=11), [In()], [Name('placeholder_3', Load(), lineno=2, col_offset=15, end_lineno=2, end_col_offset=20)], lineno=2, col_offset=7, end_lineno=2, end_col_offset=20), [Assign([Name('placeholder_1', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12)], Call(Attribute(Name('placeholder_1', Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=19), 'lower', Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=25), [], [], lineno=3, col_offset=15, end_lineno=3, end_col_offset=27), lineno=3, col_offset=8, end_lineno=3, end_col_offset=27), Assign([Name('placeholder_2', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=15)], Call(Attribute(Name('placeholder_2', Load(), lineno=4, col_offset=18, end_lineno=4, end_col_offset=25), 'lower', Load(), lineno=4, col_offset=18, end_lineno=4, end_col_offset=31), [], [], lineno=4, col_offset=18, end_lineno=4, end_col_offset=33), lineno=4, col_offset=8, end_lineno=4, end_col_offset=33)], [], lineno=2, col_offset=4, end_lineno=4, end_col_offset=33), If(Compare(Constant('-x', lineno=6, col_offset=7, end_lineno=6, end_col_offset=11), [In()], [Name('placeholder_3', Load(), lineno=6, col_offset=15, end_lineno=6, end_col_offset=20)], lineno=6, col_offset=7, end_lineno=6, end_col_offset=20), [If(Compare(Call(Name('len', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=14), [Name('placeholder_2', Load(), lineno=7, col_offset=15, end_lineno=7, end_col_offset=22)], [], lineno=7, col_offset=11, end_lineno=7, end_col_offset=23), [NotEq()], [Call(Name('len', Load(), lineno=7, col_offset=27, end_lineno=7, end_col_offset=30), [Call(Attribute(Name('placeholder_1', Load(), lineno=7, col_offset=31, end_lineno=7, end_col_offset=35), 'rstrip', Load(), lineno=7, col_offset=31, end_lineno=7, end_col_offset=42), [], [], lineno=7, col_offset=31, end_lineno=7, end_col_offset=44)], [], lineno=7, col_offset=27, end_lineno=7, end_col_offset=45)], lineno=7, col_offset=11, end_lineno=7, end_col_offset=45), [Return(Compare(Constant('-v', lineno=8, col_offset=19, end_lineno=8, end_col_offset=23), [In()], [Name('placeholder_3', Load(), lineno=8, col_offset=27, end_lineno=8, end_col_offset=32)], lineno=8, col_offset=19, end_lineno=8, end_col_offset=32), lineno=8, col_offset=12, end_lineno=8, end_col_offset=32)], [], lineno=7, col_offset=8, end_lineno=8, end_col_offset=32)], [], lineno=6, col_offset=4, end_lineno=8, end_col_offset=32), If(Compare(Constant('-v', lineno=10, col_offset=7, end_lineno=10, end_col_offset=11), [In()], [Name('placeholder_3', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=20)], lineno=10, col_offset=7, end_lineno=10, end_col_offset=20), [Return(Compare(Name('placeholder_2', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=22), [NotIn()], [Name('placeholder_1', Load(), lineno=11, col_offset=30, end_lineno=11, end_col_offset=34)], lineno=11, col_offset=15, end_lineno=11, end_col_offset=34), lineno=11, col_offset=8, end_lineno=11, end_col_offset=34)], [], lineno=10, col_offset=4, end_lineno=11, end_col_offset=34), Return(Compare(Name('placeholder_2', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=18), [In()], [Name('placeholder_1', Load(), lineno=13, col_offset=22, end_lineno=13, end_col_offset=26)], lineno=13, col_offset=11, end_lineno=13, end_col_offset=26), lineno=13, col_offset=4, end_lineno=13, end_col_offset=26)], [], lineno=1, col_offset=0, end_lineno=13, end_col_offset=26), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=16, col_offset=17, end_lineno=16, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=10)], Constant('', lineno=17, col_offset=13, end_lineno=17, end_col_offset=15), lineno=17, col_offset=4, end_lineno=17, end_col_offset=15), For(Tuple([Name('placeholder_7', Store(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=17), Name('placeholder_8', Store(), lineno=19, col_offset=19, end_lineno=19, end_col_offset=20), Name('placeholder_8', Store(), lineno=19, col_offset=22, end_lineno=19, end_col_offset=23)], Store(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=23), Name('placeholder_5', Load(), lineno=19, col_offset=27, end_lineno=19, end_col_offset=40), [If(Compare(Name('placeholder_7', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=20), [NotIn()], [Name('placeholder_6', Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=34)], lineno=20, col_offset=11, end_lineno=20, end_col_offset=34), [AugAssign(Name('placeholder_6', Store(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=18), Add(), BinOp(Name('placeholder_7', Load(), lineno=21, col_offset=22, end_lineno=21, end_col_offset=31), Add(), Constant('\n', lineno=21, col_offset=34, end_lineno=21, end_col_offset=38), lineno=21, col_offset=22, end_lineno=21, end_col_offset=38), lineno=21, col_offset=12, end_lineno=21, end_col_offset=38)], [], lineno=20, col_offset=8, end_lineno=21, end_col_offset=38)], [], lineno=19, col_offset=4, end_lineno=21, end_col_offset=38), Return(Name('placeholder_6', Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=17), lineno=23, col_offset=4, end_lineno=23, end_col_offset=17)], [], lineno=16, col_offset=0, end_lineno=23, end_col_offset=17), FunctionDef('placeholder_9', arguments([], [arg('placeholder_5', lineno=26, col_offset=17, end_lineno=26, end_col_offset=30), arg('placeholder_3', lineno=26, col_offset=32, end_lineno=26, end_col_offset=37), arg('placeholder_10', lineno=26, col_offset=39, end_lineno=26, end_col_offset=44)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=27, col_offset=4, end_lineno=27, end_col_offset=10)], List([], Load(), lineno=27, col_offset=13, end_lineno=27, end_col_offset=15), lineno=27, col_offset=4, end_lineno=27, end_col_offset=15), For(Tuple([Name('placeholder_7', Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=17), Name('placeholder_11', Store(), lineno=29, col_offset=19, end_lineno=29, end_col_offset=30), Name('placeholder_1', Store(), lineno=29, col_offset=32, end_lineno=29, end_col_offset=36)], Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=36), Name('placeholder_5', Load(), lineno=29, col_offset=40, end_lineno=29, end_col_offset=53), [Assign([Name('placeholder_12', Store(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=19)], Constant('', lineno=30, col_offset=22, end_lineno=30, end_col_offset=24), lineno=30, col_offset=8, end_lineno=30, end_col_offset=24), If(Compare(Call(Name('len', Load(), lineno=32, col_offset=11, end_lineno=32, end_col_offset=14), [Name('placeholder_10', Load(), lineno=32, col_offset=15, end_lineno=32, end_col_offset=20)], [], lineno=32, col_offset=11, end_lineno=32, end_col_offset=21), [Gt()], [Constant(1, lineno=32, col_offset=24, end_lineno=32, end_col_offset=25)], lineno=32, col_offset=11, end_lineno=32, end_col_offset=25), [AugAssign(Name('placeholder_12', Store(), lineno=33, col_offset=12, end_lineno=33, end_col_offset=23), Add(), BinOp(Name('placeholder_7', Load(), lineno=33, col_offset=27, end_lineno=33, end_col_offset=36), Add(), Constant(':', lineno=33, col_offset=39, end_lineno=33, end_col_offset=42), lineno=33, col_offset=27, end_lineno=33, end_col_offset=42), lineno=33, col_offset=12, end_lineno=33, end_col_offset=42)], [], lineno=32, col_offset=8, end_lineno=33, end_col_offset=42), If(Compare(Constant('-n', lineno=35, col_offset=11, end_lineno=35, end_col_offset=15), [In()], [Name('placeholder_3', Load(), lineno=35, col_offset=19, end_lineno=35, end_col_offset=24)], lineno=35, col_offset=11, end_lineno=35, end_col_offset=24), [AugAssign(Name('placeholder_12', Store(), lineno=36, col_offset=12, end_lineno=36, end_col_offset=23), Add(), BinOp(Call(Name('str', Load(), lineno=36, col_offset=27, end_lineno=36, end_col_offset=30), [Name('placeholder_11', Load(), lineno=36, col_offset=31, end_lineno=36, end_col_offset=42)], [], lineno=36, col_offset=27, end_lineno=36, end_col_offset=43), Add(), Constant(':', lineno=36, col_offset=46, end_lineno=36, end_col_offset=49), lineno=36, col_offset=27, end_lineno=36, end_col_offset=49), lineno=36, col_offset=12, end_lineno=36, end_col_offset=49)], [], lineno=35, col_offset=8, end_lineno=36, end_col_offset=49), AugAssign(Name('placeholder_12', Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=19), Add(), Name('placeholder_1', Load(), lineno=38, col_offset=23, end_lineno=38, end_col_offset=27), lineno=38, col_offset=8, end_lineno=38, end_col_offset=27), Expr(Call(Attribute(Name('placeholder_6', Load(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=14), 'append', Load(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=21), [Name('placeholder_12', Load(), lineno=40, col_offset=22, end_lineno=40, end_col_offset=33)], [], lineno=40, col_offset=8, end_lineno=40, end_col_offset=34), lineno=40, col_offset=8, end_lineno=40, end_col_offset=34)], [], lineno=29, col_offset=4, end_lineno=40, end_col_offset=34), Return(Call(Attribute(Constant('', lineno=42, col_offset=11, end_lineno=42, end_col_offset=13), 'join', Load(), lineno=42, col_offset=11, end_lineno=42, end_col_offset=18), [Name('placeholder_6', Load(), lineno=42, col_offset=19, end_lineno=42, end_col_offset=25)], [], lineno=42, col_offset=11, end_lineno=42, end_col_offset=26), lineno=42, col_offset=4, end_lineno=42, end_col_offset=26)], [], lineno=26, col_offset=0, end_lineno=42, end_col_offset=26), FunctionDef('placeholder_13', arguments([], [arg('placeholder_2', lineno=45, col_offset=9, end_lineno=45, end_col_offset=16), arg('placeholder_3', lineno=45, col_offset=18, end_lineno=45, end_col_offset=23), arg('placeholder_10', lineno=45, col_offset=25, end_lineno=45, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_5', Store(), lineno=46, col_offset=4, end_lineno=46, end_col_offset=17)], List([], Load(), lineno=46, col_offset=20, end_lineno=46, end_col_offset=22), lineno=46, col_offset=4, end_lineno=46, end_col_offset=22), For(Name('placeholder_7', Store(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=17), Name('placeholder_10', Load(), lineno=48, col_offset=21, end_lineno=48, end_col_offset=26), [With([withitem(Call(Name('open', Load(), lineno=49, col_offset=13, end_lineno=49, end_col_offset=17), [Name('placeholder_7', Load(), lineno=49, col_offset=18, end_lineno=49, end_col_offset=27)], [keyword('placeholder_14', Constant('utf-8', lineno=49, col_offset=38, end_lineno=49, end_col_offset=45), lineno=49, col_offset=29, end_lineno=49, end_col_offset=45)], lineno=49, col_offset=13, end_lineno=49, end_col_offset=46), Name('placeholder_15', Store(), lineno=49, col_offset=50, end_lineno=49, end_col_offset=51))], [For(Tuple([Name('placeholder_11', Store(), lineno=50, col_offset=16, end_lineno=50, end_col_offset=27), Name('placeholder_1', Store(), lineno=50, col_offset=29, end_lineno=50, end_col_offset=33)], Store(), lineno=50, col_offset=16, end_lineno=50, end_col_offset=33), Call(Name('enumerate', Load(), lineno=50, col_offset=37, end_lineno=50, end_col_offset=46), [Call(Attribute(Name('placeholder_15', Load(), lineno=50, col_offset=47, end_lineno=50, end_col_offset=48), 'readlines', Load(), lineno=50, col_offset=47, end_lineno=50, end_col_offset=58), [], [], lineno=50, col_offset=47, end_lineno=50, end_col_offset=60)], [keyword('placeholder_16', Constant(1, lineno=50, col_offset=68, end_lineno=50, end_col_offset=69), lineno=50, col_offset=62, end_lineno=50, end_col_offset=69)], lineno=50, col_offset=37, end_lineno=50, end_col_offset=70), [If(Call(Name('placeholder_0', Load(), lineno=51, col_offset=19, end_lineno=51, end_col_offset=26), [Name('placeholder_1', Load(), lineno=51, col_offset=27, end_lineno=51, end_col_offset=31), Name('placeholder_2', Load(), lineno=51, col_offset=33, end_lineno=51, end_col_offset=40), Name('placeholder_3', Load(), lineno=51, col_offset=42, end_lineno=51, end_col_offset=47)], [], lineno=51, col_offset=19, end_lineno=51, end_col_offset=48), [Expr(Call(Attribute(Name('placeholder_5', Load(), lineno=52, col_offset=20, end_lineno=52, end_col_offset=33), 'append', Load(), lineno=52, col_offset=20, end_lineno=52, end_col_offset=40), [Tuple([Name('placeholder_7', Load(), lineno=52, col_offset=42, end_lineno=52, end_col_offset=51), Name('placeholder_11', Load(), lineno=52, col_offset=53, end_lineno=52, end_col_offset=64), Name('placeholder_1', Load(), lineno=52, col_offset=66, end_lineno=52, end_col_offset=70)], Load(), lineno=52, col_offset=41, end_lineno=52, end_col_offset=71)], [], lineno=52, col_offset=20, end_lineno=52, end_col_offset=72), lineno=52, col_offset=20, end_lineno=52, end_col_offset=72)], [], lineno=51, col_offset=16, end_lineno=52, end_col_offset=72)], [], lineno=50, col_offset=12, end_lineno=52, end_col_offset=72)], lineno=49, col_offset=8, end_lineno=52, end_col_offset=72)], [], lineno=48, col_offset=4, end_lineno=52, end_col_offset=72), If(Compare(Constant('-l', lineno=54, col_offset=7, end_lineno=54, end_col_offset=11), [In()], [Name('placeholder_3', Load(), lineno=54, col_offset=15, end_lineno=54, end_col_offset=20)], lineno=54, col_offset=7, end_lineno=54, end_col_offset=20), [Return(Call(Name('placeholder_4', Load(), lineno=55, col_offset=15, end_lineno=55, end_col_offset=27), [Name('placeholder_5', Load(), lineno=55, col_offset=28, end_lineno=55, end_col_offset=41)], [], lineno=55, col_offset=15, end_lineno=55, end_col_offset=42), lineno=55, col_offset=8, end_lineno=55, end_col_offset=42)], [], lineno=54, col_offset=4, end_lineno=55, end_col_offset=42), Return(Call(Name('placeholder_9', Load(), lineno=57, col_offset=11, end_lineno=57, end_col_offset=23), [Name('placeholder_5', Load(), lineno=57, col_offset=24, end_lineno=57, end_col_offset=37), Name('placeholder_3', Load(), lineno=57, col_offset=39, end_lineno=57, end_col_offset=44), Name('placeholder_10', Load(), lineno=57, col_offset=46, end_lineno=57, end_col_offset=51)], [], lineno=57, col_offset=11, end_lineno=57, end_col_offset=52), lineno=57, col_offset=4, end_lineno=57, end_col_offset=52)], [], lineno=45, col_offset=0, end_lineno=57, end_col_offset=52)], []) \ No newline at end of file diff --git a/test/practice-hamming/.meta/config.json b/test/practice-hamming/.meta/config.json new file mode 100644 index 0000000..1280ded --- /dev/null +++ b/test/practice-hamming/.meta/config.json @@ -0,0 +1,37 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "gabriel376", + "GascaK", + "guaneec", + "iandexter", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "parthsharma2", + "pheanex", + "pywkm", + "sjakobi", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "hamming.py" + ], + "test": [ + "hamming_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Calculate the Hamming difference between two DNA strands.", + "source": "The Calculating Point Mutations problem at Rosalind", + "source_url": "https://rosalind.info/problems/hamm/" +} diff --git a/test/practice-hamming/hamming.py b/test/practice-hamming/hamming.py new file mode 100644 index 0000000..d6a3848 --- /dev/null +++ b/test/practice-hamming/hamming.py @@ -0,0 +1,5 @@ +def distance(strand_a, strand_b): + if len(strand_a) != len(strand_b): + raise ValueError('Strands must be of equal length.') + + return sum(a_part != b_part for a_part, b_part in zip(strand_a, strand_b)) diff --git a/test/practice-hamming/mapping.json b/test/practice-hamming/mapping.json new file mode 100644 index 0000000..cdf78c9 --- /dev/null +++ b/test/practice-hamming/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "distance", + "placeholder_1": "strand_a", + "placeholder_2": "strand_b", + "placeholder_3": "a_part", + "placeholder_4": "b_part" +} \ No newline at end of file diff --git a/test/practice-hamming/representation.json b/test/practice-hamming/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-hamming/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-hamming/representation.out b/test/practice-hamming/representation.out new file mode 100644 index 0000000..12ec13a --- /dev/null +++ b/test/practice-hamming/representation.out @@ -0,0 +1,438 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + if len(placeholder_1) != len(placeholder_2): + raise ValueError("Strands must be of equal length.") + return sum( + ( + placeholder_3 != placeholder_4 + for placeholder_3, placeholder_4 in zip(placeholder_1, placeholder_2) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'distance', + arguments( + [], + [ + arg( + 'strand_a', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=21), + arg( + 'strand_b', + lineno=1, + col_offset=23, + end_lineno=1, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=10), + [ + Name( + 'strand_a', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=19)], + [], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=27), + [ + Name( + 'strand_b', + Load(), + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=36)], + [], + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=37)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=37), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'Strands must be of equal length.', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=59)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=60), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=60)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=60), + Return( + Call( + Name( + 'sum', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + GeneratorExp( + Compare( + Name( + 'a_part', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=21), + [ + NotEq()], + [ + Name( + 'b_part', + Load(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=31)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=31), + [ + comprehension( + Tuple( + [ + Name( + 'a_part', + Store(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=42), + Name( + 'b_part', + Store(), + lineno=5, + col_offset=44, + end_lineno=5, + end_col_offset=50)], + Store(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=50), + Call( + Name( + 'zip', + Load(), + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=57), + [ + Name( + 'strand_a', + Load(), + lineno=5, + col_offset=58, + end_lineno=5, + end_col_offset=66), + Name( + 'strand_b', + Load(), + lineno=5, + col_offset=68, + end_lineno=5, + end_col_offset=76)], + [], + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=77), + [], + 0)], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=78)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=78), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=78)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=78)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=1, + col_offset=23, + end_lineno=1, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=10), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=19)], + [], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=27), + [ + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=36)], + [], + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=37)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=37), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'Strands must be of equal length.', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=59)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=60), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=60)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=60), + Return( + Call( + Name( + 'sum', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + GeneratorExp( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=21), + [ + NotEq()], + [ + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=31)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=31), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=42), + Name( + 'placeholder_4', + Store(), + lineno=5, + col_offset=44, + end_lineno=5, + end_col_offset=50)], + Store(), + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=50), + Call( + Name( + 'zip', + Load(), + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=57), + [ + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=58, + end_lineno=5, + end_col_offset=66), + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=68, + end_lineno=5, + end_col_offset=76)], + [], + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=77), + [], + 0)], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=78)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=78), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=78)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=78)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-hamming/representation.txt b/test/practice-hamming/representation.txt new file mode 100644 index 0000000..e9a9a3b --- /dev/null +++ b/test/practice-hamming/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=13, end_lineno=1, end_col_offset=21), arg('placeholder_2', lineno=1, col_offset=23, end_lineno=1, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=2, col_offset=7, end_lineno=2, end_col_offset=10), [Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=19)], [], lineno=2, col_offset=7, end_lineno=2, end_col_offset=20), [NotEq()], [Call(Name('len', Load(), lineno=2, col_offset=24, end_lineno=2, end_col_offset=27), [Name('placeholder_2', Load(), lineno=2, col_offset=28, end_lineno=2, end_col_offset=36)], [], lineno=2, col_offset=24, end_lineno=2, end_col_offset=37)], lineno=2, col_offset=7, end_lineno=2, end_col_offset=37), [Raise(Call(Name('ValueError', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=24), [Constant('Strands must be of equal length.', lineno=3, col_offset=25, end_lineno=3, end_col_offset=59)], [], lineno=3, col_offset=14, end_lineno=3, end_col_offset=60), lineno=3, col_offset=8, end_lineno=3, end_col_offset=60)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=60), Return(Call(Name('sum', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=14), [GeneratorExp(Compare(Name('placeholder_3', Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=21), [NotEq()], [Name('placeholder_4', Load(), lineno=5, col_offset=25, end_lineno=5, end_col_offset=31)], lineno=5, col_offset=15, end_lineno=5, end_col_offset=31), [comprehension(Tuple([Name('placeholder_3', Store(), lineno=5, col_offset=36, end_lineno=5, end_col_offset=42), Name('placeholder_4', Store(), lineno=5, col_offset=44, end_lineno=5, end_col_offset=50)], Store(), lineno=5, col_offset=36, end_lineno=5, end_col_offset=50), Call(Name('zip', Load(), lineno=5, col_offset=54, end_lineno=5, end_col_offset=57), [Name('placeholder_1', Load(), lineno=5, col_offset=58, end_lineno=5, end_col_offset=66), Name('placeholder_2', Load(), lineno=5, col_offset=68, end_lineno=5, end_col_offset=76)], [], lineno=5, col_offset=54, end_lineno=5, end_col_offset=77), [], 0)], lineno=5, col_offset=14, end_lineno=5, end_col_offset=78)], [], lineno=5, col_offset=11, end_lineno=5, end_col_offset=78), lineno=5, col_offset=4, end_lineno=5, end_col_offset=78)], [], lineno=1, col_offset=0, end_lineno=5, end_col_offset=78)], []) \ No newline at end of file diff --git a/test/practice-hangman/.meta/config.json b/test/practice-hangman/.meta/config.json new file mode 100644 index 0000000..1d05148 --- /dev/null +++ b/test/practice-hangman/.meta/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "junming403" + ], + "contributors": [ + "cmccandless", + "Dog", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "hangman.py" + ], + "test": [ + "hangman_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement the logic of the hangman game using functional reactive programming." +} diff --git a/test/practice-hangman/hangman.py b/test/practice-hangman/hangman.py new file mode 100644 index 0000000..b031686 --- /dev/null +++ b/test/practice-hangman/hangman.py @@ -0,0 +1,50 @@ +STATUS_WIN = 'win' +STATUS_LOSE = 'lose' +STATUS_ONGOING = 'ongoing' + + +class Hangman: + def __init__(self, word): + self.remaining_guesses = 9 + self.status = STATUS_ONGOING + self.word = word + self.masked_word = '' + self.guesses = [] + for _ in self.word: + self.masked_word += '_' + + def guess(self, char): + if self.status != STATUS_ONGOING: + raise ValueError('The game has already ended.') + + self.update_remaining_guesses(char) + self.update_masked_word() + self.update_status() + + def update_masked_word(self): + self.masked_word = '' + for idx in self.word: + if idx not in self.guesses: + self.masked_word += '_' + else: + self.masked_word += idx + + def update_remaining_guesses(self, char): + if char not in self.word or char in self.guesses: + self.remaining_guesses -= 1 + else: + self.guesses.append(char) + + def update_status(self): + if self.masked_word == self.word: + self.status = STATUS_WIN + elif self.remaining_guesses < 0: + self.status = STATUS_LOSE + else: + self.status = STATUS_ONGOING + + def get_masked_word(self): + return self.masked_word + + def get_status(self): + return self.status diff --git a/test/practice-hangman/mapping.json b/test/practice-hangman/mapping.json new file mode 100644 index 0000000..838c3ac --- /dev/null +++ b/test/practice-hangman/mapping.json @@ -0,0 +1,21 @@ +{ + "placeholder_0": "STATUS_WIN", + "placeholder_1": "STATUS_LOSE", + "placeholder_2": "STATUS_ONGOING", + "placeholder_3": "Hangman", + "placeholder_4": "__init__", + "placeholder_5": "word", + "placeholder_6": "remaining_guesses", + "placeholder_7": "status", + "placeholder_8": "masked_word", + "placeholder_9": "guesses", + "placeholder_10": "_", + "placeholder_11": "guess", + "placeholder_12": "char", + "placeholder_13": "update_masked_word", + "placeholder_14": "idx", + "placeholder_15": "update_remaining_guesses", + "placeholder_16": "update_status", + "placeholder_17": "get_masked_word", + "placeholder_18": "get_status" +} \ No newline at end of file diff --git a/test/practice-hangman/representation.json b/test/practice-hangman/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-hangman/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-hangman/representation.out b/test/practice-hangman/representation.out new file mode 100644 index 0000000..69973d8 --- /dev/null +++ b/test/practice-hangman/representation.out @@ -0,0 +1,2139 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = "win" +placeholder_1 = "lose" +placeholder_2 = "ongoing" + + +class placeholder_3: + def placeholder_4(self, placeholder_5): + self.placeholder_6 = 9 + self.placeholder_7 = placeholder_2 + self.placeholder_5 = placeholder_5 + self.placeholder_8 = "" + self.placeholder_9 = [] + for placeholder_10 in self.placeholder_5: + self.placeholder_8 += "_" + + def placeholder_11(self, placeholder_12): + if self.placeholder_7 != placeholder_2: + raise ValueError("The game has already ended.") + self.update_remaining_guesses(placeholder_12) + self.update_masked_word() + self.update_status() + + def placeholder_13(self): + self.placeholder_8 = "" + for placeholder_14 in self.placeholder_5: + if placeholder_14 not in self.placeholder_9: + self.placeholder_8 += "_" + else: + self.placeholder_8 += placeholder_14 + + def placeholder_15(self, placeholder_12): + if ( + placeholder_12 not in self.placeholder_5 + or placeholder_12 in self.placeholder_9 + ): + self.placeholder_6 -= 1 + else: + self.placeholder_9.append(placeholder_12) + + def placeholder_16(self): + if self.placeholder_8 == self.placeholder_5: + self.placeholder_7 = placeholder_0 + elif self.placeholder_6 < 0: + self.placeholder_7 = placeholder_1 + else: + self.placeholder_7 = placeholder_2 + + def placeholder_17(self): + return self.placeholder_8 + + def placeholder_18(self): + return self.placeholder_7 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'STATUS_WIN', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=10)], + Constant( + 'win', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=18), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=18), + Assign( + [ + Name( + 'STATUS_LOSE', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=11)], + Constant( + 'lose', + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=20), + Assign( + [ + Name( + 'STATUS_ONGOING', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=14)], + Constant( + 'ongoing', + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=26), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=26), + ClassDef( + 'Hangman', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21), + arg( + 'word', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'remaining_guesses', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=30)], + Constant( + 9, + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=34), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'status', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=19)], + Name( + 'STATUS_ONGOING', + Load(), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'word', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=17)], + Name( + 'word', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=24), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'masked_word', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=24)], + Constant( + '', + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=29), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=29), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'guesses', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=20)], + List( + [], + Load(), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=25), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=25), + For( + Name( + '_', + Store(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=13), + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=21), + 'word', + Load(), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=26), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=16), + 'masked_word', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=28), + Add(), + Constant( + '_', + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=35), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=35)], + [], + lineno=13, + col_offset=8, + end_lineno=14, + end_col_offset=35)], + [], + lineno=7, + col_offset=4, + end_lineno=14, + end_col_offset=35), + FunctionDef( + 'guess', + arguments( + [], + [ + arg( + 'self', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=18), + arg( + 'char', + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=15), + 'status', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=22), + [ + NotEq()], + [ + Name( + 'STATUS_ONGOING', + Load(), + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=40)], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=40), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=28), + [ + Constant( + 'The game has already ended.', + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=58)], + [], + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=59), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=59)], + [], + lineno=17, + col_offset=8, + end_lineno=18, + end_col_offset=59), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=12), + 'update_remaining_guesses', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=37), + [ + Name( + 'char', + Load(), + lineno=20, + col_offset=38, + end_lineno=20, + end_col_offset=42)], + [], + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=43), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=43), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12), + 'update_masked_word', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=31), + [], + [], + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=33), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=33), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=12), + 'update_status', + Load(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=26), + [], + [], + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=28), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=28)], + [], + lineno=16, + col_offset=4, + end_lineno=22, + end_col_offset=28), + FunctionDef( + 'update_masked_word', + arguments( + [], + [ + arg( + 'self', + lineno=24, + col_offset=27, + end_lineno=24, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=12), + 'masked_word', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=24)], + Constant( + '', + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=29), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=29), + For( + Name( + 'idx', + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=15), + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=23), + 'word', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=28), + [ + If( + Compare( + Name( + 'idx', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=18), + [ + NotIn()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=30), + 'guesses', + Load(), + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=38)], + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=38), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=20), + 'masked_word', + Store(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=32), + Add(), + Constant( + '_', + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=39), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=39)], + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=20), + 'masked_word', + Store(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=32), + Add(), + Name( + 'idx', + Load(), + lineno=30, + col_offset=36, + end_lineno=30, + end_col_offset=39), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=39)], + lineno=27, + col_offset=12, + end_lineno=30, + end_col_offset=39)], + [], + lineno=26, + col_offset=8, + end_lineno=30, + end_col_offset=39)], + [], + lineno=24, + col_offset=4, + end_lineno=30, + end_col_offset=39), + FunctionDef( + 'update_remaining_guesses', + arguments( + [], + [ + arg( + 'self', + lineno=32, + col_offset=33, + end_lineno=32, + end_col_offset=37), + arg( + 'char', + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'char', + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=15), + [ + NotIn()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=27), + 'word', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=32)], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=32), + Compare( + Name( + 'char', + Load(), + lineno=33, + col_offset=36, + end_lineno=33, + end_col_offset=40), + [ + In()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=44, + end_lineno=33, + end_col_offset=48), + 'guesses', + Load(), + lineno=33, + col_offset=44, + end_lineno=33, + end_col_offset=56)], + lineno=33, + col_offset=36, + end_lineno=33, + end_col_offset=56)], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=56), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=16), + 'remaining_guesses', + Store(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=34), + Sub(), + Constant( + 1, + lineno=34, + col_offset=38, + end_lineno=34, + end_col_offset=39), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=39)], + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=16), + 'guesses', + Load(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=24), + 'append', + Load(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=31), + [ + Name( + 'char', + Load(), + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=36)], + [], + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=37), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=37)], + lineno=33, + col_offset=8, + end_lineno=36, + end_col_offset=37)], + [], + lineno=32, + col_offset=4, + end_lineno=36, + end_col_offset=37), + FunctionDef( + 'update_status', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=15), + 'masked_word', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=27), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=31, + end_lineno=39, + end_col_offset=35), + 'word', + Load(), + lineno=39, + col_offset=31, + end_lineno=39, + end_col_offset=40)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=40), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=16), + 'status', + Store(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=23)], + Name( + 'STATUS_WIN', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=36), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=36)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=13, + end_lineno=41, + end_col_offset=17), + 'remaining_guesses', + Load(), + lineno=41, + col_offset=13, + end_lineno=41, + end_col_offset=35), + [ + Lt()], + [ + Constant( + 0, + lineno=41, + col_offset=38, + end_lineno=41, + end_col_offset=39)], + lineno=41, + col_offset=13, + end_lineno=41, + end_col_offset=39), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=16), + 'status', + Store(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=23)], + Name( + 'STATUS_LOSE', + Load(), + lineno=42, + col_offset=26, + end_lineno=42, + end_col_offset=37), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=37)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=16), + 'status', + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=23)], + Name( + 'STATUS_ONGOING', + Load(), + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=40), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=40)], + lineno=41, + col_offset=8, + end_lineno=44, + end_col_offset=40)], + lineno=39, + col_offset=8, + end_lineno=44, + end_col_offset=40)], + [], + lineno=38, + col_offset=4, + end_lineno=44, + end_col_offset=40), + FunctionDef( + 'get_masked_word', + arguments( + [], + [ + arg( + 'self', + lineno=46, + col_offset=24, + end_lineno=46, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=19), + 'masked_word', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=31), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=31)], + [], + lineno=46, + col_offset=4, + end_lineno=47, + end_col_offset=31), + FunctionDef( + 'get_status', + arguments( + [], + [ + arg( + 'self', + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=19), + 'status', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=26), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=26)], + [], + lineno=49, + col_offset=4, + end_lineno=50, + end_col_offset=26)], + [], + lineno=6, + col_offset=0, + end_lineno=50, + end_col_offset=26)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=10)], + Constant( + 'win', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=18), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=18), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=11)], + Constant( + 'lose', + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=20), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=14)], + Constant( + 'ongoing', + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=26), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=26), + ClassDef( + 'placeholder_3', + [], + [], + [ + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21), + arg( + 'placeholder_5', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=30)], + Constant( + 9, + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=34), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=19)], + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=17)], + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=24), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=24)], + Constant( + '', + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=29), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=29), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'placeholder_9', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=20)], + List( + [], + Load(), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=25), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=25), + For( + Name( + 'placeholder_10', + Store(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=13), + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=21), + 'placeholder_5', + Load(), + lineno=13, + col_offset=17, + end_lineno=13, + end_col_offset=26), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=16), + 'placeholder_8', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=28), + Add(), + Constant( + '_', + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=35), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=35)], + [], + lineno=13, + col_offset=8, + end_lineno=14, + end_col_offset=35)], + [], + lineno=7, + col_offset=4, + end_lineno=14, + end_col_offset=35), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=18), + arg( + 'placeholder_12', + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=15), + 'placeholder_7', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=22), + [ + NotEq()], + [ + Name( + 'placeholder_2', + Load(), + lineno=17, + col_offset=26, + end_lineno=17, + end_col_offset=40)], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=40), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=28), + [ + Constant( + 'The game has already ended.', + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=58)], + [], + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=59), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=59)], + [], + lineno=17, + col_offset=8, + end_lineno=18, + end_col_offset=59), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=12), + 'update_remaining_guesses', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=37), + [ + Name( + 'placeholder_12', + Load(), + lineno=20, + col_offset=38, + end_lineno=20, + end_col_offset=42)], + [], + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=43), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=43), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12), + 'update_masked_word', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=31), + [], + [], + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=33), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=33), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=12), + 'update_status', + Load(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=26), + [], + [], + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=28), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=28)], + [], + lineno=16, + col_offset=4, + end_lineno=22, + end_col_offset=28), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=24, + col_offset=27, + end_lineno=24, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=24)], + Constant( + '', + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=29), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=29), + For( + Name( + 'placeholder_14', + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=15), + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=23), + 'placeholder_5', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=28), + [ + If( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=18), + [ + NotIn()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=30), + 'placeholder_9', + Load(), + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=38)], + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=38), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=20), + 'placeholder_8', + Store(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=32), + Add(), + Constant( + '_', + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=39), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=39)], + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=20), + 'placeholder_8', + Store(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=32), + Add(), + Name( + 'placeholder_14', + Load(), + lineno=30, + col_offset=36, + end_lineno=30, + end_col_offset=39), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=39)], + lineno=27, + col_offset=12, + end_lineno=30, + end_col_offset=39)], + [], + lineno=26, + col_offset=8, + end_lineno=30, + end_col_offset=39)], + [], + lineno=24, + col_offset=4, + end_lineno=30, + end_col_offset=39), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=32, + col_offset=33, + end_lineno=32, + end_col_offset=37), + arg( + 'placeholder_12', + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_12', + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=15), + [ + NotIn()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=27), + 'placeholder_5', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=32)], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=32), + Compare( + Name( + 'placeholder_12', + Load(), + lineno=33, + col_offset=36, + end_lineno=33, + end_col_offset=40), + [ + In()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=44, + end_lineno=33, + end_col_offset=48), + 'placeholder_9', + Load(), + lineno=33, + col_offset=44, + end_lineno=33, + end_col_offset=56)], + lineno=33, + col_offset=36, + end_lineno=33, + end_col_offset=56)], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=56), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=16), + 'placeholder_6', + Store(), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=34), + Sub(), + Constant( + 1, + lineno=34, + col_offset=38, + end_lineno=34, + end_col_offset=39), + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=39)], + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=16), + 'placeholder_9', + Load(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=24), + 'append', + Load(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=31), + [ + Name( + 'placeholder_12', + Load(), + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=36)], + [], + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=37), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=37)], + lineno=33, + col_offset=8, + end_lineno=36, + end_col_offset=37)], + [], + lineno=32, + col_offset=4, + end_lineno=36, + end_col_offset=37), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=15), + 'placeholder_8', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=27), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=31, + end_lineno=39, + end_col_offset=35), + 'placeholder_5', + Load(), + lineno=39, + col_offset=31, + end_lineno=39, + end_col_offset=40)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=40), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=23)], + Name( + 'placeholder_0', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=36), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=36)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=13, + end_lineno=41, + end_col_offset=17), + 'placeholder_6', + Load(), + lineno=41, + col_offset=13, + end_lineno=41, + end_col_offset=35), + [ + Lt()], + [ + Constant( + 0, + lineno=41, + col_offset=38, + end_lineno=41, + end_col_offset=39)], + lineno=41, + col_offset=13, + end_lineno=41, + end_col_offset=39), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=23)], + Name( + 'placeholder_1', + Load(), + lineno=42, + col_offset=26, + end_lineno=42, + end_col_offset=37), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=37)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=23)], + Name( + 'placeholder_2', + Load(), + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=40), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=40)], + lineno=41, + col_offset=8, + end_lineno=44, + end_col_offset=40)], + lineno=39, + col_offset=8, + end_lineno=44, + end_col_offset=40)], + [], + lineno=38, + col_offset=4, + end_lineno=44, + end_col_offset=40), + FunctionDef( + 'placeholder_17', + arguments( + [], + [ + arg( + 'self', + lineno=46, + col_offset=24, + end_lineno=46, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=19), + 'placeholder_8', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=31), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=31)], + [], + lineno=46, + col_offset=4, + end_lineno=47, + end_col_offset=31), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'self', + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=26), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=26)], + [], + lineno=49, + col_offset=4, + end_lineno=50, + end_col_offset=26)], + [], + lineno=6, + col_offset=0, + end_lineno=50, + end_col_offset=26)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-hangman/representation.txt b/test/practice-hangman/representation.txt new file mode 100644 index 0000000..d6a33f4 --- /dev/null +++ b/test/practice-hangman/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=10)], Constant('win', lineno=1, col_offset=13, end_lineno=1, end_col_offset=18), lineno=1, col_offset=0, end_lineno=1, end_col_offset=18), Assign([Name('placeholder_1', Store(), lineno=2, col_offset=0, end_lineno=2, end_col_offset=11)], Constant('lose', lineno=2, col_offset=14, end_lineno=2, end_col_offset=20), lineno=2, col_offset=0, end_lineno=2, end_col_offset=20), Assign([Name('placeholder_2', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=14)], Constant('ongoing', lineno=3, col_offset=17, end_lineno=3, end_col_offset=26), lineno=3, col_offset=0, end_lineno=3, end_col_offset=26), ClassDef('placeholder_3', [], [], [FunctionDef('placeholder_4', arguments([], [arg('self', lineno=7, col_offset=17, end_lineno=7, end_col_offset=21), arg('placeholder_5', lineno=7, col_offset=23, end_lineno=7, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_6', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=30)], Constant(9, lineno=8, col_offset=33, end_lineno=8, end_col_offset=34), lineno=8, col_offset=8, end_lineno=8, end_col_offset=34), Assign([Attribute(Name('self', Load(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), 'placeholder_7', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=19)], Name('placeholder_2', Load(), lineno=9, col_offset=22, end_lineno=9, end_col_offset=36), lineno=9, col_offset=8, end_lineno=9, end_col_offset=36), Assign([Attribute(Name('self', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=12), 'placeholder_5', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=17)], Name('placeholder_5', Load(), lineno=10, col_offset=20, end_lineno=10, end_col_offset=24), lineno=10, col_offset=8, end_lineno=10, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), 'placeholder_8', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=24)], Constant('', lineno=11, col_offset=27, end_lineno=11, end_col_offset=29), lineno=11, col_offset=8, end_lineno=11, end_col_offset=29), Assign([Attribute(Name('self', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), 'placeholder_9', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=20)], List([], Load(), lineno=12, col_offset=23, end_lineno=12, end_col_offset=25), lineno=12, col_offset=8, end_lineno=12, end_col_offset=25), For(Name('placeholder_10', Store(), lineno=13, col_offset=12, end_lineno=13, end_col_offset=13), Attribute(Name('self', Load(), lineno=13, col_offset=17, end_lineno=13, end_col_offset=21), 'placeholder_5', Load(), lineno=13, col_offset=17, end_lineno=13, end_col_offset=26), [AugAssign(Attribute(Name('self', Load(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=16), 'placeholder_8', Store(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=28), Add(), Constant('_', lineno=14, col_offset=32, end_lineno=14, end_col_offset=35), lineno=14, col_offset=12, end_lineno=14, end_col_offset=35)], [], lineno=13, col_offset=8, end_lineno=14, end_col_offset=35)], [], lineno=7, col_offset=4, end_lineno=14, end_col_offset=35), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=16, col_offset=14, end_lineno=16, end_col_offset=18), arg('placeholder_12', lineno=16, col_offset=20, end_lineno=16, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=15), 'placeholder_7', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=22), [NotEq()], [Name('placeholder_2', Load(), lineno=17, col_offset=26, end_lineno=17, end_col_offset=40)], lineno=17, col_offset=11, end_lineno=17, end_col_offset=40), [Raise(Call(Name('ValueError', Load(), lineno=18, col_offset=18, end_lineno=18, end_col_offset=28), [Constant('The game has already ended.', lineno=18, col_offset=29, end_lineno=18, end_col_offset=58)], [], lineno=18, col_offset=18, end_lineno=18, end_col_offset=59), lineno=18, col_offset=12, end_lineno=18, end_col_offset=59)], [], lineno=17, col_offset=8, end_lineno=18, end_col_offset=59), Expr(Call(Attribute(Name('self', Load(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=12), 'update_remaining_guesses', Load(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=37), [Name('placeholder_12', Load(), lineno=20, col_offset=38, end_lineno=20, end_col_offset=42)], [], lineno=20, col_offset=8, end_lineno=20, end_col_offset=43), lineno=20, col_offset=8, end_lineno=20, end_col_offset=43), Expr(Call(Attribute(Name('self', Load(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=12), 'update_masked_word', Load(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=31), [], [], lineno=21, col_offset=8, end_lineno=21, end_col_offset=33), lineno=21, col_offset=8, end_lineno=21, end_col_offset=33), Expr(Call(Attribute(Name('self', Load(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=12), 'update_status', Load(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=26), [], [], lineno=22, col_offset=8, end_lineno=22, end_col_offset=28), lineno=22, col_offset=8, end_lineno=22, end_col_offset=28)], [], lineno=16, col_offset=4, end_lineno=22, end_col_offset=28), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=24, col_offset=27, end_lineno=24, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=12), 'placeholder_8', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=24)], Constant('', lineno=25, col_offset=27, end_lineno=25, end_col_offset=29), lineno=25, col_offset=8, end_lineno=25, end_col_offset=29), For(Name('placeholder_14', Store(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=15), Attribute(Name('self', Load(), lineno=26, col_offset=19, end_lineno=26, end_col_offset=23), 'placeholder_5', Load(), lineno=26, col_offset=19, end_lineno=26, end_col_offset=28), [If(Compare(Name('placeholder_14', Load(), lineno=27, col_offset=15, end_lineno=27, end_col_offset=18), [NotIn()], [Attribute(Name('self', Load(), lineno=27, col_offset=26, end_lineno=27, end_col_offset=30), 'placeholder_9', Load(), lineno=27, col_offset=26, end_lineno=27, end_col_offset=38)], lineno=27, col_offset=15, end_lineno=27, end_col_offset=38), [AugAssign(Attribute(Name('self', Load(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=20), 'placeholder_8', Store(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=32), Add(), Constant('_', lineno=28, col_offset=36, end_lineno=28, end_col_offset=39), lineno=28, col_offset=16, end_lineno=28, end_col_offset=39)], [AugAssign(Attribute(Name('self', Load(), lineno=30, col_offset=16, end_lineno=30, end_col_offset=20), 'placeholder_8', Store(), lineno=30, col_offset=16, end_lineno=30, end_col_offset=32), Add(), Name('placeholder_14', Load(), lineno=30, col_offset=36, end_lineno=30, end_col_offset=39), lineno=30, col_offset=16, end_lineno=30, end_col_offset=39)], lineno=27, col_offset=12, end_lineno=30, end_col_offset=39)], [], lineno=26, col_offset=8, end_lineno=30, end_col_offset=39)], [], lineno=24, col_offset=4, end_lineno=30, end_col_offset=39), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=32, col_offset=33, end_lineno=32, end_col_offset=37), arg('placeholder_12', lineno=32, col_offset=39, end_lineno=32, end_col_offset=43)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(BoolOp(Or(), [Compare(Name('placeholder_12', Load(), lineno=33, col_offset=11, end_lineno=33, end_col_offset=15), [NotIn()], [Attribute(Name('self', Load(), lineno=33, col_offset=23, end_lineno=33, end_col_offset=27), 'placeholder_5', Load(), lineno=33, col_offset=23, end_lineno=33, end_col_offset=32)], lineno=33, col_offset=11, end_lineno=33, end_col_offset=32), Compare(Name('placeholder_12', Load(), lineno=33, col_offset=36, end_lineno=33, end_col_offset=40), [In()], [Attribute(Name('self', Load(), lineno=33, col_offset=44, end_lineno=33, end_col_offset=48), 'placeholder_9', Load(), lineno=33, col_offset=44, end_lineno=33, end_col_offset=56)], lineno=33, col_offset=36, end_lineno=33, end_col_offset=56)], lineno=33, col_offset=11, end_lineno=33, end_col_offset=56), [AugAssign(Attribute(Name('self', Load(), lineno=34, col_offset=12, end_lineno=34, end_col_offset=16), 'placeholder_6', Store(), lineno=34, col_offset=12, end_lineno=34, end_col_offset=34), Sub(), Constant(1, lineno=34, col_offset=38, end_lineno=34, end_col_offset=39), lineno=34, col_offset=12, end_lineno=34, end_col_offset=39)], [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=36, col_offset=12, end_lineno=36, end_col_offset=16), 'placeholder_9', Load(), lineno=36, col_offset=12, end_lineno=36, end_col_offset=24), 'append', Load(), lineno=36, col_offset=12, end_lineno=36, end_col_offset=31), [Name('placeholder_12', Load(), lineno=36, col_offset=32, end_lineno=36, end_col_offset=36)], [], lineno=36, col_offset=12, end_lineno=36, end_col_offset=37), lineno=36, col_offset=12, end_lineno=36, end_col_offset=37)], lineno=33, col_offset=8, end_lineno=36, end_col_offset=37)], [], lineno=32, col_offset=4, end_lineno=36, end_col_offset=37), FunctionDef('placeholder_16', arguments([], [arg('self', lineno=38, col_offset=22, end_lineno=38, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=39, col_offset=11, end_lineno=39, end_col_offset=15), 'placeholder_8', Load(), lineno=39, col_offset=11, end_lineno=39, end_col_offset=27), [Eq()], [Attribute(Name('self', Load(), lineno=39, col_offset=31, end_lineno=39, end_col_offset=35), 'placeholder_5', Load(), lineno=39, col_offset=31, end_lineno=39, end_col_offset=40)], lineno=39, col_offset=11, end_lineno=39, end_col_offset=40), [Assign([Attribute(Name('self', Load(), lineno=40, col_offset=12, end_lineno=40, end_col_offset=16), 'placeholder_7', Store(), lineno=40, col_offset=12, end_lineno=40, end_col_offset=23)], Name('placeholder_0', Load(), lineno=40, col_offset=26, end_lineno=40, end_col_offset=36), lineno=40, col_offset=12, end_lineno=40, end_col_offset=36)], [If(Compare(Attribute(Name('self', Load(), lineno=41, col_offset=13, end_lineno=41, end_col_offset=17), 'placeholder_6', Load(), lineno=41, col_offset=13, end_lineno=41, end_col_offset=35), [Lt()], [Constant(0, lineno=41, col_offset=38, end_lineno=41, end_col_offset=39)], lineno=41, col_offset=13, end_lineno=41, end_col_offset=39), [Assign([Attribute(Name('self', Load(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=16), 'placeholder_7', Store(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=23)], Name('placeholder_1', Load(), lineno=42, col_offset=26, end_lineno=42, end_col_offset=37), lineno=42, col_offset=12, end_lineno=42, end_col_offset=37)], [Assign([Attribute(Name('self', Load(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=16), 'placeholder_7', Store(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=23)], Name('placeholder_2', Load(), lineno=44, col_offset=26, end_lineno=44, end_col_offset=40), lineno=44, col_offset=12, end_lineno=44, end_col_offset=40)], lineno=41, col_offset=8, end_lineno=44, end_col_offset=40)], lineno=39, col_offset=8, end_lineno=44, end_col_offset=40)], [], lineno=38, col_offset=4, end_lineno=44, end_col_offset=40), FunctionDef('placeholder_17', arguments([], [arg('self', lineno=46, col_offset=24, end_lineno=46, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=47, col_offset=15, end_lineno=47, end_col_offset=19), 'placeholder_8', Load(), lineno=47, col_offset=15, end_lineno=47, end_col_offset=31), lineno=47, col_offset=8, end_lineno=47, end_col_offset=31)], [], lineno=46, col_offset=4, end_lineno=47, end_col_offset=31), FunctionDef('placeholder_18', arguments([], [arg('self', lineno=49, col_offset=19, end_lineno=49, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=50, col_offset=15, end_lineno=50, end_col_offset=19), 'placeholder_7', Load(), lineno=50, col_offset=15, end_lineno=50, end_col_offset=26), lineno=50, col_offset=8, end_lineno=50, end_col_offset=26)], [], lineno=49, col_offset=4, end_lineno=50, end_col_offset=26)], [], lineno=6, col_offset=0, end_lineno=50, end_col_offset=26)], []) \ No newline at end of file diff --git a/test/practice-hello-world/.meta/config.json b/test/practice-hello-world/.meta/config.json new file mode 100644 index 0000000..fc3599f --- /dev/null +++ b/test/practice-hello-world/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [ + "michaelem" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "hebertjulio", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "NobbZ", + "pheanex", + "skeskali", + "Sukhj1nder", + "tqa236" + ], + "files": { + "solution": [ + "hello_world.py" + ], + "test": [ + "hello_world_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "The classical introductory exercise. Just say \"Hello, World!\".", + "source": "This is an exercise to introduce users to using Exercism", + "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" +} diff --git a/test/practice-hello-world/hello_world.py b/test/practice-hello-world/hello_world.py new file mode 100644 index 0000000..d695ea1 --- /dev/null +++ b/test/practice-hello-world/hello_world.py @@ -0,0 +1,2 @@ +def hello(): + return 'Hello, World!' diff --git a/test/practice-hello-world/mapping.json b/test/practice-hello-world/mapping.json new file mode 100644 index 0000000..d5276a1 --- /dev/null +++ b/test/practice-hello-world/mapping.json @@ -0,0 +1,3 @@ +{ + "placeholder_0": "hello" +} \ No newline at end of file diff --git a/test/practice-hello-world/representation.json b/test/practice-hello-world/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-hello-world/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-hello-world/representation.out b/test/practice-hello-world/representation.out new file mode 100644 index 0000000..4d3b1fe --- /dev/null +++ b/test/practice-hello-world/representation.out @@ -0,0 +1,67 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(): + return "Hello, World!" + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'hello', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Constant( + 'Hello, World!', + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=26), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=26)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Constant( + 'Hello, World!', + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=26), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=26)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-hello-world/representation.txt b/test/practice-hello-world/representation.txt new file mode 100644 index 0000000..8e14bc5 --- /dev/null +++ b/test/practice-hello-world/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Constant('Hello, World!', lineno=2, col_offset=11, end_lineno=2, end_col_offset=26), lineno=2, col_offset=4, end_lineno=2, end_col_offset=26)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=26)], []) \ No newline at end of file diff --git a/test/practice-hexadecimal/.meta/config.json b/test/practice-hexadecimal/.meta/config.json new file mode 100644 index 0000000..b61e1a2 --- /dev/null +++ b/test/practice-hexadecimal/.meta/config.json @@ -0,0 +1,30 @@ +{ + "blurb": "Convert a hexadecimal number, represented as a string (e.g. \"10af8c\"), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion).", + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "hexadecimal.py" + ], + "test": [ + "hexadecimal_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "All of Computer Science", + "source_url": "https://www.wolframalpha.com/examples/mathematics/numbers/base-conversions" +} diff --git a/test/practice-hexadecimal/hexadecimal.py b/test/practice-hexadecimal/hexadecimal.py new file mode 100644 index 0000000..672321a --- /dev/null +++ b/test/practice-hexadecimal/hexadecimal.py @@ -0,0 +1,10 @@ +from functools import reduce + + +def hexa(hex_string): + hex_string = hex_string.lower() + if set(hex_string) - set('0123456789abcdef'): + raise ValueError('Invalid hexadecimal string') + digits = [ord(letter) - ord('a') + 10 if letter in 'abcdef' else ord(letter) - ord('0') + for letter in hex_string] + return reduce(lambda var_1, var_2: var_1 * 16 + var_2, digits, 0) diff --git a/test/practice-hexadecimal/mapping.json b/test/practice-hexadecimal/mapping.json new file mode 100644 index 0000000..aa95644 --- /dev/null +++ b/test/practice-hexadecimal/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "hexa", + "placeholder_1": "hex_string", + "placeholder_2": "digits", + "placeholder_3": "letter", + "placeholder_4": "var_1", + "placeholder_5": "var_2" +} \ No newline at end of file diff --git a/test/practice-hexadecimal/representation.json b/test/practice-hexadecimal/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-hexadecimal/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-hexadecimal/representation.out b/test/practice-hexadecimal/representation.out new file mode 100644 index 0000000..4048786 --- /dev/null +++ b/test/practice-hexadecimal/representation.out @@ -0,0 +1,837 @@ +## BEGIN NORMALIZED CODE ## +from functools import reduce + + +def placeholder_0(placeholder_1): + placeholder_1 = placeholder_1.lower() + if set(placeholder_1) - set("0123456789abcdef"): + raise ValueError("Invalid hexadecimal string") + placeholder_2 = [ + ord(placeholder_3) - ord("a") + 10 + if placeholder_3 in "abcdef" + else ord(placeholder_3) - ord("0") + for placeholder_3 in placeholder_1 + ] + return reduce( + lambda placeholder_4, placeholder_5: placeholder_4 * 16 + placeholder_5, + placeholder_2, + 0, + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'functools', + [ + alias( + 'reduce', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=28)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=28), + FunctionDef( + 'hexa', + arguments( + [], + [ + arg( + 'hex_string', + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'hex_string', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=14)], + Call( + Attribute( + Name( + 'hex_string', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=27), + 'lower', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=33), + [], + [], + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=35), + If( + BinOp( + Call( + Name( + 'set', + Load(), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=10), + [ + Name( + 'hex_string', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=21)], + [], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=22), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=28), + [ + Constant( + '0123456789abcdef', + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=47)], + [], + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=48), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=48), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'Invalid hexadecimal string', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=53)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=54), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=54)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=54), + Assign( + [ + Name( + 'digits', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10)], + ListComp( + IfExp( + Compare( + Name( + 'letter', + Load(), + lineno=8, + col_offset=45, + end_lineno=8, + end_col_offset=51), + [ + In()], + [ + Constant( + 'abcdef', + lineno=8, + col_offset=55, + end_lineno=8, + end_col_offset=63)], + lineno=8, + col_offset=45, + end_lineno=8, + end_col_offset=63), + BinOp( + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=17), + [ + Name( + 'letter', + Load(), + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=24)], + [], + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=25), + Sub(), + Call( + Name( + 'ord', + Load(), + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=31), + [ + Constant( + 'a', + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=35)], + [], + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=36), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=36), + Add(), + Constant( + 10, + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=41), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=41), + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=72), + [ + Name( + 'letter', + Load(), + lineno=8, + col_offset=73, + end_lineno=8, + end_col_offset=79)], + [], + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=80), + Sub(), + Call( + Name( + 'ord', + Load(), + lineno=8, + col_offset=83, + end_lineno=8, + end_col_offset=86), + [ + Constant( + '0', + lineno=8, + col_offset=87, + end_lineno=8, + end_col_offset=90)], + [], + lineno=8, + col_offset=83, + end_lineno=8, + end_col_offset=91), + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=91), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=91), + [ + comprehension( + Name( + 'letter', + Store(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=24), + Name( + 'hex_string', + Load(), + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=38), + [], + 0)], + lineno=8, + col_offset=13, + end_lineno=9, + end_col_offset=39), + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=39), + Return( + Call( + Name( + 'reduce', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=17), + [ + Lambda( + arguments( + [], + [ + arg( + 'var_1', + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=30), + arg( + 'var_2', + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + BinOp( + BinOp( + Name( + 'var_1', + Load(), + lineno=10, + col_offset=39, + end_lineno=10, + end_col_offset=44), + Mult(), + Constant( + 16, + lineno=10, + col_offset=47, + end_lineno=10, + end_col_offset=49), + lineno=10, + col_offset=39, + end_lineno=10, + end_col_offset=49), + Add(), + Name( + 'var_2', + Load(), + lineno=10, + col_offset=52, + end_lineno=10, + end_col_offset=57), + lineno=10, + col_offset=39, + end_lineno=10, + end_col_offset=57), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=57), + Name( + 'digits', + Load(), + lineno=10, + col_offset=59, + end_lineno=10, + end_col_offset=65), + Constant( + 0, + lineno=10, + col_offset=67, + end_lineno=10, + end_col_offset=68)], + [], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=69), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=69)], + [], + lineno=4, + col_offset=0, + end_lineno=10, + end_col_offset=69)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'functools', + [ + alias( + 'reduce', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=28)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=28), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=14)], + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=27), + 'lower', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=33), + [], + [], + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=35), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=35), + If( + BinOp( + Call( + Name( + 'set', + Load(), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=10), + [ + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=21)], + [], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=22), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=28), + [ + Constant( + '0123456789abcdef', + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=47)], + [], + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=48), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=48), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'Invalid hexadecimal string', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=53)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=54), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=54)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=54), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10)], + ListComp( + IfExp( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=45, + end_lineno=8, + end_col_offset=51), + [ + In()], + [ + Constant( + 'abcdef', + lineno=8, + col_offset=55, + end_lineno=8, + end_col_offset=63)], + lineno=8, + col_offset=45, + end_lineno=8, + end_col_offset=63), + BinOp( + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=17), + [ + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=24)], + [], + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=25), + Sub(), + Call( + Name( + 'ord', + Load(), + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=31), + [ + Constant( + 'a', + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=35)], + [], + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=36), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=36), + Add(), + Constant( + 10, + lineno=8, + col_offset=39, + end_lineno=8, + end_col_offset=41), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=41), + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=72), + [ + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=73, + end_lineno=8, + end_col_offset=79)], + [], + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=80), + Sub(), + Call( + Name( + 'ord', + Load(), + lineno=8, + col_offset=83, + end_lineno=8, + end_col_offset=86), + [ + Constant( + '0', + lineno=8, + col_offset=87, + end_lineno=8, + end_col_offset=90)], + [], + lineno=8, + col_offset=83, + end_lineno=8, + end_col_offset=91), + lineno=8, + col_offset=69, + end_lineno=8, + end_col_offset=91), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=91), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=24), + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=38), + [], + 0)], + lineno=8, + col_offset=13, + end_lineno=9, + end_col_offset=39), + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=39), + Return( + Call( + Name( + 'reduce', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=17), + [ + Lambda( + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=30), + arg( + 'placeholder_5', + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + BinOp( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=39, + end_lineno=10, + end_col_offset=44), + Mult(), + Constant( + 16, + lineno=10, + col_offset=47, + end_lineno=10, + end_col_offset=49), + lineno=10, + col_offset=39, + end_lineno=10, + end_col_offset=49), + Add(), + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=52, + end_lineno=10, + end_col_offset=57), + lineno=10, + col_offset=39, + end_lineno=10, + end_col_offset=57), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=57), + Name( + 'placeholder_2', + Load(), + lineno=10, + col_offset=59, + end_lineno=10, + end_col_offset=65), + Constant( + 0, + lineno=10, + col_offset=67, + end_lineno=10, + end_col_offset=68)], + [], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=69), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=69)], + [], + lineno=4, + col_offset=0, + end_lineno=10, + end_col_offset=69)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-hexadecimal/representation.txt b/test/practice-hexadecimal/representation.txt new file mode 100644 index 0000000..e47a037 --- /dev/null +++ b/test/practice-hexadecimal/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('functools', [alias('reduce', lineno=1, col_offset=22, end_lineno=1, end_col_offset=28)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=28), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=9, end_lineno=4, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_1', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=14)], Call(Attribute(Name('placeholder_1', Load(), lineno=5, col_offset=17, end_lineno=5, end_col_offset=27), 'lower', Load(), lineno=5, col_offset=17, end_lineno=5, end_col_offset=33), [], [], lineno=5, col_offset=17, end_lineno=5, end_col_offset=35), lineno=5, col_offset=4, end_lineno=5, end_col_offset=35), If(BinOp(Call(Name('set', Load(), lineno=6, col_offset=7, end_lineno=6, end_col_offset=10), [Name('placeholder_1', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=21)], [], lineno=6, col_offset=7, end_lineno=6, end_col_offset=22), Sub(), Call(Name('set', Load(), lineno=6, col_offset=25, end_lineno=6, end_col_offset=28), [Constant('0123456789abcdef', lineno=6, col_offset=29, end_lineno=6, end_col_offset=47)], [], lineno=6, col_offset=25, end_lineno=6, end_col_offset=48), lineno=6, col_offset=7, end_lineno=6, end_col_offset=48), [Raise(Call(Name('ValueError', Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=24), [Constant('Invalid hexadecimal string', lineno=7, col_offset=25, end_lineno=7, end_col_offset=53)], [], lineno=7, col_offset=14, end_lineno=7, end_col_offset=54), lineno=7, col_offset=8, end_lineno=7, end_col_offset=54)], [], lineno=6, col_offset=4, end_lineno=7, end_col_offset=54), Assign([Name('placeholder_2', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=10)], ListComp(IfExp(Compare(Name('placeholder_3', Load(), lineno=8, col_offset=45, end_lineno=8, end_col_offset=51), [In()], [Constant('abcdef', lineno=8, col_offset=55, end_lineno=8, end_col_offset=63)], lineno=8, col_offset=45, end_lineno=8, end_col_offset=63), BinOp(BinOp(Call(Name('ord', Load(), lineno=8, col_offset=14, end_lineno=8, end_col_offset=17), [Name('placeholder_3', Load(), lineno=8, col_offset=18, end_lineno=8, end_col_offset=24)], [], lineno=8, col_offset=14, end_lineno=8, end_col_offset=25), Sub(), Call(Name('ord', Load(), lineno=8, col_offset=28, end_lineno=8, end_col_offset=31), [Constant('a', lineno=8, col_offset=32, end_lineno=8, end_col_offset=35)], [], lineno=8, col_offset=28, end_lineno=8, end_col_offset=36), lineno=8, col_offset=14, end_lineno=8, end_col_offset=36), Add(), Constant(10, lineno=8, col_offset=39, end_lineno=8, end_col_offset=41), lineno=8, col_offset=14, end_lineno=8, end_col_offset=41), BinOp(Call(Name('ord', Load(), lineno=8, col_offset=69, end_lineno=8, end_col_offset=72), [Name('placeholder_3', Load(), lineno=8, col_offset=73, end_lineno=8, end_col_offset=79)], [], lineno=8, col_offset=69, end_lineno=8, end_col_offset=80), Sub(), Call(Name('ord', Load(), lineno=8, col_offset=83, end_lineno=8, end_col_offset=86), [Constant('0', lineno=8, col_offset=87, end_lineno=8, end_col_offset=90)], [], lineno=8, col_offset=83, end_lineno=8, end_col_offset=91), lineno=8, col_offset=69, end_lineno=8, end_col_offset=91), lineno=8, col_offset=14, end_lineno=8, end_col_offset=91), [comprehension(Name('placeholder_3', Store(), lineno=9, col_offset=18, end_lineno=9, end_col_offset=24), Name('placeholder_1', Load(), lineno=9, col_offset=28, end_lineno=9, end_col_offset=38), [], 0)], lineno=8, col_offset=13, end_lineno=9, end_col_offset=39), lineno=8, col_offset=4, end_lineno=9, end_col_offset=39), Return(Call(Name('reduce', Load(), lineno=10, col_offset=11, end_lineno=10, end_col_offset=17), [Lambda(arguments([], [arg('placeholder_4', lineno=10, col_offset=25, end_lineno=10, end_col_offset=30), arg('placeholder_5', lineno=10, col_offset=32, end_lineno=10, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), BinOp(BinOp(Name('placeholder_4', Load(), lineno=10, col_offset=39, end_lineno=10, end_col_offset=44), Mult(), Constant(16, lineno=10, col_offset=47, end_lineno=10, end_col_offset=49), lineno=10, col_offset=39, end_lineno=10, end_col_offset=49), Add(), Name('placeholder_5', Load(), lineno=10, col_offset=52, end_lineno=10, end_col_offset=57), lineno=10, col_offset=39, end_lineno=10, end_col_offset=57), lineno=10, col_offset=18, end_lineno=10, end_col_offset=57), Name('placeholder_2', Load(), lineno=10, col_offset=59, end_lineno=10, end_col_offset=65), Constant(0, lineno=10, col_offset=67, end_lineno=10, end_col_offset=68)], [], lineno=10, col_offset=11, end_lineno=10, end_col_offset=69), lineno=10, col_offset=4, end_lineno=10, end_col_offset=69)], [], lineno=4, col_offset=0, end_lineno=10, end_col_offset=69)], []) \ No newline at end of file diff --git a/test/practice-high-scores/.meta/config.json b/test/practice-high-scores/.meta/config.json new file mode 100644 index 0000000..c712113 --- /dev/null +++ b/test/practice-high-scores/.meta/config.json @@ -0,0 +1,29 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "gabriel376", + "GascaK", + "IsaacG", + "simmol", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "high_scores.py" + ], + "test": [ + "high_scores_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Manage a player's High Score list.", + "source": "Tribute to the eighties' arcade game Frogger" +} diff --git a/test/practice-high-scores/high_scores.py b/test/practice-high-scores/high_scores.py new file mode 100644 index 0000000..d9f6066 --- /dev/null +++ b/test/practice-high-scores/high_scores.py @@ -0,0 +1,12 @@ +class HighScores: + def __init__(self, scores): + self.scores = scores + + def latest(self): + return self.scores[-1] + + def personal_best(self): + return max(self.scores) + + def personal_top_three(self): + return sorted(self.scores, reverse=True)[:3] diff --git a/test/practice-high-scores/mapping.json b/test/practice-high-scores/mapping.json new file mode 100644 index 0000000..135ea1c --- /dev/null +++ b/test/practice-high-scores/mapping.json @@ -0,0 +1,9 @@ +{ + "placeholder_0": "HighScores", + "placeholder_1": "__init__", + "placeholder_2": "scores", + "placeholder_3": "latest", + "placeholder_4": "personal_best", + "placeholder_5": "personal_top_three", + "placeholder_6": "reverse" +} \ No newline at end of file diff --git a/test/practice-high-scores/representation.json b/test/practice-high-scores/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-high-scores/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-high-scores/representation.out b/test/practice-high-scores/representation.out new file mode 100644 index 0000000..fa84b22 --- /dev/null +++ b/test/practice-high-scores/representation.out @@ -0,0 +1,537 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2): + self.placeholder_2 = placeholder_2 + + def placeholder_3(self): + return self.placeholder_2[-1] + + def placeholder_4(self): + return max(self.placeholder_2) + + def placeholder_5(self): + return sorted(self.placeholder_2, placeholder_6=True)[:3] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'HighScores', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'scores', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'scores', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=19)], + Name( + 'scores', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=28), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=28)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=28), + FunctionDef( + 'latest', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=19), + 'scores', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=26), + UnaryOp( + USub(), + Constant( + 1, + lineno=6, + col_offset=28, + end_lineno=6, + end_col_offset=29), + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=29), + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=30), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=30)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=30), + FunctionDef( + 'personal_best', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'max', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=18), + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=23), + 'scores', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=30)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=31), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=31)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=31), + FunctionDef( + 'personal_top_three', + arguments( + [], + [ + arg( + 'self', + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Call( + Name( + 'sorted', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=21), + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=26), + 'scores', + Load(), + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=33)], + [ + keyword( + 'reverse', + Constant( + True, + lineno=12, + col_offset=43, + end_lineno=12, + end_col_offset=47), + lineno=12, + col_offset=35, + end_lineno=12, + end_col_offset=47)], + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=48), + Slice( + upper=Constant( + 3, + lineno=12, + col_offset=50, + end_lineno=12, + end_col_offset=51), + lineno=12, + col_offset=49, + end_lineno=12, + end_col_offset=51), + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=52), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=52)], + [], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=52)], + [], + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=52)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=19)], + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=28), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=28)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=28), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=26), + UnaryOp( + USub(), + Constant( + 1, + lineno=6, + col_offset=28, + end_lineno=6, + end_col_offset=29), + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=29), + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=30), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=30)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=30), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=22, + end_lineno=8, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'max', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=18), + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=23), + 'placeholder_2', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=30)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=31), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=31)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=31), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Call( + Name( + 'sorted', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=21), + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=26), + 'placeholder_2', + Load(), + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=33)], + [ + keyword( + 'placeholder_6', + Constant( + True, + lineno=12, + col_offset=43, + end_lineno=12, + end_col_offset=47), + lineno=12, + col_offset=35, + end_lineno=12, + end_col_offset=47)], + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=48), + Slice( + upper=Constant( + 3, + lineno=12, + col_offset=50, + end_lineno=12, + end_col_offset=51), + lineno=12, + col_offset=49, + end_lineno=12, + end_col_offset=51), + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=52), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=52)], + [], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=52)], + [], + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=52)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-high-scores/representation.txt b/test/practice-high-scores/representation.txt new file mode 100644 index 0000000..c9ae0be --- /dev/null +++ b/test/practice-high-scores/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_2', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=19)], Name('placeholder_2', Load(), lineno=3, col_offset=22, end_lineno=3, end_col_offset=28), lineno=3, col_offset=8, end_lineno=3, end_col_offset=28)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=28), FunctionDef('placeholder_3', arguments([], [arg('self', lineno=5, col_offset=15, end_lineno=5, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Subscript(Attribute(Name('self', Load(), lineno=6, col_offset=15, end_lineno=6, end_col_offset=19), 'placeholder_2', Load(), lineno=6, col_offset=15, end_lineno=6, end_col_offset=26), UnaryOp(USub(), Constant(1, lineno=6, col_offset=28, end_lineno=6, end_col_offset=29), lineno=6, col_offset=27, end_lineno=6, end_col_offset=29), Load(), lineno=6, col_offset=15, end_lineno=6, end_col_offset=30), lineno=6, col_offset=8, end_lineno=6, end_col_offset=30)], [], lineno=5, col_offset=4, end_lineno=6, end_col_offset=30), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=8, col_offset=22, end_lineno=8, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('max', Load(), lineno=9, col_offset=15, end_lineno=9, end_col_offset=18), [Attribute(Name('self', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=23), 'placeholder_2', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=30)], [], lineno=9, col_offset=15, end_lineno=9, end_col_offset=31), lineno=9, col_offset=8, end_lineno=9, end_col_offset=31)], [], lineno=8, col_offset=4, end_lineno=9, end_col_offset=31), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=11, col_offset=27, end_lineno=11, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Subscript(Call(Name('sorted', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=21), [Attribute(Name('self', Load(), lineno=12, col_offset=22, end_lineno=12, end_col_offset=26), 'placeholder_2', Load(), lineno=12, col_offset=22, end_lineno=12, end_col_offset=33)], [keyword('placeholder_6', Constant(True, lineno=12, col_offset=43, end_lineno=12, end_col_offset=47), lineno=12, col_offset=35, end_lineno=12, end_col_offset=47)], lineno=12, col_offset=15, end_lineno=12, end_col_offset=48), Slice(upper=Constant(3, lineno=12, col_offset=50, end_lineno=12, end_col_offset=51), lineno=12, col_offset=49, end_lineno=12, end_col_offset=51), Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=52), lineno=12, col_offset=8, end_lineno=12, end_col_offset=52)], [], lineno=11, col_offset=4, end_lineno=12, end_col_offset=52)], [], lineno=1, col_offset=0, end_lineno=12, end_col_offset=52)], []) \ No newline at end of file diff --git a/test/practice-house/.meta/config.json b/test/practice-house/.meta/config.json new file mode 100644 index 0000000..328c8c9 --- /dev/null +++ b/test/practice-house/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "dvermd", + "kytrinyx", + "MartinDelille", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "house.py" + ], + "test": [ + "house_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Output the nursery rhyme 'This is the House that Jack Built'.", + "source": "British nursery rhyme", + "source_url": "https://en.wikipedia.org/wiki/This_Is_The_House_That_Jack_Built" +} diff --git a/test/practice-house/house.py b/test/practice-house/house.py new file mode 100644 index 0000000..30e289b --- /dev/null +++ b/test/practice-house/house.py @@ -0,0 +1,23 @@ +PARTS = [('lay in', 'the house that Jack built.'), + ('ate', 'the malt'), + ('killed', 'the rat'), + ('worried', 'the cat'), + ('tossed', 'the dog'), + ('milked', 'the cow with the crumpled horn'), + ('kissed', 'the maiden all forlorn'), + ('married', 'the man all tattered and torn'), + ('woke', 'the priest all shaven and shorn'), + ('kept', 'the rooster that crowed in the morn'), + ('belonged to', 'the farmer sowing his corn'), + ('', 'the horse and the hound and the horn')] + + +def verse(verse_num): + verse = [f'This is {PARTS[verse_num][1]}'] + verse.extend(['that {0} {1}'.format(*PARTS[idx]) + for idx in range(verse_num - 1, -1, -1)]) + return ' '.join(verse) + + +def recite(start_verse, end_verse): + return [verse(verse_num) for verse_num in range(start_verse-1, end_verse)] diff --git a/test/practice-house/mapping.json b/test/practice-house/mapping.json new file mode 100644 index 0000000..01b0f57 --- /dev/null +++ b/test/practice-house/mapping.json @@ -0,0 +1,9 @@ +{ + "placeholder_0": "PARTS", + "placeholder_1": "verse", + "placeholder_2": "verse_num", + "placeholder_3": "idx", + "placeholder_4": "recite", + "placeholder_5": "start_verse", + "placeholder_6": "end_verse" +} \ No newline at end of file diff --git a/test/practice-house/representation.json b/test/practice-house/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-house/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-house/representation.out b/test/practice-house/representation.out new file mode 100644 index 0000000..a25fb90 --- /dev/null +++ b/test/practice-house/representation.out @@ -0,0 +1,1293 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = [ + ("lay in", "the house that Jack built."), + ("ate", "the malt"), + ("killed", "the rat"), + ("worried", "the cat"), + ("tossed", "the dog"), + ("milked", "the cow with the crumpled horn"), + ("kissed", "the maiden all forlorn"), + ("married", "the man all tattered and torn"), + ("woke", "the priest all shaven and shorn"), + ("kept", "the rooster that crowed in the morn"), + ("belonged to", "the farmer sowing his corn"), + ("", "the horse and the hound and the horn"), +] + + +def placeholder_1(placeholder_2): + placeholder_1 = [f"This is {placeholder_0[placeholder_2][1]}"] + placeholder_1.extend( + [ + "that {0} {1}".format(*placeholder_0[placeholder_3]) + for placeholder_3 in range(placeholder_2 - 1, -1, -1) + ] + ) + return " ".join(placeholder_1) + + +def placeholder_4(placeholder_5, placeholder_6): + return [ + placeholder_1(placeholder_2) + for placeholder_2 in range(placeholder_5 - 1, placeholder_6) + ] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'PARTS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=5)], + List( + [ + Tuple( + [ + Constant( + 'lay in', + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=18), + Constant( + 'the house that Jack built.', + lineno=1, + col_offset=20, + end_lineno=1, + end_col_offset=48)], + Load(), + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=49), + Tuple( + [ + Constant( + 'ate', + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=15), + Constant( + 'the malt', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=27)], + Load(), + lineno=2, + col_offset=9, + end_lineno=2, + end_col_offset=28), + Tuple( + [ + Constant( + 'killed', + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=18), + Constant( + 'the rat', + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=29)], + Load(), + lineno=3, + col_offset=9, + end_lineno=3, + end_col_offset=30), + Tuple( + [ + Constant( + 'worried', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=19), + Constant( + 'the cat', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=30)], + Load(), + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=31), + Tuple( + [ + Constant( + 'tossed', + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=18), + Constant( + 'the dog', + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=29)], + Load(), + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=30), + Tuple( + [ + Constant( + 'milked', + lineno=6, + col_offset=10, + end_lineno=6, + end_col_offset=18), + Constant( + 'the cow with the crumpled horn', + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=52)], + Load(), + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=53), + Tuple( + [ + Constant( + 'kissed', + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=18), + Constant( + 'the maiden all forlorn', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=44)], + Load(), + lineno=7, + col_offset=9, + end_lineno=7, + end_col_offset=45), + Tuple( + [ + Constant( + 'married', + lineno=8, + col_offset=10, + end_lineno=8, + end_col_offset=19), + Constant( + 'the man all tattered and torn', + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=52)], + Load(), + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=53), + Tuple( + [ + Constant( + 'woke', + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=16), + Constant( + 'the priest all shaven and shorn', + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=51)], + Load(), + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=52), + Tuple( + [ + Constant( + 'kept', + lineno=10, + col_offset=10, + end_lineno=10, + end_col_offset=16), + Constant( + 'the rooster that crowed in the morn', + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=55)], + Load(), + lineno=10, + col_offset=9, + end_lineno=10, + end_col_offset=56), + Tuple( + [ + Constant( + 'belonged to', + lineno=11, + col_offset=10, + end_lineno=11, + end_col_offset=23), + Constant( + 'the farmer sowing his corn', + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=53)], + Load(), + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=54), + Tuple( + [ + Constant( + '', + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=12), + Constant( + 'the horse and the hound and the horn', + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=52)], + Load(), + lineno=12, + col_offset=9, + end_lineno=12, + end_col_offset=53)], + Load(), + lineno=1, + col_offset=8, + end_lineno=12, + end_col_offset=54), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=54), + FunctionDef( + 'verse', + arguments( + [], + [ + arg( + 'verse_num', + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'verse', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=9)], + List( + [ + JoinedStr( + [ + Constant( + 'This is ', + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=45), + FormattedValue( + Subscript( + Subscript( + Name( + 'PARTS', + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=29), + Name( + 'verse_num', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=39), + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=40), + Constant( + 1, + lineno=16, + col_offset=41, + end_lineno=16, + end_col_offset=42), + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=43), + -1, + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=45)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=45)], + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=46), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=46), + Expr( + Call( + Attribute( + Name( + 'verse', + Load(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=9), + 'extend', + Load(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=16), + [ + ListComp( + Call( + Attribute( + Constant( + 'that {0} {1}', + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=32), + 'format', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=39), + [ + Starred( + Subscript( + Name( + 'PARTS', + Load(), + lineno=17, + col_offset=41, + end_lineno=17, + end_col_offset=46), + Name( + 'idx', + Load(), + lineno=17, + col_offset=47, + end_lineno=17, + end_col_offset=50), + Load(), + lineno=17, + col_offset=41, + end_lineno=17, + end_col_offset=51), + Load(), + lineno=17, + col_offset=40, + end_lineno=17, + end_col_offset=51)], + [], + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=52), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=21), + Call( + Name( + 'range', + Load(), + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=30), + [ + BinOp( + Name( + 'verse_num', + Load(), + lineno=18, + col_offset=31, + end_lineno=18, + end_col_offset=40), + Sub(), + Constant( + 1, + lineno=18, + col_offset=43, + end_lineno=18, + end_col_offset=44), + lineno=18, + col_offset=31, + end_lineno=18, + end_col_offset=44), + UnaryOp( + USub(), + Constant( + 1, + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=48), + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=48), + UnaryOp( + USub(), + Constant( + 1, + lineno=18, + col_offset=51, + end_lineno=18, + end_col_offset=52), + lineno=18, + col_offset=50, + end_lineno=18, + end_col_offset=52)], + [], + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=53), + [], + 0)], + lineno=17, + col_offset=17, + end_lineno=18, + end_col_offset=54)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=55), + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=55), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=14), + 'join', + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=19), + [ + Name( + 'verse', + Load(), + lineno=19, + col_offset=20, + end_lineno=19, + end_col_offset=25)], + [], + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=26), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=26)], + [], + lineno=15, + col_offset=0, + end_lineno=19, + end_col_offset=26), + FunctionDef( + 'recite', + arguments( + [], + [ + arg( + 'start_verse', + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=22), + arg( + 'end_verse', + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'verse', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + [ + Name( + 'verse_num', + Load(), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=27)], + [], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=28), + [ + comprehension( + Name( + 'verse_num', + Store(), + lineno=23, + col_offset=33, + end_lineno=23, + end_col_offset=42), + Call( + Name( + 'range', + Load(), + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=51), + [ + BinOp( + Name( + 'start_verse', + Load(), + lineno=23, + col_offset=52, + end_lineno=23, + end_col_offset=63), + Sub(), + Constant( + 1, + lineno=23, + col_offset=64, + end_lineno=23, + end_col_offset=65), + lineno=23, + col_offset=52, + end_lineno=23, + end_col_offset=65), + Name( + 'end_verse', + Load(), + lineno=23, + col_offset=67, + end_lineno=23, + end_col_offset=76)], + [], + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=77), + [], + 0)], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=78), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=78)], + [], + lineno=22, + col_offset=0, + end_lineno=23, + end_col_offset=78)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=5)], + List( + [ + Tuple( + [ + Constant( + 'lay in', + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=18), + Constant( + 'the house that Jack built.', + lineno=1, + col_offset=20, + end_lineno=1, + end_col_offset=48)], + Load(), + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=49), + Tuple( + [ + Constant( + 'ate', + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=15), + Constant( + 'the malt', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=27)], + Load(), + lineno=2, + col_offset=9, + end_lineno=2, + end_col_offset=28), + Tuple( + [ + Constant( + 'killed', + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=18), + Constant( + 'the rat', + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=29)], + Load(), + lineno=3, + col_offset=9, + end_lineno=3, + end_col_offset=30), + Tuple( + [ + Constant( + 'worried', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=19), + Constant( + 'the cat', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=30)], + Load(), + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=31), + Tuple( + [ + Constant( + 'tossed', + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=18), + Constant( + 'the dog', + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=29)], + Load(), + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=30), + Tuple( + [ + Constant( + 'milked', + lineno=6, + col_offset=10, + end_lineno=6, + end_col_offset=18), + Constant( + 'the cow with the crumpled horn', + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=52)], + Load(), + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=53), + Tuple( + [ + Constant( + 'kissed', + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=18), + Constant( + 'the maiden all forlorn', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=44)], + Load(), + lineno=7, + col_offset=9, + end_lineno=7, + end_col_offset=45), + Tuple( + [ + Constant( + 'married', + lineno=8, + col_offset=10, + end_lineno=8, + end_col_offset=19), + Constant( + 'the man all tattered and torn', + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=52)], + Load(), + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=53), + Tuple( + [ + Constant( + 'woke', + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=16), + Constant( + 'the priest all shaven and shorn', + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=51)], + Load(), + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=52), + Tuple( + [ + Constant( + 'kept', + lineno=10, + col_offset=10, + end_lineno=10, + end_col_offset=16), + Constant( + 'the rooster that crowed in the morn', + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=55)], + Load(), + lineno=10, + col_offset=9, + end_lineno=10, + end_col_offset=56), + Tuple( + [ + Constant( + 'belonged to', + lineno=11, + col_offset=10, + end_lineno=11, + end_col_offset=23), + Constant( + 'the farmer sowing his corn', + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=53)], + Load(), + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=54), + Tuple( + [ + Constant( + '', + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=12), + Constant( + 'the horse and the hound and the horn', + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=52)], + Load(), + lineno=12, + col_offset=9, + end_lineno=12, + end_col_offset=53)], + Load(), + lineno=1, + col_offset=8, + end_lineno=12, + end_col_offset=54), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=54), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=9)], + List( + [ + JoinedStr( + [ + Constant( + 'This is ', + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=45), + FormattedValue( + Subscript( + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=29), + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=39), + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=40), + Constant( + 1, + lineno=16, + col_offset=41, + end_lineno=16, + end_col_offset=42), + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=43), + -1, + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=45)], + lineno=16, + col_offset=13, + end_lineno=16, + end_col_offset=45)], + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=46), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=46), + Expr( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=9), + 'extend', + Load(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=16), + [ + ListComp( + Call( + Attribute( + Constant( + 'that {0} {1}', + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=32), + 'format', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=39), + [ + Starred( + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=17, + col_offset=41, + end_lineno=17, + end_col_offset=46), + Name( + 'placeholder_3', + Load(), + lineno=17, + col_offset=47, + end_lineno=17, + end_col_offset=50), + Load(), + lineno=17, + col_offset=41, + end_lineno=17, + end_col_offset=51), + Load(), + lineno=17, + col_offset=40, + end_lineno=17, + end_col_offset=51)], + [], + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=52), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=21), + Call( + Name( + 'range', + Load(), + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=30), + [ + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=18, + col_offset=31, + end_lineno=18, + end_col_offset=40), + Sub(), + Constant( + 1, + lineno=18, + col_offset=43, + end_lineno=18, + end_col_offset=44), + lineno=18, + col_offset=31, + end_lineno=18, + end_col_offset=44), + UnaryOp( + USub(), + Constant( + 1, + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=48), + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=48), + UnaryOp( + USub(), + Constant( + 1, + lineno=18, + col_offset=51, + end_lineno=18, + end_col_offset=52), + lineno=18, + col_offset=50, + end_lineno=18, + end_col_offset=52)], + [], + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=53), + [], + 0)], + lineno=17, + col_offset=17, + end_lineno=18, + end_col_offset=54)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=55), + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=55), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=14), + 'join', + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=19), + [ + Name( + 'placeholder_1', + Load(), + lineno=19, + col_offset=20, + end_lineno=19, + end_col_offset=25)], + [], + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=26), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=26)], + [], + lineno=15, + col_offset=0, + end_lineno=19, + end_col_offset=26), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=22), + arg( + 'placeholder_6', + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'placeholder_1', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + [ + Name( + 'placeholder_2', + Load(), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=27)], + [], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=28), + [ + comprehension( + Name( + 'placeholder_2', + Store(), + lineno=23, + col_offset=33, + end_lineno=23, + end_col_offset=42), + Call( + Name( + 'range', + Load(), + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=51), + [ + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=23, + col_offset=52, + end_lineno=23, + end_col_offset=63), + Sub(), + Constant( + 1, + lineno=23, + col_offset=64, + end_lineno=23, + end_col_offset=65), + lineno=23, + col_offset=52, + end_lineno=23, + end_col_offset=65), + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=67, + end_lineno=23, + end_col_offset=76)], + [], + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=77), + [], + 0)], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=78), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=78)], + [], + lineno=22, + col_offset=0, + end_lineno=23, + end_col_offset=78)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-house/representation.txt b/test/practice-house/representation.txt new file mode 100644 index 0000000..611ad22 --- /dev/null +++ b/test/practice-house/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=5)], List([Tuple([Constant('lay in', lineno=1, col_offset=10, end_lineno=1, end_col_offset=18), Constant('the house that Jack built.', lineno=1, col_offset=20, end_lineno=1, end_col_offset=48)], Load(), lineno=1, col_offset=9, end_lineno=1, end_col_offset=49), Tuple([Constant('ate', lineno=2, col_offset=10, end_lineno=2, end_col_offset=15), Constant('the malt', lineno=2, col_offset=17, end_lineno=2, end_col_offset=27)], Load(), lineno=2, col_offset=9, end_lineno=2, end_col_offset=28), Tuple([Constant('killed', lineno=3, col_offset=10, end_lineno=3, end_col_offset=18), Constant('the rat', lineno=3, col_offset=20, end_lineno=3, end_col_offset=29)], Load(), lineno=3, col_offset=9, end_lineno=3, end_col_offset=30), Tuple([Constant('worried', lineno=4, col_offset=10, end_lineno=4, end_col_offset=19), Constant('the cat', lineno=4, col_offset=21, end_lineno=4, end_col_offset=30)], Load(), lineno=4, col_offset=9, end_lineno=4, end_col_offset=31), Tuple([Constant('tossed', lineno=5, col_offset=10, end_lineno=5, end_col_offset=18), Constant('the dog', lineno=5, col_offset=20, end_lineno=5, end_col_offset=29)], Load(), lineno=5, col_offset=9, end_lineno=5, end_col_offset=30), Tuple([Constant('milked', lineno=6, col_offset=10, end_lineno=6, end_col_offset=18), Constant('the cow with the crumpled horn', lineno=6, col_offset=20, end_lineno=6, end_col_offset=52)], Load(), lineno=6, col_offset=9, end_lineno=6, end_col_offset=53), Tuple([Constant('kissed', lineno=7, col_offset=10, end_lineno=7, end_col_offset=18), Constant('the maiden all forlorn', lineno=7, col_offset=20, end_lineno=7, end_col_offset=44)], Load(), lineno=7, col_offset=9, end_lineno=7, end_col_offset=45), Tuple([Constant('married', lineno=8, col_offset=10, end_lineno=8, end_col_offset=19), Constant('the man all tattered and torn', lineno=8, col_offset=21, end_lineno=8, end_col_offset=52)], Load(), lineno=8, col_offset=9, end_lineno=8, end_col_offset=53), Tuple([Constant('woke', lineno=9, col_offset=10, end_lineno=9, end_col_offset=16), Constant('the priest all shaven and shorn', lineno=9, col_offset=18, end_lineno=9, end_col_offset=51)], Load(), lineno=9, col_offset=9, end_lineno=9, end_col_offset=52), Tuple([Constant('kept', lineno=10, col_offset=10, end_lineno=10, end_col_offset=16), Constant('the rooster that crowed in the morn', lineno=10, col_offset=18, end_lineno=10, end_col_offset=55)], Load(), lineno=10, col_offset=9, end_lineno=10, end_col_offset=56), Tuple([Constant('belonged to', lineno=11, col_offset=10, end_lineno=11, end_col_offset=23), Constant('the farmer sowing his corn', lineno=11, col_offset=25, end_lineno=11, end_col_offset=53)], Load(), lineno=11, col_offset=9, end_lineno=11, end_col_offset=54), Tuple([Constant('', lineno=12, col_offset=10, end_lineno=12, end_col_offset=12), Constant('the horse and the hound and the horn', lineno=12, col_offset=14, end_lineno=12, end_col_offset=52)], Load(), lineno=12, col_offset=9, end_lineno=12, end_col_offset=53)], Load(), lineno=1, col_offset=8, end_lineno=12, end_col_offset=54), lineno=1, col_offset=0, end_lineno=12, end_col_offset=54), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=15, col_offset=10, end_lineno=15, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_1', Store(), lineno=16, col_offset=4, end_lineno=16, end_col_offset=9)], List([JoinedStr([Constant('This is ', lineno=16, col_offset=13, end_lineno=16, end_col_offset=45), FormattedValue(Subscript(Subscript(Name('placeholder_0', Load(), lineno=16, col_offset=24, end_lineno=16, end_col_offset=29), Name('placeholder_2', Load(), lineno=16, col_offset=30, end_lineno=16, end_col_offset=39), Load(), lineno=16, col_offset=24, end_lineno=16, end_col_offset=40), Constant(1, lineno=16, col_offset=41, end_lineno=16, end_col_offset=42), Load(), lineno=16, col_offset=24, end_lineno=16, end_col_offset=43), -1, lineno=16, col_offset=13, end_lineno=16, end_col_offset=45)], lineno=16, col_offset=13, end_lineno=16, end_col_offset=45)], Load(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=46), lineno=16, col_offset=4, end_lineno=16, end_col_offset=46), Expr(Call(Attribute(Name('placeholder_1', Load(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=9), 'extend', Load(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=16), [ListComp(Call(Attribute(Constant('that {0} {1}', lineno=17, col_offset=18, end_lineno=17, end_col_offset=32), 'format', Load(), lineno=17, col_offset=18, end_lineno=17, end_col_offset=39), [Starred(Subscript(Name('placeholder_0', Load(), lineno=17, col_offset=41, end_lineno=17, end_col_offset=46), Name('placeholder_3', Load(), lineno=17, col_offset=47, end_lineno=17, end_col_offset=50), Load(), lineno=17, col_offset=41, end_lineno=17, end_col_offset=51), Load(), lineno=17, col_offset=40, end_lineno=17, end_col_offset=51)], [], lineno=17, col_offset=18, end_lineno=17, end_col_offset=52), [comprehension(Name('placeholder_3', Store(), lineno=18, col_offset=18, end_lineno=18, end_col_offset=21), Call(Name('range', Load(), lineno=18, col_offset=25, end_lineno=18, end_col_offset=30), [BinOp(Name('placeholder_2', Load(), lineno=18, col_offset=31, end_lineno=18, end_col_offset=40), Sub(), Constant(1, lineno=18, col_offset=43, end_lineno=18, end_col_offset=44), lineno=18, col_offset=31, end_lineno=18, end_col_offset=44), UnaryOp(USub(), Constant(1, lineno=18, col_offset=47, end_lineno=18, end_col_offset=48), lineno=18, col_offset=46, end_lineno=18, end_col_offset=48), UnaryOp(USub(), Constant(1, lineno=18, col_offset=51, end_lineno=18, end_col_offset=52), lineno=18, col_offset=50, end_lineno=18, end_col_offset=52)], [], lineno=18, col_offset=25, end_lineno=18, end_col_offset=53), [], 0)], lineno=17, col_offset=17, end_lineno=18, end_col_offset=54)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=55), lineno=17, col_offset=4, end_lineno=18, end_col_offset=55), Return(Call(Attribute(Constant(' ', lineno=19, col_offset=11, end_lineno=19, end_col_offset=14), 'join', Load(), lineno=19, col_offset=11, end_lineno=19, end_col_offset=19), [Name('placeholder_1', Load(), lineno=19, col_offset=20, end_lineno=19, end_col_offset=25)], [], lineno=19, col_offset=11, end_lineno=19, end_col_offset=26), lineno=19, col_offset=4, end_lineno=19, end_col_offset=26)], [], lineno=15, col_offset=0, end_lineno=19, end_col_offset=26), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=22, col_offset=11, end_lineno=22, end_col_offset=22), arg('placeholder_6', lineno=22, col_offset=24, end_lineno=22, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Call(Name('placeholder_1', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=17), [Name('placeholder_2', Load(), lineno=23, col_offset=18, end_lineno=23, end_col_offset=27)], [], lineno=23, col_offset=12, end_lineno=23, end_col_offset=28), [comprehension(Name('placeholder_2', Store(), lineno=23, col_offset=33, end_lineno=23, end_col_offset=42), Call(Name('range', Load(), lineno=23, col_offset=46, end_lineno=23, end_col_offset=51), [BinOp(Name('placeholder_5', Load(), lineno=23, col_offset=52, end_lineno=23, end_col_offset=63), Sub(), Constant(1, lineno=23, col_offset=64, end_lineno=23, end_col_offset=65), lineno=23, col_offset=52, end_lineno=23, end_col_offset=65), Name('placeholder_6', Load(), lineno=23, col_offset=67, end_lineno=23, end_col_offset=76)], [], lineno=23, col_offset=46, end_lineno=23, end_col_offset=77), [], 0)], lineno=23, col_offset=11, end_lineno=23, end_col_offset=78), lineno=23, col_offset=4, end_lineno=23, end_col_offset=78)], [], lineno=22, col_offset=0, end_lineno=23, end_col_offset=78)], []) \ No newline at end of file diff --git a/test/practice-isbn-verifier/.meta/config.json b/test/practice-isbn-verifier/.meta/config.json new file mode 100644 index 0000000..78b6dcc --- /dev/null +++ b/test/practice-isbn-verifier/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "pheanex" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "isbn_verifier.py" + ], + "test": [ + "isbn_verifier_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Check if a given string is a valid ISBN-10 number.", + "source": "Converting a string into a number and some basic processing utilizing a relatable real world example.", + "source_url": "https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation" +} diff --git a/test/practice-isbn-verifier/isbn_verifier.py b/test/practice-isbn-verifier/isbn_verifier.py new file mode 100644 index 0000000..f2f14f3 --- /dev/null +++ b/test/practice-isbn-verifier/isbn_verifier.py @@ -0,0 +1,8 @@ +def is_valid(isbn): + chars = list(isbn.replace('-', '')) + if chars and chars[-1] == 'X': + chars[-1] = '10' + if not len(chars) == 10 or not all(char.isdigit() for char in chars): + return False + indices = list(range(10, 0, -1)) + return sum(int(char) * idx for char, idx in zip(chars, indices)) % 11 == 0 diff --git a/test/practice-isbn-verifier/mapping.json b/test/practice-isbn-verifier/mapping.json new file mode 100644 index 0000000..65fa618 --- /dev/null +++ b/test/practice-isbn-verifier/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "is_valid", + "placeholder_1": "isbn", + "placeholder_2": "chars", + "placeholder_3": "char", + "placeholder_4": "indices", + "placeholder_5": "idx" +} \ No newline at end of file diff --git a/test/practice-isbn-verifier/representation.json b/test/practice-isbn-verifier/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-isbn-verifier/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-isbn-verifier/representation.out b/test/practice-isbn-verifier/representation.out new file mode 100644 index 0000000..f0e4f6a --- /dev/null +++ b/test/practice-isbn-verifier/representation.out @@ -0,0 +1,1052 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = list(placeholder_1.replace("-", "")) + if placeholder_2 and placeholder_2[-1] == "X": + placeholder_2[-1] = "10" + if not len(placeholder_2) == 10 or not all( + (placeholder_3.isdigit() for placeholder_3 in placeholder_2) + ): + return False + placeholder_4 = list(range(10, 0, -1)) + return ( + sum( + ( + int(placeholder_3) * placeholder_5 + for placeholder_3, placeholder_5 in zip(placeholder_2, placeholder_4) + ) + ) + % 11 + == 0 + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'is_valid', + arguments( + [], + [ + arg( + 'isbn', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'chars', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9)], + Call( + Name( + 'list', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=16), + [ + Call( + Attribute( + Name( + 'isbn', + Load(), + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + 'replace', + Load(), + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=29), + [ + Constant( + '-', + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=33), + Constant( + '', + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=37)], + [], + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=38)], + [], + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=39), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=39), + If( + BoolOp( + And(), + [ + Name( + 'chars', + Load(), + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=12), + Compare( + Subscript( + Name( + 'chars', + Load(), + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=22), + UnaryOp( + USub(), + Constant( + 1, + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=25), + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=25), + Load(), + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=26), + [ + Eq()], + [ + Constant( + 'X', + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=33)], + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=33)], + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=33), + [ + Assign( + [ + Subscript( + Name( + 'chars', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=13), + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=16), + lineno=4, + col_offset=14, + end_lineno=4, + end_col_offset=16), + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=17)], + Constant( + '10', + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=24), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=24)], + [], + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=24), + If( + BoolOp( + Or(), + [ + UnaryOp( + Not(), + Compare( + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + Name( + 'chars', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=20)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 10, + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=27)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=27), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=27), + UnaryOp( + Not(), + Call( + Name( + 'all', + Load(), + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=38), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'char', + Load(), + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=43), + 'isdigit', + Load(), + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=51), + [], + [], + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=53), + [ + comprehension( + Name( + 'char', + Store(), + lineno=5, + col_offset=58, + end_lineno=5, + end_col_offset=62), + Name( + 'chars', + Load(), + lineno=5, + col_offset=66, + end_lineno=5, + end_col_offset=71), + [], + 0)], + lineno=5, + col_offset=38, + end_lineno=5, + end_col_offset=72)], + [], + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=72), + lineno=5, + col_offset=31, + end_lineno=5, + end_col_offset=72)], + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=72), + [ + Return( + Constant( + False, + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=20), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=20)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=20), + Assign( + [ + Name( + 'indices', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11)], + Call( + Name( + 'list', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=18), + [ + Call( + Name( + 'range', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 10, + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=27), + Constant( + 0, + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=30), + UnaryOp( + USub(), + Constant( + 1, + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=34), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=34)], + [], + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=35)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=36), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=36), + Return( + Compare( + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=14), + [ + GeneratorExp( + BinOp( + Call( + Name( + 'int', + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=18), + [ + Name( + 'char', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=23)], + [], + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=24), + Mult(), + Name( + 'idx', + Load(), + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=30), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=30), + [ + comprehension( + Tuple( + [ + Name( + 'char', + Store(), + lineno=8, + col_offset=35, + end_lineno=8, + end_col_offset=39), + Name( + 'idx', + Store(), + lineno=8, + col_offset=41, + end_lineno=8, + end_col_offset=44)], + Store(), + lineno=8, + col_offset=35, + end_lineno=8, + end_col_offset=44), + Call( + Name( + 'zip', + Load(), + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=51), + [ + Name( + 'chars', + Load(), + lineno=8, + col_offset=52, + end_lineno=8, + end_col_offset=57), + Name( + 'indices', + Load(), + lineno=8, + col_offset=59, + end_lineno=8, + end_col_offset=66)], + [], + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=67), + [], + 0)], + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=68)], + [], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=68), + Mod(), + Constant( + 11, + lineno=8, + col_offset=71, + end_lineno=8, + end_col_offset=73), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=73), + [ + Eq()], + [ + Constant( + 0, + lineno=8, + col_offset=77, + end_lineno=8, + end_col_offset=78)], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=78), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=78)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=78)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9)], + Call( + Name( + 'list', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=16), + [ + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + 'replace', + Load(), + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=29), + [ + Constant( + '-', + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=33), + Constant( + '', + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=37)], + [], + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=38)], + [], + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=39), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=39), + If( + BoolOp( + And(), + [ + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=12), + Compare( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=22), + UnaryOp( + USub(), + Constant( + 1, + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=25), + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=25), + Load(), + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=26), + [ + Eq()], + [ + Constant( + 'X', + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=33)], + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=33)], + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=33), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=13), + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=16), + lineno=4, + col_offset=14, + end_lineno=4, + end_col_offset=16), + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=17)], + Constant( + '10', + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=24), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=24)], + [], + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=24), + If( + BoolOp( + Or(), + [ + UnaryOp( + Not(), + Compare( + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=20)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 10, + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=27)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=27), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=27), + UnaryOp( + Not(), + Call( + Name( + 'all', + Load(), + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=38), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=43), + 'isdigit', + Load(), + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=51), + [], + [], + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=53), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=58, + end_lineno=5, + end_col_offset=62), + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=66, + end_lineno=5, + end_col_offset=71), + [], + 0)], + lineno=5, + col_offset=38, + end_lineno=5, + end_col_offset=72)], + [], + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=72), + lineno=5, + col_offset=31, + end_lineno=5, + end_col_offset=72)], + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=72), + [ + Return( + Constant( + False, + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=20), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=20)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=20), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11)], + Call( + Name( + 'list', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=18), + [ + Call( + Name( + 'range', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 10, + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=27), + Constant( + 0, + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=30), + UnaryOp( + USub(), + Constant( + 1, + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=34), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=34)], + [], + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=35)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=36), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=36), + Return( + Compare( + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=14), + [ + GeneratorExp( + BinOp( + Call( + Name( + 'int', + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=18), + [ + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=23)], + [], + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=24), + Mult(), + Name( + 'placeholder_5', + Load(), + lineno=8, + col_offset=27, + end_lineno=8, + end_col_offset=30), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=30), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_3', + Store(), + lineno=8, + col_offset=35, + end_lineno=8, + end_col_offset=39), + Name( + 'placeholder_5', + Store(), + lineno=8, + col_offset=41, + end_lineno=8, + end_col_offset=44)], + Store(), + lineno=8, + col_offset=35, + end_lineno=8, + end_col_offset=44), + Call( + Name( + 'zip', + Load(), + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=51), + [ + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=52, + end_lineno=8, + end_col_offset=57), + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=59, + end_lineno=8, + end_col_offset=66)], + [], + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=67), + [], + 0)], + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=68)], + [], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=68), + Mod(), + Constant( + 11, + lineno=8, + col_offset=71, + end_lineno=8, + end_col_offset=73), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=73), + [ + Eq()], + [ + Constant( + 0, + lineno=8, + col_offset=77, + end_lineno=8, + end_col_offset=78)], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=78), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=78)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=78)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-isbn-verifier/representation.txt b/test/practice-isbn-verifier/representation.txt new file mode 100644 index 0000000..a0d13dc --- /dev/null +++ b/test/practice-isbn-verifier/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=13, end_lineno=1, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=9)], Call(Name('list', Load(), lineno=2, col_offset=12, end_lineno=2, end_col_offset=16), [Call(Attribute(Name('placeholder_1', Load(), lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), 'replace', Load(), lineno=2, col_offset=17, end_lineno=2, end_col_offset=29), [Constant('-', lineno=2, col_offset=30, end_lineno=2, end_col_offset=33), Constant('', lineno=2, col_offset=35, end_lineno=2, end_col_offset=37)], [], lineno=2, col_offset=17, end_lineno=2, end_col_offset=38)], [], lineno=2, col_offset=12, end_lineno=2, end_col_offset=39), lineno=2, col_offset=4, end_lineno=2, end_col_offset=39), If(BoolOp(And(), [Name('placeholder_2', Load(), lineno=3, col_offset=7, end_lineno=3, end_col_offset=12), Compare(Subscript(Name('placeholder_2', Load(), lineno=3, col_offset=17, end_lineno=3, end_col_offset=22), UnaryOp(USub(), Constant(1, lineno=3, col_offset=24, end_lineno=3, end_col_offset=25), lineno=3, col_offset=23, end_lineno=3, end_col_offset=25), Load(), lineno=3, col_offset=17, end_lineno=3, end_col_offset=26), [Eq()], [Constant('X', lineno=3, col_offset=30, end_lineno=3, end_col_offset=33)], lineno=3, col_offset=17, end_lineno=3, end_col_offset=33)], lineno=3, col_offset=7, end_lineno=3, end_col_offset=33), [Assign([Subscript(Name('placeholder_2', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=13), UnaryOp(USub(), Constant(1, lineno=4, col_offset=15, end_lineno=4, end_col_offset=16), lineno=4, col_offset=14, end_lineno=4, end_col_offset=16), Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=17)], Constant('10', lineno=4, col_offset=20, end_lineno=4, end_col_offset=24), lineno=4, col_offset=8, end_lineno=4, end_col_offset=24)], [], lineno=3, col_offset=4, end_lineno=4, end_col_offset=24), If(BoolOp(Or(), [UnaryOp(Not(), Compare(Call(Name('len', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=14), [Name('placeholder_2', Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=20)], [], lineno=5, col_offset=11, end_lineno=5, end_col_offset=21), [Eq()], [Constant(10, lineno=5, col_offset=25, end_lineno=5, end_col_offset=27)], lineno=5, col_offset=11, end_lineno=5, end_col_offset=27), lineno=5, col_offset=7, end_lineno=5, end_col_offset=27), UnaryOp(Not(), Call(Name('all', Load(), lineno=5, col_offset=35, end_lineno=5, end_col_offset=38), [GeneratorExp(Call(Attribute(Name('placeholder_3', Load(), lineno=5, col_offset=39, end_lineno=5, end_col_offset=43), 'isdigit', Load(), lineno=5, col_offset=39, end_lineno=5, end_col_offset=51), [], [], lineno=5, col_offset=39, end_lineno=5, end_col_offset=53), [comprehension(Name('placeholder_3', Store(), lineno=5, col_offset=58, end_lineno=5, end_col_offset=62), Name('placeholder_2', Load(), lineno=5, col_offset=66, end_lineno=5, end_col_offset=71), [], 0)], lineno=5, col_offset=38, end_lineno=5, end_col_offset=72)], [], lineno=5, col_offset=35, end_lineno=5, end_col_offset=72), lineno=5, col_offset=31, end_lineno=5, end_col_offset=72)], lineno=5, col_offset=7, end_lineno=5, end_col_offset=72), [Return(Constant(False, lineno=6, col_offset=15, end_lineno=6, end_col_offset=20), lineno=6, col_offset=8, end_lineno=6, end_col_offset=20)], [], lineno=5, col_offset=4, end_lineno=6, end_col_offset=20), Assign([Name('placeholder_4', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=11)], Call(Name('list', Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=18), [Call(Name('range', Load(), lineno=7, col_offset=19, end_lineno=7, end_col_offset=24), [Constant(10, lineno=7, col_offset=25, end_lineno=7, end_col_offset=27), Constant(0, lineno=7, col_offset=29, end_lineno=7, end_col_offset=30), UnaryOp(USub(), Constant(1, lineno=7, col_offset=33, end_lineno=7, end_col_offset=34), lineno=7, col_offset=32, end_lineno=7, end_col_offset=34)], [], lineno=7, col_offset=19, end_lineno=7, end_col_offset=35)], [], lineno=7, col_offset=14, end_lineno=7, end_col_offset=36), lineno=7, col_offset=4, end_lineno=7, end_col_offset=36), Return(Compare(BinOp(Call(Name('sum', Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=14), [GeneratorExp(BinOp(Call(Name('int', Load(), lineno=8, col_offset=15, end_lineno=8, end_col_offset=18), [Name('placeholder_3', Load(), lineno=8, col_offset=19, end_lineno=8, end_col_offset=23)], [], lineno=8, col_offset=15, end_lineno=8, end_col_offset=24), Mult(), Name('placeholder_5', Load(), lineno=8, col_offset=27, end_lineno=8, end_col_offset=30), lineno=8, col_offset=15, end_lineno=8, end_col_offset=30), [comprehension(Tuple([Name('placeholder_3', Store(), lineno=8, col_offset=35, end_lineno=8, end_col_offset=39), Name('placeholder_5', Store(), lineno=8, col_offset=41, end_lineno=8, end_col_offset=44)], Store(), lineno=8, col_offset=35, end_lineno=8, end_col_offset=44), Call(Name('zip', Load(), lineno=8, col_offset=48, end_lineno=8, end_col_offset=51), [Name('placeholder_2', Load(), lineno=8, col_offset=52, end_lineno=8, end_col_offset=57), Name('placeholder_4', Load(), lineno=8, col_offset=59, end_lineno=8, end_col_offset=66)], [], lineno=8, col_offset=48, end_lineno=8, end_col_offset=67), [], 0)], lineno=8, col_offset=14, end_lineno=8, end_col_offset=68)], [], lineno=8, col_offset=11, end_lineno=8, end_col_offset=68), Mod(), Constant(11, lineno=8, col_offset=71, end_lineno=8, end_col_offset=73), lineno=8, col_offset=11, end_lineno=8, end_col_offset=73), [Eq()], [Constant(0, lineno=8, col_offset=77, end_lineno=8, end_col_offset=78)], lineno=8, col_offset=11, end_lineno=8, end_col_offset=78), lineno=8, col_offset=4, end_lineno=8, end_col_offset=78)], [], lineno=1, col_offset=0, end_lineno=8, end_col_offset=78)], []) \ No newline at end of file diff --git a/test/practice-isogram/.meta/config.json b/test/practice-isogram/.meta/config.json new file mode 100644 index 0000000..302b30a --- /dev/null +++ b/test/practice-isogram/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "abhijitparida", + "cmccandless", + "Dog", + "ikhadykin", + "N-Parsons", + "Nishant23", + "olufotebig", + "rever0f", + "sdublish", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "isogram.py" + ], + "test": [ + "isogram_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Determine if a word or phrase is an isogram.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Isogram" +} diff --git a/test/practice-isogram/isogram.py b/test/practice-isogram/isogram.py new file mode 100644 index 0000000..1705877 --- /dev/null +++ b/test/practice-isogram/isogram.py @@ -0,0 +1,3 @@ +def is_isogram(string): + characters_lower = [char.lower() for char in string if char.isalpha()] + return len(set(characters_lower)) == len(characters_lower) diff --git a/test/practice-isogram/mapping.json b/test/practice-isogram/mapping.json new file mode 100644 index 0000000..d64bdca --- /dev/null +++ b/test/practice-isogram/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "is_isogram", + "placeholder_1": "string", + "placeholder_2": "characters_lower", + "placeholder_3": "char" +} \ No newline at end of file diff --git a/test/practice-isogram/representation.json b/test/practice-isogram/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-isogram/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-isogram/representation.out b/test/practice-isogram/representation.out new file mode 100644 index 0000000..752a2f7 --- /dev/null +++ b/test/practice-isogram/representation.out @@ -0,0 +1,356 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = [ + placeholder_3.lower() + for placeholder_3 in placeholder_1 + if placeholder_3.isalpha() + ] + return len(set(placeholder_2)) == len(placeholder_2) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'is_isogram', + arguments( + [], + [ + arg( + 'string', + lineno=1, + col_offset=15, + end_lineno=1, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'characters_lower', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=20)], + ListComp( + Call( + Attribute( + Name( + 'char', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=28), + 'lower', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=34), + [], + [], + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=36), + [ + comprehension( + Name( + 'char', + Store(), + lineno=2, + col_offset=41, + end_lineno=2, + end_col_offset=45), + Name( + 'string', + Load(), + lineno=2, + col_offset=49, + end_lineno=2, + end_col_offset=55), + [ + Call( + Attribute( + Name( + 'char', + Load(), + lineno=2, + col_offset=59, + end_lineno=2, + end_col_offset=63), + 'isalpha', + Load(), + lineno=2, + col_offset=59, + end_lineno=2, + end_col_offset=71), + [], + [], + lineno=2, + col_offset=59, + end_lineno=2, + end_col_offset=73)], + 0)], + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=74), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=74), + Return( + Compare( + Call( + Name( + 'len', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=14), + [ + Call( + Name( + 'set', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=18), + [ + Name( + 'characters_lower', + Load(), + lineno=3, + col_offset=19, + end_lineno=3, + end_col_offset=35)], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=36)], + [], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=37), + [ + Eq()], + [ + Call( + Name( + 'len', + Load(), + lineno=3, + col_offset=41, + end_lineno=3, + end_col_offset=44), + [ + Name( + 'characters_lower', + Load(), + lineno=3, + col_offset=45, + end_lineno=3, + end_col_offset=61)], + [], + lineno=3, + col_offset=41, + end_lineno=3, + end_col_offset=62)], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=62), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=62)], + [], + lineno=1, + col_offset=0, + end_lineno=3, + end_col_offset=62)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=15, + end_lineno=1, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=20)], + ListComp( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=28), + 'lower', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=34), + [], + [], + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=36), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=41, + end_lineno=2, + end_col_offset=45), + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=49, + end_lineno=2, + end_col_offset=55), + [ + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=59, + end_lineno=2, + end_col_offset=63), + 'isalpha', + Load(), + lineno=2, + col_offset=59, + end_lineno=2, + end_col_offset=71), + [], + [], + lineno=2, + col_offset=59, + end_lineno=2, + end_col_offset=73)], + 0)], + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=74), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=74), + Return( + Compare( + Call( + Name( + 'len', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=14), + [ + Call( + Name( + 'set', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=18), + [ + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=19, + end_lineno=3, + end_col_offset=35)], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=36)], + [], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=37), + [ + Eq()], + [ + Call( + Name( + 'len', + Load(), + lineno=3, + col_offset=41, + end_lineno=3, + end_col_offset=44), + [ + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=45, + end_lineno=3, + end_col_offset=61)], + [], + lineno=3, + col_offset=41, + end_lineno=3, + end_col_offset=62)], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=62), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=62)], + [], + lineno=1, + col_offset=0, + end_lineno=3, + end_col_offset=62)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-isogram/representation.txt b/test/practice-isogram/representation.txt new file mode 100644 index 0000000..60bf391 --- /dev/null +++ b/test/practice-isogram/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=15, end_lineno=1, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=20)], ListComp(Call(Attribute(Name('placeholder_3', Load(), lineno=2, col_offset=24, end_lineno=2, end_col_offset=28), 'lower', Load(), lineno=2, col_offset=24, end_lineno=2, end_col_offset=34), [], [], lineno=2, col_offset=24, end_lineno=2, end_col_offset=36), [comprehension(Name('placeholder_3', Store(), lineno=2, col_offset=41, end_lineno=2, end_col_offset=45), Name('placeholder_1', Load(), lineno=2, col_offset=49, end_lineno=2, end_col_offset=55), [Call(Attribute(Name('placeholder_3', Load(), lineno=2, col_offset=59, end_lineno=2, end_col_offset=63), 'isalpha', Load(), lineno=2, col_offset=59, end_lineno=2, end_col_offset=71), [], [], lineno=2, col_offset=59, end_lineno=2, end_col_offset=73)], 0)], lineno=2, col_offset=23, end_lineno=2, end_col_offset=74), lineno=2, col_offset=4, end_lineno=2, end_col_offset=74), Return(Compare(Call(Name('len', Load(), lineno=3, col_offset=11, end_lineno=3, end_col_offset=14), [Call(Name('set', Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=18), [Name('placeholder_2', Load(), lineno=3, col_offset=19, end_lineno=3, end_col_offset=35)], [], lineno=3, col_offset=15, end_lineno=3, end_col_offset=36)], [], lineno=3, col_offset=11, end_lineno=3, end_col_offset=37), [Eq()], [Call(Name('len', Load(), lineno=3, col_offset=41, end_lineno=3, end_col_offset=44), [Name('placeholder_2', Load(), lineno=3, col_offset=45, end_lineno=3, end_col_offset=61)], [], lineno=3, col_offset=41, end_lineno=3, end_col_offset=62)], lineno=3, col_offset=11, end_lineno=3, end_col_offset=62), lineno=3, col_offset=4, end_lineno=3, end_col_offset=62)], [], lineno=1, col_offset=0, end_lineno=3, end_col_offset=62)], []) \ No newline at end of file diff --git a/test/practice-killer-sudoku-helper/.meta/config.json b/test/practice-killer-sudoku-helper/.meta/config.json new file mode 100644 index 0000000..eb5a6f8 --- /dev/null +++ b/test/practice-killer-sudoku-helper/.meta/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "meatball133", + "Bethanyg" + ], + "contributors": [], + "files": { + "solution": [ + "killer_sudoku_helper.py" + ], + "test": [ + "killer_sudoku_helper_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Write a tool that makes it easier to solve Killer Sudokus", + "source": "Created by Sascha Mann, Jeremy Walker, and BethanyG for the Julia track on Exercism.", + "source_url": "https://github.com/exercism/julia/pull/413" +} diff --git a/test/practice-killer-sudoku-helper/killer_sudoku_helper.py b/test/practice-killer-sudoku-helper/killer_sudoku_helper.py new file mode 100644 index 0000000..ac3a7f8 --- /dev/null +++ b/test/practice-killer-sudoku-helper/killer_sudoku_helper.py @@ -0,0 +1,16 @@ +import itertools + +def combinations(target, size, exclude): + result = [] + possible = [index for index in + range(1, int((target ** 2 /size) ** 0.6)) + if index not in exclude] + + if size == 1: + return [[target]] + else: + for index in range(len(possible), 0, -1): + for seq in itertools.combinations(possible, index): + if sum(seq) == target and len(seq) == size: + result.append(list(seq)) + return result diff --git a/test/practice-killer-sudoku-helper/mapping.json b/test/practice-killer-sudoku-helper/mapping.json new file mode 100644 index 0000000..8276659 --- /dev/null +++ b/test/practice-killer-sudoku-helper/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "combinations", + "placeholder_1": "target", + "placeholder_2": "size", + "placeholder_3": "exclude", + "placeholder_4": "result", + "placeholder_5": "possible", + "placeholder_6": "index", + "placeholder_7": "seq" +} \ No newline at end of file diff --git a/test/practice-killer-sudoku-helper/representation.json b/test/practice-killer-sudoku-helper/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-killer-sudoku-helper/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-killer-sudoku-helper/representation.out b/test/practice-killer-sudoku-helper/representation.out new file mode 100644 index 0000000..567774d --- /dev/null +++ b/test/practice-killer-sudoku-helper/representation.out @@ -0,0 +1,1066 @@ +## BEGIN NORMALIZED CODE ## +import itertools + + +def placeholder_0(placeholder_1, placeholder_2, placeholder_3): + placeholder_4 = [] + placeholder_5 = [ + placeholder_6 + for placeholder_6 in range(1, int((placeholder_1**2 / placeholder_2) ** 0.6)) + if placeholder_6 not in placeholder_3 + ] + if placeholder_2 == 1: + return [[placeholder_1]] + else: + for placeholder_6 in range(len(placeholder_5), 0, -1): + for placeholder_7 in itertools.placeholder_0(placeholder_5, placeholder_6): + if ( + sum(placeholder_7) == placeholder_1 + and len(placeholder_7) == placeholder_2 + ): + placeholder_4.append(list(placeholder_7)) + return placeholder_4 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'itertools', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=16)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16), + FunctionDef( + 'combinations', + arguments( + [], + [ + arg( + 'target', + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=23), + arg( + 'size', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=29), + arg( + 'exclude', + lineno=3, + col_offset=31, + end_lineno=3, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=10)], + List( + [], + Load(), + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=15), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=15), + Assign( + [ + Name( + 'possible', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12)], + ListComp( + Name( + 'index', + Load(), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=21), + [ + comprehension( + Name( + 'index', + Store(), + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=31), + Call( + Name( + 'range', + Load(), + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=21), + [ + Constant( + 1, + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=23), + Call( + Name( + 'int', + Load(), + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=28), + [ + BinOp( + BinOp( + BinOp( + Name( + 'target', + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=36), + Pow(), + Constant( + 2, + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=41), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=41), + Div(), + Name( + 'size', + Load(), + lineno=6, + col_offset=43, + end_lineno=6, + end_col_offset=47), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=47), + Pow(), + Constant( + 0.6, + lineno=6, + col_offset=52, + end_lineno=6, + end_col_offset=55), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=55)], + [], + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=56)], + [], + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=57), + [ + Compare( + Name( + 'index', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=24), + [ + NotIn()], + [ + Name( + 'exclude', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=39)], + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=39)], + 0)], + lineno=5, + col_offset=15, + end_lineno=7, + end_col_offset=40), + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=40), + If( + Compare( + Name( + 'size', + Load(), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=11), + [ + Eq()], + [ + Constant( + 1, + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16)], + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=16), + [ + Return( + List( + [ + List( + [ + Name( + 'target', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=23)], + Load(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=24)], + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=25), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=25)], + [ + For( + Name( + 'index', + Store(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=17), + Call( + Name( + 'range', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=26), + [ + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=30), + [ + Name( + 'possible', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=39)], + [], + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=40), + Constant( + 0, + lineno=12, + col_offset=42, + end_lineno=12, + end_col_offset=43), + UnaryOp( + USub(), + Constant( + 1, + lineno=12, + col_offset=46, + end_lineno=12, + end_col_offset=47), + lineno=12, + col_offset=45, + end_lineno=12, + end_col_offset=47)], + [], + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=48), + [ + For( + Name( + 'seq', + Store(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=19), + Call( + Attribute( + Name( + 'itertools', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=32), + 'combinations', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=45), + [ + Name( + 'possible', + Load(), + lineno=13, + col_offset=46, + end_lineno=13, + end_col_offset=54), + Name( + 'index', + Load(), + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=61)], + [], + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=62), + [ + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=22), + [ + Name( + 'seq', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=26)], + [], + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=27), + [ + Eq()], + [ + Name( + 'target', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=37)], + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=37), + Compare( + Call( + Name( + 'len', + Load(), + lineno=14, + col_offset=42, + end_lineno=14, + end_col_offset=45), + [ + Name( + 'seq', + Load(), + lineno=14, + col_offset=46, + end_lineno=14, + end_col_offset=49)], + [], + lineno=14, + col_offset=42, + end_lineno=14, + end_col_offset=50), + [ + Eq()], + [ + Name( + 'size', + Load(), + lineno=14, + col_offset=54, + end_lineno=14, + end_col_offset=58)], + lineno=14, + col_offset=42, + end_lineno=14, + end_col_offset=58)], + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=58), + [ + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=26), + 'append', + Load(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=33), + [ + Call( + Name( + 'list', + Load(), + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=38), + [ + Name( + 'seq', + Load(), + lineno=15, + col_offset=39, + end_lineno=15, + end_col_offset=42)], + [], + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=43)], + [], + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=44), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=44)], + [], + lineno=14, + col_offset=16, + end_lineno=15, + end_col_offset=44)], + [], + lineno=13, + col_offset=12, + end_lineno=15, + end_col_offset=44)], + [], + lineno=12, + col_offset=8, + end_lineno=15, + end_col_offset=44)], + lineno=9, + col_offset=4, + end_lineno=15, + end_col_offset=44), + Return( + Name( + 'result', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=17)], + [], + lineno=3, + col_offset=0, + end_lineno=16, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'itertools', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=16)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=23), + arg( + 'placeholder_2', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=29), + arg( + 'placeholder_3', + lineno=3, + col_offset=31, + end_lineno=3, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=10)], + List( + [], + Load(), + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=15), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=15), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12)], + ListComp( + Name( + 'placeholder_6', + Load(), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=21), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=31), + Call( + Name( + 'range', + Load(), + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=21), + [ + Constant( + 1, + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=23), + Call( + Name( + 'int', + Load(), + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=28), + [ + BinOp( + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=36), + Pow(), + Constant( + 2, + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=41), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=41), + Div(), + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=43, + end_lineno=6, + end_col_offset=47), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=47), + Pow(), + Constant( + 0.6, + lineno=6, + col_offset=52, + end_lineno=6, + end_col_offset=55), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=55)], + [], + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=56)], + [], + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=57), + [ + Compare( + Name( + 'placeholder_6', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=24), + [ + NotIn()], + [ + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=39)], + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=39)], + 0)], + lineno=5, + col_offset=15, + end_lineno=7, + end_col_offset=40), + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=40), + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=11), + [ + Eq()], + [ + Constant( + 1, + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16)], + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=16), + [ + Return( + List( + [ + List( + [ + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=23)], + Load(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=24)], + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=25), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=25)], + [ + For( + Name( + 'placeholder_6', + Store(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=17), + Call( + Name( + 'range', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=26), + [ + Call( + Name( + 'len', + Load(), + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=30), + [ + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=39)], + [], + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=40), + Constant( + 0, + lineno=12, + col_offset=42, + end_lineno=12, + end_col_offset=43), + UnaryOp( + USub(), + Constant( + 1, + lineno=12, + col_offset=46, + end_lineno=12, + end_col_offset=47), + lineno=12, + col_offset=45, + end_lineno=12, + end_col_offset=47)], + [], + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=48), + [ + For( + Name( + 'placeholder_7', + Store(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=19), + Call( + Attribute( + Name( + 'itertools', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=32), + 'placeholder_0', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=45), + [ + Name( + 'placeholder_5', + Load(), + lineno=13, + col_offset=46, + end_lineno=13, + end_col_offset=54), + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=56, + end_lineno=13, + end_col_offset=61)], + [], + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=62), + [ + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=22), + [ + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=26)], + [], + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=27), + [ + Eq()], + [ + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=37)], + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=37), + Compare( + Call( + Name( + 'len', + Load(), + lineno=14, + col_offset=42, + end_lineno=14, + end_col_offset=45), + [ + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=46, + end_lineno=14, + end_col_offset=49)], + [], + lineno=14, + col_offset=42, + end_lineno=14, + end_col_offset=50), + [ + Eq()], + [ + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=54, + end_lineno=14, + end_col_offset=58)], + lineno=14, + col_offset=42, + end_lineno=14, + end_col_offset=58)], + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=58), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=26), + 'append', + Load(), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=33), + [ + Call( + Name( + 'list', + Load(), + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=38), + [ + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=39, + end_lineno=15, + end_col_offset=42)], + [], + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=43)], + [], + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=44), + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=44)], + [], + lineno=14, + col_offset=16, + end_lineno=15, + end_col_offset=44)], + [], + lineno=13, + col_offset=12, + end_lineno=15, + end_col_offset=44)], + [], + lineno=12, + col_offset=8, + end_lineno=15, + end_col_offset=44)], + lineno=9, + col_offset=4, + end_lineno=15, + end_col_offset=44), + Return( + Name( + 'placeholder_4', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=17)], + [], + lineno=3, + col_offset=0, + end_lineno=16, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-killer-sudoku-helper/representation.txt b/test/practice-killer-sudoku-helper/representation.txt new file mode 100644 index 0000000..d30f1dc --- /dev/null +++ b/test/practice-killer-sudoku-helper/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('itertools', lineno=1, col_offset=7, end_lineno=1, end_col_offset=16)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=16), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=3, col_offset=17, end_lineno=3, end_col_offset=23), arg('placeholder_2', lineno=3, col_offset=25, end_lineno=3, end_col_offset=29), arg('placeholder_3', lineno=3, col_offset=31, end_lineno=3, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=10)], List([], Load(), lineno=4, col_offset=13, end_lineno=4, end_col_offset=15), lineno=4, col_offset=4, end_lineno=4, end_col_offset=15), Assign([Name('placeholder_5', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=12)], ListComp(Name('placeholder_6', Load(), lineno=5, col_offset=16, end_lineno=5, end_col_offset=21), [comprehension(Name('placeholder_6', Store(), lineno=5, col_offset=26, end_lineno=5, end_col_offset=31), Call(Name('range', Load(), lineno=6, col_offset=16, end_lineno=6, end_col_offset=21), [Constant(1, lineno=6, col_offset=22, end_lineno=6, end_col_offset=23), Call(Name('int', Load(), lineno=6, col_offset=25, end_lineno=6, end_col_offset=28), [BinOp(BinOp(BinOp(Name('placeholder_1', Load(), lineno=6, col_offset=30, end_lineno=6, end_col_offset=36), Pow(), Constant(2, lineno=6, col_offset=40, end_lineno=6, end_col_offset=41), lineno=6, col_offset=30, end_lineno=6, end_col_offset=41), Div(), Name('placeholder_2', Load(), lineno=6, col_offset=43, end_lineno=6, end_col_offset=47), lineno=6, col_offset=30, end_lineno=6, end_col_offset=47), Pow(), Constant(0.6, lineno=6, col_offset=52, end_lineno=6, end_col_offset=55), lineno=6, col_offset=29, end_lineno=6, end_col_offset=55)], [], lineno=6, col_offset=25, end_lineno=6, end_col_offset=56)], [], lineno=6, col_offset=16, end_lineno=6, end_col_offset=57), [Compare(Name('placeholder_6', Load(), lineno=7, col_offset=19, end_lineno=7, end_col_offset=24), [NotIn()], [Name('placeholder_3', Load(), lineno=7, col_offset=32, end_lineno=7, end_col_offset=39)], lineno=7, col_offset=19, end_lineno=7, end_col_offset=39)], 0)], lineno=5, col_offset=15, end_lineno=7, end_col_offset=40), lineno=5, col_offset=4, end_lineno=7, end_col_offset=40), If(Compare(Name('placeholder_2', Load(), lineno=9, col_offset=7, end_lineno=9, end_col_offset=11), [Eq()], [Constant(1, lineno=9, col_offset=15, end_lineno=9, end_col_offset=16)], lineno=9, col_offset=7, end_lineno=9, end_col_offset=16), [Return(List([List([Name('placeholder_1', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=23)], Load(), lineno=10, col_offset=16, end_lineno=10, end_col_offset=24)], Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=25), lineno=10, col_offset=8, end_lineno=10, end_col_offset=25)], [For(Name('placeholder_6', Store(), lineno=12, col_offset=12, end_lineno=12, end_col_offset=17), Call(Name('range', Load(), lineno=12, col_offset=21, end_lineno=12, end_col_offset=26), [Call(Name('len', Load(), lineno=12, col_offset=27, end_lineno=12, end_col_offset=30), [Name('placeholder_5', Load(), lineno=12, col_offset=31, end_lineno=12, end_col_offset=39)], [], lineno=12, col_offset=27, end_lineno=12, end_col_offset=40), Constant(0, lineno=12, col_offset=42, end_lineno=12, end_col_offset=43), UnaryOp(USub(), Constant(1, lineno=12, col_offset=46, end_lineno=12, end_col_offset=47), lineno=12, col_offset=45, end_lineno=12, end_col_offset=47)], [], lineno=12, col_offset=21, end_lineno=12, end_col_offset=48), [For(Name('placeholder_7', Store(), lineno=13, col_offset=16, end_lineno=13, end_col_offset=19), Call(Attribute(Name('itertools', Load(), lineno=13, col_offset=23, end_lineno=13, end_col_offset=32), 'placeholder_0', Load(), lineno=13, col_offset=23, end_lineno=13, end_col_offset=45), [Name('placeholder_5', Load(), lineno=13, col_offset=46, end_lineno=13, end_col_offset=54), Name('placeholder_6', Load(), lineno=13, col_offset=56, end_lineno=13, end_col_offset=61)], [], lineno=13, col_offset=23, end_lineno=13, end_col_offset=62), [If(BoolOp(And(), [Compare(Call(Name('sum', Load(), lineno=14, col_offset=19, end_lineno=14, end_col_offset=22), [Name('placeholder_7', Load(), lineno=14, col_offset=23, end_lineno=14, end_col_offset=26)], [], lineno=14, col_offset=19, end_lineno=14, end_col_offset=27), [Eq()], [Name('placeholder_1', Load(), lineno=14, col_offset=31, end_lineno=14, end_col_offset=37)], lineno=14, col_offset=19, end_lineno=14, end_col_offset=37), Compare(Call(Name('len', Load(), lineno=14, col_offset=42, end_lineno=14, end_col_offset=45), [Name('placeholder_7', Load(), lineno=14, col_offset=46, end_lineno=14, end_col_offset=49)], [], lineno=14, col_offset=42, end_lineno=14, end_col_offset=50), [Eq()], [Name('placeholder_2', Load(), lineno=14, col_offset=54, end_lineno=14, end_col_offset=58)], lineno=14, col_offset=42, end_lineno=14, end_col_offset=58)], lineno=14, col_offset=19, end_lineno=14, end_col_offset=58), [Expr(Call(Attribute(Name('placeholder_4', Load(), lineno=15, col_offset=20, end_lineno=15, end_col_offset=26), 'append', Load(), lineno=15, col_offset=20, end_lineno=15, end_col_offset=33), [Call(Name('list', Load(), lineno=15, col_offset=34, end_lineno=15, end_col_offset=38), [Name('placeholder_7', Load(), lineno=15, col_offset=39, end_lineno=15, end_col_offset=42)], [], lineno=15, col_offset=34, end_lineno=15, end_col_offset=43)], [], lineno=15, col_offset=20, end_lineno=15, end_col_offset=44), lineno=15, col_offset=20, end_lineno=15, end_col_offset=44)], [], lineno=14, col_offset=16, end_lineno=15, end_col_offset=44)], [], lineno=13, col_offset=12, end_lineno=15, end_col_offset=44)], [], lineno=12, col_offset=8, end_lineno=15, end_col_offset=44)], lineno=9, col_offset=4, end_lineno=15, end_col_offset=44), Return(Name('placeholder_4', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=17), lineno=16, col_offset=4, end_lineno=16, end_col_offset=17)], [], lineno=3, col_offset=0, end_lineno=16, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-kindergarten-garden/.meta/additional_tests.json b/test/practice-kindergarten-garden/.meta/additional_tests.json new file mode 100644 index 0000000..f5f525a --- /dev/null +++ b/test/practice-kindergarten-garden/.meta/additional_tests.json @@ -0,0 +1,29 @@ +{ + "cases": [ + { + "description": "students are unordered", + "cases": [ + { + "description": "first student", + "property": "plants", + "input": { + "diagram": "VCRRGVRG\nRVGCCGCV", + "students": ["Samantha", "Patricia", "Xander", "Roger"], + "student": "Patricia" + }, + "expected": ["Violets", "Clover", "Radishes", "Violets"] + }, + { + "description": "last student", + "property": "plants", + "input": { + "diagram": "VCRRGVRG\nRVGCCGCV", + "students": ["Samantha", "Patricia", "Xander", "Roger"], + "student": "Xander" + }, + "expected": ["Radishes", "Grass", "Clover", "Violets"] + } + ] + } + ] +} diff --git a/test/practice-kindergarten-garden/.meta/config.json b/test/practice-kindergarten-garden/.meta/config.json new file mode 100644 index 0000000..58767fd --- /dev/null +++ b/test/practice-kindergarten-garden/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "Mofeywalker", + "N-Parsons", + "pheanex", + "smalley", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "kindergarten_garden.py" + ], + "test": [ + "kindergarten_garden_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a diagram, determine which plants each child in the kindergarten class is responsible for.", + "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", + "source_url": "https://turing.edu" +} diff --git a/test/practice-kindergarten-garden/kindergarten_garden.py b/test/practice-kindergarten-garden/kindergarten_garden.py new file mode 100644 index 0000000..262c6ad --- /dev/null +++ b/test/practice-kindergarten-garden/kindergarten_garden.py @@ -0,0 +1,35 @@ +class Garden: + + STUDENTS = [ + 'Alice', + 'Bob', + 'Charlie', + 'David', + 'Eve', + 'Fred', + 'Ginny', + 'Harriet', + 'Ileana', + 'Joseph', + 'Kincaid', + 'Larry', + ] + PLANTS = {'C': 'Clover', 'G': 'Grass', 'R': 'Radishes', 'V': 'Violets'} + + def __init__(self, diagram, students=None): + students = sorted(students or self.STUDENTS) + front, back = diagram.splitlines() + self.cups = {} + for idx, student in enumerate(students[: len(front)]): + start = idx * 2 + stop = start + 2 + self.cups.setdefault(student, []) + self.cups[student].extend( + self.PLANTS[plant] for plant in front[start:stop] + ) + self.cups[student].extend( + self.PLANTS[plant] for plant in back[start:stop] + ) + + def plants(self, student): + return self.cups.get(student, []) diff --git a/test/practice-kindergarten-garden/mapping.json b/test/practice-kindergarten-garden/mapping.json new file mode 100644 index 0000000..a0fb978 --- /dev/null +++ b/test/practice-kindergarten-garden/mapping.json @@ -0,0 +1,17 @@ +{ + "placeholder_0": "Garden", + "placeholder_1": "STUDENTS", + "placeholder_2": "PLANTS", + "placeholder_3": "__init__", + "placeholder_4": "diagram", + "placeholder_5": "students", + "placeholder_6": "front", + "placeholder_7": "back", + "placeholder_8": "cups", + "placeholder_9": "idx", + "placeholder_10": "student", + "placeholder_11": "start", + "placeholder_12": "stop", + "placeholder_13": "plant", + "placeholder_14": "plants" +} \ No newline at end of file diff --git a/test/practice-kindergarten-garden/representation.json b/test/practice-kindergarten-garden/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-kindergarten-garden/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-kindergarten-garden/representation.out b/test/practice-kindergarten-garden/representation.out new file mode 100644 index 0000000..cf03c6f --- /dev/null +++ b/test/practice-kindergarten-garden/representation.out @@ -0,0 +1,1747 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + placeholder_1 = [ + "Alice", + "Bob", + "Charlie", + "David", + "Eve", + "Fred", + "Ginny", + "Harriet", + "Ileana", + "Joseph", + "Kincaid", + "Larry", + ] + placeholder_2 = {"C": "Clover", "G": "Grass", "R": "Radishes", "V": "Violets"} + + def placeholder_3(self, placeholder_4, placeholder_5=None): + placeholder_5 = sorted(placeholder_5 or self.placeholder_1) + placeholder_6, placeholder_7 = placeholder_4.splitlines() + self.placeholder_8 = {} + for placeholder_9, placeholder_10 in enumerate( + placeholder_5[: len(placeholder_6)] + ): + placeholder_11 = placeholder_9 * 2 + placeholder_12 = placeholder_11 + 2 + self.placeholder_8.setdefault(placeholder_10, []) + self.placeholder_8[placeholder_10].extend( + ( + self.placeholder_2[placeholder_13] + for placeholder_13 in placeholder_6[placeholder_11:placeholder_12] + ) + ) + self.placeholder_8[placeholder_10].extend( + ( + self.placeholder_2[placeholder_13] + for placeholder_13 in placeholder_7[placeholder_11:placeholder_12] + ) + ) + + def placeholder_14(self, placeholder_10): + return self.placeholder_8.get(placeholder_10, []) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Garden', + [], + [], + [ + Assign( + [ + Name( + 'STUDENTS', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=12)], + List( + [ + Constant( + 'Alice', + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=15), + Constant( + 'Bob', + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=13), + Constant( + 'Charlie', + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=17), + Constant( + 'David', + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=15), + Constant( + 'Eve', + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=13), + Constant( + 'Fred', + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=14), + Constant( + 'Ginny', + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=15), + Constant( + 'Harriet', + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=17), + Constant( + 'Ileana', + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=16), + Constant( + 'Joseph', + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=16), + Constant( + 'Kincaid', + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=17), + Constant( + 'Larry', + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=15)], + Load(), + lineno=3, + col_offset=15, + end_lineno=16, + end_col_offset=5), + lineno=3, + col_offset=4, + end_lineno=16, + end_col_offset=5), + Assign( + [ + Name( + 'PLANTS', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=10)], + Dict( + [ + Constant( + 'C', + lineno=17, + col_offset=14, + end_lineno=17, + end_col_offset=17), + Constant( + 'G', + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=32), + Constant( + 'R', + lineno=17, + col_offset=43, + end_lineno=17, + end_col_offset=46), + Constant( + 'V', + lineno=17, + col_offset=60, + end_lineno=17, + end_col_offset=63)], + [ + Constant( + 'Clover', + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=27), + Constant( + 'Grass', + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=41), + Constant( + 'Radishes', + lineno=17, + col_offset=48, + end_lineno=17, + end_col_offset=58), + Constant( + 'Violets', + lineno=17, + col_offset=65, + end_lineno=17, + end_col_offset=74)], + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=75), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=75), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=21), + arg( + 'diagram', + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=30), + arg( + 'students', + lineno=19, + col_offset=32, + end_lineno=19, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=19, + col_offset=41, + end_lineno=19, + end_col_offset=45)]), + [ + Assign( + [ + Name( + 'students', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=16)], + Call( + Name( + 'sorted', + Load(), + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=25), + [ + BoolOp( + Or(), + [ + Name( + 'students', + Load(), + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=34), + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=38, + end_lineno=20, + end_col_offset=42), + 'STUDENTS', + Load(), + lineno=20, + col_offset=38, + end_lineno=20, + end_col_offset=51)], + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=51)], + [], + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=52), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=52), + Assign( + [ + Tuple( + [ + Name( + 'front', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=13), + Name( + 'back', + Store(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19)], + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=19)], + Call( + Attribute( + Name( + 'diagram', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=29), + 'splitlines', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=40), + [], + [], + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=42), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=42), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=12), + 'cups', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=17)], + Dict( + [], + [], + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=22), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=22), + For( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=15), + Name( + 'student', + Store(), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=24)], + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=24), + Call( + Name( + 'enumerate', + Load(), + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=37), + [ + Subscript( + Name( + 'students', + Load(), + lineno=23, + col_offset=38, + end_lineno=23, + end_col_offset=46), + Slice( + upper=Call( + Name( + 'len', + Load(), + lineno=23, + col_offset=49, + end_lineno=23, + end_col_offset=52), + [ + Name( + 'front', + Load(), + lineno=23, + col_offset=53, + end_lineno=23, + end_col_offset=58)], + [], + lineno=23, + col_offset=49, + end_lineno=23, + end_col_offset=59), + lineno=23, + col_offset=47, + end_lineno=23, + end_col_offset=59), + Load(), + lineno=23, + col_offset=38, + end_lineno=23, + end_col_offset=60)], + [], + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=61), + [ + Assign( + [ + Name( + 'start', + Store(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=17)], + BinOp( + Name( + 'idx', + Load(), + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=23), + Mult(), + Constant( + 2, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27), + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=27), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=27), + Assign( + [ + Name( + 'stop', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=16)], + BinOp( + Name( + 'start', + Load(), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=24), + Add(), + Constant( + 2, + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=28), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=28), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=28), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=16), + 'cups', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=21), + 'setdefault', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=32), + [ + Name( + 'student', + Load(), + lineno=26, + col_offset=33, + end_lineno=26, + end_col_offset=40), + List( + [], + Load(), + lineno=26, + col_offset=42, + end_lineno=26, + end_col_offset=44)], + [], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=45), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=45), + Expr( + Call( + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16), + 'cups', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=21), + Name( + 'student', + Load(), + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=29), + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=30), + 'extend', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=37), + [ + GeneratorExp( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=20), + 'PLANTS', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=27), + Name( + 'plant', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=33), + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=34), + [ + comprehension( + Name( + 'plant', + Store(), + lineno=28, + col_offset=39, + end_lineno=28, + end_col_offset=44), + Subscript( + Name( + 'front', + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=53), + Slice( + Name( + 'start', + Load(), + lineno=28, + col_offset=54, + end_lineno=28, + end_col_offset=59), + Name( + 'stop', + Load(), + lineno=28, + col_offset=60, + end_lineno=28, + end_col_offset=64), + lineno=28, + col_offset=54, + end_lineno=28, + end_col_offset=64), + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=65), + [], + 0)], + lineno=27, + col_offset=37, + end_lineno=29, + end_col_offset=13)], + [], + lineno=27, + col_offset=12, + end_lineno=29, + end_col_offset=13), + lineno=27, + col_offset=12, + end_lineno=29, + end_col_offset=13), + Expr( + Call( + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=16), + 'cups', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=21), + Name( + 'student', + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=29), + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=30), + 'extend', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=37), + [ + GeneratorExp( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=20), + 'PLANTS', + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=27), + Name( + 'plant', + Load(), + lineno=31, + col_offset=28, + end_lineno=31, + end_col_offset=33), + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=34), + [ + comprehension( + Name( + 'plant', + Store(), + lineno=31, + col_offset=39, + end_lineno=31, + end_col_offset=44), + Subscript( + Name( + 'back', + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=52), + Slice( + Name( + 'start', + Load(), + lineno=31, + col_offset=53, + end_lineno=31, + end_col_offset=58), + Name( + 'stop', + Load(), + lineno=31, + col_offset=59, + end_lineno=31, + end_col_offset=63), + lineno=31, + col_offset=53, + end_lineno=31, + end_col_offset=63), + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=64), + [], + 0)], + lineno=30, + col_offset=37, + end_lineno=32, + end_col_offset=13)], + [], + lineno=30, + col_offset=12, + end_lineno=32, + end_col_offset=13), + lineno=30, + col_offset=12, + end_lineno=32, + end_col_offset=13)], + [], + lineno=23, + col_offset=8, + end_lineno=32, + end_col_offset=13)], + [], + lineno=19, + col_offset=4, + end_lineno=32, + end_col_offset=13), + FunctionDef( + 'plants', + arguments( + [], + [ + arg( + 'self', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=19), + arg( + 'student', + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=19), + 'cups', + Load(), + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=24), + 'get', + Load(), + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=28), + [ + Name( + 'student', + Load(), + lineno=35, + col_offset=29, + end_lineno=35, + end_col_offset=36), + List( + [], + Load(), + lineno=35, + col_offset=38, + end_lineno=35, + end_col_offset=40)], + [], + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=41), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=41)], + [], + lineno=34, + col_offset=4, + end_lineno=35, + end_col_offset=41)], + [], + lineno=1, + col_offset=0, + end_lineno=35, + end_col_offset=41)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=12)], + List( + [ + Constant( + 'Alice', + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=15), + Constant( + 'Bob', + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=13), + Constant( + 'Charlie', + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=17), + Constant( + 'David', + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=15), + Constant( + 'Eve', + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=13), + Constant( + 'Fred', + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=14), + Constant( + 'Ginny', + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=15), + Constant( + 'Harriet', + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=17), + Constant( + 'Ileana', + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=16), + Constant( + 'Joseph', + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=16), + Constant( + 'Kincaid', + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=17), + Constant( + 'Larry', + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=15)], + Load(), + lineno=3, + col_offset=15, + end_lineno=16, + end_col_offset=5), + lineno=3, + col_offset=4, + end_lineno=16, + end_col_offset=5), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=10)], + Dict( + [ + Constant( + 'C', + lineno=17, + col_offset=14, + end_lineno=17, + end_col_offset=17), + Constant( + 'G', + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=32), + Constant( + 'R', + lineno=17, + col_offset=43, + end_lineno=17, + end_col_offset=46), + Constant( + 'V', + lineno=17, + col_offset=60, + end_lineno=17, + end_col_offset=63)], + [ + Constant( + 'Clover', + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=27), + Constant( + 'Grass', + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=41), + Constant( + 'Radishes', + lineno=17, + col_offset=48, + end_lineno=17, + end_col_offset=58), + Constant( + 'Violets', + lineno=17, + col_offset=65, + end_lineno=17, + end_col_offset=74)], + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=75), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=75), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=21), + arg( + 'placeholder_4', + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=30), + arg( + 'placeholder_5', + lineno=19, + col_offset=32, + end_lineno=19, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=19, + col_offset=41, + end_lineno=19, + end_col_offset=45)]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=16)], + Call( + Name( + 'sorted', + Load(), + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=25), + [ + BoolOp( + Or(), + [ + Name( + 'placeholder_5', + Load(), + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=34), + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=38, + end_lineno=20, + end_col_offset=42), + 'placeholder_1', + Load(), + lineno=20, + col_offset=38, + end_lineno=20, + end_col_offset=51)], + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=51)], + [], + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=52), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=52), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_6', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=13), + Name( + 'placeholder_7', + Store(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19)], + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=19)], + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=29), + 'splitlines', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=40), + [], + [], + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=42), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=42), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=17)], + Dict( + [], + [], + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=22), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=22), + For( + Tuple( + [ + Name( + 'placeholder_9', + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=15), + Name( + 'placeholder_10', + Store(), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=24)], + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=24), + Call( + Name( + 'enumerate', + Load(), + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=37), + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=23, + col_offset=38, + end_lineno=23, + end_col_offset=46), + Slice( + upper=Call( + Name( + 'len', + Load(), + lineno=23, + col_offset=49, + end_lineno=23, + end_col_offset=52), + [ + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=53, + end_lineno=23, + end_col_offset=58)], + [], + lineno=23, + col_offset=49, + end_lineno=23, + end_col_offset=59), + lineno=23, + col_offset=47, + end_lineno=23, + end_col_offset=59), + Load(), + lineno=23, + col_offset=38, + end_lineno=23, + end_col_offset=60)], + [], + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=61), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=17)], + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=23), + Mult(), + Constant( + 2, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27), + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=27), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=16)], + BinOp( + Name( + 'placeholder_11', + Load(), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=24), + Add(), + Constant( + 2, + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=28), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=28), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=28), + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=16), + 'placeholder_8', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=21), + 'setdefault', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=32), + [ + Name( + 'placeholder_10', + Load(), + lineno=26, + col_offset=33, + end_lineno=26, + end_col_offset=40), + List( + [], + Load(), + lineno=26, + col_offset=42, + end_lineno=26, + end_col_offset=44)], + [], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=45), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=45), + Expr( + Call( + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16), + 'placeholder_8', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=21), + Name( + 'placeholder_10', + Load(), + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=29), + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=30), + 'extend', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=37), + [ + GeneratorExp( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=20), + 'placeholder_2', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=27), + Name( + 'placeholder_13', + Load(), + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=33), + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=34), + [ + comprehension( + Name( + 'placeholder_13', + Store(), + lineno=28, + col_offset=39, + end_lineno=28, + end_col_offset=44), + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=53), + Slice( + Name( + 'placeholder_11', + Load(), + lineno=28, + col_offset=54, + end_lineno=28, + end_col_offset=59), + Name( + 'placeholder_12', + Load(), + lineno=28, + col_offset=60, + end_lineno=28, + end_col_offset=64), + lineno=28, + col_offset=54, + end_lineno=28, + end_col_offset=64), + Load(), + lineno=28, + col_offset=48, + end_lineno=28, + end_col_offset=65), + [], + 0)], + lineno=27, + col_offset=37, + end_lineno=29, + end_col_offset=13)], + [], + lineno=27, + col_offset=12, + end_lineno=29, + end_col_offset=13), + lineno=27, + col_offset=12, + end_lineno=29, + end_col_offset=13), + Expr( + Call( + Attribute( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=16), + 'placeholder_8', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=21), + Name( + 'placeholder_10', + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=29), + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=30), + 'extend', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=37), + [ + GeneratorExp( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=20), + 'placeholder_2', + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=27), + Name( + 'placeholder_13', + Load(), + lineno=31, + col_offset=28, + end_lineno=31, + end_col_offset=33), + Load(), + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=34), + [ + comprehension( + Name( + 'placeholder_13', + Store(), + lineno=31, + col_offset=39, + end_lineno=31, + end_col_offset=44), + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=52), + Slice( + Name( + 'placeholder_11', + Load(), + lineno=31, + col_offset=53, + end_lineno=31, + end_col_offset=58), + Name( + 'placeholder_12', + Load(), + lineno=31, + col_offset=59, + end_lineno=31, + end_col_offset=63), + lineno=31, + col_offset=53, + end_lineno=31, + end_col_offset=63), + Load(), + lineno=31, + col_offset=48, + end_lineno=31, + end_col_offset=64), + [], + 0)], + lineno=30, + col_offset=37, + end_lineno=32, + end_col_offset=13)], + [], + lineno=30, + col_offset=12, + end_lineno=32, + end_col_offset=13), + lineno=30, + col_offset=12, + end_lineno=32, + end_col_offset=13)], + [], + lineno=23, + col_offset=8, + end_lineno=32, + end_col_offset=13)], + [], + lineno=19, + col_offset=4, + end_lineno=32, + end_col_offset=13), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'self', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=19), + arg( + 'placeholder_10', + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=19), + 'placeholder_8', + Load(), + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=24), + 'get', + Load(), + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=28), + [ + Name( + 'placeholder_10', + Load(), + lineno=35, + col_offset=29, + end_lineno=35, + end_col_offset=36), + List( + [], + Load(), + lineno=35, + col_offset=38, + end_lineno=35, + end_col_offset=40)], + [], + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=41), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=41)], + [], + lineno=34, + col_offset=4, + end_lineno=35, + end_col_offset=41)], + [], + lineno=1, + col_offset=0, + end_lineno=35, + end_col_offset=41)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-kindergarten-garden/representation.txt b/test/practice-kindergarten-garden/representation.txt new file mode 100644 index 0000000..7d9174e --- /dev/null +++ b/test/practice-kindergarten-garden/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [Assign([Name('placeholder_1', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=12)], List([Constant('Alice', lineno=4, col_offset=8, end_lineno=4, end_col_offset=15), Constant('Bob', lineno=5, col_offset=8, end_lineno=5, end_col_offset=13), Constant('Charlie', lineno=6, col_offset=8, end_lineno=6, end_col_offset=17), Constant('David', lineno=7, col_offset=8, end_lineno=7, end_col_offset=15), Constant('Eve', lineno=8, col_offset=8, end_lineno=8, end_col_offset=13), Constant('Fred', lineno=9, col_offset=8, end_lineno=9, end_col_offset=14), Constant('Ginny', lineno=10, col_offset=8, end_lineno=10, end_col_offset=15), Constant('Harriet', lineno=11, col_offset=8, end_lineno=11, end_col_offset=17), Constant('Ileana', lineno=12, col_offset=8, end_lineno=12, end_col_offset=16), Constant('Joseph', lineno=13, col_offset=8, end_lineno=13, end_col_offset=16), Constant('Kincaid', lineno=14, col_offset=8, end_lineno=14, end_col_offset=17), Constant('Larry', lineno=15, col_offset=8, end_lineno=15, end_col_offset=15)], Load(), lineno=3, col_offset=15, end_lineno=16, end_col_offset=5), lineno=3, col_offset=4, end_lineno=16, end_col_offset=5), Assign([Name('placeholder_2', Store(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=10)], Dict([Constant('C', lineno=17, col_offset=14, end_lineno=17, end_col_offset=17), Constant('G', lineno=17, col_offset=29, end_lineno=17, end_col_offset=32), Constant('R', lineno=17, col_offset=43, end_lineno=17, end_col_offset=46), Constant('V', lineno=17, col_offset=60, end_lineno=17, end_col_offset=63)], [Constant('Clover', lineno=17, col_offset=19, end_lineno=17, end_col_offset=27), Constant('Grass', lineno=17, col_offset=34, end_lineno=17, end_col_offset=41), Constant('Radishes', lineno=17, col_offset=48, end_lineno=17, end_col_offset=58), Constant('Violets', lineno=17, col_offset=65, end_lineno=17, end_col_offset=74)], lineno=17, col_offset=13, end_lineno=17, end_col_offset=75), lineno=17, col_offset=4, end_lineno=17, end_col_offset=75), FunctionDef('placeholder_3', arguments([], [arg('self', lineno=19, col_offset=17, end_lineno=19, end_col_offset=21), arg('placeholder_4', lineno=19, col_offset=23, end_lineno=19, end_col_offset=30), arg('placeholder_5', lineno=19, col_offset=32, end_lineno=19, end_col_offset=40)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=19, col_offset=41, end_lineno=19, end_col_offset=45)]), [Assign([Name('placeholder_5', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=16)], Call(Name('sorted', Load(), lineno=20, col_offset=19, end_lineno=20, end_col_offset=25), [BoolOp(Or(), [Name('placeholder_5', Load(), lineno=20, col_offset=26, end_lineno=20, end_col_offset=34), Attribute(Name('self', Load(), lineno=20, col_offset=38, end_lineno=20, end_col_offset=42), 'placeholder_1', Load(), lineno=20, col_offset=38, end_lineno=20, end_col_offset=51)], lineno=20, col_offset=26, end_lineno=20, end_col_offset=51)], [], lineno=20, col_offset=19, end_lineno=20, end_col_offset=52), lineno=20, col_offset=8, end_lineno=20, end_col_offset=52), Assign([Tuple([Name('placeholder_6', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=13), Name('placeholder_7', Store(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=19)], Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=19)], Call(Attribute(Name('placeholder_4', Load(), lineno=21, col_offset=22, end_lineno=21, end_col_offset=29), 'splitlines', Load(), lineno=21, col_offset=22, end_lineno=21, end_col_offset=40), [], [], lineno=21, col_offset=22, end_lineno=21, end_col_offset=42), lineno=21, col_offset=8, end_lineno=21, end_col_offset=42), Assign([Attribute(Name('self', Load(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=12), 'placeholder_8', Store(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=17)], Dict([], [], lineno=22, col_offset=20, end_lineno=22, end_col_offset=22), lineno=22, col_offset=8, end_lineno=22, end_col_offset=22), For(Tuple([Name('placeholder_9', Store(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=15), Name('placeholder_10', Store(), lineno=23, col_offset=17, end_lineno=23, end_col_offset=24)], Store(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=24), Call(Name('enumerate', Load(), lineno=23, col_offset=28, end_lineno=23, end_col_offset=37), [Subscript(Name('placeholder_5', Load(), lineno=23, col_offset=38, end_lineno=23, end_col_offset=46), Slice(upper=Call(Name('len', Load(), lineno=23, col_offset=49, end_lineno=23, end_col_offset=52), [Name('placeholder_6', Load(), lineno=23, col_offset=53, end_lineno=23, end_col_offset=58)], [], lineno=23, col_offset=49, end_lineno=23, end_col_offset=59), lineno=23, col_offset=47, end_lineno=23, end_col_offset=59), Load(), lineno=23, col_offset=38, end_lineno=23, end_col_offset=60)], [], lineno=23, col_offset=28, end_lineno=23, end_col_offset=61), [Assign([Name('placeholder_11', Store(), lineno=24, col_offset=12, end_lineno=24, end_col_offset=17)], BinOp(Name('placeholder_9', Load(), lineno=24, col_offset=20, end_lineno=24, end_col_offset=23), Mult(), Constant(2, lineno=24, col_offset=26, end_lineno=24, end_col_offset=27), lineno=24, col_offset=20, end_lineno=24, end_col_offset=27), lineno=24, col_offset=12, end_lineno=24, end_col_offset=27), Assign([Name('placeholder_12', Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=16)], BinOp(Name('placeholder_11', Load(), lineno=25, col_offset=19, end_lineno=25, end_col_offset=24), Add(), Constant(2, lineno=25, col_offset=27, end_lineno=25, end_col_offset=28), lineno=25, col_offset=19, end_lineno=25, end_col_offset=28), lineno=25, col_offset=12, end_lineno=25, end_col_offset=28), Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=16), 'placeholder_8', Load(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=21), 'setdefault', Load(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=32), [Name('placeholder_10', Load(), lineno=26, col_offset=33, end_lineno=26, end_col_offset=40), List([], Load(), lineno=26, col_offset=42, end_lineno=26, end_col_offset=44)], [], lineno=26, col_offset=12, end_lineno=26, end_col_offset=45), lineno=26, col_offset=12, end_lineno=26, end_col_offset=45), Expr(Call(Attribute(Subscript(Attribute(Name('self', Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=16), 'placeholder_8', Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=21), Name('placeholder_10', Load(), lineno=27, col_offset=22, end_lineno=27, end_col_offset=29), Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=30), 'extend', Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=37), [GeneratorExp(Subscript(Attribute(Name('self', Load(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=20), 'placeholder_2', Load(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=27), Name('placeholder_13', Load(), lineno=28, col_offset=28, end_lineno=28, end_col_offset=33), Load(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=34), [comprehension(Name('placeholder_13', Store(), lineno=28, col_offset=39, end_lineno=28, end_col_offset=44), Subscript(Name('placeholder_6', Load(), lineno=28, col_offset=48, end_lineno=28, end_col_offset=53), Slice(Name('placeholder_11', Load(), lineno=28, col_offset=54, end_lineno=28, end_col_offset=59), Name('placeholder_12', Load(), lineno=28, col_offset=60, end_lineno=28, end_col_offset=64), lineno=28, col_offset=54, end_lineno=28, end_col_offset=64), Load(), lineno=28, col_offset=48, end_lineno=28, end_col_offset=65), [], 0)], lineno=27, col_offset=37, end_lineno=29, end_col_offset=13)], [], lineno=27, col_offset=12, end_lineno=29, end_col_offset=13), lineno=27, col_offset=12, end_lineno=29, end_col_offset=13), Expr(Call(Attribute(Subscript(Attribute(Name('self', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=16), 'placeholder_8', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=21), Name('placeholder_10', Load(), lineno=30, col_offset=22, end_lineno=30, end_col_offset=29), Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=30), 'extend', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=37), [GeneratorExp(Subscript(Attribute(Name('self', Load(), lineno=31, col_offset=16, end_lineno=31, end_col_offset=20), 'placeholder_2', Load(), lineno=31, col_offset=16, end_lineno=31, end_col_offset=27), Name('placeholder_13', Load(), lineno=31, col_offset=28, end_lineno=31, end_col_offset=33), Load(), lineno=31, col_offset=16, end_lineno=31, end_col_offset=34), [comprehension(Name('placeholder_13', Store(), lineno=31, col_offset=39, end_lineno=31, end_col_offset=44), Subscript(Name('placeholder_7', Load(), lineno=31, col_offset=48, end_lineno=31, end_col_offset=52), Slice(Name('placeholder_11', Load(), lineno=31, col_offset=53, end_lineno=31, end_col_offset=58), Name('placeholder_12', Load(), lineno=31, col_offset=59, end_lineno=31, end_col_offset=63), lineno=31, col_offset=53, end_lineno=31, end_col_offset=63), Load(), lineno=31, col_offset=48, end_lineno=31, end_col_offset=64), [], 0)], lineno=30, col_offset=37, end_lineno=32, end_col_offset=13)], [], lineno=30, col_offset=12, end_lineno=32, end_col_offset=13), lineno=30, col_offset=12, end_lineno=32, end_col_offset=13)], [], lineno=23, col_offset=8, end_lineno=32, end_col_offset=13)], [], lineno=19, col_offset=4, end_lineno=32, end_col_offset=13), FunctionDef('placeholder_14', arguments([], [arg('self', lineno=34, col_offset=15, end_lineno=34, end_col_offset=19), arg('placeholder_10', lineno=34, col_offset=21, end_lineno=34, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Attribute(Name('self', Load(), lineno=35, col_offset=15, end_lineno=35, end_col_offset=19), 'placeholder_8', Load(), lineno=35, col_offset=15, end_lineno=35, end_col_offset=24), 'get', Load(), lineno=35, col_offset=15, end_lineno=35, end_col_offset=28), [Name('placeholder_10', Load(), lineno=35, col_offset=29, end_lineno=35, end_col_offset=36), List([], Load(), lineno=35, col_offset=38, end_lineno=35, end_col_offset=40)], [], lineno=35, col_offset=15, end_lineno=35, end_col_offset=41), lineno=35, col_offset=8, end_lineno=35, end_col_offset=41)], [], lineno=34, col_offset=4, end_lineno=35, end_col_offset=41)], [], lineno=1, col_offset=0, end_lineno=35, end_col_offset=41)], []) \ No newline at end of file diff --git a/test/practice-knapsack/.meta/config.json b/test/practice-knapsack/.meta/config.json new file mode 100644 index 0000000..91b4803 --- /dev/null +++ b/test/practice-knapsack/.meta/config.json @@ -0,0 +1,26 @@ +{ + "authors": [ + "omer-g" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "kylecjo", + "yawpitch" + ], + "files": { + "solution": [ + "knapsack.py" + ], + "test": [ + "knapsack_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a knapsack that can only carry a certain weight, determine which items to put in the knapsack in order to maximize their combined value.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Knapsack_problem" +} diff --git a/test/practice-knapsack/knapsack.py b/test/practice-knapsack/knapsack.py new file mode 100644 index 0000000..548dd5a --- /dev/null +++ b/test/practice-knapsack/knapsack.py @@ -0,0 +1,15 @@ +def maximum_value(maximum_weight, items): + totals = [[0 for _ in range(len(items) + 1)] + for _ in range(maximum_weight + 1)] + + for weight in range(1, maximum_weight + 1): + for index, item in enumerate(items, 1): + if item['weight'] <= weight: + value = item['value'] + \ + totals[weight - item['weight']][index - 1] + + value_without_item = totals[weight][index - 1] + totals[weight][index] = max(value, value_without_item) + else: + totals[weight][index] = totals[weight][index - 1] + return totals[maximum_weight][len(items)] diff --git a/test/practice-knapsack/mapping.json b/test/practice-knapsack/mapping.json new file mode 100644 index 0000000..4d08027 --- /dev/null +++ b/test/practice-knapsack/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "maximum_value", + "placeholder_1": "maximum_weight", + "placeholder_2": "items", + "placeholder_3": "totals", + "placeholder_4": "_", + "placeholder_5": "placeholder_4", + "placeholder_6": "weight", + "placeholder_7": "index", + "placeholder_8": "item", + "placeholder_9": "value", + "placeholder_10": "value_without_item" +} \ No newline at end of file diff --git a/test/practice-knapsack/representation.json b/test/practice-knapsack/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-knapsack/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-knapsack/representation.out b/test/practice-knapsack/representation.out new file mode 100644 index 0000000..6d8d131 --- /dev/null +++ b/test/practice-knapsack/representation.out @@ -0,0 +1,1388 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + placeholder_3 = [ + [0 for placeholder_5 in range(len(placeholder_2) + 1)] + for placeholder_4 in range(placeholder_1 + 1) + ] + for placeholder_6 in range(1, placeholder_1 + 1): + for placeholder_7, placeholder_8 in enumerate(placeholder_2, 1): + if placeholder_8["weight"] <= placeholder_6: + placeholder_9 = ( + placeholder_8["value"] + + placeholder_3[placeholder_6 - placeholder_8["weight"]][ + placeholder_7 - 1 + ] + ) + placeholder_10 = placeholder_3[placeholder_6][placeholder_7 - 1] + placeholder_3[placeholder_6][placeholder_7] = max( + placeholder_9, placeholder_10 + ) + else: + placeholder_3[placeholder_6][placeholder_7] = placeholder_3[ + placeholder_6 + ][placeholder_7 - 1] + return placeholder_3[placeholder_1][len(placeholder_2)] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'maximum_value', + arguments( + [], + [ + arg( + 'maximum_weight', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=32), + arg( + 'items', + lineno=1, + col_offset=34, + end_lineno=1, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'totals', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=10)], + ListComp( + ListComp( + Constant( + 0, + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=16), + [ + comprehension( + Name( + '_', + Store(), + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=22), + Call( + Name( + 'range', + Load(), + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=31), + [ + BinOp( + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=35), + [ + Name( + 'items', + Load(), + lineno=2, + col_offset=36, + end_lineno=2, + end_col_offset=41)], + [], + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=42), + Add(), + Constant( + 1, + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=46), + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=46)], + [], + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=47), + [], + 0)], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=48), + [ + comprehension( + Name( + '_', + Store(), + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=28), + [ + BinOp( + Name( + 'maximum_weight', + Load(), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=43), + Add(), + Constant( + 1, + lineno=3, + col_offset=46, + end_lineno=3, + end_col_offset=47), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=47)], + [], + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=48), + [], + 0)], + lineno=2, + col_offset=13, + end_lineno=3, + end_col_offset=49), + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=49), + For( + Name( + 'weight', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=14), + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=23), + [ + Constant( + 1, + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=25), + BinOp( + Name( + 'maximum_weight', + Load(), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=41), + Add(), + Constant( + 1, + lineno=5, + col_offset=44, + end_lineno=5, + end_col_offset=45), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=45)], + [], + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=46), + [ + For( + Tuple( + [ + Name( + 'index', + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=17), + Name( + 'item', + Store(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=23)], + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=23), + Call( + Name( + 'enumerate', + Load(), + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=36), + [ + Name( + 'items', + Load(), + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=42), + Constant( + 1, + lineno=6, + col_offset=44, + end_lineno=6, + end_col_offset=45)], + [], + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=46), + [ + If( + Compare( + Subscript( + Name( + 'item', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=19), + Constant( + 'weight', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=28), + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=29), + [ + LtE()], + [ + Name( + 'weight', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=39)], + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=39), + [ + Assign( + [ + Name( + 'value', + Store(), + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=21)], + BinOp( + Subscript( + Name( + 'item', + Load(), + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=28), + Constant( + 'value', + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=36), + Load(), + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=37), + Add(), + Subscript( + Subscript( + Name( + 'totals', + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=30), + BinOp( + Name( + 'weight', + Load(), + lineno=9, + col_offset=31, + end_lineno=9, + end_col_offset=37), + Sub(), + Subscript( + Name( + 'item', + Load(), + lineno=9, + col_offset=40, + end_lineno=9, + end_col_offset=44), + Constant( + 'weight', + lineno=9, + col_offset=45, + end_lineno=9, + end_col_offset=53), + Load(), + lineno=9, + col_offset=40, + end_lineno=9, + end_col_offset=54), + lineno=9, + col_offset=31, + end_lineno=9, + end_col_offset=54), + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=55), + BinOp( + Name( + 'index', + Load(), + lineno=9, + col_offset=56, + end_lineno=9, + end_col_offset=61), + Sub(), + Constant( + 1, + lineno=9, + col_offset=64, + end_lineno=9, + end_col_offset=65), + lineno=9, + col_offset=56, + end_lineno=9, + end_col_offset=65), + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=66), + lineno=8, + col_offset=24, + end_lineno=9, + end_col_offset=66), + lineno=8, + col_offset=16, + end_lineno=9, + end_col_offset=66), + Assign( + [ + Name( + 'value_without_item', + Store(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=34)], + Subscript( + Subscript( + Name( + 'totals', + Load(), + lineno=11, + col_offset=37, + end_lineno=11, + end_col_offset=43), + Name( + 'weight', + Load(), + lineno=11, + col_offset=44, + end_lineno=11, + end_col_offset=50), + Load(), + lineno=11, + col_offset=37, + end_lineno=11, + end_col_offset=51), + BinOp( + Name( + 'index', + Load(), + lineno=11, + col_offset=52, + end_lineno=11, + end_col_offset=57), + Sub(), + Constant( + 1, + lineno=11, + col_offset=60, + end_lineno=11, + end_col_offset=61), + lineno=11, + col_offset=52, + end_lineno=11, + end_col_offset=61), + Load(), + lineno=11, + col_offset=37, + end_lineno=11, + end_col_offset=62), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=62), + Assign( + [ + Subscript( + Subscript( + Name( + 'totals', + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=22), + Name( + 'weight', + Load(), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=29), + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=30), + Name( + 'index', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=36), + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=37)], + Call( + Name( + 'max', + Load(), + lineno=12, + col_offset=40, + end_lineno=12, + end_col_offset=43), + [ + Name( + 'value', + Load(), + lineno=12, + col_offset=44, + end_lineno=12, + end_col_offset=49), + Name( + 'value_without_item', + Load(), + lineno=12, + col_offset=51, + end_lineno=12, + end_col_offset=69)], + [], + lineno=12, + col_offset=40, + end_lineno=12, + end_col_offset=70), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=70)], + [ + Assign( + [ + Subscript( + Subscript( + Name( + 'totals', + Load(), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=22), + Name( + 'weight', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=29), + Load(), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=30), + Name( + 'index', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=36), + Store(), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=37)], + Subscript( + Subscript( + Name( + 'totals', + Load(), + lineno=14, + col_offset=40, + end_lineno=14, + end_col_offset=46), + Name( + 'weight', + Load(), + lineno=14, + col_offset=47, + end_lineno=14, + end_col_offset=53), + Load(), + lineno=14, + col_offset=40, + end_lineno=14, + end_col_offset=54), + BinOp( + Name( + 'index', + Load(), + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=60), + Sub(), + Constant( + 1, + lineno=14, + col_offset=63, + end_lineno=14, + end_col_offset=64), + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=64), + Load(), + lineno=14, + col_offset=40, + end_lineno=14, + end_col_offset=65), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=65)], + lineno=7, + col_offset=12, + end_lineno=14, + end_col_offset=65)], + [], + lineno=6, + col_offset=8, + end_lineno=14, + end_col_offset=65)], + [], + lineno=5, + col_offset=4, + end_lineno=14, + end_col_offset=65), + Return( + Subscript( + Subscript( + Name( + 'totals', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=17), + Name( + 'maximum_weight', + Load(), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=32), + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=33), + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=37), + [ + Name( + 'items', + Load(), + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=43)], + [], + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=44), + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=45), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=45)], + [], + lineno=1, + col_offset=0, + end_lineno=15, + end_col_offset=45)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=32), + arg( + 'placeholder_2', + lineno=1, + col_offset=34, + end_lineno=1, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=10)], + ListComp( + ListComp( + Constant( + 0, + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=16), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=22), + Call( + Name( + 'range', + Load(), + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=31), + [ + BinOp( + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=35), + [ + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=36, + end_lineno=2, + end_col_offset=41)], + [], + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=42), + Add(), + Constant( + 1, + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=46), + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=46)], + [], + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=47), + [], + 0)], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=48), + [ + comprehension( + Name( + 'placeholder_4', + Store(), + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=28), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=43), + Add(), + Constant( + 1, + lineno=3, + col_offset=46, + end_lineno=3, + end_col_offset=47), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=47)], + [], + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=48), + [], + 0)], + lineno=2, + col_offset=13, + end_lineno=3, + end_col_offset=49), + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=49), + For( + Name( + 'placeholder_6', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=14), + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=23), + [ + Constant( + 1, + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=25), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=41), + Add(), + Constant( + 1, + lineno=5, + col_offset=44, + end_lineno=5, + end_col_offset=45), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=45)], + [], + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=46), + [ + For( + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=17), + Name( + 'placeholder_8', + Store(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=23)], + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=23), + Call( + Name( + 'enumerate', + Load(), + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=36), + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=42), + Constant( + 1, + lineno=6, + col_offset=44, + end_lineno=6, + end_col_offset=45)], + [], + lineno=6, + col_offset=27, + end_lineno=6, + end_col_offset=46), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=19), + Constant( + 'weight', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=28), + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=29), + [ + LtE()], + [ + Name( + 'placeholder_6', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=39)], + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=39), + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=21)], + BinOp( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=28), + Constant( + 'value', + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=36), + Load(), + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=37), + Add(), + Subscript( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=30), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=9, + col_offset=31, + end_lineno=9, + end_col_offset=37), + Sub(), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=9, + col_offset=40, + end_lineno=9, + end_col_offset=44), + Constant( + 'weight', + lineno=9, + col_offset=45, + end_lineno=9, + end_col_offset=53), + Load(), + lineno=9, + col_offset=40, + end_lineno=9, + end_col_offset=54), + lineno=9, + col_offset=31, + end_lineno=9, + end_col_offset=54), + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=55), + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=9, + col_offset=56, + end_lineno=9, + end_col_offset=61), + Sub(), + Constant( + 1, + lineno=9, + col_offset=64, + end_lineno=9, + end_col_offset=65), + lineno=9, + col_offset=56, + end_lineno=9, + end_col_offset=65), + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=66), + lineno=8, + col_offset=24, + end_lineno=9, + end_col_offset=66), + lineno=8, + col_offset=16, + end_lineno=9, + end_col_offset=66), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=34)], + Subscript( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=37, + end_lineno=11, + end_col_offset=43), + Name( + 'placeholder_6', + Load(), + lineno=11, + col_offset=44, + end_lineno=11, + end_col_offset=50), + Load(), + lineno=11, + col_offset=37, + end_lineno=11, + end_col_offset=51), + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=52, + end_lineno=11, + end_col_offset=57), + Sub(), + Constant( + 1, + lineno=11, + col_offset=60, + end_lineno=11, + end_col_offset=61), + lineno=11, + col_offset=52, + end_lineno=11, + end_col_offset=61), + Load(), + lineno=11, + col_offset=37, + end_lineno=11, + end_col_offset=62), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=62), + Assign( + [ + Subscript( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=22), + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=29), + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=30), + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=36), + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=37)], + Call( + Name( + 'max', + Load(), + lineno=12, + col_offset=40, + end_lineno=12, + end_col_offset=43), + [ + Name( + 'placeholder_9', + Load(), + lineno=12, + col_offset=44, + end_lineno=12, + end_col_offset=49), + Name( + 'placeholder_10', + Load(), + lineno=12, + col_offset=51, + end_lineno=12, + end_col_offset=69)], + [], + lineno=12, + col_offset=40, + end_lineno=12, + end_col_offset=70), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=70)], + [ + Assign( + [ + Subscript( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=22), + Name( + 'placeholder_6', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=29), + Load(), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=30), + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=36), + Store(), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=37)], + Subscript( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=14, + col_offset=40, + end_lineno=14, + end_col_offset=46), + Name( + 'placeholder_6', + Load(), + lineno=14, + col_offset=47, + end_lineno=14, + end_col_offset=53), + Load(), + lineno=14, + col_offset=40, + end_lineno=14, + end_col_offset=54), + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=60), + Sub(), + Constant( + 1, + lineno=14, + col_offset=63, + end_lineno=14, + end_col_offset=64), + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=64), + Load(), + lineno=14, + col_offset=40, + end_lineno=14, + end_col_offset=65), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=65)], + lineno=7, + col_offset=12, + end_lineno=14, + end_col_offset=65)], + [], + lineno=6, + col_offset=8, + end_lineno=14, + end_col_offset=65)], + [], + lineno=5, + col_offset=4, + end_lineno=14, + end_col_offset=65), + Return( + Subscript( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=17), + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=32), + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=33), + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=37), + [ + Name( + 'placeholder_2', + Load(), + lineno=15, + col_offset=38, + end_lineno=15, + end_col_offset=43)], + [], + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=44), + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=45), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=45)], + [], + lineno=1, + col_offset=0, + end_lineno=15, + end_col_offset=45)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-knapsack/representation.txt b/test/practice-knapsack/representation.txt new file mode 100644 index 0000000..22a6c51 --- /dev/null +++ b/test/practice-knapsack/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=18, end_lineno=1, end_col_offset=32), arg('placeholder_2', lineno=1, col_offset=34, end_lineno=1, end_col_offset=39)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=10)], ListComp(ListComp(Constant(0, lineno=2, col_offset=15, end_lineno=2, end_col_offset=16), [comprehension(Name('placeholder_5', Store(), lineno=2, col_offset=21, end_lineno=2, end_col_offset=22), Call(Name('range', Load(), lineno=2, col_offset=26, end_lineno=2, end_col_offset=31), [BinOp(Call(Name('len', Load(), lineno=2, col_offset=32, end_lineno=2, end_col_offset=35), [Name('placeholder_2', Load(), lineno=2, col_offset=36, end_lineno=2, end_col_offset=41)], [], lineno=2, col_offset=32, end_lineno=2, end_col_offset=42), Add(), Constant(1, lineno=2, col_offset=45, end_lineno=2, end_col_offset=46), lineno=2, col_offset=32, end_lineno=2, end_col_offset=46)], [], lineno=2, col_offset=26, end_lineno=2, end_col_offset=47), [], 0)], lineno=2, col_offset=14, end_lineno=2, end_col_offset=48), [comprehension(Name('placeholder_4', Store(), lineno=3, col_offset=18, end_lineno=3, end_col_offset=19), Call(Name('range', Load(), lineno=3, col_offset=23, end_lineno=3, end_col_offset=28), [BinOp(Name('placeholder_1', Load(), lineno=3, col_offset=29, end_lineno=3, end_col_offset=43), Add(), Constant(1, lineno=3, col_offset=46, end_lineno=3, end_col_offset=47), lineno=3, col_offset=29, end_lineno=3, end_col_offset=47)], [], lineno=3, col_offset=23, end_lineno=3, end_col_offset=48), [], 0)], lineno=2, col_offset=13, end_lineno=3, end_col_offset=49), lineno=2, col_offset=4, end_lineno=3, end_col_offset=49), For(Name('placeholder_6', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=14), Call(Name('range', Load(), lineno=5, col_offset=18, end_lineno=5, end_col_offset=23), [Constant(1, lineno=5, col_offset=24, end_lineno=5, end_col_offset=25), BinOp(Name('placeholder_1', Load(), lineno=5, col_offset=27, end_lineno=5, end_col_offset=41), Add(), Constant(1, lineno=5, col_offset=44, end_lineno=5, end_col_offset=45), lineno=5, col_offset=27, end_lineno=5, end_col_offset=45)], [], lineno=5, col_offset=18, end_lineno=5, end_col_offset=46), [For(Tuple([Name('placeholder_7', Store(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=17), Name('placeholder_8', Store(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=23)], Store(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=23), Call(Name('enumerate', Load(), lineno=6, col_offset=27, end_lineno=6, end_col_offset=36), [Name('placeholder_2', Load(), lineno=6, col_offset=37, end_lineno=6, end_col_offset=42), Constant(1, lineno=6, col_offset=44, end_lineno=6, end_col_offset=45)], [], lineno=6, col_offset=27, end_lineno=6, end_col_offset=46), [If(Compare(Subscript(Name('placeholder_8', Load(), lineno=7, col_offset=15, end_lineno=7, end_col_offset=19), Constant('weight', lineno=7, col_offset=20, end_lineno=7, end_col_offset=28), Load(), lineno=7, col_offset=15, end_lineno=7, end_col_offset=29), [LtE()], [Name('placeholder_6', Load(), lineno=7, col_offset=33, end_lineno=7, end_col_offset=39)], lineno=7, col_offset=15, end_lineno=7, end_col_offset=39), [Assign([Name('placeholder_9', Store(), lineno=8, col_offset=16, end_lineno=8, end_col_offset=21)], BinOp(Subscript(Name('placeholder_8', Load(), lineno=8, col_offset=24, end_lineno=8, end_col_offset=28), Constant('value', lineno=8, col_offset=29, end_lineno=8, end_col_offset=36), Load(), lineno=8, col_offset=24, end_lineno=8, end_col_offset=37), Add(), Subscript(Subscript(Name('placeholder_3', Load(), lineno=9, col_offset=24, end_lineno=9, end_col_offset=30), BinOp(Name('placeholder_6', Load(), lineno=9, col_offset=31, end_lineno=9, end_col_offset=37), Sub(), Subscript(Name('placeholder_8', Load(), lineno=9, col_offset=40, end_lineno=9, end_col_offset=44), Constant('weight', lineno=9, col_offset=45, end_lineno=9, end_col_offset=53), Load(), lineno=9, col_offset=40, end_lineno=9, end_col_offset=54), lineno=9, col_offset=31, end_lineno=9, end_col_offset=54), Load(), lineno=9, col_offset=24, end_lineno=9, end_col_offset=55), BinOp(Name('placeholder_7', Load(), lineno=9, col_offset=56, end_lineno=9, end_col_offset=61), Sub(), Constant(1, lineno=9, col_offset=64, end_lineno=9, end_col_offset=65), lineno=9, col_offset=56, end_lineno=9, end_col_offset=65), Load(), lineno=9, col_offset=24, end_lineno=9, end_col_offset=66), lineno=8, col_offset=24, end_lineno=9, end_col_offset=66), lineno=8, col_offset=16, end_lineno=9, end_col_offset=66), Assign([Name('placeholder_10', Store(), lineno=11, col_offset=16, end_lineno=11, end_col_offset=34)], Subscript(Subscript(Name('placeholder_3', Load(), lineno=11, col_offset=37, end_lineno=11, end_col_offset=43), Name('placeholder_6', Load(), lineno=11, col_offset=44, end_lineno=11, end_col_offset=50), Load(), lineno=11, col_offset=37, end_lineno=11, end_col_offset=51), BinOp(Name('placeholder_7', Load(), lineno=11, col_offset=52, end_lineno=11, end_col_offset=57), Sub(), Constant(1, lineno=11, col_offset=60, end_lineno=11, end_col_offset=61), lineno=11, col_offset=52, end_lineno=11, end_col_offset=61), Load(), lineno=11, col_offset=37, end_lineno=11, end_col_offset=62), lineno=11, col_offset=16, end_lineno=11, end_col_offset=62), Assign([Subscript(Subscript(Name('placeholder_3', Load(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=22), Name('placeholder_6', Load(), lineno=12, col_offset=23, end_lineno=12, end_col_offset=29), Load(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=30), Name('placeholder_7', Load(), lineno=12, col_offset=31, end_lineno=12, end_col_offset=36), Store(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=37)], Call(Name('max', Load(), lineno=12, col_offset=40, end_lineno=12, end_col_offset=43), [Name('placeholder_9', Load(), lineno=12, col_offset=44, end_lineno=12, end_col_offset=49), Name('placeholder_10', Load(), lineno=12, col_offset=51, end_lineno=12, end_col_offset=69)], [], lineno=12, col_offset=40, end_lineno=12, end_col_offset=70), lineno=12, col_offset=16, end_lineno=12, end_col_offset=70)], [Assign([Subscript(Subscript(Name('placeholder_3', Load(), lineno=14, col_offset=16, end_lineno=14, end_col_offset=22), Name('placeholder_6', Load(), lineno=14, col_offset=23, end_lineno=14, end_col_offset=29), Load(), lineno=14, col_offset=16, end_lineno=14, end_col_offset=30), Name('placeholder_7', Load(), lineno=14, col_offset=31, end_lineno=14, end_col_offset=36), Store(), lineno=14, col_offset=16, end_lineno=14, end_col_offset=37)], Subscript(Subscript(Name('placeholder_3', Load(), lineno=14, col_offset=40, end_lineno=14, end_col_offset=46), Name('placeholder_6', Load(), lineno=14, col_offset=47, end_lineno=14, end_col_offset=53), Load(), lineno=14, col_offset=40, end_lineno=14, end_col_offset=54), BinOp(Name('placeholder_7', Load(), lineno=14, col_offset=55, end_lineno=14, end_col_offset=60), Sub(), Constant(1, lineno=14, col_offset=63, end_lineno=14, end_col_offset=64), lineno=14, col_offset=55, end_lineno=14, end_col_offset=64), Load(), lineno=14, col_offset=40, end_lineno=14, end_col_offset=65), lineno=14, col_offset=16, end_lineno=14, end_col_offset=65)], lineno=7, col_offset=12, end_lineno=14, end_col_offset=65)], [], lineno=6, col_offset=8, end_lineno=14, end_col_offset=65)], [], lineno=5, col_offset=4, end_lineno=14, end_col_offset=65), Return(Subscript(Subscript(Name('placeholder_3', Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=17), Name('placeholder_1', Load(), lineno=15, col_offset=18, end_lineno=15, end_col_offset=32), Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=33), Call(Name('len', Load(), lineno=15, col_offset=34, end_lineno=15, end_col_offset=37), [Name('placeholder_2', Load(), lineno=15, col_offset=38, end_lineno=15, end_col_offset=43)], [], lineno=15, col_offset=34, end_lineno=15, end_col_offset=44), Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=45), lineno=15, col_offset=4, end_lineno=15, end_col_offset=45)], [], lineno=1, col_offset=0, end_lineno=15, end_col_offset=45)], []) \ No newline at end of file diff --git a/test/practice-largest-series-product/.meta/additional_tests.json b/test/practice-largest-series-product/.meta/additional_tests.json new file mode 100644 index 0000000..e5b5d5c --- /dev/null +++ b/test/practice-largest-series-product/.meta/additional_tests.json @@ -0,0 +1,13 @@ +{ + "cases": [ + { + "description": "euler big number", + "property": "largestProduct", + "input": { + "digits": "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450", + "span": 13 + }, + "expected": 23514624000 + } + ] +} diff --git a/test/practice-largest-series-product/.meta/config.json b/test/practice-largest-series-product/.meta/config.json new file mode 100644 index 0000000..138f359 --- /dev/null +++ b/test/practice-largest-series-product/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "alexpjohnson", + "behrtam", + "cmccandless", + "Dog", + "fortrieb", + "iandexter", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "petertseng", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "largest_series_product.py" + ], + "test": [ + "largest_series_product_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.", + "source": "A variation on Problem 8 at Project Euler", + "source_url": "https://projecteuler.net/problem=8" +} diff --git a/test/practice-largest-series-product/largest_series_product.py b/test/practice-largest-series-product/largest_series_product.py new file mode 100644 index 0000000..0599e74 --- /dev/null +++ b/test/practice-largest-series-product/largest_series_product.py @@ -0,0 +1,23 @@ +from functools import reduce +from operator import mul + + +def slices(series, size): + + if not size <= len(series): + raise ValueError('span must be smaller than string length') + elif not 0 < size: + raise ValueError('span must not be negative') + elif not all(item.isdigit() for item in series): + raise ValueError('digits input must only contain digits') + + numbers = [int(digit) for digit in series] + + return [numbers[idx:idx + size] + for idx in range(len(numbers) - size + 1)] + + +def largest_product(series, size): + if size == 0: + return 1 + return max(reduce(mul, slice) for slice in slices(series, size)) diff --git a/test/practice-largest-series-product/mapping.json b/test/practice-largest-series-product/mapping.json new file mode 100644 index 0000000..4eb805f --- /dev/null +++ b/test/practice-largest-series-product/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "slices", + "placeholder_1": "series", + "placeholder_2": "size", + "placeholder_3": "item", + "placeholder_4": "numbers", + "placeholder_5": "digit", + "placeholder_6": "idx", + "placeholder_7": "largest_product" +} \ No newline at end of file diff --git a/test/practice-largest-series-product/representation.json b/test/practice-largest-series-product/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-largest-series-product/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-largest-series-product/representation.out b/test/practice-largest-series-product/representation.out new file mode 100644 index 0000000..103b32b --- /dev/null +++ b/test/practice-largest-series-product/representation.out @@ -0,0 +1,1283 @@ +## BEGIN NORMALIZED CODE ## +from functools import reduce +from operator import mul + + +def placeholder_0(placeholder_1, placeholder_2): + if not placeholder_2 <= len(placeholder_1): + raise ValueError("span must be smaller than string length") + elif not 0 < placeholder_2: + raise ValueError("span must not be negative") + elif not all((placeholder_3.isdigit() for placeholder_3 in placeholder_1)): + raise ValueError("digits input must only contain digits") + placeholder_4 = [int(placeholder_5) for placeholder_5 in placeholder_1] + return [ + placeholder_4[placeholder_6 : placeholder_6 + placeholder_2] + for placeholder_6 in range(len(placeholder_4) - placeholder_2 + 1) + ] + + +def placeholder_7(placeholder_1, placeholder_2): + if placeholder_2 == 0: + return 1 + return max( + (reduce(mul, slice) for slice in placeholder_0(placeholder_1, placeholder_2)) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'functools', + [ + alias( + 'reduce', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=28)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=28), + ImportFrom( + 'operator', + [ + alias( + 'mul', + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=24)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=24), + FunctionDef( + 'slices', + arguments( + [], + [ + arg( + 'series', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17), + arg( + 'size', + lineno=5, + col_offset=19, + end_lineno=5, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Compare( + Name( + 'size', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=15), + [ + LtE()], + [ + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=22), + [ + Name( + 'series', + Load(), + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=29)], + [], + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=30)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=30), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=24), + [ + Constant( + 'span must be smaller than string length', + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=66)], + [], + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=67), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=67)], + [ + If( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=14), + [ + Lt()], + [ + Name( + 'size', + Load(), + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=21), + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=21), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=24), + [ + Constant( + 'span must not be negative', + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=52)], + [], + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=53), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=53)], + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'all', + Load(), + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=16), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'item', + Load(), + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=21), + 'isdigit', + Load(), + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=29), + [], + [], + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=31), + [ + comprehension( + Name( + 'item', + Store(), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=40), + Name( + 'series', + Load(), + lineno=11, + col_offset=44, + end_lineno=11, + end_col_offset=50), + [], + 0)], + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=51)], + [], + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=51), + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=51), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=24), + [ + Constant( + 'digits input must only contain digits', + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=64)], + [], + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=65), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=65)], + [], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=65)], + lineno=9, + col_offset=4, + end_lineno=12, + end_col_offset=65)], + lineno=7, + col_offset=4, + end_lineno=12, + end_col_offset=65), + Assign( + [ + Name( + 'numbers', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=11)], + ListComp( + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=18), + [ + Name( + 'digit', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=24)], + [], + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=25), + [ + comprehension( + Name( + 'digit', + Store(), + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=35), + Name( + 'series', + Load(), + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=45), + [], + 0)], + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=46), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=46), + Return( + ListComp( + Subscript( + Name( + 'numbers', + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=19), + Slice( + Name( + 'idx', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=23), + BinOp( + Name( + 'idx', + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=27), + Add(), + Name( + 'size', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=34), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=34), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=34), + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=35), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=28), + [ + BinOp( + BinOp( + Call( + Name( + 'len', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=32), + [ + Name( + 'numbers', + Load(), + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=40)], + [], + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=41), + Sub(), + Name( + 'size', + Load(), + lineno=17, + col_offset=44, + end_lineno=17, + end_col_offset=48), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=48), + Add(), + Constant( + 1, + lineno=17, + col_offset=51, + end_lineno=17, + end_col_offset=52), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=52)], + [], + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=53), + [], + 0)], + lineno=16, + col_offset=11, + end_lineno=17, + end_col_offset=54), + lineno=16, + col_offset=4, + end_lineno=17, + end_col_offset=54)], + [], + lineno=5, + col_offset=0, + end_lineno=17, + end_col_offset=54), + FunctionDef( + 'largest_product', + arguments( + [], + [ + arg( + 'series', + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=26), + arg( + 'size', + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'size', + Load(), + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=11), + [ + Eq()], + [ + Constant( + 0, + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=16)], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=16), + [ + Return( + Constant( + 1, + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=16), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=16)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=16), + Return( + Call( + Name( + 'max', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=14), + [ + GeneratorExp( + Call( + Name( + 'reduce', + Load(), + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=21), + [ + Name( + 'mul', + Load(), + lineno=23, + col_offset=22, + end_lineno=23, + end_col_offset=25), + Name( + 'slice', + Load(), + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=32)], + [], + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=33), + [ + comprehension( + Name( + 'slice', + Store(), + lineno=23, + col_offset=38, + end_lineno=23, + end_col_offset=43), + Call( + Name( + 'slices', + Load(), + lineno=23, + col_offset=47, + end_lineno=23, + end_col_offset=53), + [ + Name( + 'series', + Load(), + lineno=23, + col_offset=54, + end_lineno=23, + end_col_offset=60), + Name( + 'size', + Load(), + lineno=23, + col_offset=62, + end_lineno=23, + end_col_offset=66)], + [], + lineno=23, + col_offset=47, + end_lineno=23, + end_col_offset=67), + [], + 0)], + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=68)], + [], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=68), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=68)], + [], + lineno=20, + col_offset=0, + end_lineno=23, + end_col_offset=68)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'functools', + [ + alias( + 'reduce', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=28)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=28), + ImportFrom( + 'operator', + [ + alias( + 'mul', + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=24)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=24), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17), + arg( + 'placeholder_2', + lineno=5, + col_offset=19, + end_lineno=5, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Compare( + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=15), + [ + LtE()], + [ + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=22), + [ + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=29)], + [], + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=30)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=30), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=24), + [ + Constant( + 'span must be smaller than string length', + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=66)], + [], + lineno=8, + col_offset=14, + end_lineno=8, + end_col_offset=67), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=67)], + [ + If( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=14), + [ + Lt()], + [ + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=21), + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=21), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=24), + [ + Constant( + 'span must not be negative', + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=52)], + [], + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=53), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=53)], + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'all', + Load(), + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=16), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=21), + 'isdigit', + Load(), + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=29), + [], + [], + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=31), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=40), + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=44, + end_lineno=11, + end_col_offset=50), + [], + 0)], + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=51)], + [], + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=51), + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=51), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=24), + [ + Constant( + 'digits input must only contain digits', + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=64)], + [], + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=65), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=65)], + [], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=65)], + lineno=9, + col_offset=4, + end_lineno=12, + end_col_offset=65)], + lineno=7, + col_offset=4, + end_lineno=12, + end_col_offset=65), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=11)], + ListComp( + Call( + Name( + 'int', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=18), + [ + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=24)], + [], + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=25), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=35), + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=45), + [], + 0)], + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=46), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=46), + Return( + ListComp( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=19), + Slice( + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=23), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=27), + Add(), + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=34), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=34), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=34), + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=35), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=28), + [ + BinOp( + BinOp( + Call( + Name( + 'len', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=32), + [ + Name( + 'placeholder_4', + Load(), + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=40)], + [], + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=41), + Sub(), + Name( + 'placeholder_2', + Load(), + lineno=17, + col_offset=44, + end_lineno=17, + end_col_offset=48), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=48), + Add(), + Constant( + 1, + lineno=17, + col_offset=51, + end_lineno=17, + end_col_offset=52), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=52)], + [], + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=53), + [], + 0)], + lineno=16, + col_offset=11, + end_lineno=17, + end_col_offset=54), + lineno=16, + col_offset=4, + end_lineno=17, + end_col_offset=54)], + [], + lineno=5, + col_offset=0, + end_lineno=17, + end_col_offset=54), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=26), + arg( + 'placeholder_2', + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=11), + [ + Eq()], + [ + Constant( + 0, + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=16)], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=16), + [ + Return( + Constant( + 1, + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=16), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=16)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=16), + Return( + Call( + Name( + 'max', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=14), + [ + GeneratorExp( + Call( + Name( + 'reduce', + Load(), + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=21), + [ + Name( + 'mul', + Load(), + lineno=23, + col_offset=22, + end_lineno=23, + end_col_offset=25), + Name( + 'slice', + Load(), + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=32)], + [], + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=33), + [ + comprehension( + Name( + 'slice', + Store(), + lineno=23, + col_offset=38, + end_lineno=23, + end_col_offset=43), + Call( + Name( + 'placeholder_0', + Load(), + lineno=23, + col_offset=47, + end_lineno=23, + end_col_offset=53), + [ + Name( + 'placeholder_1', + Load(), + lineno=23, + col_offset=54, + end_lineno=23, + end_col_offset=60), + Name( + 'placeholder_2', + Load(), + lineno=23, + col_offset=62, + end_lineno=23, + end_col_offset=66)], + [], + lineno=23, + col_offset=47, + end_lineno=23, + end_col_offset=67), + [], + 0)], + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=68)], + [], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=68), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=68)], + [], + lineno=20, + col_offset=0, + end_lineno=23, + end_col_offset=68)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-largest-series-product/representation.txt b/test/practice-largest-series-product/representation.txt new file mode 100644 index 0000000..5d883dc --- /dev/null +++ b/test/practice-largest-series-product/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('functools', [alias('reduce', lineno=1, col_offset=22, end_lineno=1, end_col_offset=28)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=28), ImportFrom('operator', [alias('mul', lineno=2, col_offset=21, end_lineno=2, end_col_offset=24)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=24), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=11, end_lineno=5, end_col_offset=17), arg('placeholder_2', lineno=5, col_offset=19, end_lineno=5, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Compare(Name('placeholder_2', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=15), [LtE()], [Call(Name('len', Load(), lineno=7, col_offset=19, end_lineno=7, end_col_offset=22), [Name('placeholder_1', Load(), lineno=7, col_offset=23, end_lineno=7, end_col_offset=29)], [], lineno=7, col_offset=19, end_lineno=7, end_col_offset=30)], lineno=7, col_offset=11, end_lineno=7, end_col_offset=30), lineno=7, col_offset=7, end_lineno=7, end_col_offset=30), [Raise(Call(Name('ValueError', Load(), lineno=8, col_offset=14, end_lineno=8, end_col_offset=24), [Constant('span must be smaller than string length', lineno=8, col_offset=25, end_lineno=8, end_col_offset=66)], [], lineno=8, col_offset=14, end_lineno=8, end_col_offset=67), lineno=8, col_offset=8, end_lineno=8, end_col_offset=67)], [If(UnaryOp(Not(), Compare(Constant(0, lineno=9, col_offset=13, end_lineno=9, end_col_offset=14), [Lt()], [Name('placeholder_2', Load(), lineno=9, col_offset=17, end_lineno=9, end_col_offset=21)], lineno=9, col_offset=13, end_lineno=9, end_col_offset=21), lineno=9, col_offset=9, end_lineno=9, end_col_offset=21), [Raise(Call(Name('ValueError', Load(), lineno=10, col_offset=14, end_lineno=10, end_col_offset=24), [Constant('span must not be negative', lineno=10, col_offset=25, end_lineno=10, end_col_offset=52)], [], lineno=10, col_offset=14, end_lineno=10, end_col_offset=53), lineno=10, col_offset=8, end_lineno=10, end_col_offset=53)], [If(UnaryOp(Not(), Call(Name('all', Load(), lineno=11, col_offset=13, end_lineno=11, end_col_offset=16), [GeneratorExp(Call(Attribute(Name('placeholder_3', Load(), lineno=11, col_offset=17, end_lineno=11, end_col_offset=21), 'isdigit', Load(), lineno=11, col_offset=17, end_lineno=11, end_col_offset=29), [], [], lineno=11, col_offset=17, end_lineno=11, end_col_offset=31), [comprehension(Name('placeholder_3', Store(), lineno=11, col_offset=36, end_lineno=11, end_col_offset=40), Name('placeholder_1', Load(), lineno=11, col_offset=44, end_lineno=11, end_col_offset=50), [], 0)], lineno=11, col_offset=16, end_lineno=11, end_col_offset=51)], [], lineno=11, col_offset=13, end_lineno=11, end_col_offset=51), lineno=11, col_offset=9, end_lineno=11, end_col_offset=51), [Raise(Call(Name('ValueError', Load(), lineno=12, col_offset=14, end_lineno=12, end_col_offset=24), [Constant('digits input must only contain digits', lineno=12, col_offset=25, end_lineno=12, end_col_offset=64)], [], lineno=12, col_offset=14, end_lineno=12, end_col_offset=65), lineno=12, col_offset=8, end_lineno=12, end_col_offset=65)], [], lineno=11, col_offset=4, end_lineno=12, end_col_offset=65)], lineno=9, col_offset=4, end_lineno=12, end_col_offset=65)], lineno=7, col_offset=4, end_lineno=12, end_col_offset=65), Assign([Name('placeholder_4', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=11)], ListComp(Call(Name('int', Load(), lineno=14, col_offset=15, end_lineno=14, end_col_offset=18), [Name('placeholder_5', Load(), lineno=14, col_offset=19, end_lineno=14, end_col_offset=24)], [], lineno=14, col_offset=15, end_lineno=14, end_col_offset=25), [comprehension(Name('placeholder_5', Store(), lineno=14, col_offset=30, end_lineno=14, end_col_offset=35), Name('placeholder_1', Load(), lineno=14, col_offset=39, end_lineno=14, end_col_offset=45), [], 0)], lineno=14, col_offset=14, end_lineno=14, end_col_offset=46), lineno=14, col_offset=4, end_lineno=14, end_col_offset=46), Return(ListComp(Subscript(Name('placeholder_4', Load(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=19), Slice(Name('placeholder_6', Load(), lineno=16, col_offset=20, end_lineno=16, end_col_offset=23), BinOp(Name('placeholder_6', Load(), lineno=16, col_offset=24, end_lineno=16, end_col_offset=27), Add(), Name('placeholder_2', Load(), lineno=16, col_offset=30, end_lineno=16, end_col_offset=34), lineno=16, col_offset=24, end_lineno=16, end_col_offset=34), lineno=16, col_offset=20, end_lineno=16, end_col_offset=34), Load(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=35), [comprehension(Name('placeholder_6', Store(), lineno=17, col_offset=16, end_lineno=17, end_col_offset=19), Call(Name('range', Load(), lineno=17, col_offset=23, end_lineno=17, end_col_offset=28), [BinOp(BinOp(Call(Name('len', Load(), lineno=17, col_offset=29, end_lineno=17, end_col_offset=32), [Name('placeholder_4', Load(), lineno=17, col_offset=33, end_lineno=17, end_col_offset=40)], [], lineno=17, col_offset=29, end_lineno=17, end_col_offset=41), Sub(), Name('placeholder_2', Load(), lineno=17, col_offset=44, end_lineno=17, end_col_offset=48), lineno=17, col_offset=29, end_lineno=17, end_col_offset=48), Add(), Constant(1, lineno=17, col_offset=51, end_lineno=17, end_col_offset=52), lineno=17, col_offset=29, end_lineno=17, end_col_offset=52)], [], lineno=17, col_offset=23, end_lineno=17, end_col_offset=53), [], 0)], lineno=16, col_offset=11, end_lineno=17, end_col_offset=54), lineno=16, col_offset=4, end_lineno=17, end_col_offset=54)], [], lineno=5, col_offset=0, end_lineno=17, end_col_offset=54), FunctionDef('placeholder_7', arguments([], [arg('placeholder_1', lineno=20, col_offset=20, end_lineno=20, end_col_offset=26), arg('placeholder_2', lineno=20, col_offset=28, end_lineno=20, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_2', Load(), lineno=21, col_offset=7, end_lineno=21, end_col_offset=11), [Eq()], [Constant(0, lineno=21, col_offset=15, end_lineno=21, end_col_offset=16)], lineno=21, col_offset=7, end_lineno=21, end_col_offset=16), [Return(Constant(1, lineno=22, col_offset=15, end_lineno=22, end_col_offset=16), lineno=22, col_offset=8, end_lineno=22, end_col_offset=16)], [], lineno=21, col_offset=4, end_lineno=22, end_col_offset=16), Return(Call(Name('max', Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=14), [GeneratorExp(Call(Name('reduce', Load(), lineno=23, col_offset=15, end_lineno=23, end_col_offset=21), [Name('mul', Load(), lineno=23, col_offset=22, end_lineno=23, end_col_offset=25), Name('slice', Load(), lineno=23, col_offset=27, end_lineno=23, end_col_offset=32)], [], lineno=23, col_offset=15, end_lineno=23, end_col_offset=33), [comprehension(Name('slice', Store(), lineno=23, col_offset=38, end_lineno=23, end_col_offset=43), Call(Name('placeholder_0', Load(), lineno=23, col_offset=47, end_lineno=23, end_col_offset=53), [Name('placeholder_1', Load(), lineno=23, col_offset=54, end_lineno=23, end_col_offset=60), Name('placeholder_2', Load(), lineno=23, col_offset=62, end_lineno=23, end_col_offset=66)], [], lineno=23, col_offset=47, end_lineno=23, end_col_offset=67), [], 0)], lineno=23, col_offset=14, end_lineno=23, end_col_offset=68)], [], lineno=23, col_offset=11, end_lineno=23, end_col_offset=68), lineno=23, col_offset=4, end_lineno=23, end_col_offset=68)], [], lineno=20, col_offset=0, end_lineno=23, end_col_offset=68)], []) \ No newline at end of file diff --git a/test/practice-leap/.meta/config.json b/test/practice-leap/.meta/config.json new file mode 100644 index 0000000..fd2bd24 --- /dev/null +++ b/test/practice-leap/.meta/config.json @@ -0,0 +1,38 @@ +{ + "authors": [], + "contributors": [ + "AnAccountForReportingBugs", + "behrtam", + "BethanyG", + "betojulio", + "cmccandless", + "cruxicheiros", + "Dog", + "fluxusfrequency", + "iandexter", + "ikhadykin", + "kytrinyx", + "lowks", + "N-Parsons", + "olufotebig", + "pheanex", + "sambryant4", + "sjakobi", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "leap.py" + ], + "test": [ + "leap_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a year, report if it is a leap year.", + "source": "CodeRanch Cattle Drive, Assignment 3", + "source_url": "https://coderanch.com/t/718816/Leap" +} diff --git a/test/practice-leap/leap.py b/test/practice-leap/leap.py new file mode 100644 index 0000000..df5c3e6 --- /dev/null +++ b/test/practice-leap/leap.py @@ -0,0 +1,2 @@ +def leap_year(year): + return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) diff --git a/test/practice-leap/mapping.json b/test/practice-leap/mapping.json new file mode 100644 index 0000000..c42848d --- /dev/null +++ b/test/practice-leap/mapping.json @@ -0,0 +1,4 @@ +{ + "placeholder_0": "leap_year", + "placeholder_1": "year" +} \ No newline at end of file diff --git a/test/practice-leap/representation.json b/test/practice-leap/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-leap/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-leap/representation.out b/test/practice-leap/representation.out new file mode 100644 index 0000000..2c83026 --- /dev/null +++ b/test/practice-leap/representation.out @@ -0,0 +1,295 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return placeholder_1 % 4 == 0 and ( + placeholder_1 % 100 != 0 or placeholder_1 % 400 == 0 + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'leap_year', + arguments( + [], + [ + arg( + 'year', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + BinOp( + Name( + 'year', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=15), + Mod(), + Constant( + 4, + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=19), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=19), + [ + Eq()], + [ + Constant( + 0, + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=24)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=24), + BoolOp( + Or(), + [ + Compare( + BinOp( + Name( + 'year', + Load(), + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=34), + Mod(), + Constant( + 100, + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=40), + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=40), + [ + NotEq()], + [ + Constant( + 0, + lineno=2, + col_offset=44, + end_lineno=2, + end_col_offset=45)], + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=45), + Compare( + BinOp( + Name( + 'year', + Load(), + lineno=2, + col_offset=49, + end_lineno=2, + end_col_offset=53), + Mod(), + Constant( + 400, + lineno=2, + col_offset=56, + end_lineno=2, + end_col_offset=59), + lineno=2, + col_offset=49, + end_lineno=2, + end_col_offset=59), + [ + Eq()], + [ + Constant( + 0, + lineno=2, + col_offset=63, + end_lineno=2, + end_col_offset=64)], + lineno=2, + col_offset=49, + end_lineno=2, + end_col_offset=64)], + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=64)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=65), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=65)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=65)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=15), + Mod(), + Constant( + 4, + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=19), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=19), + [ + Eq()], + [ + Constant( + 0, + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=24)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=24), + BoolOp( + Or(), + [ + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=34), + Mod(), + Constant( + 100, + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=40), + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=40), + [ + NotEq()], + [ + Constant( + 0, + lineno=2, + col_offset=44, + end_lineno=2, + end_col_offset=45)], + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=45), + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=49, + end_lineno=2, + end_col_offset=53), + Mod(), + Constant( + 400, + lineno=2, + col_offset=56, + end_lineno=2, + end_col_offset=59), + lineno=2, + col_offset=49, + end_lineno=2, + end_col_offset=59), + [ + Eq()], + [ + Constant( + 0, + lineno=2, + col_offset=63, + end_lineno=2, + end_col_offset=64)], + lineno=2, + col_offset=49, + end_lineno=2, + end_col_offset=64)], + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=64)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=65), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=65)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=65)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-leap/representation.txt b/test/practice-leap/representation.txt new file mode 100644 index 0000000..1192f53 --- /dev/null +++ b/test/practice-leap/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=14, end_lineno=1, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(BinOp(Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=15), Mod(), Constant(4, lineno=2, col_offset=18, end_lineno=2, end_col_offset=19), lineno=2, col_offset=11, end_lineno=2, end_col_offset=19), [Eq()], [Constant(0, lineno=2, col_offset=23, end_lineno=2, end_col_offset=24)], lineno=2, col_offset=11, end_lineno=2, end_col_offset=24), BoolOp(Or(), [Compare(BinOp(Name('placeholder_1', Load(), lineno=2, col_offset=30, end_lineno=2, end_col_offset=34), Mod(), Constant(100, lineno=2, col_offset=37, end_lineno=2, end_col_offset=40), lineno=2, col_offset=30, end_lineno=2, end_col_offset=40), [NotEq()], [Constant(0, lineno=2, col_offset=44, end_lineno=2, end_col_offset=45)], lineno=2, col_offset=30, end_lineno=2, end_col_offset=45), Compare(BinOp(Name('placeholder_1', Load(), lineno=2, col_offset=49, end_lineno=2, end_col_offset=53), Mod(), Constant(400, lineno=2, col_offset=56, end_lineno=2, end_col_offset=59), lineno=2, col_offset=49, end_lineno=2, end_col_offset=59), [Eq()], [Constant(0, lineno=2, col_offset=63, end_lineno=2, end_col_offset=64)], lineno=2, col_offset=49, end_lineno=2, end_col_offset=64)], lineno=2, col_offset=30, end_lineno=2, end_col_offset=64)], lineno=2, col_offset=11, end_lineno=2, end_col_offset=65), lineno=2, col_offset=4, end_lineno=2, end_col_offset=65)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=65)], []) \ No newline at end of file diff --git a/test/practice-ledger/.meta/config.json b/test/practice-ledger/.meta/config.json new file mode 100644 index 0000000..5b9998b --- /dev/null +++ b/test/practice-ledger/.meta/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "BethanyG", + "Dog", + "IsaaG", + "tqa236" + ], + "files": { + "solution": [ + "ledger.py" + ], + "test": [ + "ledger_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Refactor a ledger printer." +} diff --git a/test/practice-ledger/ledger.py b/test/practice-ledger/ledger.py new file mode 100644 index 0000000..46e8e3c --- /dev/null +++ b/test/practice-ledger/ledger.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- +from datetime import datetime + +ROW_FMT = '{{:<{1}}} | {{:<{2}}} | {{:{0}{3}}}' + + +def truncate(s, length=25): + if len(s) <= length: + return s + return s[:length - 3] + '...' + + +class LCInfo: + def __init__(self, locale, currency, columns): + self.columns = columns + if locale == 'en_US': + headers = ['Date', 'Description', 'Change'] + self.datefmt = '{0.month:02}/{0.day:02}/{0.year:04}' + self.cur_fmt = '{}{}{}{}' + self.lead_neg = '(' + self.trail_neg = ')' + self.thousands = ',' + self.decimal = '.' + elif locale == 'nl_NL': + headers = ['Datum', 'Omschrijving', 'Verandering'] + self.datefmt = '{0.day:02}-{0.month:02}-{0.year:04}' + self.cur_fmt = '{1} {0}{2}{3}' + self.lead_neg = '-' + self.trail_neg = ' ' + self.thousands = '.' + self.decimal = ',' + fmt = ROW_FMT.format('<', *columns) + self.headers = fmt.format(*headers) + self.cur_symbol = { + 'USD': '$', + 'EUR': '€', + }.get(currency) + + def number(self, n): + n_int, n_float = divmod(abs(n), 100) + n_int_parts = [] + while n_int > 0: + n_int, idx = divmod(n_int, 1000) + n_int_parts.insert(0, str(idx)) + return '{}{}{:02}'.format( + self.thousands.join(n_int_parts) or '0', + self.decimal, + n_float, + ) + + def currency(self, change): + return self.cur_fmt.format( + self.lead_neg if change < 0 else '', + self.cur_symbol, + self.number(change), + self.trail_neg if change < 0 else ' ', + ) + + def entry(self, entry): + date, change, desc = entry + fmt = ROW_FMT.format('>', *self.columns) + return fmt.format( + self.datefmt.format(date), + truncate(desc), + self.currency(change), + ) + + def table(self, entries): + lines = [self.headers] + lines.extend(map(self.entry, sorted(entries))) + return '\n'.join(lines) + + +def create_entry(date, description, change): + return ( + datetime.strptime(date, '%Y-%m-%d'), + change, + description + ) + + +def format_entries(currency, locale, entries): + columns = (10, 25, 13) + lcinfo = LCInfo(locale, currency, columns) + return lcinfo.table(entries) diff --git a/test/practice-ledger/mapping.json b/test/practice-ledger/mapping.json new file mode 100644 index 0000000..c02d45e --- /dev/null +++ b/test/practice-ledger/mapping.json @@ -0,0 +1,37 @@ +{ + "placeholder_0": "ROW_FMT", + "placeholder_1": "truncate", + "placeholder_2": "s", + "placeholder_3": "length", + "placeholder_4": "LCInfo", + "placeholder_5": "__init__", + "placeholder_6": "locale", + "placeholder_7": "currency", + "placeholder_8": "columns", + "placeholder_9": "headers", + "placeholder_10": "datefmt", + "placeholder_11": "cur_fmt", + "placeholder_12": "lead_neg", + "placeholder_13": "trail_neg", + "placeholder_14": "thousands", + "placeholder_15": "decimal", + "placeholder_16": "fmt", + "placeholder_17": "cur_symbol", + "placeholder_18": "number", + "placeholder_19": "n", + "placeholder_20": "n_int", + "placeholder_21": "n_float", + "placeholder_22": "n_int_parts", + "placeholder_23": "idx", + "placeholder_24": "change", + "placeholder_25": "entry", + "placeholder_26": "date", + "placeholder_27": "desc", + "placeholder_28": "table", + "placeholder_29": "entries", + "placeholder_30": "lines", + "placeholder_31": "create_entry", + "placeholder_32": "description", + "placeholder_33": "format_entries", + "placeholder_34": "lcinfo" +} \ No newline at end of file diff --git a/test/practice-ledger/representation.json b/test/practice-ledger/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-ledger/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-ledger/representation.out b/test/practice-ledger/representation.out new file mode 100644 index 0000000..be45515 --- /dev/null +++ b/test/practice-ledger/representation.out @@ -0,0 +1,4206 @@ +## BEGIN NORMALIZED CODE ## +from datetime import datetime + +placeholder_0 = "{{:<{1}}} | {{:<{2}}} | {{:{0}{3}}}" + + +def placeholder_1(placeholder_2, placeholder_3=25): + if len(placeholder_2) <= placeholder_3: + return placeholder_2 + return placeholder_2[: placeholder_3 - 3] + "..." + + +class placeholder_4: + def placeholder_5(self, placeholder_6, placeholder_7, placeholder_8): + self.placeholder_8 = placeholder_8 + if placeholder_6 == "en_US": + placeholder_9 = ["Date", "Description", "Change"] + self.placeholder_10 = "{0.month:02}/{0.day:02}/{0.year:04}" + self.placeholder_11 = "{}{}{}{}" + self.placeholder_12 = "(" + self.placeholder_13 = ")" + self.placeholder_14 = "," + self.placeholder_15 = "." + elif placeholder_6 == "nl_NL": + placeholder_9 = ["Datum", "Omschrijving", "Verandering"] + self.placeholder_10 = "{0.day:02}-{0.month:02}-{0.year:04}" + self.placeholder_11 = "{1} {0}{2}{3}" + self.placeholder_12 = "-" + self.placeholder_13 = " " + self.placeholder_14 = "." + self.placeholder_15 = "," + placeholder_16 = placeholder_0.format("<", *placeholder_8) + self.placeholder_9 = placeholder_16.format(*placeholder_9) + self.placeholder_17 = {"USD": "$", "EUR": "€"}.get(placeholder_7) + + def placeholder_18(self, placeholder_19): + placeholder_20, placeholder_21 = divmod(abs(placeholder_19), 100) + placeholder_22 = [] + while placeholder_20 > 0: + placeholder_20, placeholder_23 = divmod(placeholder_20, 1000) + placeholder_22.insert(0, str(placeholder_23)) + return "{}{}{:02}".format( + self.placeholder_14.join(placeholder_22) or "0", + self.placeholder_15, + placeholder_21, + ) + + def placeholder_7(self, placeholder_24): + return self.placeholder_11.format( + self.placeholder_12 if placeholder_24 < 0 else "", + self.placeholder_17, + self.placeholder_18(placeholder_24), + self.placeholder_13 if placeholder_24 < 0 else " ", + ) + + def placeholder_25(self, placeholder_25): + placeholder_26, placeholder_24, placeholder_27 = placeholder_25 + placeholder_16 = placeholder_0.format(">", *self.placeholder_8) + return placeholder_16.format( + self.placeholder_10.format(placeholder_26), + placeholder_1(placeholder_27), + self.placeholder_7(placeholder_24), + ) + + def placeholder_28(self, placeholder_29): + placeholder_30 = [self.placeholder_9] + placeholder_30.extend(map(self.placeholder_25, sorted(placeholder_29))) + return "\n".join(placeholder_30) + + +def placeholder_31(placeholder_26, placeholder_32, placeholder_24): + return ( + datetime.strptime(placeholder_26, "%Y-%m-%d"), + placeholder_24, + placeholder_32, + ) + + +def placeholder_33(placeholder_7, placeholder_6, placeholder_29): + placeholder_8 = (10, 25, 13) + placeholder_34 = placeholder_4(placeholder_6, placeholder_7, placeholder_8) + return placeholder_34.placeholder_28(placeholder_29) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'datetime', + [ + alias( + 'datetime', + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=29)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=29), + Assign( + [ + Name( + 'ROW_FMT', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=7)], + Constant( + '{{:<{1}}} | {{:<{2}}} | {{:{0}{3}}}', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=47), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=47), + FunctionDef( + 'truncate', + arguments( + [], + [ + arg( + 's', + lineno=7, + col_offset=13, + end_lineno=7, + end_col_offset=14), + arg( + 'length', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 25, + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=25)]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=10), + [ + Name( + 's', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=12)], + [], + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=13), + [ + LtE()], + [ + Name( + 'length', + Load(), + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=23)], + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=23), + [ + Return( + Name( + 's', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=16)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=16), + Return( + BinOp( + Subscript( + Name( + 's', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=12), + Slice( + upper=BinOp( + Name( + 'length', + Load(), + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=20), + Sub(), + Constant( + 3, + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=24), + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=24), + lineno=10, + col_offset=13, + end_lineno=10, + end_col_offset=24), + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=25), + Add(), + Constant( + '...', + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=33), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=33), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=33)], + [], + lineno=7, + col_offset=0, + end_lineno=10, + end_col_offset=33), + ClassDef( + 'LCInfo', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'locale', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=29), + arg( + 'currency', + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=39), + arg( + 'columns', + lineno=14, + col_offset=41, + end_lineno=14, + end_col_offset=48)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + 'columns', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=20)], + Name( + 'columns', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=30), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=30), + If( + Compare( + Name( + 'locale', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 'en_US', + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=28)], + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=28), + [ + Assign( + [ + Name( + 'headers', + Store(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=19)], + List( + [ + Constant( + 'Date', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=29), + Constant( + 'Description', + lineno=17, + col_offset=31, + end_lineno=17, + end_col_offset=44), + Constant( + 'Change', + lineno=17, + col_offset=46, + end_lineno=17, + end_col_offset=54)], + Load(), + lineno=17, + col_offset=22, + end_lineno=17, + end_col_offset=55), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=55), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=16), + 'datefmt', + Store(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=24)], + Constant( + '{0.month:02}/{0.day:02}/{0.year:04}', + lineno=18, + col_offset=27, + end_lineno=18, + end_col_offset=64), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=64), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=16), + 'cur_fmt', + Store(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=24)], + Constant( + '{}{}{}{}', + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=37), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=37), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=16), + 'lead_neg', + Store(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=25)], + Constant( + '(', + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=31), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=31), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=16), + 'trail_neg', + Store(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=26)], + Constant( + ')', + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=32), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=16), + 'thousands', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=26)], + Constant( + ',', + lineno=22, + col_offset=29, + end_lineno=22, + end_col_offset=32), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=16), + 'decimal', + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=24)], + Constant( + '.', + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=30), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=30)], + [ + If( + Compare( + Name( + 'locale', + Load(), + lineno=24, + col_offset=13, + end_lineno=24, + end_col_offset=19), + [ + Eq()], + [ + Constant( + 'nl_NL', + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=30)], + lineno=24, + col_offset=13, + end_lineno=24, + end_col_offset=30), + [ + Assign( + [ + Name( + 'headers', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=19)], + List( + [ + Constant( + 'Datum', + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=30), + Constant( + 'Omschrijving', + lineno=25, + col_offset=32, + end_lineno=25, + end_col_offset=46), + Constant( + 'Verandering', + lineno=25, + col_offset=48, + end_lineno=25, + end_col_offset=61)], + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=62), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=62), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=16), + 'datefmt', + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=24)], + Constant( + '{0.day:02}-{0.month:02}-{0.year:04}', + lineno=26, + col_offset=27, + end_lineno=26, + end_col_offset=64), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=64), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16), + 'cur_fmt', + Store(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=24)], + Constant( + '{1} {0}{2}{3}', + lineno=27, + col_offset=27, + end_lineno=27, + end_col_offset=42), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=42), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=16), + 'lead_neg', + Store(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=25)], + Constant( + '-', + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=31), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=31), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=16), + 'trail_neg', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=26)], + Constant( + ' ', + lineno=29, + col_offset=29, + end_lineno=29, + end_col_offset=32), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=16), + 'thousands', + Store(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=26)], + Constant( + '.', + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=32), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=16), + 'decimal', + Store(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=24)], + Constant( + ',', + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=30), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=30)], + [], + lineno=24, + col_offset=8, + end_lineno=31, + end_col_offset=30)], + lineno=16, + col_offset=8, + end_lineno=31, + end_col_offset=30), + Assign( + [ + Name( + 'fmt', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=11)], + Call( + Attribute( + Name( + 'ROW_FMT', + Load(), + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=21), + 'format', + Load(), + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=28), + [ + Constant( + '<', + lineno=32, + col_offset=29, + end_lineno=32, + end_col_offset=32), + Starred( + Name( + 'columns', + Load(), + lineno=32, + col_offset=35, + end_lineno=32, + end_col_offset=42), + Load(), + lineno=32, + col_offset=34, + end_lineno=32, + end_col_offset=42)], + [], + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=43), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=43), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=12), + 'headers', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=20)], + Call( + Attribute( + Name( + 'fmt', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=26), + 'format', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=33), + [ + Starred( + Name( + 'headers', + Load(), + lineno=33, + col_offset=35, + end_lineno=33, + end_col_offset=42), + Load(), + lineno=33, + col_offset=34, + end_lineno=33, + end_col_offset=42)], + [], + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=43), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=43), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'cur_symbol', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=23)], + Call( + Attribute( + Dict( + [ + Constant( + 'USD', + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=17), + Constant( + 'EUR', + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=17)], + [ + Constant( + '$', + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=22), + Constant( + '€', + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=24)], + lineno=34, + col_offset=26, + end_lineno=37, + end_col_offset=9), + 'get', + Load(), + lineno=34, + col_offset=26, + end_lineno=37, + end_col_offset=13), + [ + Name( + 'currency', + Load(), + lineno=37, + col_offset=14, + end_lineno=37, + end_col_offset=22)], + [], + lineno=34, + col_offset=26, + end_lineno=37, + end_col_offset=23), + lineno=34, + col_offset=8, + end_lineno=37, + end_col_offset=23)], + [], + lineno=14, + col_offset=4, + end_lineno=37, + end_col_offset=23), + FunctionDef( + 'number', + arguments( + [], + [ + arg( + 'self', + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=19), + arg( + 'n', + lineno=39, + col_offset=21, + end_lineno=39, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'n_int', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=13), + Name( + 'n_float', + Store(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=22)], + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=22)], + Call( + Name( + 'divmod', + Load(), + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=31), + [ + Call( + Name( + 'abs', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=35), + [ + Name( + 'n', + Load(), + lineno=40, + col_offset=36, + end_lineno=40, + end_col_offset=37)], + [], + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=38), + Constant( + 100, + lineno=40, + col_offset=40, + end_lineno=40, + end_col_offset=43)], + [], + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=44), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=44), + Assign( + [ + Name( + 'n_int_parts', + Store(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=19)], + List( + [], + Load(), + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=24), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=24), + While( + Compare( + Name( + 'n_int', + Load(), + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=19), + [ + Gt()], + [ + Constant( + 0, + lineno=42, + col_offset=22, + end_lineno=42, + end_col_offset=23)], + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=23), + [ + Assign( + [ + Tuple( + [ + Name( + 'n_int', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=17), + Name( + 'idx', + Store(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=22)], + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=22)], + Call( + Name( + 'divmod', + Load(), + lineno=43, + col_offset=25, + end_lineno=43, + end_col_offset=31), + [ + Name( + 'n_int', + Load(), + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=37), + Constant( + 1000, + lineno=43, + col_offset=39, + end_lineno=43, + end_col_offset=43)], + [], + lineno=43, + col_offset=25, + end_lineno=43, + end_col_offset=44), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=44), + Expr( + Call( + Attribute( + Name( + 'n_int_parts', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=23), + 'insert', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=30), + [ + Constant( + 0, + lineno=44, + col_offset=31, + end_lineno=44, + end_col_offset=32), + Call( + Name( + 'str', + Load(), + lineno=44, + col_offset=34, + end_lineno=44, + end_col_offset=37), + [ + Name( + 'idx', + Load(), + lineno=44, + col_offset=38, + end_lineno=44, + end_col_offset=41)], + [], + lineno=44, + col_offset=34, + end_lineno=44, + end_col_offset=42)], + [], + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=43), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=43)], + [], + lineno=42, + col_offset=8, + end_lineno=44, + end_col_offset=43), + Return( + Call( + Attribute( + Constant( + '{}{}{:02}', + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=26), + 'format', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=33), + [ + BoolOp( + Or(), + [ + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=16), + 'thousands', + Load(), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=26), + 'join', + Load(), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=31), + [ + Name( + 'n_int_parts', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=43)], + [], + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=44), + Constant( + '0', + lineno=46, + col_offset=48, + end_lineno=46, + end_col_offset=51)], + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=51), + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=16), + 'decimal', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=24), + Name( + 'n_float', + Load(), + lineno=48, + col_offset=12, + end_lineno=48, + end_col_offset=19)], + [], + lineno=45, + col_offset=15, + end_lineno=49, + end_col_offset=9), + lineno=45, + col_offset=8, + end_lineno=49, + end_col_offset=9)], + [], + lineno=39, + col_offset=4, + end_lineno=49, + end_col_offset=9), + FunctionDef( + 'currency', + arguments( + [], + [ + arg( + 'self', + lineno=51, + col_offset=17, + end_lineno=51, + end_col_offset=21), + arg( + 'change', + lineno=51, + col_offset=23, + end_lineno=51, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=19), + 'cur_fmt', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=27), + 'format', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=34), + [ + IfExp( + Compare( + Name( + 'change', + Load(), + lineno=53, + col_offset=29, + end_lineno=53, + end_col_offset=35), + [ + Lt()], + [ + Constant( + 0, + lineno=53, + col_offset=38, + end_lineno=53, + end_col_offset=39)], + lineno=53, + col_offset=29, + end_lineno=53, + end_col_offset=39), + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=16), + 'lead_neg', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=25), + Constant( + '', + lineno=53, + col_offset=45, + end_lineno=53, + end_col_offset=47), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=47), + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=16), + 'cur_symbol', + Load(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=27), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=16), + 'number', + Load(), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=23), + [ + Name( + 'change', + Load(), + lineno=55, + col_offset=24, + end_lineno=55, + end_col_offset=30)], + [], + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=31), + IfExp( + Compare( + Name( + 'change', + Load(), + lineno=56, + col_offset=30, + end_lineno=56, + end_col_offset=36), + [ + Lt()], + [ + Constant( + 0, + lineno=56, + col_offset=39, + end_lineno=56, + end_col_offset=40)], + lineno=56, + col_offset=30, + end_lineno=56, + end_col_offset=40), + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=16), + 'trail_neg', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=26), + Constant( + ' ', + lineno=56, + col_offset=46, + end_lineno=56, + end_col_offset=49), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=49)], + [], + lineno=52, + col_offset=15, + end_lineno=57, + end_col_offset=9), + lineno=52, + col_offset=8, + end_lineno=57, + end_col_offset=9)], + [], + lineno=51, + col_offset=4, + end_lineno=57, + end_col_offset=9), + FunctionDef( + 'entry', + arguments( + [], + [ + arg( + 'self', + lineno=59, + col_offset=14, + end_lineno=59, + end_col_offset=18), + arg( + 'entry', + lineno=59, + col_offset=20, + end_lineno=59, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'date', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=12), + Name( + 'change', + Store(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=20), + Name( + 'desc', + Store(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=26)], + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=26)], + Name( + 'entry', + Load(), + lineno=60, + col_offset=29, + end_lineno=60, + end_col_offset=34), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=34), + Assign( + [ + Name( + 'fmt', + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=11)], + Call( + Attribute( + Name( + 'ROW_FMT', + Load(), + lineno=61, + col_offset=14, + end_lineno=61, + end_col_offset=21), + 'format', + Load(), + lineno=61, + col_offset=14, + end_lineno=61, + end_col_offset=28), + [ + Constant( + '>', + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=32), + Starred( + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=35, + end_lineno=61, + end_col_offset=39), + 'columns', + Load(), + lineno=61, + col_offset=35, + end_lineno=61, + end_col_offset=47), + Load(), + lineno=61, + col_offset=34, + end_lineno=61, + end_col_offset=47)], + [], + lineno=61, + col_offset=14, + end_lineno=61, + end_col_offset=48), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=48), + Return( + Call( + Attribute( + Name( + 'fmt', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=18), + 'format', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=25), + [ + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=16), + 'datefmt', + Load(), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=24), + 'format', + Load(), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=31), + [ + Name( + 'date', + Load(), + lineno=63, + col_offset=32, + end_lineno=63, + end_col_offset=36)], + [], + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=37), + Call( + Name( + 'truncate', + Load(), + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=20), + [ + Name( + 'desc', + Load(), + lineno=64, + col_offset=21, + end_lineno=64, + end_col_offset=25)], + [], + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=26), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=16), + 'currency', + Load(), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=25), + [ + Name( + 'change', + Load(), + lineno=65, + col_offset=26, + end_lineno=65, + end_col_offset=32)], + [], + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=33)], + [], + lineno=62, + col_offset=15, + end_lineno=66, + end_col_offset=9), + lineno=62, + col_offset=8, + end_lineno=66, + end_col_offset=9)], + [], + lineno=59, + col_offset=4, + end_lineno=66, + end_col_offset=9), + FunctionDef( + 'table', + arguments( + [], + [ + arg( + 'self', + lineno=68, + col_offset=14, + end_lineno=68, + end_col_offset=18), + arg( + 'entries', + lineno=68, + col_offset=20, + end_lineno=68, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'lines', + Store(), + lineno=69, + col_offset=8, + end_lineno=69, + end_col_offset=13)], + List( + [ + Attribute( + Name( + 'self', + Load(), + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=21), + 'headers', + Load(), + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=29)], + Load(), + lineno=69, + col_offset=16, + end_lineno=69, + end_col_offset=30), + lineno=69, + col_offset=8, + end_lineno=69, + end_col_offset=30), + Expr( + Call( + Attribute( + Name( + 'lines', + Load(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=13), + 'extend', + Load(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=20), + [ + Call( + Name( + 'map', + Load(), + lineno=70, + col_offset=21, + end_lineno=70, + end_col_offset=24), + [ + Attribute( + Name( + 'self', + Load(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=29), + 'entry', + Load(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=35), + Call( + Name( + 'sorted', + Load(), + lineno=70, + col_offset=37, + end_lineno=70, + end_col_offset=43), + [ + Name( + 'entries', + Load(), + lineno=70, + col_offset=44, + end_lineno=70, + end_col_offset=51)], + [], + lineno=70, + col_offset=37, + end_lineno=70, + end_col_offset=52)], + [], + lineno=70, + col_offset=21, + end_lineno=70, + end_col_offset=53)], + [], + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=54), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=54), + Return( + Call( + Attribute( + Constant( + '\n', + lineno=71, + col_offset=15, + end_lineno=71, + end_col_offset=19), + 'join', + Load(), + lineno=71, + col_offset=15, + end_lineno=71, + end_col_offset=24), + [ + Name( + 'lines', + Load(), + lineno=71, + col_offset=25, + end_lineno=71, + end_col_offset=30)], + [], + lineno=71, + col_offset=15, + end_lineno=71, + end_col_offset=31), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=31)], + [], + lineno=68, + col_offset=4, + end_lineno=71, + end_col_offset=31)], + [], + lineno=13, + col_offset=0, + end_lineno=71, + end_col_offset=31), + FunctionDef( + 'create_entry', + arguments( + [], + [ + arg( + 'date', + lineno=74, + col_offset=17, + end_lineno=74, + end_col_offset=21), + arg( + 'description', + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=34), + arg( + 'change', + lineno=74, + col_offset=36, + end_lineno=74, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Tuple( + [ + Call( + Attribute( + Name( + 'datetime', + Load(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=16), + 'strptime', + Load(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=25), + [ + Name( + 'date', + Load(), + lineno=76, + col_offset=26, + end_lineno=76, + end_col_offset=30), + Constant( + '%Y-%m-%d', + lineno=76, + col_offset=32, + end_lineno=76, + end_col_offset=42)], + [], + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=43), + Name( + 'change', + Load(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=14), + Name( + 'description', + Load(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=19)], + Load(), + lineno=75, + col_offset=11, + end_lineno=79, + end_col_offset=5), + lineno=75, + col_offset=4, + end_lineno=79, + end_col_offset=5)], + [], + lineno=74, + col_offset=0, + end_lineno=79, + end_col_offset=5), + FunctionDef( + 'format_entries', + arguments( + [], + [ + arg( + 'currency', + lineno=82, + col_offset=19, + end_lineno=82, + end_col_offset=27), + arg( + 'locale', + lineno=82, + col_offset=29, + end_lineno=82, + end_col_offset=35), + arg( + 'entries', + lineno=82, + col_offset=37, + end_lineno=82, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'columns', + Store(), + lineno=83, + col_offset=4, + end_lineno=83, + end_col_offset=11)], + Tuple( + [ + Constant( + 10, + lineno=83, + col_offset=15, + end_lineno=83, + end_col_offset=17), + Constant( + 25, + lineno=83, + col_offset=19, + end_lineno=83, + end_col_offset=21), + Constant( + 13, + lineno=83, + col_offset=23, + end_lineno=83, + end_col_offset=25)], + Load(), + lineno=83, + col_offset=14, + end_lineno=83, + end_col_offset=26), + lineno=83, + col_offset=4, + end_lineno=83, + end_col_offset=26), + Assign( + [ + Name( + 'lcinfo', + Store(), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=10)], + Call( + Name( + 'LCInfo', + Load(), + lineno=84, + col_offset=13, + end_lineno=84, + end_col_offset=19), + [ + Name( + 'locale', + Load(), + lineno=84, + col_offset=20, + end_lineno=84, + end_col_offset=26), + Name( + 'currency', + Load(), + lineno=84, + col_offset=28, + end_lineno=84, + end_col_offset=36), + Name( + 'columns', + Load(), + lineno=84, + col_offset=38, + end_lineno=84, + end_col_offset=45)], + [], + lineno=84, + col_offset=13, + end_lineno=84, + end_col_offset=46), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=46), + Return( + Call( + Attribute( + Name( + 'lcinfo', + Load(), + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=17), + 'table', + Load(), + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=23), + [ + Name( + 'entries', + Load(), + lineno=85, + col_offset=24, + end_lineno=85, + end_col_offset=31)], + [], + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=32), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=32)], + [], + lineno=82, + col_offset=0, + end_lineno=85, + end_col_offset=32)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'datetime', + [ + alias( + 'datetime', + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=29)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=29), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=7)], + Constant( + '{{:<{1}}} | {{:<{2}}} | {{:{0}{3}}}', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=47), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=47), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=7, + col_offset=13, + end_lineno=7, + end_col_offset=14), + arg( + 'placeholder_3', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 25, + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=25)]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=10), + [ + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=12)], + [], + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=13), + [ + LtE()], + [ + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=23)], + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=23), + [ + Return( + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=16)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=16), + Return( + BinOp( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=12), + Slice( + upper=BinOp( + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=20), + Sub(), + Constant( + 3, + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=24), + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=24), + lineno=10, + col_offset=13, + end_lineno=10, + end_col_offset=24), + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=25), + Add(), + Constant( + '...', + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=33), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=33), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=33)], + [], + lineno=7, + col_offset=0, + end_lineno=10, + end_col_offset=33), + ClassDef( + 'placeholder_4', + [], + [], + [ + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'placeholder_6', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=29), + arg( + 'placeholder_7', + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=39), + arg( + 'placeholder_8', + lineno=14, + col_offset=41, + end_lineno=14, + end_col_offset=48)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=20)], + Name( + 'placeholder_8', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=30), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=30), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 'en_US', + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=28)], + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=28), + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=19)], + List( + [ + Constant( + 'Date', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=29), + Constant( + 'Description', + lineno=17, + col_offset=31, + end_lineno=17, + end_col_offset=44), + Constant( + 'Change', + lineno=17, + col_offset=46, + end_lineno=17, + end_col_offset=54)], + Load(), + lineno=17, + col_offset=22, + end_lineno=17, + end_col_offset=55), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=55), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=16), + 'placeholder_10', + Store(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=24)], + Constant( + '{0.month:02}/{0.day:02}/{0.year:04}', + lineno=18, + col_offset=27, + end_lineno=18, + end_col_offset=64), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=64), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=16), + 'placeholder_11', + Store(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=24)], + Constant( + '{}{}{}{}', + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=37), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=37), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=16), + 'placeholder_12', + Store(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=25)], + Constant( + '(', + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=31), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=31), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=16), + 'placeholder_13', + Store(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=26)], + Constant( + ')', + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=32), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=16), + 'placeholder_14', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=26)], + Constant( + ',', + lineno=22, + col_offset=29, + end_lineno=22, + end_col_offset=32), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=16), + 'placeholder_15', + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=24)], + Constant( + '.', + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=30), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=30)], + [ + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=24, + col_offset=13, + end_lineno=24, + end_col_offset=19), + [ + Eq()], + [ + Constant( + 'nl_NL', + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=30)], + lineno=24, + col_offset=13, + end_lineno=24, + end_col_offset=30), + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=19)], + List( + [ + Constant( + 'Datum', + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=30), + Constant( + 'Omschrijving', + lineno=25, + col_offset=32, + end_lineno=25, + end_col_offset=46), + Constant( + 'Verandering', + lineno=25, + col_offset=48, + end_lineno=25, + end_col_offset=61)], + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=62), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=62), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=16), + 'placeholder_10', + Store(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=24)], + Constant( + '{0.day:02}-{0.month:02}-{0.year:04}', + lineno=26, + col_offset=27, + end_lineno=26, + end_col_offset=64), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=64), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16), + 'placeholder_11', + Store(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=24)], + Constant( + '{1} {0}{2}{3}', + lineno=27, + col_offset=27, + end_lineno=27, + end_col_offset=42), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=42), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=16), + 'placeholder_12', + Store(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=25)], + Constant( + '-', + lineno=28, + col_offset=28, + end_lineno=28, + end_col_offset=31), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=31), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=16), + 'placeholder_13', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=26)], + Constant( + ' ', + lineno=29, + col_offset=29, + end_lineno=29, + end_col_offset=32), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=16), + 'placeholder_14', + Store(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=26)], + Constant( + '.', + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=32), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=16), + 'placeholder_15', + Store(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=24)], + Constant( + ',', + lineno=31, + col_offset=27, + end_lineno=31, + end_col_offset=30), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=30)], + [], + lineno=24, + col_offset=8, + end_lineno=31, + end_col_offset=30)], + lineno=16, + col_offset=8, + end_lineno=31, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=11)], + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=21), + 'format', + Load(), + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=28), + [ + Constant( + '<', + lineno=32, + col_offset=29, + end_lineno=32, + end_col_offset=32), + Starred( + Name( + 'placeholder_8', + Load(), + lineno=32, + col_offset=35, + end_lineno=32, + end_col_offset=42), + Load(), + lineno=32, + col_offset=34, + end_lineno=32, + end_col_offset=42)], + [], + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=43), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=43), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=12), + 'placeholder_9', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=20)], + Call( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=26), + 'format', + Load(), + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=33), + [ + Starred( + Name( + 'placeholder_9', + Load(), + lineno=33, + col_offset=35, + end_lineno=33, + end_col_offset=42), + Load(), + lineno=33, + col_offset=34, + end_lineno=33, + end_col_offset=42)], + [], + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=43), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=43), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'placeholder_17', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=23)], + Call( + Attribute( + Dict( + [ + Constant( + 'USD', + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=17), + Constant( + 'EUR', + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=17)], + [ + Constant( + '$', + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=22), + Constant( + '€', + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=24)], + lineno=34, + col_offset=26, + end_lineno=37, + end_col_offset=9), + 'get', + Load(), + lineno=34, + col_offset=26, + end_lineno=37, + end_col_offset=13), + [ + Name( + 'placeholder_7', + Load(), + lineno=37, + col_offset=14, + end_lineno=37, + end_col_offset=22)], + [], + lineno=34, + col_offset=26, + end_lineno=37, + end_col_offset=23), + lineno=34, + col_offset=8, + end_lineno=37, + end_col_offset=23)], + [], + lineno=14, + col_offset=4, + end_lineno=37, + end_col_offset=23), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'self', + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=19), + arg( + 'placeholder_19', + lineno=39, + col_offset=21, + end_lineno=39, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_20', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=13), + Name( + 'placeholder_21', + Store(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=22)], + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=22)], + Call( + Name( + 'divmod', + Load(), + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=31), + [ + Call( + Name( + 'abs', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=35), + [ + Name( + 'placeholder_19', + Load(), + lineno=40, + col_offset=36, + end_lineno=40, + end_col_offset=37)], + [], + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=38), + Constant( + 100, + lineno=40, + col_offset=40, + end_lineno=40, + end_col_offset=43)], + [], + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=44), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=19)], + List( + [], + Load(), + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=24), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=24), + While( + Compare( + Name( + 'placeholder_20', + Load(), + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=19), + [ + Gt()], + [ + Constant( + 0, + lineno=42, + col_offset=22, + end_lineno=42, + end_col_offset=23)], + lineno=42, + col_offset=14, + end_lineno=42, + end_col_offset=23), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_20', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=17), + Name( + 'placeholder_23', + Store(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=22)], + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=22)], + Call( + Name( + 'divmod', + Load(), + lineno=43, + col_offset=25, + end_lineno=43, + end_col_offset=31), + [ + Name( + 'placeholder_20', + Load(), + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=37), + Constant( + 1000, + lineno=43, + col_offset=39, + end_lineno=43, + end_col_offset=43)], + [], + lineno=43, + col_offset=25, + end_lineno=43, + end_col_offset=44), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=44), + Expr( + Call( + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=23), + 'insert', + Load(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=30), + [ + Constant( + 0, + lineno=44, + col_offset=31, + end_lineno=44, + end_col_offset=32), + Call( + Name( + 'str', + Load(), + lineno=44, + col_offset=34, + end_lineno=44, + end_col_offset=37), + [ + Name( + 'placeholder_23', + Load(), + lineno=44, + col_offset=38, + end_lineno=44, + end_col_offset=41)], + [], + lineno=44, + col_offset=34, + end_lineno=44, + end_col_offset=42)], + [], + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=43), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=43)], + [], + lineno=42, + col_offset=8, + end_lineno=44, + end_col_offset=43), + Return( + Call( + Attribute( + Constant( + '{}{}{:02}', + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=26), + 'format', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=33), + [ + BoolOp( + Or(), + [ + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=16), + 'placeholder_14', + Load(), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=26), + 'join', + Load(), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=31), + [ + Name( + 'placeholder_22', + Load(), + lineno=46, + col_offset=32, + end_lineno=46, + end_col_offset=43)], + [], + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=44), + Constant( + '0', + lineno=46, + col_offset=48, + end_lineno=46, + end_col_offset=51)], + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=51), + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=16), + 'placeholder_15', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=24), + Name( + 'placeholder_21', + Load(), + lineno=48, + col_offset=12, + end_lineno=48, + end_col_offset=19)], + [], + lineno=45, + col_offset=15, + end_lineno=49, + end_col_offset=9), + lineno=45, + col_offset=8, + end_lineno=49, + end_col_offset=9)], + [], + lineno=39, + col_offset=4, + end_lineno=49, + end_col_offset=9), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=51, + col_offset=17, + end_lineno=51, + end_col_offset=21), + arg( + 'placeholder_24', + lineno=51, + col_offset=23, + end_lineno=51, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=19), + 'placeholder_11', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=27), + 'format', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=34), + [ + IfExp( + Compare( + Name( + 'placeholder_24', + Load(), + lineno=53, + col_offset=29, + end_lineno=53, + end_col_offset=35), + [ + Lt()], + [ + Constant( + 0, + lineno=53, + col_offset=38, + end_lineno=53, + end_col_offset=39)], + lineno=53, + col_offset=29, + end_lineno=53, + end_col_offset=39), + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=16), + 'placeholder_12', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=25), + Constant( + '', + lineno=53, + col_offset=45, + end_lineno=53, + end_col_offset=47), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=47), + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=16), + 'placeholder_17', + Load(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=27), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=16), + 'placeholder_18', + Load(), + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=23), + [ + Name( + 'placeholder_24', + Load(), + lineno=55, + col_offset=24, + end_lineno=55, + end_col_offset=30)], + [], + lineno=55, + col_offset=12, + end_lineno=55, + end_col_offset=31), + IfExp( + Compare( + Name( + 'placeholder_24', + Load(), + lineno=56, + col_offset=30, + end_lineno=56, + end_col_offset=36), + [ + Lt()], + [ + Constant( + 0, + lineno=56, + col_offset=39, + end_lineno=56, + end_col_offset=40)], + lineno=56, + col_offset=30, + end_lineno=56, + end_col_offset=40), + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=16), + 'placeholder_13', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=26), + Constant( + ' ', + lineno=56, + col_offset=46, + end_lineno=56, + end_col_offset=49), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=49)], + [], + lineno=52, + col_offset=15, + end_lineno=57, + end_col_offset=9), + lineno=52, + col_offset=8, + end_lineno=57, + end_col_offset=9)], + [], + lineno=51, + col_offset=4, + end_lineno=57, + end_col_offset=9), + FunctionDef( + 'placeholder_25', + arguments( + [], + [ + arg( + 'self', + lineno=59, + col_offset=14, + end_lineno=59, + end_col_offset=18), + arg( + 'placeholder_25', + lineno=59, + col_offset=20, + end_lineno=59, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_26', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=12), + Name( + 'placeholder_24', + Store(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=20), + Name( + 'placeholder_27', + Store(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=26)], + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=26)], + Name( + 'placeholder_25', + Load(), + lineno=60, + col_offset=29, + end_lineno=60, + end_col_offset=34), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=34), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=11)], + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=61, + col_offset=14, + end_lineno=61, + end_col_offset=21), + 'format', + Load(), + lineno=61, + col_offset=14, + end_lineno=61, + end_col_offset=28), + [ + Constant( + '>', + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=32), + Starred( + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=35, + end_lineno=61, + end_col_offset=39), + 'placeholder_8', + Load(), + lineno=61, + col_offset=35, + end_lineno=61, + end_col_offset=47), + Load(), + lineno=61, + col_offset=34, + end_lineno=61, + end_col_offset=47)], + [], + lineno=61, + col_offset=14, + end_lineno=61, + end_col_offset=48), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=48), + Return( + Call( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=18), + 'format', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=25), + [ + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=16), + 'placeholder_10', + Load(), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=24), + 'format', + Load(), + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=31), + [ + Name( + 'placeholder_26', + Load(), + lineno=63, + col_offset=32, + end_lineno=63, + end_col_offset=36)], + [], + lineno=63, + col_offset=12, + end_lineno=63, + end_col_offset=37), + Call( + Name( + 'placeholder_1', + Load(), + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=20), + [ + Name( + 'placeholder_27', + Load(), + lineno=64, + col_offset=21, + end_lineno=64, + end_col_offset=25)], + [], + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=26), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=16), + 'placeholder_7', + Load(), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=25), + [ + Name( + 'placeholder_24', + Load(), + lineno=65, + col_offset=26, + end_lineno=65, + end_col_offset=32)], + [], + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=33)], + [], + lineno=62, + col_offset=15, + end_lineno=66, + end_col_offset=9), + lineno=62, + col_offset=8, + end_lineno=66, + end_col_offset=9)], + [], + lineno=59, + col_offset=4, + end_lineno=66, + end_col_offset=9), + FunctionDef( + 'placeholder_28', + arguments( + [], + [ + arg( + 'self', + lineno=68, + col_offset=14, + end_lineno=68, + end_col_offset=18), + arg( + 'placeholder_29', + lineno=68, + col_offset=20, + end_lineno=68, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_30', + Store(), + lineno=69, + col_offset=8, + end_lineno=69, + end_col_offset=13)], + List( + [ + Attribute( + Name( + 'self', + Load(), + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=21), + 'placeholder_9', + Load(), + lineno=69, + col_offset=17, + end_lineno=69, + end_col_offset=29)], + Load(), + lineno=69, + col_offset=16, + end_lineno=69, + end_col_offset=30), + lineno=69, + col_offset=8, + end_lineno=69, + end_col_offset=30), + Expr( + Call( + Attribute( + Name( + 'placeholder_30', + Load(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=13), + 'extend', + Load(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=20), + [ + Call( + Name( + 'map', + Load(), + lineno=70, + col_offset=21, + end_lineno=70, + end_col_offset=24), + [ + Attribute( + Name( + 'self', + Load(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=29), + 'placeholder_25', + Load(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=35), + Call( + Name( + 'sorted', + Load(), + lineno=70, + col_offset=37, + end_lineno=70, + end_col_offset=43), + [ + Name( + 'placeholder_29', + Load(), + lineno=70, + col_offset=44, + end_lineno=70, + end_col_offset=51)], + [], + lineno=70, + col_offset=37, + end_lineno=70, + end_col_offset=52)], + [], + lineno=70, + col_offset=21, + end_lineno=70, + end_col_offset=53)], + [], + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=54), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=54), + Return( + Call( + Attribute( + Constant( + '\n', + lineno=71, + col_offset=15, + end_lineno=71, + end_col_offset=19), + 'join', + Load(), + lineno=71, + col_offset=15, + end_lineno=71, + end_col_offset=24), + [ + Name( + 'placeholder_30', + Load(), + lineno=71, + col_offset=25, + end_lineno=71, + end_col_offset=30)], + [], + lineno=71, + col_offset=15, + end_lineno=71, + end_col_offset=31), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=31)], + [], + lineno=68, + col_offset=4, + end_lineno=71, + end_col_offset=31)], + [], + lineno=13, + col_offset=0, + end_lineno=71, + end_col_offset=31), + FunctionDef( + 'placeholder_31', + arguments( + [], + [ + arg( + 'placeholder_26', + lineno=74, + col_offset=17, + end_lineno=74, + end_col_offset=21), + arg( + 'placeholder_32', + lineno=74, + col_offset=23, + end_lineno=74, + end_col_offset=34), + arg( + 'placeholder_24', + lineno=74, + col_offset=36, + end_lineno=74, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Tuple( + [ + Call( + Attribute( + Name( + 'datetime', + Load(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=16), + 'strptime', + Load(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=25), + [ + Name( + 'placeholder_26', + Load(), + lineno=76, + col_offset=26, + end_lineno=76, + end_col_offset=30), + Constant( + '%Y-%m-%d', + lineno=76, + col_offset=32, + end_lineno=76, + end_col_offset=42)], + [], + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=43), + Name( + 'placeholder_24', + Load(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=14), + Name( + 'placeholder_32', + Load(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=19)], + Load(), + lineno=75, + col_offset=11, + end_lineno=79, + end_col_offset=5), + lineno=75, + col_offset=4, + end_lineno=79, + end_col_offset=5)], + [], + lineno=74, + col_offset=0, + end_lineno=79, + end_col_offset=5), + FunctionDef( + 'placeholder_33', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=82, + col_offset=19, + end_lineno=82, + end_col_offset=27), + arg( + 'placeholder_6', + lineno=82, + col_offset=29, + end_lineno=82, + end_col_offset=35), + arg( + 'placeholder_29', + lineno=82, + col_offset=37, + end_lineno=82, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=83, + col_offset=4, + end_lineno=83, + end_col_offset=11)], + Tuple( + [ + Constant( + 10, + lineno=83, + col_offset=15, + end_lineno=83, + end_col_offset=17), + Constant( + 25, + lineno=83, + col_offset=19, + end_lineno=83, + end_col_offset=21), + Constant( + 13, + lineno=83, + col_offset=23, + end_lineno=83, + end_col_offset=25)], + Load(), + lineno=83, + col_offset=14, + end_lineno=83, + end_col_offset=26), + lineno=83, + col_offset=4, + end_lineno=83, + end_col_offset=26), + Assign( + [ + Name( + 'placeholder_34', + Store(), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=10)], + Call( + Name( + 'placeholder_4', + Load(), + lineno=84, + col_offset=13, + end_lineno=84, + end_col_offset=19), + [ + Name( + 'placeholder_6', + Load(), + lineno=84, + col_offset=20, + end_lineno=84, + end_col_offset=26), + Name( + 'placeholder_7', + Load(), + lineno=84, + col_offset=28, + end_lineno=84, + end_col_offset=36), + Name( + 'placeholder_8', + Load(), + lineno=84, + col_offset=38, + end_lineno=84, + end_col_offset=45)], + [], + lineno=84, + col_offset=13, + end_lineno=84, + end_col_offset=46), + lineno=84, + col_offset=4, + end_lineno=84, + end_col_offset=46), + Return( + Call( + Attribute( + Name( + 'placeholder_34', + Load(), + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=17), + 'placeholder_28', + Load(), + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=23), + [ + Name( + 'placeholder_29', + Load(), + lineno=85, + col_offset=24, + end_lineno=85, + end_col_offset=31)], + [], + lineno=85, + col_offset=11, + end_lineno=85, + end_col_offset=32), + lineno=85, + col_offset=4, + end_lineno=85, + end_col_offset=32)], + [], + lineno=82, + col_offset=0, + end_lineno=85, + end_col_offset=32)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-ledger/representation.txt b/test/practice-ledger/representation.txt new file mode 100644 index 0000000..12ca476 --- /dev/null +++ b/test/practice-ledger/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('datetime', [alias('datetime', lineno=2, col_offset=21, end_lineno=2, end_col_offset=29)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=29), Assign([Name('placeholder_0', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=7)], Constant('{{:<{1}}} | {{:<{2}}} | {{:{0}{3}}}', lineno=4, col_offset=10, end_lineno=4, end_col_offset=47), lineno=4, col_offset=0, end_lineno=4, end_col_offset=47), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=7, col_offset=13, end_lineno=7, end_col_offset=14), arg('placeholder_3', lineno=7, col_offset=16, end_lineno=7, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(25, lineno=7, col_offset=23, end_lineno=7, end_col_offset=25)]), [If(Compare(Call(Name('len', Load(), lineno=8, col_offset=7, end_lineno=8, end_col_offset=10), [Name('placeholder_2', Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=12)], [], lineno=8, col_offset=7, end_lineno=8, end_col_offset=13), [LtE()], [Name('placeholder_3', Load(), lineno=8, col_offset=17, end_lineno=8, end_col_offset=23)], lineno=8, col_offset=7, end_lineno=8, end_col_offset=23), [Return(Name('placeholder_2', Load(), lineno=9, col_offset=15, end_lineno=9, end_col_offset=16), lineno=9, col_offset=8, end_lineno=9, end_col_offset=16)], [], lineno=8, col_offset=4, end_lineno=9, end_col_offset=16), Return(BinOp(Subscript(Name('placeholder_2', Load(), lineno=10, col_offset=11, end_lineno=10, end_col_offset=12), Slice(upper=BinOp(Name('placeholder_3', Load(), lineno=10, col_offset=14, end_lineno=10, end_col_offset=20), Sub(), Constant(3, lineno=10, col_offset=23, end_lineno=10, end_col_offset=24), lineno=10, col_offset=14, end_lineno=10, end_col_offset=24), lineno=10, col_offset=13, end_lineno=10, end_col_offset=24), Load(), lineno=10, col_offset=11, end_lineno=10, end_col_offset=25), Add(), Constant('...', lineno=10, col_offset=28, end_lineno=10, end_col_offset=33), lineno=10, col_offset=11, end_lineno=10, end_col_offset=33), lineno=10, col_offset=4, end_lineno=10, end_col_offset=33)], [], lineno=7, col_offset=0, end_lineno=10, end_col_offset=33), ClassDef('placeholder_4', [], [], [FunctionDef('placeholder_5', arguments([], [arg('self', lineno=14, col_offset=17, end_lineno=14, end_col_offset=21), arg('placeholder_6', lineno=14, col_offset=23, end_lineno=14, end_col_offset=29), arg('placeholder_7', lineno=14, col_offset=31, end_lineno=14, end_col_offset=39), arg('placeholder_8', lineno=14, col_offset=41, end_lineno=14, end_col_offset=48)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=12), 'placeholder_8', Store(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=20)], Name('placeholder_8', Load(), lineno=15, col_offset=23, end_lineno=15, end_col_offset=30), lineno=15, col_offset=8, end_lineno=15, end_col_offset=30), If(Compare(Name('placeholder_6', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=17), [Eq()], [Constant('en_US', lineno=16, col_offset=21, end_lineno=16, end_col_offset=28)], lineno=16, col_offset=11, end_lineno=16, end_col_offset=28), [Assign([Name('placeholder_9', Store(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=19)], List([Constant('Date', lineno=17, col_offset=23, end_lineno=17, end_col_offset=29), Constant('Description', lineno=17, col_offset=31, end_lineno=17, end_col_offset=44), Constant('Change', lineno=17, col_offset=46, end_lineno=17, end_col_offset=54)], Load(), lineno=17, col_offset=22, end_lineno=17, end_col_offset=55), lineno=17, col_offset=12, end_lineno=17, end_col_offset=55), Assign([Attribute(Name('self', Load(), lineno=18, col_offset=12, end_lineno=18, end_col_offset=16), 'placeholder_10', Store(), lineno=18, col_offset=12, end_lineno=18, end_col_offset=24)], Constant('{0.month:02}/{0.day:02}/{0.year:04}', lineno=18, col_offset=27, end_lineno=18, end_col_offset=64), lineno=18, col_offset=12, end_lineno=18, end_col_offset=64), Assign([Attribute(Name('self', Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=16), 'placeholder_11', Store(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=24)], Constant('{}{}{}{}', lineno=19, col_offset=27, end_lineno=19, end_col_offset=37), lineno=19, col_offset=12, end_lineno=19, end_col_offset=37), Assign([Attribute(Name('self', Load(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=16), 'placeholder_12', Store(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=25)], Constant('(', lineno=20, col_offset=28, end_lineno=20, end_col_offset=31), lineno=20, col_offset=12, end_lineno=20, end_col_offset=31), Assign([Attribute(Name('self', Load(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=16), 'placeholder_13', Store(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=26)], Constant(')', lineno=21, col_offset=29, end_lineno=21, end_col_offset=32), lineno=21, col_offset=12, end_lineno=21, end_col_offset=32), Assign([Attribute(Name('self', Load(), lineno=22, col_offset=12, end_lineno=22, end_col_offset=16), 'placeholder_14', Store(), lineno=22, col_offset=12, end_lineno=22, end_col_offset=26)], Constant(',', lineno=22, col_offset=29, end_lineno=22, end_col_offset=32), lineno=22, col_offset=12, end_lineno=22, end_col_offset=32), Assign([Attribute(Name('self', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=16), 'placeholder_15', Store(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=24)], Constant('.', lineno=23, col_offset=27, end_lineno=23, end_col_offset=30), lineno=23, col_offset=12, end_lineno=23, end_col_offset=30)], [If(Compare(Name('placeholder_6', Load(), lineno=24, col_offset=13, end_lineno=24, end_col_offset=19), [Eq()], [Constant('nl_NL', lineno=24, col_offset=23, end_lineno=24, end_col_offset=30)], lineno=24, col_offset=13, end_lineno=24, end_col_offset=30), [Assign([Name('placeholder_9', Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=19)], List([Constant('Datum', lineno=25, col_offset=23, end_lineno=25, end_col_offset=30), Constant('Omschrijving', lineno=25, col_offset=32, end_lineno=25, end_col_offset=46), Constant('Verandering', lineno=25, col_offset=48, end_lineno=25, end_col_offset=61)], Load(), lineno=25, col_offset=22, end_lineno=25, end_col_offset=62), lineno=25, col_offset=12, end_lineno=25, end_col_offset=62), Assign([Attribute(Name('self', Load(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=16), 'placeholder_10', Store(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=24)], Constant('{0.day:02}-{0.month:02}-{0.year:04}', lineno=26, col_offset=27, end_lineno=26, end_col_offset=64), lineno=26, col_offset=12, end_lineno=26, end_col_offset=64), Assign([Attribute(Name('self', Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=16), 'placeholder_11', Store(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=24)], Constant('{1} {0}{2}{3}', lineno=27, col_offset=27, end_lineno=27, end_col_offset=42), lineno=27, col_offset=12, end_lineno=27, end_col_offset=42), Assign([Attribute(Name('self', Load(), lineno=28, col_offset=12, end_lineno=28, end_col_offset=16), 'placeholder_12', Store(), lineno=28, col_offset=12, end_lineno=28, end_col_offset=25)], Constant('-', lineno=28, col_offset=28, end_lineno=28, end_col_offset=31), lineno=28, col_offset=12, end_lineno=28, end_col_offset=31), Assign([Attribute(Name('self', Load(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=16), 'placeholder_13', Store(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=26)], Constant(' ', lineno=29, col_offset=29, end_lineno=29, end_col_offset=32), lineno=29, col_offset=12, end_lineno=29, end_col_offset=32), Assign([Attribute(Name('self', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=16), 'placeholder_14', Store(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=26)], Constant('.', lineno=30, col_offset=29, end_lineno=30, end_col_offset=32), lineno=30, col_offset=12, end_lineno=30, end_col_offset=32), Assign([Attribute(Name('self', Load(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=16), 'placeholder_15', Store(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=24)], Constant(',', lineno=31, col_offset=27, end_lineno=31, end_col_offset=30), lineno=31, col_offset=12, end_lineno=31, end_col_offset=30)], [], lineno=24, col_offset=8, end_lineno=31, end_col_offset=30)], lineno=16, col_offset=8, end_lineno=31, end_col_offset=30), Assign([Name('placeholder_16', Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=11)], Call(Attribute(Name('placeholder_0', Load(), lineno=32, col_offset=14, end_lineno=32, end_col_offset=21), 'format', Load(), lineno=32, col_offset=14, end_lineno=32, end_col_offset=28), [Constant('<', lineno=32, col_offset=29, end_lineno=32, end_col_offset=32), Starred(Name('placeholder_8', Load(), lineno=32, col_offset=35, end_lineno=32, end_col_offset=42), Load(), lineno=32, col_offset=34, end_lineno=32, end_col_offset=42)], [], lineno=32, col_offset=14, end_lineno=32, end_col_offset=43), lineno=32, col_offset=8, end_lineno=32, end_col_offset=43), Assign([Attribute(Name('self', Load(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=12), 'placeholder_9', Store(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=20)], Call(Attribute(Name('placeholder_16', Load(), lineno=33, col_offset=23, end_lineno=33, end_col_offset=26), 'format', Load(), lineno=33, col_offset=23, end_lineno=33, end_col_offset=33), [Starred(Name('placeholder_9', Load(), lineno=33, col_offset=35, end_lineno=33, end_col_offset=42), Load(), lineno=33, col_offset=34, end_lineno=33, end_col_offset=42)], [], lineno=33, col_offset=23, end_lineno=33, end_col_offset=43), lineno=33, col_offset=8, end_lineno=33, end_col_offset=43), Assign([Attribute(Name('self', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=12), 'placeholder_17', Store(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=23)], Call(Attribute(Dict([Constant('USD', lineno=35, col_offset=12, end_lineno=35, end_col_offset=17), Constant('EUR', lineno=36, col_offset=12, end_lineno=36, end_col_offset=17)], [Constant('$', lineno=35, col_offset=19, end_lineno=35, end_col_offset=22), Constant('€', lineno=36, col_offset=19, end_lineno=36, end_col_offset=24)], lineno=34, col_offset=26, end_lineno=37, end_col_offset=9), 'get', Load(), lineno=34, col_offset=26, end_lineno=37, end_col_offset=13), [Name('placeholder_7', Load(), lineno=37, col_offset=14, end_lineno=37, end_col_offset=22)], [], lineno=34, col_offset=26, end_lineno=37, end_col_offset=23), lineno=34, col_offset=8, end_lineno=37, end_col_offset=23)], [], lineno=14, col_offset=4, end_lineno=37, end_col_offset=23), FunctionDef('placeholder_18', arguments([], [arg('self', lineno=39, col_offset=15, end_lineno=39, end_col_offset=19), arg('placeholder_19', lineno=39, col_offset=21, end_lineno=39, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Tuple([Name('placeholder_20', Store(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=13), Name('placeholder_21', Store(), lineno=40, col_offset=15, end_lineno=40, end_col_offset=22)], Store(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=22)], Call(Name('divmod', Load(), lineno=40, col_offset=25, end_lineno=40, end_col_offset=31), [Call(Name('abs', Load(), lineno=40, col_offset=32, end_lineno=40, end_col_offset=35), [Name('placeholder_19', Load(), lineno=40, col_offset=36, end_lineno=40, end_col_offset=37)], [], lineno=40, col_offset=32, end_lineno=40, end_col_offset=38), Constant(100, lineno=40, col_offset=40, end_lineno=40, end_col_offset=43)], [], lineno=40, col_offset=25, end_lineno=40, end_col_offset=44), lineno=40, col_offset=8, end_lineno=40, end_col_offset=44), Assign([Name('placeholder_22', Store(), lineno=41, col_offset=8, end_lineno=41, end_col_offset=19)], List([], Load(), lineno=41, col_offset=22, end_lineno=41, end_col_offset=24), lineno=41, col_offset=8, end_lineno=41, end_col_offset=24), While(Compare(Name('placeholder_20', Load(), lineno=42, col_offset=14, end_lineno=42, end_col_offset=19), [Gt()], [Constant(0, lineno=42, col_offset=22, end_lineno=42, end_col_offset=23)], lineno=42, col_offset=14, end_lineno=42, end_col_offset=23), [Assign([Tuple([Name('placeholder_20', Store(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=17), Name('placeholder_23', Store(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=22)], Store(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=22)], Call(Name('divmod', Load(), lineno=43, col_offset=25, end_lineno=43, end_col_offset=31), [Name('placeholder_20', Load(), lineno=43, col_offset=32, end_lineno=43, end_col_offset=37), Constant(1000, lineno=43, col_offset=39, end_lineno=43, end_col_offset=43)], [], lineno=43, col_offset=25, end_lineno=43, end_col_offset=44), lineno=43, col_offset=12, end_lineno=43, end_col_offset=44), Expr(Call(Attribute(Name('placeholder_22', Load(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=23), 'insert', Load(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=30), [Constant(0, lineno=44, col_offset=31, end_lineno=44, end_col_offset=32), Call(Name('str', Load(), lineno=44, col_offset=34, end_lineno=44, end_col_offset=37), [Name('placeholder_23', Load(), lineno=44, col_offset=38, end_lineno=44, end_col_offset=41)], [], lineno=44, col_offset=34, end_lineno=44, end_col_offset=42)], [], lineno=44, col_offset=12, end_lineno=44, end_col_offset=43), lineno=44, col_offset=12, end_lineno=44, end_col_offset=43)], [], lineno=42, col_offset=8, end_lineno=44, end_col_offset=43), Return(Call(Attribute(Constant('{}{}{:02}', lineno=45, col_offset=15, end_lineno=45, end_col_offset=26), 'format', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=33), [BoolOp(Or(), [Call(Attribute(Attribute(Name('self', Load(), lineno=46, col_offset=12, end_lineno=46, end_col_offset=16), 'placeholder_14', Load(), lineno=46, col_offset=12, end_lineno=46, end_col_offset=26), 'join', Load(), lineno=46, col_offset=12, end_lineno=46, end_col_offset=31), [Name('placeholder_22', Load(), lineno=46, col_offset=32, end_lineno=46, end_col_offset=43)], [], lineno=46, col_offset=12, end_lineno=46, end_col_offset=44), Constant('0', lineno=46, col_offset=48, end_lineno=46, end_col_offset=51)], lineno=46, col_offset=12, end_lineno=46, end_col_offset=51), Attribute(Name('self', Load(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=16), 'placeholder_15', Load(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=24), Name('placeholder_21', Load(), lineno=48, col_offset=12, end_lineno=48, end_col_offset=19)], [], lineno=45, col_offset=15, end_lineno=49, end_col_offset=9), lineno=45, col_offset=8, end_lineno=49, end_col_offset=9)], [], lineno=39, col_offset=4, end_lineno=49, end_col_offset=9), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=51, col_offset=17, end_lineno=51, end_col_offset=21), arg('placeholder_24', lineno=51, col_offset=23, end_lineno=51, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Attribute(Name('self', Load(), lineno=52, col_offset=15, end_lineno=52, end_col_offset=19), 'placeholder_11', Load(), lineno=52, col_offset=15, end_lineno=52, end_col_offset=27), 'format', Load(), lineno=52, col_offset=15, end_lineno=52, end_col_offset=34), [IfExp(Compare(Name('placeholder_24', Load(), lineno=53, col_offset=29, end_lineno=53, end_col_offset=35), [Lt()], [Constant(0, lineno=53, col_offset=38, end_lineno=53, end_col_offset=39)], lineno=53, col_offset=29, end_lineno=53, end_col_offset=39), Attribute(Name('self', Load(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=16), 'placeholder_12', Load(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=25), Constant('', lineno=53, col_offset=45, end_lineno=53, end_col_offset=47), lineno=53, col_offset=12, end_lineno=53, end_col_offset=47), Attribute(Name('self', Load(), lineno=54, col_offset=12, end_lineno=54, end_col_offset=16), 'placeholder_17', Load(), lineno=54, col_offset=12, end_lineno=54, end_col_offset=27), Call(Attribute(Name('self', Load(), lineno=55, col_offset=12, end_lineno=55, end_col_offset=16), 'placeholder_18', Load(), lineno=55, col_offset=12, end_lineno=55, end_col_offset=23), [Name('placeholder_24', Load(), lineno=55, col_offset=24, end_lineno=55, end_col_offset=30)], [], lineno=55, col_offset=12, end_lineno=55, end_col_offset=31), IfExp(Compare(Name('placeholder_24', Load(), lineno=56, col_offset=30, end_lineno=56, end_col_offset=36), [Lt()], [Constant(0, lineno=56, col_offset=39, end_lineno=56, end_col_offset=40)], lineno=56, col_offset=30, end_lineno=56, end_col_offset=40), Attribute(Name('self', Load(), lineno=56, col_offset=12, end_lineno=56, end_col_offset=16), 'placeholder_13', Load(), lineno=56, col_offset=12, end_lineno=56, end_col_offset=26), Constant(' ', lineno=56, col_offset=46, end_lineno=56, end_col_offset=49), lineno=56, col_offset=12, end_lineno=56, end_col_offset=49)], [], lineno=52, col_offset=15, end_lineno=57, end_col_offset=9), lineno=52, col_offset=8, end_lineno=57, end_col_offset=9)], [], lineno=51, col_offset=4, end_lineno=57, end_col_offset=9), FunctionDef('placeholder_25', arguments([], [arg('self', lineno=59, col_offset=14, end_lineno=59, end_col_offset=18), arg('placeholder_25', lineno=59, col_offset=20, end_lineno=59, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Tuple([Name('placeholder_26', Store(), lineno=60, col_offset=8, end_lineno=60, end_col_offset=12), Name('placeholder_24', Store(), lineno=60, col_offset=14, end_lineno=60, end_col_offset=20), Name('placeholder_27', Store(), lineno=60, col_offset=22, end_lineno=60, end_col_offset=26)], Store(), lineno=60, col_offset=8, end_lineno=60, end_col_offset=26)], Name('placeholder_25', Load(), lineno=60, col_offset=29, end_lineno=60, end_col_offset=34), lineno=60, col_offset=8, end_lineno=60, end_col_offset=34), Assign([Name('placeholder_16', Store(), lineno=61, col_offset=8, end_lineno=61, end_col_offset=11)], Call(Attribute(Name('placeholder_0', Load(), lineno=61, col_offset=14, end_lineno=61, end_col_offset=21), 'format', Load(), lineno=61, col_offset=14, end_lineno=61, end_col_offset=28), [Constant('>', lineno=61, col_offset=29, end_lineno=61, end_col_offset=32), Starred(Attribute(Name('self', Load(), lineno=61, col_offset=35, end_lineno=61, end_col_offset=39), 'placeholder_8', Load(), lineno=61, col_offset=35, end_lineno=61, end_col_offset=47), Load(), lineno=61, col_offset=34, end_lineno=61, end_col_offset=47)], [], lineno=61, col_offset=14, end_lineno=61, end_col_offset=48), lineno=61, col_offset=8, end_lineno=61, end_col_offset=48), Return(Call(Attribute(Name('placeholder_16', Load(), lineno=62, col_offset=15, end_lineno=62, end_col_offset=18), 'format', Load(), lineno=62, col_offset=15, end_lineno=62, end_col_offset=25), [Call(Attribute(Attribute(Name('self', Load(), lineno=63, col_offset=12, end_lineno=63, end_col_offset=16), 'placeholder_10', Load(), lineno=63, col_offset=12, end_lineno=63, end_col_offset=24), 'format', Load(), lineno=63, col_offset=12, end_lineno=63, end_col_offset=31), [Name('placeholder_26', Load(), lineno=63, col_offset=32, end_lineno=63, end_col_offset=36)], [], lineno=63, col_offset=12, end_lineno=63, end_col_offset=37), Call(Name('placeholder_1', Load(), lineno=64, col_offset=12, end_lineno=64, end_col_offset=20), [Name('placeholder_27', Load(), lineno=64, col_offset=21, end_lineno=64, end_col_offset=25)], [], lineno=64, col_offset=12, end_lineno=64, end_col_offset=26), Call(Attribute(Name('self', Load(), lineno=65, col_offset=12, end_lineno=65, end_col_offset=16), 'placeholder_7', Load(), lineno=65, col_offset=12, end_lineno=65, end_col_offset=25), [Name('placeholder_24', Load(), lineno=65, col_offset=26, end_lineno=65, end_col_offset=32)], [], lineno=65, col_offset=12, end_lineno=65, end_col_offset=33)], [], lineno=62, col_offset=15, end_lineno=66, end_col_offset=9), lineno=62, col_offset=8, end_lineno=66, end_col_offset=9)], [], lineno=59, col_offset=4, end_lineno=66, end_col_offset=9), FunctionDef('placeholder_28', arguments([], [arg('self', lineno=68, col_offset=14, end_lineno=68, end_col_offset=18), arg('placeholder_29', lineno=68, col_offset=20, end_lineno=68, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_30', Store(), lineno=69, col_offset=8, end_lineno=69, end_col_offset=13)], List([Attribute(Name('self', Load(), lineno=69, col_offset=17, end_lineno=69, end_col_offset=21), 'placeholder_9', Load(), lineno=69, col_offset=17, end_lineno=69, end_col_offset=29)], Load(), lineno=69, col_offset=16, end_lineno=69, end_col_offset=30), lineno=69, col_offset=8, end_lineno=69, end_col_offset=30), Expr(Call(Attribute(Name('placeholder_30', Load(), lineno=70, col_offset=8, end_lineno=70, end_col_offset=13), 'extend', Load(), lineno=70, col_offset=8, end_lineno=70, end_col_offset=20), [Call(Name('map', Load(), lineno=70, col_offset=21, end_lineno=70, end_col_offset=24), [Attribute(Name('self', Load(), lineno=70, col_offset=25, end_lineno=70, end_col_offset=29), 'placeholder_25', Load(), lineno=70, col_offset=25, end_lineno=70, end_col_offset=35), Call(Name('sorted', Load(), lineno=70, col_offset=37, end_lineno=70, end_col_offset=43), [Name('placeholder_29', Load(), lineno=70, col_offset=44, end_lineno=70, end_col_offset=51)], [], lineno=70, col_offset=37, end_lineno=70, end_col_offset=52)], [], lineno=70, col_offset=21, end_lineno=70, end_col_offset=53)], [], lineno=70, col_offset=8, end_lineno=70, end_col_offset=54), lineno=70, col_offset=8, end_lineno=70, end_col_offset=54), Return(Call(Attribute(Constant('\n', lineno=71, col_offset=15, end_lineno=71, end_col_offset=19), 'join', Load(), lineno=71, col_offset=15, end_lineno=71, end_col_offset=24), [Name('placeholder_30', Load(), lineno=71, col_offset=25, end_lineno=71, end_col_offset=30)], [], lineno=71, col_offset=15, end_lineno=71, end_col_offset=31), lineno=71, col_offset=8, end_lineno=71, end_col_offset=31)], [], lineno=68, col_offset=4, end_lineno=71, end_col_offset=31)], [], lineno=13, col_offset=0, end_lineno=71, end_col_offset=31), FunctionDef('placeholder_31', arguments([], [arg('placeholder_26', lineno=74, col_offset=17, end_lineno=74, end_col_offset=21), arg('placeholder_32', lineno=74, col_offset=23, end_lineno=74, end_col_offset=34), arg('placeholder_24', lineno=74, col_offset=36, end_lineno=74, end_col_offset=42)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Tuple([Call(Attribute(Name('datetime', Load(), lineno=76, col_offset=8, end_lineno=76, end_col_offset=16), 'strptime', Load(), lineno=76, col_offset=8, end_lineno=76, end_col_offset=25), [Name('placeholder_26', Load(), lineno=76, col_offset=26, end_lineno=76, end_col_offset=30), Constant('%Y-%m-%d', lineno=76, col_offset=32, end_lineno=76, end_col_offset=42)], [], lineno=76, col_offset=8, end_lineno=76, end_col_offset=43), Name('placeholder_24', Load(), lineno=77, col_offset=8, end_lineno=77, end_col_offset=14), Name('placeholder_32', Load(), lineno=78, col_offset=8, end_lineno=78, end_col_offset=19)], Load(), lineno=75, col_offset=11, end_lineno=79, end_col_offset=5), lineno=75, col_offset=4, end_lineno=79, end_col_offset=5)], [], lineno=74, col_offset=0, end_lineno=79, end_col_offset=5), FunctionDef('placeholder_33', arguments([], [arg('placeholder_7', lineno=82, col_offset=19, end_lineno=82, end_col_offset=27), arg('placeholder_6', lineno=82, col_offset=29, end_lineno=82, end_col_offset=35), arg('placeholder_29', lineno=82, col_offset=37, end_lineno=82, end_col_offset=44)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=83, col_offset=4, end_lineno=83, end_col_offset=11)], Tuple([Constant(10, lineno=83, col_offset=15, end_lineno=83, end_col_offset=17), Constant(25, lineno=83, col_offset=19, end_lineno=83, end_col_offset=21), Constant(13, lineno=83, col_offset=23, end_lineno=83, end_col_offset=25)], Load(), lineno=83, col_offset=14, end_lineno=83, end_col_offset=26), lineno=83, col_offset=4, end_lineno=83, end_col_offset=26), Assign([Name('placeholder_34', Store(), lineno=84, col_offset=4, end_lineno=84, end_col_offset=10)], Call(Name('placeholder_4', Load(), lineno=84, col_offset=13, end_lineno=84, end_col_offset=19), [Name('placeholder_6', Load(), lineno=84, col_offset=20, end_lineno=84, end_col_offset=26), Name('placeholder_7', Load(), lineno=84, col_offset=28, end_lineno=84, end_col_offset=36), Name('placeholder_8', Load(), lineno=84, col_offset=38, end_lineno=84, end_col_offset=45)], [], lineno=84, col_offset=13, end_lineno=84, end_col_offset=46), lineno=84, col_offset=4, end_lineno=84, end_col_offset=46), Return(Call(Attribute(Name('placeholder_34', Load(), lineno=85, col_offset=11, end_lineno=85, end_col_offset=17), 'placeholder_28', Load(), lineno=85, col_offset=11, end_lineno=85, end_col_offset=23), [Name('placeholder_29', Load(), lineno=85, col_offset=24, end_lineno=85, end_col_offset=31)], [], lineno=85, col_offset=11, end_lineno=85, end_col_offset=32), lineno=85, col_offset=4, end_lineno=85, end_col_offset=32)], [], lineno=82, col_offset=0, end_lineno=85, end_col_offset=32)], []) \ No newline at end of file diff --git a/test/practice-linked-list/.meta/additional_tests.json b/test/practice-linked-list/.meta/additional_tests.json new file mode 100644 index 0000000..a791426 --- /dev/null +++ b/test/practice-linked-list/.meta/additional_tests.json @@ -0,0 +1,130 @@ +{ + "cases": [ + { + "uuid": "c472bec8-45b5-477f-96c1-3bed58ca0b1a", + "description": "Using pop raises an error if the list is empty", + "property": "list", + "input": { + "operations": [ + { + "operation": "pop" + } + + ] + }, "expected": {"error": "List is empty"} + }, + { + "uuid": "394a61d3-7a69-4153-9eb7-f8d8e23cf6f0", + "description" : "Can return with pop and then raise an error if empty", + "property": "list", + "input": { + "operations": [ + { + "operation": "push", + "value": 1 + }, + { + "operation": "unshift", + "value": 5 + }, + { + "operation": "pop", + "expected": 1 + }, + { + "operation": "pop", + "expected": 5 + }, + { + "operation": "pop" + } + ] + }, + "expected": {"error": "List is empty"} + }, + { + "uuid": "6d1a1817-0d4c-4953-abfd-c5cd5639871f", + "description": "Using shift raises an error if the list is empty", + "property": "list", + "input": { + "operations": [ + { + "operation": "shift" + } + + ] + }, + "expected": {"error": "List is empty"} + }, + { + "uuid": "cae5d135-f948-44ce-8940-c9b898b95756", + "description": "Can return with shift and then raise an error if empty", + "property": "list", + "input": { + "operations": [ + { + "operation": "push", + "value": 1 + }, + { + "operation": "unshift", + "value": 5 + }, + { + "operation": "pop", + "expected": 1 + }, + { + "operation": "shift", + "expected": 5 + }, + { + "operation": "shift" + } + + ] + }, + "expected": {"error": "List is empty"} + }, + { + "uuid": "1fa81a88-9af7-49a1-a4b1-b1aa641bfcbb", + "description": "Using delete raises an error if the list is empty", + "property": "list", + "input": { + "operations": [ + { + "operation": "delete", + "value": 0 + } + + ] + }, + "expected": {"error": "Value not found"} + }, + { + "uuid": "f7f9d2dc-be1b-4f42-be2e-c29980ce0823", + "description": "Using delete raises an error if the value is not found", + "property": "list", + "input": { + "operations": [ + { + "operation": "push", + "value": 5 + }, + { + "operation": "push", + "value": 7 + }, + { + "operation": "pop", + "expected": 7 + }, + { + "operation": "delete", + "value": 7 + } + + ] + }, "expected": {"error": "Value not found"} + } +]} \ No newline at end of file diff --git a/test/practice-linked-list/.meta/config.json b/test/practice-linked-list/.meta/config.json new file mode 100644 index 0000000..3c1731c --- /dev/null +++ b/test/practice-linked-list/.meta/config.json @@ -0,0 +1,28 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "cmccandless", + "Dog", + "frerich", + "Mofeywalker", + "N-Parsons", + "pheanex", + "tqa236", + "meatball133" + ], + "files": { + "solution": [ + "linked_list.py" + ], + "test": [ + "linked_list_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement a doubly linked list.", + "source": "Classic computer science topic" +} diff --git a/test/practice-linked-list/linked_list.py b/test/practice-linked-list/linked_list.py new file mode 100644 index 0000000..acc13d4 --- /dev/null +++ b/test/practice-linked-list/linked_list.py @@ -0,0 +1,94 @@ +class Node: + def __init__(self, value, succeeding=None, previous=None): + self.value = value + self.succeeding = succeeding + self.prev = previous + + +class LinkedList: + def __init__(self): + self.head = None + self.tail = None + self.length = 0 + + def __len__(self): + return self.length + + def __iter__(self): + current_node = self.head + while current_node: + yield (current_node.value, current_node.succeeding, current_node.prev) + current_node = current_node.succeeding + + def delete(self, to_delete): + if self.length == 0: + raise ValueError("Value not found") + found = False + node = self.head + + for value, succeeding, prev in self: + if value == to_delete: + if prev: + node.prev.succeeding = succeeding + else: + self.head = succeeding + if succeeding: + node.succeeding.prev = prev + else: + self.tail = prev + + found = True + self.length -= 1 + break + node = node.succeeding + if not found: + raise ValueError("Value not found") + + def push(self, value): + new_node = Node(value) + if not self.head: + self.head = self.tail = new_node + else: + new_node.prev = self.tail + self.tail.succeeding = new_node + self.tail = new_node + + self.length += 1 + + def pop(self): + node = self.tail + + if self.length == 0: + raise IndexError("List is empty") + if node is None or node.prev is None: + self.head = self.tail = None + else: + self.tail = self.tail.prev + self.tail.succeeding = None + self.length -= 1 + + return node.value + + def shift(self): + if self.length == 0: + raise IndexError("List is empty") + node = self.head + if node is None or node.succeeding is None: + self.head = self.tail = None + else: + self.head = self.head.succeeding + self.head.prev = None + self.length -= 1 + + return node.value + + def unshift(self, value): + new_node = Node(value) + if not self.head: + self.head = self.tail = new_node + else: + new_node.succeeding = self.head + self.head.prev = new_node + self.head = new_node + + self.length += 1 diff --git a/test/practice-linked-list/mapping.json b/test/practice-linked-list/mapping.json new file mode 100644 index 0000000..97bda9e --- /dev/null +++ b/test/practice-linked-list/mapping.json @@ -0,0 +1,24 @@ +{ + "placeholder_0": "Node", + "placeholder_1": "__init__", + "placeholder_2": "value", + "placeholder_3": "succeeding", + "placeholder_4": "previous", + "placeholder_5": "prev", + "placeholder_6": "LinkedList", + "placeholder_7": "head", + "placeholder_8": "tail", + "placeholder_9": "length", + "placeholder_10": "__len__", + "placeholder_11": "__iter__", + "placeholder_12": "current_node", + "placeholder_13": "delete", + "placeholder_14": "to_delete", + "placeholder_15": "found", + "placeholder_16": "node", + "placeholder_17": "push", + "placeholder_18": "new_node", + "placeholder_19": "pop", + "placeholder_20": "shift", + "placeholder_21": "unshift" +} \ No newline at end of file diff --git a/test/practice-linked-list/representation.json b/test/practice-linked-list/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-linked-list/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-linked-list/representation.out b/test/practice-linked-list/representation.out new file mode 100644 index 0000000..db6907b --- /dev/null +++ b/test/practice-linked-list/representation.out @@ -0,0 +1,4234 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3=None, placeholder_4=None): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 + self.placeholder_5 = placeholder_4 + + +class placeholder_6: + def placeholder_1(self): + self.placeholder_7 = None + self.placeholder_8 = None + self.placeholder_9 = 0 + + def placeholder_10(self): + return self.placeholder_9 + + def placeholder_11(self): + placeholder_12 = self.placeholder_7 + while placeholder_12: + yield (current_node.value, current_node.succeeding, current_node.prev) + placeholder_12 = placeholder_12.placeholder_3 + + def placeholder_13(self, placeholder_14): + if self.placeholder_9 == 0: + raise ValueError("Value not found") + placeholder_15 = False + placeholder_16 = self.placeholder_7 + for placeholder_2, placeholder_3, placeholder_5 in self: + if placeholder_2 == placeholder_14: + if placeholder_5: + placeholder_16.placeholder_5.placeholder_3 = placeholder_3 + else: + self.placeholder_7 = placeholder_3 + if placeholder_3: + placeholder_16.placeholder_3.placeholder_5 = placeholder_5 + else: + self.placeholder_8 = placeholder_5 + placeholder_15 = True + self.placeholder_9 -= 1 + break + placeholder_16 = placeholder_16.placeholder_3 + if not placeholder_15: + raise ValueError("Value not found") + + def placeholder_17(self, placeholder_2): + placeholder_18 = placeholder_0(placeholder_2) + if not self.placeholder_7: + self.placeholder_7 = self.placeholder_8 = placeholder_18 + else: + placeholder_18.placeholder_5 = self.placeholder_8 + self.placeholder_8.placeholder_3 = placeholder_18 + self.placeholder_8 = placeholder_18 + self.placeholder_9 += 1 + + def placeholder_19(self): + placeholder_16 = self.placeholder_8 + if self.placeholder_9 == 0: + raise IndexError("List is empty") + if placeholder_16 is None or placeholder_16.placeholder_5 is None: + self.placeholder_7 = self.placeholder_8 = None + else: + self.placeholder_8 = self.placeholder_8.placeholder_5 + self.placeholder_8.placeholder_3 = None + self.placeholder_9 -= 1 + return placeholder_16.placeholder_2 + + def placeholder_20(self): + if self.placeholder_9 == 0: + raise IndexError("List is empty") + placeholder_16 = self.placeholder_7 + if placeholder_16 is None or placeholder_16.placeholder_3 is None: + self.placeholder_7 = self.placeholder_8 = None + else: + self.placeholder_7 = self.placeholder_7.placeholder_3 + self.placeholder_7.placeholder_5 = None + self.placeholder_9 -= 1 + return placeholder_16.placeholder_2 + + def placeholder_21(self, placeholder_2): + placeholder_18 = placeholder_0(placeholder_2) + if not self.placeholder_7: + self.placeholder_7 = self.placeholder_8 = placeholder_18 + else: + placeholder_18.placeholder_3 = self.placeholder_7 + self.placeholder_7.placeholder_5 = placeholder_18 + self.placeholder_7 = placeholder_18 + self.placeholder_9 += 1 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Node', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'value', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=28), + arg( + 'succeeding', + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=40), + arg( + 'previous', + lineno=2, + col_offset=47, + end_lineno=2, + end_col_offset=55)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=2, + col_offset=41, + end_lineno=2, + end_col_offset=45), + Constant( + None, + lineno=2, + col_offset=56, + end_lineno=2, + end_col_offset=60)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'value', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=18)], + Name( + 'value', + Load(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=26), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'succeeding', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=23)], + Name( + 'succeeding', + Load(), + lineno=4, + col_offset=26, + end_lineno=4, + end_col_offset=36), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'prev', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17)], + Name( + 'previous', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=28), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=28)], + [], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=28)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=28), + ClassDef( + 'LinkedList', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'head', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=17)], + Constant( + None, + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=24), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'tail', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=17)], + Constant( + None, + lineno=11, + col_offset=20, + end_lineno=11, + end_col_offset=24), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'length', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=19)], + Constant( + 0, + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=23), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=23)], + [], + lineno=9, + col_offset=4, + end_lineno=12, + end_col_offset=23), + FunctionDef( + '__len__', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + 'length', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=26), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=26)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=26), + FunctionDef( + '__iter__', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'current_node', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=20)], + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=27), + 'head', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=32), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=32), + While( + Name( + 'current_node', + Load(), + lineno=19, + col_offset=14, + end_lineno=19, + end_col_offset=26), + [ + Expr( + Yield( + Tuple( + [ + Attribute( + Name( + 'current_node', + Load(), + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=31), + 'value', + Load(), + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=37), + Attribute( + Name( + 'current_node', + Load(), + lineno=20, + col_offset=39, + end_lineno=20, + end_col_offset=51), + 'succeeding', + Load(), + lineno=20, + col_offset=39, + end_lineno=20, + end_col_offset=62), + Attribute( + Name( + 'current_node', + Load(), + lineno=20, + col_offset=64, + end_lineno=20, + end_col_offset=76), + 'prev', + Load(), + lineno=20, + col_offset=64, + end_lineno=20, + end_col_offset=81)], + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=82), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=82), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=82), + Assign( + [ + Name( + 'current_node', + Store(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=24)], + Attribute( + Name( + 'current_node', + Load(), + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=39), + 'succeeding', + Load(), + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=50), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=50)], + [], + lineno=19, + col_offset=8, + end_lineno=21, + end_col_offset=50)], + [], + lineno=17, + col_offset=4, + end_lineno=21, + end_col_offset=50), + FunctionDef( + 'delete', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=19), + arg( + 'to_delete', + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=15), + 'length', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=28), + [ + Constant( + 'Value not found', + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=46)], + [], + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=47), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=47)], + [], + lineno=24, + col_offset=8, + end_lineno=25, + end_col_offset=47), + Assign( + [ + Name( + 'found', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=13)], + Constant( + False, + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=21), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=21), + Assign( + [ + Name( + 'node', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=12)], + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=19), + 'head', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=24), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=24), + For( + Tuple( + [ + Name( + 'value', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=17), + Name( + 'succeeding', + Store(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=29), + Name( + 'prev', + Store(), + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=35)], + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=35), + Name( + 'self', + Load(), + lineno=29, + col_offset=39, + end_lineno=29, + end_col_offset=43), + [ + If( + Compare( + Name( + 'value', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=20), + [ + Eq()], + [ + Name( + 'to_delete', + Load(), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=33)], + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=33), + [ + If( + Name( + 'prev', + Load(), + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=23), + [ + Assign( + [ + Attribute( + Attribute( + Name( + 'node', + Load(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=24), + 'prev', + Load(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=29), + 'succeeding', + Store(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=40)], + Name( + 'succeeding', + Load(), + lineno=32, + col_offset=43, + end_lineno=32, + end_col_offset=53), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=53)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=20, + end_lineno=34, + end_col_offset=24), + 'head', + Store(), + lineno=34, + col_offset=20, + end_lineno=34, + end_col_offset=29)], + Name( + 'succeeding', + Load(), + lineno=34, + col_offset=32, + end_lineno=34, + end_col_offset=42), + lineno=34, + col_offset=20, + end_lineno=34, + end_col_offset=42)], + lineno=31, + col_offset=16, + end_lineno=34, + end_col_offset=42), + If( + Name( + 'succeeding', + Load(), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=29), + [ + Assign( + [ + Attribute( + Attribute( + Name( + 'node', + Load(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=24), + 'succeeding', + Load(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=35), + 'prev', + Store(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=40)], + Name( + 'prev', + Load(), + lineno=36, + col_offset=43, + end_lineno=36, + end_col_offset=47), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=47)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=24), + 'tail', + Store(), + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=29)], + Name( + 'prev', + Load(), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=36), + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=36)], + lineno=35, + col_offset=16, + end_lineno=38, + end_col_offset=36), + Assign( + [ + Name( + 'found', + Store(), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=21)], + Constant( + True, + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=28), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=28), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=20), + 'length', + Store(), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=27), + Sub(), + Constant( + 1, + lineno=41, + col_offset=31, + end_lineno=41, + end_col_offset=32), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=32), + Break( + lineno=42, + col_offset=16, + end_lineno=42, + end_col_offset=21)], + [], + lineno=30, + col_offset=12, + end_lineno=42, + end_col_offset=21), + Assign( + [ + Name( + 'node', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=16)], + Attribute( + Name( + 'node', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=23), + 'succeeding', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=34), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=34)], + [], + lineno=29, + col_offset=8, + end_lineno=43, + end_col_offset=34), + If( + UnaryOp( + Not(), + Name( + 'found', + Load(), + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=20), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=28), + [ + Constant( + 'Value not found', + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=46)], + [], + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=47), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=47)], + [], + lineno=44, + col_offset=8, + end_lineno=45, + end_col_offset=47)], + [], + lineno=23, + col_offset=4, + end_lineno=45, + end_col_offset=47), + FunctionDef( + 'push', + arguments( + [], + [ + arg( + 'self', + lineno=47, + col_offset=13, + end_lineno=47, + end_col_offset=17), + arg( + 'value', + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'new_node', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=16)], + Call( + Name( + 'Node', + Load(), + lineno=48, + col_offset=19, + end_lineno=48, + end_col_offset=23), + [ + Name( + 'value', + Load(), + lineno=48, + col_offset=24, + end_lineno=48, + end_col_offset=29)], + [], + lineno=48, + col_offset=19, + end_lineno=48, + end_col_offset=30), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=30), + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=19), + 'head', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=24), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=24), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=16), + 'head', + Store(), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=21), + Attribute( + Name( + 'self', + Load(), + lineno=50, + col_offset=24, + end_lineno=50, + end_col_offset=28), + 'tail', + Store(), + lineno=50, + col_offset=24, + end_lineno=50, + end_col_offset=33)], + Name( + 'new_node', + Load(), + lineno=50, + col_offset=36, + end_lineno=50, + end_col_offset=44), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=44)], + [ + Assign( + [ + Attribute( + Name( + 'new_node', + Load(), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=20), + 'prev', + Store(), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=25)], + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=28, + end_lineno=52, + end_col_offset=32), + 'tail', + Load(), + lineno=52, + col_offset=28, + end_lineno=52, + end_col_offset=37), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=37), + Assign( + [ + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=16), + 'tail', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=21), + 'succeeding', + Store(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=32)], + Name( + 'new_node', + Load(), + lineno=53, + col_offset=35, + end_lineno=53, + end_col_offset=43), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=43), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=16), + 'tail', + Store(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=21)], + Name( + 'new_node', + Load(), + lineno=54, + col_offset=24, + end_lineno=54, + end_col_offset=32), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=32)], + lineno=49, + col_offset=8, + end_lineno=54, + end_col_offset=32), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=12), + 'length', + Store(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=56, + col_offset=23, + end_lineno=56, + end_col_offset=24), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=24)], + [], + lineno=47, + col_offset=4, + end_lineno=56, + end_col_offset=24), + FunctionDef( + 'pop', + arguments( + [], + [ + arg( + 'self', + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'node', + Store(), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=12)], + Attribute( + Name( + 'self', + Load(), + lineno=59, + col_offset=15, + end_lineno=59, + end_col_offset=19), + 'tail', + Load(), + lineno=59, + col_offset=15, + end_lineno=59, + end_col_offset=24), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=24), + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=15), + 'length', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=61, + col_offset=26, + end_lineno=61, + end_col_offset=27)], + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=62, + col_offset=18, + end_lineno=62, + end_col_offset=28), + [ + Constant( + 'List is empty', + lineno=62, + col_offset=29, + end_lineno=62, + end_col_offset=44)], + [], + lineno=62, + col_offset=18, + end_lineno=62, + end_col_offset=45), + lineno=62, + col_offset=12, + end_lineno=62, + end_col_offset=45)], + [], + lineno=61, + col_offset=8, + end_lineno=62, + end_col_offset=45), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'node', + Load(), + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=15), + [ + Is()], + [ + Constant( + None, + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=23)], + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=23), + Compare( + Attribute( + Name( + 'node', + Load(), + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=31), + 'prev', + Load(), + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=36), + [ + Is()], + [ + Constant( + None, + lineno=63, + col_offset=40, + end_lineno=63, + end_col_offset=44)], + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=44)], + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=44), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=16), + 'head', + Store(), + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=21), + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=24, + end_lineno=64, + end_col_offset=28), + 'tail', + Store(), + lineno=64, + col_offset=24, + end_lineno=64, + end_col_offset=33)], + Constant( + None, + lineno=64, + col_offset=36, + end_lineno=64, + end_col_offset=40), + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=40)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=16), + 'tail', + Store(), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=21)], + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=66, + col_offset=24, + end_lineno=66, + end_col_offset=28), + 'tail', + Load(), + lineno=66, + col_offset=24, + end_lineno=66, + end_col_offset=33), + 'prev', + Load(), + lineno=66, + col_offset=24, + end_lineno=66, + end_col_offset=38), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=38), + Assign( + [ + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=16), + 'tail', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=21), + 'succeeding', + Store(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=32)], + Constant( + None, + lineno=67, + col_offset=35, + end_lineno=67, + end_col_offset=39), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=39)], + lineno=63, + col_offset=8, + end_lineno=67, + end_col_offset=39), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=12), + 'length', + Store(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=19), + Sub(), + Constant( + 1, + lineno=68, + col_offset=23, + end_lineno=68, + end_col_offset=24), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=24), + Return( + Attribute( + Name( + 'node', + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=19), + 'value', + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=25), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=25)], + [], + lineno=58, + col_offset=4, + end_lineno=70, + end_col_offset=25), + FunctionDef( + 'shift', + arguments( + [], + [ + arg( + 'self', + lineno=72, + col_offset=14, + end_lineno=72, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=15), + 'length', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=73, + col_offset=26, + end_lineno=73, + end_col_offset=27)], + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=74, + col_offset=18, + end_lineno=74, + end_col_offset=28), + [ + Constant( + 'List is empty', + lineno=74, + col_offset=29, + end_lineno=74, + end_col_offset=44)], + [], + lineno=74, + col_offset=18, + end_lineno=74, + end_col_offset=45), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=45)], + [], + lineno=73, + col_offset=8, + end_lineno=74, + end_col_offset=45), + Assign( + [ + Name( + 'node', + Store(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=12)], + Attribute( + Name( + 'self', + Load(), + lineno=75, + col_offset=15, + end_lineno=75, + end_col_offset=19), + 'head', + Load(), + lineno=75, + col_offset=15, + end_lineno=75, + end_col_offset=24), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=24), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'node', + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=15), + [ + Is()], + [ + Constant( + None, + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=23)], + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=23), + Compare( + Attribute( + Name( + 'node', + Load(), + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=31), + 'succeeding', + Load(), + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=42), + [ + Is()], + [ + Constant( + None, + lineno=76, + col_offset=46, + end_lineno=76, + end_col_offset=50)], + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=50)], + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=50), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=16), + 'head', + Store(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=21), + Attribute( + Name( + 'self', + Load(), + lineno=77, + col_offset=24, + end_lineno=77, + end_col_offset=28), + 'tail', + Store(), + lineno=77, + col_offset=24, + end_lineno=77, + end_col_offset=33)], + Constant( + None, + lineno=77, + col_offset=36, + end_lineno=77, + end_col_offset=40), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=40)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=16), + 'head', + Store(), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=21)], + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=79, + col_offset=24, + end_lineno=79, + end_col_offset=28), + 'head', + Load(), + lineno=79, + col_offset=24, + end_lineno=79, + end_col_offset=33), + 'succeeding', + Load(), + lineno=79, + col_offset=24, + end_lineno=79, + end_col_offset=44), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=44), + Assign( + [ + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=16), + 'head', + Load(), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=21), + 'prev', + Store(), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=26)], + Constant( + None, + lineno=80, + col_offset=29, + end_lineno=80, + end_col_offset=33), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=33)], + lineno=76, + col_offset=8, + end_lineno=80, + end_col_offset=33), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=12), + 'length', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=19), + Sub(), + Constant( + 1, + lineno=81, + col_offset=23, + end_lineno=81, + end_col_offset=24), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=24), + Return( + Attribute( + Name( + 'node', + Load(), + lineno=83, + col_offset=15, + end_lineno=83, + end_col_offset=19), + 'value', + Load(), + lineno=83, + col_offset=15, + end_lineno=83, + end_col_offset=25), + lineno=83, + col_offset=8, + end_lineno=83, + end_col_offset=25)], + [], + lineno=72, + col_offset=4, + end_lineno=83, + end_col_offset=25), + FunctionDef( + 'unshift', + arguments( + [], + [ + arg( + 'self', + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=20), + arg( + 'value', + lineno=85, + col_offset=22, + end_lineno=85, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'new_node', + Store(), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=16)], + Call( + Name( + 'Node', + Load(), + lineno=86, + col_offset=19, + end_lineno=86, + end_col_offset=23), + [ + Name( + 'value', + Load(), + lineno=86, + col_offset=24, + end_lineno=86, + end_col_offset=29)], + [], + lineno=86, + col_offset=19, + end_lineno=86, + end_col_offset=30), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=30), + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=15, + end_lineno=87, + end_col_offset=19), + 'head', + Load(), + lineno=87, + col_offset=15, + end_lineno=87, + end_col_offset=24), + lineno=87, + col_offset=11, + end_lineno=87, + end_col_offset=24), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=88, + col_offset=12, + end_lineno=88, + end_col_offset=16), + 'head', + Store(), + lineno=88, + col_offset=12, + end_lineno=88, + end_col_offset=21), + Attribute( + Name( + 'self', + Load(), + lineno=88, + col_offset=24, + end_lineno=88, + end_col_offset=28), + 'tail', + Store(), + lineno=88, + col_offset=24, + end_lineno=88, + end_col_offset=33)], + Name( + 'new_node', + Load(), + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=44), + lineno=88, + col_offset=12, + end_lineno=88, + end_col_offset=44)], + [ + Assign( + [ + Attribute( + Name( + 'new_node', + Load(), + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=20), + 'succeeding', + Store(), + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=31)], + Attribute( + Name( + 'self', + Load(), + lineno=90, + col_offset=34, + end_lineno=90, + end_col_offset=38), + 'head', + Load(), + lineno=90, + col_offset=34, + end_lineno=90, + end_col_offset=43), + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=43), + Assign( + [ + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=16), + 'head', + Load(), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=21), + 'prev', + Store(), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=26)], + Name( + 'new_node', + Load(), + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=37), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=37), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=92, + col_offset=12, + end_lineno=92, + end_col_offset=16), + 'head', + Store(), + lineno=92, + col_offset=12, + end_lineno=92, + end_col_offset=21)], + Name( + 'new_node', + Load(), + lineno=92, + col_offset=24, + end_lineno=92, + end_col_offset=32), + lineno=92, + col_offset=12, + end_lineno=92, + end_col_offset=32)], + lineno=87, + col_offset=8, + end_lineno=92, + end_col_offset=32), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=12), + 'length', + Store(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=94, + col_offset=23, + end_lineno=94, + end_col_offset=24), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=24)], + [], + lineno=85, + col_offset=4, + end_lineno=94, + end_col_offset=24)], + [], + lineno=8, + col_offset=0, + end_lineno=94, + end_col_offset=24)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=28), + arg( + 'placeholder_3', + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=40), + arg( + 'placeholder_4', + lineno=2, + col_offset=47, + end_lineno=2, + end_col_offset=55)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=2, + col_offset=41, + end_lineno=2, + end_col_offset=45), + Constant( + None, + lineno=2, + col_offset=56, + end_lineno=2, + end_col_offset=60)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=18)], + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=26), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=23)], + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=26, + end_lineno=4, + end_col_offset=36), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17)], + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=28), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=28)], + [], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=28)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=28), + ClassDef( + 'placeholder_6', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=17)], + Constant( + None, + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=24), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=17)], + Constant( + None, + lineno=11, + col_offset=20, + end_lineno=11, + end_col_offset=24), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'placeholder_9', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=19)], + Constant( + 0, + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=23), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=23)], + [], + lineno=9, + col_offset=4, + end_lineno=12, + end_col_offset=23), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + 'placeholder_9', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=26), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=26)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=26), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=20)], + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=27), + 'placeholder_7', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=32), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=32), + While( + Name( + 'placeholder_12', + Load(), + lineno=19, + col_offset=14, + end_lineno=19, + end_col_offset=26), + [ + Expr( + Yield( + Tuple( + [ + Attribute( + Name( + 'current_node', + Load(), + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=31), + 'value', + Load(), + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=37), + Attribute( + Name( + 'current_node', + Load(), + lineno=20, + col_offset=39, + end_lineno=20, + end_col_offset=51), + 'succeeding', + Load(), + lineno=20, + col_offset=39, + end_lineno=20, + end_col_offset=62), + Attribute( + Name( + 'current_node', + Load(), + lineno=20, + col_offset=64, + end_lineno=20, + end_col_offset=76), + 'prev', + Load(), + lineno=20, + col_offset=64, + end_lineno=20, + end_col_offset=81)], + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=82), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=82), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=82), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=24)], + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=39), + 'placeholder_3', + Load(), + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=50), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=50)], + [], + lineno=19, + col_offset=8, + end_lineno=21, + end_col_offset=50)], + [], + lineno=17, + col_offset=4, + end_lineno=21, + end_col_offset=50), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=19), + arg( + 'placeholder_14', + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=15), + 'placeholder_9', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=28), + [ + Constant( + 'Value not found', + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=46)], + [], + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=47), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=47)], + [], + lineno=24, + col_offset=8, + end_lineno=25, + end_col_offset=47), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=13)], + Constant( + False, + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=21), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=21), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=12)], + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=24), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=24), + For( + Tuple( + [ + Name( + 'placeholder_2', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=17), + Name( + 'placeholder_3', + Store(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=29), + Name( + 'placeholder_5', + Store(), + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=35)], + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=35), + Name( + 'self', + Load(), + lineno=29, + col_offset=39, + end_lineno=29, + end_col_offset=43), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=20), + [ + Eq()], + [ + Name( + 'placeholder_14', + Load(), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=33)], + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=33), + [ + If( + Name( + 'placeholder_5', + Load(), + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=23), + [ + Assign( + [ + Attribute( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=24), + 'placeholder_5', + Load(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=29), + 'placeholder_3', + Store(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=40)], + Name( + 'placeholder_3', + Load(), + lineno=32, + col_offset=43, + end_lineno=32, + end_col_offset=53), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=53)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=20, + end_lineno=34, + end_col_offset=24), + 'placeholder_7', + Store(), + lineno=34, + col_offset=20, + end_lineno=34, + end_col_offset=29)], + Name( + 'placeholder_3', + Load(), + lineno=34, + col_offset=32, + end_lineno=34, + end_col_offset=42), + lineno=34, + col_offset=20, + end_lineno=34, + end_col_offset=42)], + lineno=31, + col_offset=16, + end_lineno=34, + end_col_offset=42), + If( + Name( + 'placeholder_3', + Load(), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=29), + [ + Assign( + [ + Attribute( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=24), + 'placeholder_3', + Load(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=35), + 'placeholder_5', + Store(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=40)], + Name( + 'placeholder_5', + Load(), + lineno=36, + col_offset=43, + end_lineno=36, + end_col_offset=47), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=47)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=24), + 'placeholder_8', + Store(), + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=29)], + Name( + 'placeholder_5', + Load(), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=36), + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=36)], + lineno=35, + col_offset=16, + end_lineno=38, + end_col_offset=36), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=21)], + Constant( + True, + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=28), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=28), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=20), + 'placeholder_9', + Store(), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=27), + Sub(), + Constant( + 1, + lineno=41, + col_offset=31, + end_lineno=41, + end_col_offset=32), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=32), + Break( + lineno=42, + col_offset=16, + end_lineno=42, + end_col_offset=21)], + [], + lineno=30, + col_offset=12, + end_lineno=42, + end_col_offset=21), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=16)], + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=23), + 'placeholder_3', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=34), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=34)], + [], + lineno=29, + col_offset=8, + end_lineno=43, + end_col_offset=34), + If( + UnaryOp( + Not(), + Name( + 'placeholder_15', + Load(), + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=20), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=28), + [ + Constant( + 'Value not found', + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=46)], + [], + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=47), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=47)], + [], + lineno=44, + col_offset=8, + end_lineno=45, + end_col_offset=47)], + [], + lineno=23, + col_offset=4, + end_lineno=45, + end_col_offset=47), + FunctionDef( + 'placeholder_17', + arguments( + [], + [ + arg( + 'self', + lineno=47, + col_offset=13, + end_lineno=47, + end_col_offset=17), + arg( + 'placeholder_2', + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=16)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=48, + col_offset=19, + end_lineno=48, + end_col_offset=23), + [ + Name( + 'placeholder_2', + Load(), + lineno=48, + col_offset=24, + end_lineno=48, + end_col_offset=29)], + [], + lineno=48, + col_offset=19, + end_lineno=48, + end_col_offset=30), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=30), + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=24), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=24), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=21), + Attribute( + Name( + 'self', + Load(), + lineno=50, + col_offset=24, + end_lineno=50, + end_col_offset=28), + 'placeholder_8', + Store(), + lineno=50, + col_offset=24, + end_lineno=50, + end_col_offset=33)], + Name( + 'placeholder_18', + Load(), + lineno=50, + col_offset=36, + end_lineno=50, + end_col_offset=44), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=44)], + [ + Assign( + [ + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=20), + 'placeholder_5', + Store(), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=25)], + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=28, + end_lineno=52, + end_col_offset=32), + 'placeholder_8', + Load(), + lineno=52, + col_offset=28, + end_lineno=52, + end_col_offset=37), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=37), + Assign( + [ + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=16), + 'placeholder_8', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=21), + 'placeholder_3', + Store(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=32)], + Name( + 'placeholder_18', + Load(), + lineno=53, + col_offset=35, + end_lineno=53, + end_col_offset=43), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=43), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=16), + 'placeholder_8', + Store(), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=21)], + Name( + 'placeholder_18', + Load(), + lineno=54, + col_offset=24, + end_lineno=54, + end_col_offset=32), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=32)], + lineno=49, + col_offset=8, + end_lineno=54, + end_col_offset=32), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=12), + 'placeholder_9', + Store(), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=56, + col_offset=23, + end_lineno=56, + end_col_offset=24), + lineno=56, + col_offset=8, + end_lineno=56, + end_col_offset=24)], + [], + lineno=47, + col_offset=4, + end_lineno=56, + end_col_offset=24), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'self', + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=12)], + Attribute( + Name( + 'self', + Load(), + lineno=59, + col_offset=15, + end_lineno=59, + end_col_offset=19), + 'placeholder_8', + Load(), + lineno=59, + col_offset=15, + end_lineno=59, + end_col_offset=24), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=24), + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=15), + 'placeholder_9', + Load(), + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=61, + col_offset=26, + end_lineno=61, + end_col_offset=27)], + lineno=61, + col_offset=11, + end_lineno=61, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=62, + col_offset=18, + end_lineno=62, + end_col_offset=28), + [ + Constant( + 'List is empty', + lineno=62, + col_offset=29, + end_lineno=62, + end_col_offset=44)], + [], + lineno=62, + col_offset=18, + end_lineno=62, + end_col_offset=45), + lineno=62, + col_offset=12, + end_lineno=62, + end_col_offset=45)], + [], + lineno=61, + col_offset=8, + end_lineno=62, + end_col_offset=45), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_16', + Load(), + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=15), + [ + Is()], + [ + Constant( + None, + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=23)], + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=23), + Compare( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=31), + 'placeholder_5', + Load(), + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=36), + [ + Is()], + [ + Constant( + None, + lineno=63, + col_offset=40, + end_lineno=63, + end_col_offset=44)], + lineno=63, + col_offset=27, + end_lineno=63, + end_col_offset=44)], + lineno=63, + col_offset=11, + end_lineno=63, + end_col_offset=44), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=21), + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=24, + end_lineno=64, + end_col_offset=28), + 'placeholder_8', + Store(), + lineno=64, + col_offset=24, + end_lineno=64, + end_col_offset=33)], + Constant( + None, + lineno=64, + col_offset=36, + end_lineno=64, + end_col_offset=40), + lineno=64, + col_offset=12, + end_lineno=64, + end_col_offset=40)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=16), + 'placeholder_8', + Store(), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=21)], + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=66, + col_offset=24, + end_lineno=66, + end_col_offset=28), + 'placeholder_8', + Load(), + lineno=66, + col_offset=24, + end_lineno=66, + end_col_offset=33), + 'placeholder_5', + Load(), + lineno=66, + col_offset=24, + end_lineno=66, + end_col_offset=38), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=38), + Assign( + [ + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=16), + 'placeholder_8', + Load(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=21), + 'placeholder_3', + Store(), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=32)], + Constant( + None, + lineno=67, + col_offset=35, + end_lineno=67, + end_col_offset=39), + lineno=67, + col_offset=12, + end_lineno=67, + end_col_offset=39)], + lineno=63, + col_offset=8, + end_lineno=67, + end_col_offset=39), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=12), + 'placeholder_9', + Store(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=19), + Sub(), + Constant( + 1, + lineno=68, + col_offset=23, + end_lineno=68, + end_col_offset=24), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=24), + Return( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=25), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=25)], + [], + lineno=58, + col_offset=4, + end_lineno=70, + end_col_offset=25), + FunctionDef( + 'placeholder_20', + arguments( + [], + [ + arg( + 'self', + lineno=72, + col_offset=14, + end_lineno=72, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=15), + 'placeholder_9', + Load(), + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=73, + col_offset=26, + end_lineno=73, + end_col_offset=27)], + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'IndexError', + Load(), + lineno=74, + col_offset=18, + end_lineno=74, + end_col_offset=28), + [ + Constant( + 'List is empty', + lineno=74, + col_offset=29, + end_lineno=74, + end_col_offset=44)], + [], + lineno=74, + col_offset=18, + end_lineno=74, + end_col_offset=45), + lineno=74, + col_offset=12, + end_lineno=74, + end_col_offset=45)], + [], + lineno=73, + col_offset=8, + end_lineno=74, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=12)], + Attribute( + Name( + 'self', + Load(), + lineno=75, + col_offset=15, + end_lineno=75, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=75, + col_offset=15, + end_lineno=75, + end_col_offset=24), + lineno=75, + col_offset=8, + end_lineno=75, + end_col_offset=24), + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_16', + Load(), + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=15), + [ + Is()], + [ + Constant( + None, + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=23)], + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=23), + Compare( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=31), + 'placeholder_3', + Load(), + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=42), + [ + Is()], + [ + Constant( + None, + lineno=76, + col_offset=46, + end_lineno=76, + end_col_offset=50)], + lineno=76, + col_offset=27, + end_lineno=76, + end_col_offset=50)], + lineno=76, + col_offset=11, + end_lineno=76, + end_col_offset=50), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=21), + Attribute( + Name( + 'self', + Load(), + lineno=77, + col_offset=24, + end_lineno=77, + end_col_offset=28), + 'placeholder_8', + Store(), + lineno=77, + col_offset=24, + end_lineno=77, + end_col_offset=33)], + Constant( + None, + lineno=77, + col_offset=36, + end_lineno=77, + end_col_offset=40), + lineno=77, + col_offset=12, + end_lineno=77, + end_col_offset=40)], + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=21)], + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=79, + col_offset=24, + end_lineno=79, + end_col_offset=28), + 'placeholder_7', + Load(), + lineno=79, + col_offset=24, + end_lineno=79, + end_col_offset=33), + 'placeholder_3', + Load(), + lineno=79, + col_offset=24, + end_lineno=79, + end_col_offset=44), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=44), + Assign( + [ + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=16), + 'placeholder_7', + Load(), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=21), + 'placeholder_5', + Store(), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=26)], + Constant( + None, + lineno=80, + col_offset=29, + end_lineno=80, + end_col_offset=33), + lineno=80, + col_offset=12, + end_lineno=80, + end_col_offset=33)], + lineno=76, + col_offset=8, + end_lineno=80, + end_col_offset=33), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=12), + 'placeholder_9', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=19), + Sub(), + Constant( + 1, + lineno=81, + col_offset=23, + end_lineno=81, + end_col_offset=24), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=24), + Return( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=83, + col_offset=15, + end_lineno=83, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=83, + col_offset=15, + end_lineno=83, + end_col_offset=25), + lineno=83, + col_offset=8, + end_lineno=83, + end_col_offset=25)], + [], + lineno=72, + col_offset=4, + end_lineno=83, + end_col_offset=25), + FunctionDef( + 'placeholder_21', + arguments( + [], + [ + arg( + 'self', + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=20), + arg( + 'placeholder_2', + lineno=85, + col_offset=22, + end_lineno=85, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=16)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=86, + col_offset=19, + end_lineno=86, + end_col_offset=23), + [ + Name( + 'placeholder_2', + Load(), + lineno=86, + col_offset=24, + end_lineno=86, + end_col_offset=29)], + [], + lineno=86, + col_offset=19, + end_lineno=86, + end_col_offset=30), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=30), + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=87, + col_offset=15, + end_lineno=87, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=87, + col_offset=15, + end_lineno=87, + end_col_offset=24), + lineno=87, + col_offset=11, + end_lineno=87, + end_col_offset=24), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=88, + col_offset=12, + end_lineno=88, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=88, + col_offset=12, + end_lineno=88, + end_col_offset=21), + Attribute( + Name( + 'self', + Load(), + lineno=88, + col_offset=24, + end_lineno=88, + end_col_offset=28), + 'placeholder_8', + Store(), + lineno=88, + col_offset=24, + end_lineno=88, + end_col_offset=33)], + Name( + 'placeholder_18', + Load(), + lineno=88, + col_offset=36, + end_lineno=88, + end_col_offset=44), + lineno=88, + col_offset=12, + end_lineno=88, + end_col_offset=44)], + [ + Assign( + [ + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=20), + 'placeholder_3', + Store(), + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=31)], + Attribute( + Name( + 'self', + Load(), + lineno=90, + col_offset=34, + end_lineno=90, + end_col_offset=38), + 'placeholder_7', + Load(), + lineno=90, + col_offset=34, + end_lineno=90, + end_col_offset=43), + lineno=90, + col_offset=12, + end_lineno=90, + end_col_offset=43), + Assign( + [ + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=16), + 'placeholder_7', + Load(), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=21), + 'placeholder_5', + Store(), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=26)], + Name( + 'placeholder_18', + Load(), + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=37), + lineno=91, + col_offset=12, + end_lineno=91, + end_col_offset=37), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=92, + col_offset=12, + end_lineno=92, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=92, + col_offset=12, + end_lineno=92, + end_col_offset=21)], + Name( + 'placeholder_18', + Load(), + lineno=92, + col_offset=24, + end_lineno=92, + end_col_offset=32), + lineno=92, + col_offset=12, + end_lineno=92, + end_col_offset=32)], + lineno=87, + col_offset=8, + end_lineno=92, + end_col_offset=32), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=12), + 'placeholder_9', + Store(), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=94, + col_offset=23, + end_lineno=94, + end_col_offset=24), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=24)], + [], + lineno=85, + col_offset=4, + end_lineno=94, + end_col_offset=24)], + [], + lineno=8, + col_offset=0, + end_lineno=94, + end_col_offset=24)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-linked-list/representation.txt b/test/practice-linked-list/representation.txt new file mode 100644 index 0000000..9755cc7 --- /dev/null +++ b/test/practice-linked-list/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=28), arg('placeholder_3', lineno=2, col_offset=30, end_lineno=2, end_col_offset=40), arg('placeholder_4', lineno=2, col_offset=47, end_lineno=2, end_col_offset=55)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=2, col_offset=41, end_lineno=2, end_col_offset=45), Constant(None, lineno=2, col_offset=56, end_lineno=2, end_col_offset=60)]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_2', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=18)], Name('placeholder_2', Load(), lineno=3, col_offset=21, end_lineno=3, end_col_offset=26), lineno=3, col_offset=8, end_lineno=3, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=12), 'placeholder_3', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=23)], Name('placeholder_3', Load(), lineno=4, col_offset=26, end_lineno=4, end_col_offset=36), lineno=4, col_offset=8, end_lineno=4, end_col_offset=36), Assign([Attribute(Name('self', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=12), 'placeholder_5', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=17)], Name('placeholder_4', Load(), lineno=5, col_offset=20, end_lineno=5, end_col_offset=28), lineno=5, col_offset=8, end_lineno=5, end_col_offset=28)], [], lineno=2, col_offset=4, end_lineno=5, end_col_offset=28)], [], lineno=1, col_offset=0, end_lineno=5, end_col_offset=28), ClassDef('placeholder_6', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=9, col_offset=17, end_lineno=9, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=12), 'placeholder_7', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=17)], Constant(None, lineno=10, col_offset=20, end_lineno=10, end_col_offset=24), lineno=10, col_offset=8, end_lineno=10, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), 'placeholder_8', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=17)], Constant(None, lineno=11, col_offset=20, end_lineno=11, end_col_offset=24), lineno=11, col_offset=8, end_lineno=11, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), 'placeholder_9', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=19)], Constant(0, lineno=12, col_offset=22, end_lineno=12, end_col_offset=23), lineno=12, col_offset=8, end_lineno=12, end_col_offset=23)], [], lineno=9, col_offset=4, end_lineno=12, end_col_offset=23), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=14, col_offset=16, end_lineno=14, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), 'placeholder_9', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=26), lineno=15, col_offset=8, end_lineno=15, end_col_offset=26)], [], lineno=14, col_offset=4, end_lineno=15, end_col_offset=26), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=17, col_offset=17, end_lineno=17, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_12', Store(), lineno=18, col_offset=8, end_lineno=18, end_col_offset=20)], Attribute(Name('self', Load(), lineno=18, col_offset=23, end_lineno=18, end_col_offset=27), 'placeholder_7', Load(), lineno=18, col_offset=23, end_lineno=18, end_col_offset=32), lineno=18, col_offset=8, end_lineno=18, end_col_offset=32), While(Name('placeholder_12', Load(), lineno=19, col_offset=14, end_lineno=19, end_col_offset=26), [Expr(Yield(Tuple([Attribute(Name('current_node', Load(), lineno=20, col_offset=19, end_lineno=20, end_col_offset=31), 'value', Load(), lineno=20, col_offset=19, end_lineno=20, end_col_offset=37), Attribute(Name('current_node', Load(), lineno=20, col_offset=39, end_lineno=20, end_col_offset=51), 'succeeding', Load(), lineno=20, col_offset=39, end_lineno=20, end_col_offset=62), Attribute(Name('current_node', Load(), lineno=20, col_offset=64, end_lineno=20, end_col_offset=76), 'prev', Load(), lineno=20, col_offset=64, end_lineno=20, end_col_offset=81)], Load(), lineno=20, col_offset=18, end_lineno=20, end_col_offset=82), lineno=20, col_offset=12, end_lineno=20, end_col_offset=82), lineno=20, col_offset=12, end_lineno=20, end_col_offset=82), Assign([Name('placeholder_12', Store(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=24)], Attribute(Name('placeholder_12', Load(), lineno=21, col_offset=27, end_lineno=21, end_col_offset=39), 'placeholder_3', Load(), lineno=21, col_offset=27, end_lineno=21, end_col_offset=50), lineno=21, col_offset=12, end_lineno=21, end_col_offset=50)], [], lineno=19, col_offset=8, end_lineno=21, end_col_offset=50)], [], lineno=17, col_offset=4, end_lineno=21, end_col_offset=50), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=23, col_offset=15, end_lineno=23, end_col_offset=19), arg('placeholder_14', lineno=23, col_offset=21, end_lineno=23, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=15), 'placeholder_9', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=22), [Eq()], [Constant(0, lineno=24, col_offset=26, end_lineno=24, end_col_offset=27)], lineno=24, col_offset=11, end_lineno=24, end_col_offset=27), [Raise(Call(Name('ValueError', Load(), lineno=25, col_offset=18, end_lineno=25, end_col_offset=28), [Constant('Value not found', lineno=25, col_offset=29, end_lineno=25, end_col_offset=46)], [], lineno=25, col_offset=18, end_lineno=25, end_col_offset=47), lineno=25, col_offset=12, end_lineno=25, end_col_offset=47)], [], lineno=24, col_offset=8, end_lineno=25, end_col_offset=47), Assign([Name('placeholder_15', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=13)], Constant(False, lineno=26, col_offset=16, end_lineno=26, end_col_offset=21), lineno=26, col_offset=8, end_lineno=26, end_col_offset=21), Assign([Name('placeholder_16', Store(), lineno=27, col_offset=8, end_lineno=27, end_col_offset=12)], Attribute(Name('self', Load(), lineno=27, col_offset=15, end_lineno=27, end_col_offset=19), 'placeholder_7', Load(), lineno=27, col_offset=15, end_lineno=27, end_col_offset=24), lineno=27, col_offset=8, end_lineno=27, end_col_offset=24), For(Tuple([Name('placeholder_2', Store(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=17), Name('placeholder_3', Store(), lineno=29, col_offset=19, end_lineno=29, end_col_offset=29), Name('placeholder_5', Store(), lineno=29, col_offset=31, end_lineno=29, end_col_offset=35)], Store(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=35), Name('self', Load(), lineno=29, col_offset=39, end_lineno=29, end_col_offset=43), [If(Compare(Name('placeholder_2', Load(), lineno=30, col_offset=15, end_lineno=30, end_col_offset=20), [Eq()], [Name('placeholder_14', Load(), lineno=30, col_offset=24, end_lineno=30, end_col_offset=33)], lineno=30, col_offset=15, end_lineno=30, end_col_offset=33), [If(Name('placeholder_5', Load(), lineno=31, col_offset=19, end_lineno=31, end_col_offset=23), [Assign([Attribute(Attribute(Name('placeholder_16', Load(), lineno=32, col_offset=20, end_lineno=32, end_col_offset=24), 'placeholder_5', Load(), lineno=32, col_offset=20, end_lineno=32, end_col_offset=29), 'placeholder_3', Store(), lineno=32, col_offset=20, end_lineno=32, end_col_offset=40)], Name('placeholder_3', Load(), lineno=32, col_offset=43, end_lineno=32, end_col_offset=53), lineno=32, col_offset=20, end_lineno=32, end_col_offset=53)], [Assign([Attribute(Name('self', Load(), lineno=34, col_offset=20, end_lineno=34, end_col_offset=24), 'placeholder_7', Store(), lineno=34, col_offset=20, end_lineno=34, end_col_offset=29)], Name('placeholder_3', Load(), lineno=34, col_offset=32, end_lineno=34, end_col_offset=42), lineno=34, col_offset=20, end_lineno=34, end_col_offset=42)], lineno=31, col_offset=16, end_lineno=34, end_col_offset=42), If(Name('placeholder_3', Load(), lineno=35, col_offset=19, end_lineno=35, end_col_offset=29), [Assign([Attribute(Attribute(Name('placeholder_16', Load(), lineno=36, col_offset=20, end_lineno=36, end_col_offset=24), 'placeholder_3', Load(), lineno=36, col_offset=20, end_lineno=36, end_col_offset=35), 'placeholder_5', Store(), lineno=36, col_offset=20, end_lineno=36, end_col_offset=40)], Name('placeholder_5', Load(), lineno=36, col_offset=43, end_lineno=36, end_col_offset=47), lineno=36, col_offset=20, end_lineno=36, end_col_offset=47)], [Assign([Attribute(Name('self', Load(), lineno=38, col_offset=20, end_lineno=38, end_col_offset=24), 'placeholder_8', Store(), lineno=38, col_offset=20, end_lineno=38, end_col_offset=29)], Name('placeholder_5', Load(), lineno=38, col_offset=32, end_lineno=38, end_col_offset=36), lineno=38, col_offset=20, end_lineno=38, end_col_offset=36)], lineno=35, col_offset=16, end_lineno=38, end_col_offset=36), Assign([Name('placeholder_15', Store(), lineno=40, col_offset=16, end_lineno=40, end_col_offset=21)], Constant(True, lineno=40, col_offset=24, end_lineno=40, end_col_offset=28), lineno=40, col_offset=16, end_lineno=40, end_col_offset=28), AugAssign(Attribute(Name('self', Load(), lineno=41, col_offset=16, end_lineno=41, end_col_offset=20), 'placeholder_9', Store(), lineno=41, col_offset=16, end_lineno=41, end_col_offset=27), Sub(), Constant(1, lineno=41, col_offset=31, end_lineno=41, end_col_offset=32), lineno=41, col_offset=16, end_lineno=41, end_col_offset=32), Break(lineno=42, col_offset=16, end_lineno=42, end_col_offset=21)], [], lineno=30, col_offset=12, end_lineno=42, end_col_offset=21), Assign([Name('placeholder_16', Store(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=16)], Attribute(Name('placeholder_16', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=23), 'placeholder_3', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=34), lineno=43, col_offset=12, end_lineno=43, end_col_offset=34)], [], lineno=29, col_offset=8, end_lineno=43, end_col_offset=34), If(UnaryOp(Not(), Name('placeholder_15', Load(), lineno=44, col_offset=15, end_lineno=44, end_col_offset=20), lineno=44, col_offset=11, end_lineno=44, end_col_offset=20), [Raise(Call(Name('ValueError', Load(), lineno=45, col_offset=18, end_lineno=45, end_col_offset=28), [Constant('Value not found', lineno=45, col_offset=29, end_lineno=45, end_col_offset=46)], [], lineno=45, col_offset=18, end_lineno=45, end_col_offset=47), lineno=45, col_offset=12, end_lineno=45, end_col_offset=47)], [], lineno=44, col_offset=8, end_lineno=45, end_col_offset=47)], [], lineno=23, col_offset=4, end_lineno=45, end_col_offset=47), FunctionDef('placeholder_17', arguments([], [arg('self', lineno=47, col_offset=13, end_lineno=47, end_col_offset=17), arg('placeholder_2', lineno=47, col_offset=19, end_lineno=47, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_18', Store(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=16)], Call(Name('placeholder_0', Load(), lineno=48, col_offset=19, end_lineno=48, end_col_offset=23), [Name('placeholder_2', Load(), lineno=48, col_offset=24, end_lineno=48, end_col_offset=29)], [], lineno=48, col_offset=19, end_lineno=48, end_col_offset=30), lineno=48, col_offset=8, end_lineno=48, end_col_offset=30), If(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=19), 'placeholder_7', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=24), lineno=49, col_offset=11, end_lineno=49, end_col_offset=24), [Assign([Attribute(Name('self', Load(), lineno=50, col_offset=12, end_lineno=50, end_col_offset=16), 'placeholder_7', Store(), lineno=50, col_offset=12, end_lineno=50, end_col_offset=21), Attribute(Name('self', Load(), lineno=50, col_offset=24, end_lineno=50, end_col_offset=28), 'placeholder_8', Store(), lineno=50, col_offset=24, end_lineno=50, end_col_offset=33)], Name('placeholder_18', Load(), lineno=50, col_offset=36, end_lineno=50, end_col_offset=44), lineno=50, col_offset=12, end_lineno=50, end_col_offset=44)], [Assign([Attribute(Name('placeholder_18', Load(), lineno=52, col_offset=12, end_lineno=52, end_col_offset=20), 'placeholder_5', Store(), lineno=52, col_offset=12, end_lineno=52, end_col_offset=25)], Attribute(Name('self', Load(), lineno=52, col_offset=28, end_lineno=52, end_col_offset=32), 'placeholder_8', Load(), lineno=52, col_offset=28, end_lineno=52, end_col_offset=37), lineno=52, col_offset=12, end_lineno=52, end_col_offset=37), Assign([Attribute(Attribute(Name('self', Load(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=16), 'placeholder_8', Load(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=21), 'placeholder_3', Store(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=32)], Name('placeholder_18', Load(), lineno=53, col_offset=35, end_lineno=53, end_col_offset=43), lineno=53, col_offset=12, end_lineno=53, end_col_offset=43), Assign([Attribute(Name('self', Load(), lineno=54, col_offset=12, end_lineno=54, end_col_offset=16), 'placeholder_8', Store(), lineno=54, col_offset=12, end_lineno=54, end_col_offset=21)], Name('placeholder_18', Load(), lineno=54, col_offset=24, end_lineno=54, end_col_offset=32), lineno=54, col_offset=12, end_lineno=54, end_col_offset=32)], lineno=49, col_offset=8, end_lineno=54, end_col_offset=32), AugAssign(Attribute(Name('self', Load(), lineno=56, col_offset=8, end_lineno=56, end_col_offset=12), 'placeholder_9', Store(), lineno=56, col_offset=8, end_lineno=56, end_col_offset=19), Add(), Constant(1, lineno=56, col_offset=23, end_lineno=56, end_col_offset=24), lineno=56, col_offset=8, end_lineno=56, end_col_offset=24)], [], lineno=47, col_offset=4, end_lineno=56, end_col_offset=24), FunctionDef('placeholder_19', arguments([], [arg('self', lineno=58, col_offset=12, end_lineno=58, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_16', Store(), lineno=59, col_offset=8, end_lineno=59, end_col_offset=12)], Attribute(Name('self', Load(), lineno=59, col_offset=15, end_lineno=59, end_col_offset=19), 'placeholder_8', Load(), lineno=59, col_offset=15, end_lineno=59, end_col_offset=24), lineno=59, col_offset=8, end_lineno=59, end_col_offset=24), If(Compare(Attribute(Name('self', Load(), lineno=61, col_offset=11, end_lineno=61, end_col_offset=15), 'placeholder_9', Load(), lineno=61, col_offset=11, end_lineno=61, end_col_offset=22), [Eq()], [Constant(0, lineno=61, col_offset=26, end_lineno=61, end_col_offset=27)], lineno=61, col_offset=11, end_lineno=61, end_col_offset=27), [Raise(Call(Name('IndexError', Load(), lineno=62, col_offset=18, end_lineno=62, end_col_offset=28), [Constant('List is empty', lineno=62, col_offset=29, end_lineno=62, end_col_offset=44)], [], lineno=62, col_offset=18, end_lineno=62, end_col_offset=45), lineno=62, col_offset=12, end_lineno=62, end_col_offset=45)], [], lineno=61, col_offset=8, end_lineno=62, end_col_offset=45), If(BoolOp(Or(), [Compare(Name('placeholder_16', Load(), lineno=63, col_offset=11, end_lineno=63, end_col_offset=15), [Is()], [Constant(None, lineno=63, col_offset=19, end_lineno=63, end_col_offset=23)], lineno=63, col_offset=11, end_lineno=63, end_col_offset=23), Compare(Attribute(Name('placeholder_16', Load(), lineno=63, col_offset=27, end_lineno=63, end_col_offset=31), 'placeholder_5', Load(), lineno=63, col_offset=27, end_lineno=63, end_col_offset=36), [Is()], [Constant(None, lineno=63, col_offset=40, end_lineno=63, end_col_offset=44)], lineno=63, col_offset=27, end_lineno=63, end_col_offset=44)], lineno=63, col_offset=11, end_lineno=63, end_col_offset=44), [Assign([Attribute(Name('self', Load(), lineno=64, col_offset=12, end_lineno=64, end_col_offset=16), 'placeholder_7', Store(), lineno=64, col_offset=12, end_lineno=64, end_col_offset=21), Attribute(Name('self', Load(), lineno=64, col_offset=24, end_lineno=64, end_col_offset=28), 'placeholder_8', Store(), lineno=64, col_offset=24, end_lineno=64, end_col_offset=33)], Constant(None, lineno=64, col_offset=36, end_lineno=64, end_col_offset=40), lineno=64, col_offset=12, end_lineno=64, end_col_offset=40)], [Assign([Attribute(Name('self', Load(), lineno=66, col_offset=12, end_lineno=66, end_col_offset=16), 'placeholder_8', Store(), lineno=66, col_offset=12, end_lineno=66, end_col_offset=21)], Attribute(Attribute(Name('self', Load(), lineno=66, col_offset=24, end_lineno=66, end_col_offset=28), 'placeholder_8', Load(), lineno=66, col_offset=24, end_lineno=66, end_col_offset=33), 'placeholder_5', Load(), lineno=66, col_offset=24, end_lineno=66, end_col_offset=38), lineno=66, col_offset=12, end_lineno=66, end_col_offset=38), Assign([Attribute(Attribute(Name('self', Load(), lineno=67, col_offset=12, end_lineno=67, end_col_offset=16), 'placeholder_8', Load(), lineno=67, col_offset=12, end_lineno=67, end_col_offset=21), 'placeholder_3', Store(), lineno=67, col_offset=12, end_lineno=67, end_col_offset=32)], Constant(None, lineno=67, col_offset=35, end_lineno=67, end_col_offset=39), lineno=67, col_offset=12, end_lineno=67, end_col_offset=39)], lineno=63, col_offset=8, end_lineno=67, end_col_offset=39), AugAssign(Attribute(Name('self', Load(), lineno=68, col_offset=8, end_lineno=68, end_col_offset=12), 'placeholder_9', Store(), lineno=68, col_offset=8, end_lineno=68, end_col_offset=19), Sub(), Constant(1, lineno=68, col_offset=23, end_lineno=68, end_col_offset=24), lineno=68, col_offset=8, end_lineno=68, end_col_offset=24), Return(Attribute(Name('placeholder_16', Load(), lineno=70, col_offset=15, end_lineno=70, end_col_offset=19), 'placeholder_2', Load(), lineno=70, col_offset=15, end_lineno=70, end_col_offset=25), lineno=70, col_offset=8, end_lineno=70, end_col_offset=25)], [], lineno=58, col_offset=4, end_lineno=70, end_col_offset=25), FunctionDef('placeholder_20', arguments([], [arg('self', lineno=72, col_offset=14, end_lineno=72, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=73, col_offset=11, end_lineno=73, end_col_offset=15), 'placeholder_9', Load(), lineno=73, col_offset=11, end_lineno=73, end_col_offset=22), [Eq()], [Constant(0, lineno=73, col_offset=26, end_lineno=73, end_col_offset=27)], lineno=73, col_offset=11, end_lineno=73, end_col_offset=27), [Raise(Call(Name('IndexError', Load(), lineno=74, col_offset=18, end_lineno=74, end_col_offset=28), [Constant('List is empty', lineno=74, col_offset=29, end_lineno=74, end_col_offset=44)], [], lineno=74, col_offset=18, end_lineno=74, end_col_offset=45), lineno=74, col_offset=12, end_lineno=74, end_col_offset=45)], [], lineno=73, col_offset=8, end_lineno=74, end_col_offset=45), Assign([Name('placeholder_16', Store(), lineno=75, col_offset=8, end_lineno=75, end_col_offset=12)], Attribute(Name('self', Load(), lineno=75, col_offset=15, end_lineno=75, end_col_offset=19), 'placeholder_7', Load(), lineno=75, col_offset=15, end_lineno=75, end_col_offset=24), lineno=75, col_offset=8, end_lineno=75, end_col_offset=24), If(BoolOp(Or(), [Compare(Name('placeholder_16', Load(), lineno=76, col_offset=11, end_lineno=76, end_col_offset=15), [Is()], [Constant(None, lineno=76, col_offset=19, end_lineno=76, end_col_offset=23)], lineno=76, col_offset=11, end_lineno=76, end_col_offset=23), Compare(Attribute(Name('placeholder_16', Load(), lineno=76, col_offset=27, end_lineno=76, end_col_offset=31), 'placeholder_3', Load(), lineno=76, col_offset=27, end_lineno=76, end_col_offset=42), [Is()], [Constant(None, lineno=76, col_offset=46, end_lineno=76, end_col_offset=50)], lineno=76, col_offset=27, end_lineno=76, end_col_offset=50)], lineno=76, col_offset=11, end_lineno=76, end_col_offset=50), [Assign([Attribute(Name('self', Load(), lineno=77, col_offset=12, end_lineno=77, end_col_offset=16), 'placeholder_7', Store(), lineno=77, col_offset=12, end_lineno=77, end_col_offset=21), Attribute(Name('self', Load(), lineno=77, col_offset=24, end_lineno=77, end_col_offset=28), 'placeholder_8', Store(), lineno=77, col_offset=24, end_lineno=77, end_col_offset=33)], Constant(None, lineno=77, col_offset=36, end_lineno=77, end_col_offset=40), lineno=77, col_offset=12, end_lineno=77, end_col_offset=40)], [Assign([Attribute(Name('self', Load(), lineno=79, col_offset=12, end_lineno=79, end_col_offset=16), 'placeholder_7', Store(), lineno=79, col_offset=12, end_lineno=79, end_col_offset=21)], Attribute(Attribute(Name('self', Load(), lineno=79, col_offset=24, end_lineno=79, end_col_offset=28), 'placeholder_7', Load(), lineno=79, col_offset=24, end_lineno=79, end_col_offset=33), 'placeholder_3', Load(), lineno=79, col_offset=24, end_lineno=79, end_col_offset=44), lineno=79, col_offset=12, end_lineno=79, end_col_offset=44), Assign([Attribute(Attribute(Name('self', Load(), lineno=80, col_offset=12, end_lineno=80, end_col_offset=16), 'placeholder_7', Load(), lineno=80, col_offset=12, end_lineno=80, end_col_offset=21), 'placeholder_5', Store(), lineno=80, col_offset=12, end_lineno=80, end_col_offset=26)], Constant(None, lineno=80, col_offset=29, end_lineno=80, end_col_offset=33), lineno=80, col_offset=12, end_lineno=80, end_col_offset=33)], lineno=76, col_offset=8, end_lineno=80, end_col_offset=33), AugAssign(Attribute(Name('self', Load(), lineno=81, col_offset=8, end_lineno=81, end_col_offset=12), 'placeholder_9', Store(), lineno=81, col_offset=8, end_lineno=81, end_col_offset=19), Sub(), Constant(1, lineno=81, col_offset=23, end_lineno=81, end_col_offset=24), lineno=81, col_offset=8, end_lineno=81, end_col_offset=24), Return(Attribute(Name('placeholder_16', Load(), lineno=83, col_offset=15, end_lineno=83, end_col_offset=19), 'placeholder_2', Load(), lineno=83, col_offset=15, end_lineno=83, end_col_offset=25), lineno=83, col_offset=8, end_lineno=83, end_col_offset=25)], [], lineno=72, col_offset=4, end_lineno=83, end_col_offset=25), FunctionDef('placeholder_21', arguments([], [arg('self', lineno=85, col_offset=16, end_lineno=85, end_col_offset=20), arg('placeholder_2', lineno=85, col_offset=22, end_lineno=85, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_18', Store(), lineno=86, col_offset=8, end_lineno=86, end_col_offset=16)], Call(Name('placeholder_0', Load(), lineno=86, col_offset=19, end_lineno=86, end_col_offset=23), [Name('placeholder_2', Load(), lineno=86, col_offset=24, end_lineno=86, end_col_offset=29)], [], lineno=86, col_offset=19, end_lineno=86, end_col_offset=30), lineno=86, col_offset=8, end_lineno=86, end_col_offset=30), If(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=87, col_offset=15, end_lineno=87, end_col_offset=19), 'placeholder_7', Load(), lineno=87, col_offset=15, end_lineno=87, end_col_offset=24), lineno=87, col_offset=11, end_lineno=87, end_col_offset=24), [Assign([Attribute(Name('self', Load(), lineno=88, col_offset=12, end_lineno=88, end_col_offset=16), 'placeholder_7', Store(), lineno=88, col_offset=12, end_lineno=88, end_col_offset=21), Attribute(Name('self', Load(), lineno=88, col_offset=24, end_lineno=88, end_col_offset=28), 'placeholder_8', Store(), lineno=88, col_offset=24, end_lineno=88, end_col_offset=33)], Name('placeholder_18', Load(), lineno=88, col_offset=36, end_lineno=88, end_col_offset=44), lineno=88, col_offset=12, end_lineno=88, end_col_offset=44)], [Assign([Attribute(Name('placeholder_18', Load(), lineno=90, col_offset=12, end_lineno=90, end_col_offset=20), 'placeholder_3', Store(), lineno=90, col_offset=12, end_lineno=90, end_col_offset=31)], Attribute(Name('self', Load(), lineno=90, col_offset=34, end_lineno=90, end_col_offset=38), 'placeholder_7', Load(), lineno=90, col_offset=34, end_lineno=90, end_col_offset=43), lineno=90, col_offset=12, end_lineno=90, end_col_offset=43), Assign([Attribute(Attribute(Name('self', Load(), lineno=91, col_offset=12, end_lineno=91, end_col_offset=16), 'placeholder_7', Load(), lineno=91, col_offset=12, end_lineno=91, end_col_offset=21), 'placeholder_5', Store(), lineno=91, col_offset=12, end_lineno=91, end_col_offset=26)], Name('placeholder_18', Load(), lineno=91, col_offset=29, end_lineno=91, end_col_offset=37), lineno=91, col_offset=12, end_lineno=91, end_col_offset=37), Assign([Attribute(Name('self', Load(), lineno=92, col_offset=12, end_lineno=92, end_col_offset=16), 'placeholder_7', Store(), lineno=92, col_offset=12, end_lineno=92, end_col_offset=21)], Name('placeholder_18', Load(), lineno=92, col_offset=24, end_lineno=92, end_col_offset=32), lineno=92, col_offset=12, end_lineno=92, end_col_offset=32)], lineno=87, col_offset=8, end_lineno=92, end_col_offset=32), AugAssign(Attribute(Name('self', Load(), lineno=94, col_offset=8, end_lineno=94, end_col_offset=12), 'placeholder_9', Store(), lineno=94, col_offset=8, end_lineno=94, end_col_offset=19), Add(), Constant(1, lineno=94, col_offset=23, end_lineno=94, end_col_offset=24), lineno=94, col_offset=8, end_lineno=94, end_col_offset=24)], [], lineno=85, col_offset=4, end_lineno=94, end_col_offset=24)], [], lineno=8, col_offset=0, end_lineno=94, end_col_offset=24)], []) \ No newline at end of file diff --git a/test/practice-list-ops/.meta/additional_tests.json b/test/practice-list-ops/.meta/additional_tests.json new file mode 100644 index 0000000..39c0a8b --- /dev/null +++ b/test/practice-list-ops/.meta/additional_tests.json @@ -0,0 +1,22 @@ +{ + "cases": [ + { + "description": "foldr add string", + "property": "foldr", + "input": { + "list": ["e", "x", "e", "r", "c", "i", "s", "m"], + "initial": "!", + "function": "(acc, el) -> el + acc" + }, + "expected": "exercism!" + }, + { + "description": "reverse mixed types", + "property": "reverse", + "input": { + "list": ["xyz", 4.0, "cat", 1] + }, + "expected": [1, "cat", 4.0, "xyz"] + } + ] +} diff --git a/test/practice-list-ops/.meta/config.json b/test/practice-list-ops/.meta/config.json new file mode 100644 index 0000000..cdb3313 --- /dev/null +++ b/test/practice-list-ops/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "dvermd", + "gabriel376", + "IsaacG", + "N-Parsons", + "pheanex", + "rootulp", + "thomasjpfan", + "tqa236" + ], + "files": { + "solution": [ + "list_ops.py" + ], + "test": [ + "list_ops_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement basic list operations." +} diff --git a/test/practice-list-ops/list_ops.py b/test/practice-list-ops/list_ops.py new file mode 100644 index 0000000..75f4503 --- /dev/null +++ b/test/practice-list-ops/list_ops.py @@ -0,0 +1,36 @@ +def append(list1, list2): + return concat([list1, list2]) + + +def concat(lists): + return [element for list in lists for element in list] + + +def filter(function, list): + return [item for item in list if function(item)] + + +def length(list): + return sum(1 for _ in list) + + +def map(function, list): + return [function(element) for element in list] + + +def foldl(function, list, initial): + if len(list) == 0: + return initial + else: + return foldl(function, list[1:], function(initial, list[0])) + + +def foldr(function, list, initial): + if len(list) == 0: + return initial + else: + return function(foldr(function, list[1:], initial), list[0]) + + +def reverse(list): + return list[::-1] diff --git a/test/practice-list-ops/mapping.json b/test/practice-list-ops/mapping.json new file mode 100644 index 0000000..5cc4a7e --- /dev/null +++ b/test/practice-list-ops/mapping.json @@ -0,0 +1,16 @@ +{ + "placeholder_0": "append", + "placeholder_1": "list1", + "placeholder_2": "list2", + "placeholder_3": "concat", + "placeholder_4": "lists", + "placeholder_5": "element", + "placeholder_6": "function", + "placeholder_7": "item", + "placeholder_8": "length", + "placeholder_9": "_", + "placeholder_10": "foldl", + "placeholder_11": "initial", + "placeholder_12": "foldr", + "placeholder_13": "reverse" +} \ No newline at end of file diff --git a/test/practice-list-ops/representation.json b/test/practice-list-ops/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-list-ops/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-list-ops/representation.out b/test/practice-list-ops/representation.out new file mode 100644 index 0000000..2a6bcae --- /dev/null +++ b/test/practice-list-ops/representation.out @@ -0,0 +1,1595 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return concat([placeholder_1, placeholder_2]) + + +def placeholder_3(placeholder_4): + return [placeholder_5 for list in placeholder_4 for placeholder_5 in list] + + +def filter(placeholder_6, list): + return [placeholder_7 for placeholder_7 in list if placeholder_6(placeholder_7)] + + +def placeholder_8(list): + return sum((1 for placeholder_9 in list)) + + +def map(placeholder_6, list): + return [placeholder_6(placeholder_5) for placeholder_5 in list] + + +def placeholder_10(placeholder_6, list, placeholder_11): + if len(list) == 0: + return placeholder_11 + else: + return placeholder_10( + placeholder_6, list[1:], placeholder_6(placeholder_11, list[0]) + ) + + +def placeholder_12(placeholder_6, list, placeholder_11): + if len(list) == 0: + return placeholder_11 + else: + return placeholder_6( + placeholder_12(placeholder_6, list[1:], placeholder_11), list[0] + ) + + +def placeholder_13(list): + return list[::-1] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'append', + arguments( + [], + [ + arg( + 'list1', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=16), + arg( + 'list2', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'concat', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + [ + List( + [ + Name( + 'list1', + Load(), + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=24), + Name( + 'list2', + Load(), + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=31)], + Load(), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=32)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=33), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=33)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=33), + FunctionDef( + 'concat', + arguments( + [], + [ + arg( + 'lists', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'element', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=19), + [ + comprehension( + Name( + 'list', + Store(), + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=28), + Name( + 'lists', + Load(), + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=37), + [], + 0), + comprehension( + Name( + 'element', + Store(), + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=49), + Name( + 'list', + Load(), + lineno=6, + col_offset=53, + end_lineno=6, + end_col_offset=57), + [], + 0)], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=58), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=58)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=58), + FunctionDef( + 'filter', + arguments( + [], + [ + arg( + 'function', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=19), + arg( + 'list', + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'item', + Load(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=16), + [ + comprehension( + Name( + 'item', + Store(), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=25), + Name( + 'list', + Load(), + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=33), + [ + Call( + Name( + 'function', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=45), + [ + Name( + 'item', + Load(), + lineno=10, + col_offset=46, + end_lineno=10, + end_col_offset=50)], + [], + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=51)], + 0)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=52), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=52)], + [], + lineno=9, + col_offset=0, + end_lineno=10, + end_col_offset=52), + FunctionDef( + 'length', + arguments( + [], + [ + arg( + 'list', + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + [ + GeneratorExp( + Constant( + 1, + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=16), + [ + comprehension( + Name( + '_', + Store(), + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=22), + Name( + 'list', + Load(), + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=30), + [], + 0)], + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=31)], + [], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=31), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=31)], + [], + lineno=13, + col_offset=0, + end_lineno=14, + end_col_offset=31), + FunctionDef( + 'map', + arguments( + [], + [ + arg( + 'function', + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=16), + arg( + 'list', + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'function', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=20), + [ + Name( + 'element', + Load(), + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=28)], + [], + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=29), + [ + comprehension( + Name( + 'element', + Store(), + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=41), + Name( + 'list', + Load(), + lineno=18, + col_offset=45, + end_lineno=18, + end_col_offset=49), + [], + 0)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=50), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=50)], + [], + lineno=17, + col_offset=0, + end_lineno=18, + end_col_offset=50), + FunctionDef( + 'foldl', + arguments( + [], + [ + arg( + 'function', + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=18), + arg( + 'list', + lineno=21, + col_offset=20, + end_lineno=21, + end_col_offset=24), + arg( + 'initial', + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=10), + [ + Name( + 'list', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=15)], + [], + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 0, + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=21)], + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=21), + [ + Return( + Name( + 'initial', + Load(), + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=22), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=22)], + [ + Return( + Call( + Name( + 'foldl', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=20), + [ + Name( + 'function', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=29), + Subscript( + Name( + 'list', + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=35), + Slice( + Constant( + 1, + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=37), + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=38), + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=39), + Call( + Name( + 'function', + Load(), + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=49), + [ + Name( + 'initial', + Load(), + lineno=25, + col_offset=50, + end_lineno=25, + end_col_offset=57), + Subscript( + Name( + 'list', + Load(), + lineno=25, + col_offset=59, + end_lineno=25, + end_col_offset=63), + Constant( + 0, + lineno=25, + col_offset=64, + end_lineno=25, + end_col_offset=65), + Load(), + lineno=25, + col_offset=59, + end_lineno=25, + end_col_offset=66)], + [], + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=67)], + [], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=68), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=68)], + lineno=22, + col_offset=4, + end_lineno=25, + end_col_offset=68)], + [], + lineno=21, + col_offset=0, + end_lineno=25, + end_col_offset=68), + FunctionDef( + 'foldr', + arguments( + [], + [ + arg( + 'function', + lineno=28, + col_offset=10, + end_lineno=28, + end_col_offset=18), + arg( + 'list', + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=24), + arg( + 'initial', + lineno=28, + col_offset=26, + end_lineno=28, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=10), + [ + Name( + 'list', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=15)], + [], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 0, + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=21)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=21), + [ + Return( + Name( + 'initial', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=22), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=22)], + [ + Return( + Call( + Name( + 'function', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=23), + [ + Call( + Name( + 'foldr', + Load(), + lineno=32, + col_offset=24, + end_lineno=32, + end_col_offset=29), + [ + Name( + 'function', + Load(), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=38), + Subscript( + Name( + 'list', + Load(), + lineno=32, + col_offset=40, + end_lineno=32, + end_col_offset=44), + Slice( + Constant( + 1, + lineno=32, + col_offset=45, + end_lineno=32, + end_col_offset=46), + lineno=32, + col_offset=45, + end_lineno=32, + end_col_offset=47), + Load(), + lineno=32, + col_offset=40, + end_lineno=32, + end_col_offset=48), + Name( + 'initial', + Load(), + lineno=32, + col_offset=50, + end_lineno=32, + end_col_offset=57)], + [], + lineno=32, + col_offset=24, + end_lineno=32, + end_col_offset=58), + Subscript( + Name( + 'list', + Load(), + lineno=32, + col_offset=60, + end_lineno=32, + end_col_offset=64), + Constant( + 0, + lineno=32, + col_offset=65, + end_lineno=32, + end_col_offset=66), + Load(), + lineno=32, + col_offset=60, + end_lineno=32, + end_col_offset=67)], + [], + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=68), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=68)], + lineno=29, + col_offset=4, + end_lineno=32, + end_col_offset=68)], + [], + lineno=28, + col_offset=0, + end_lineno=32, + end_col_offset=68), + FunctionDef( + 'reverse', + arguments( + [], + [ + arg( + 'list', + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Name( + 'list', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=15), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=20), + lineno=36, + col_offset=18, + end_lineno=36, + end_col_offset=20), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=20), + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=21), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=21)], + [], + lineno=35, + col_offset=0, + end_lineno=36, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=16), + arg( + 'placeholder_2', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'concat', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + [ + List( + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=24), + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=31)], + Load(), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=32)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=33), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=33)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=33), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'placeholder_5', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=19), + [ + comprehension( + Name( + 'list', + Store(), + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=28), + Name( + 'placeholder_4', + Load(), + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=37), + [], + 0), + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=49), + Name( + 'list', + Load(), + lineno=6, + col_offset=53, + end_lineno=6, + end_col_offset=57), + [], + 0)], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=58), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=58)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=58), + FunctionDef( + 'filter', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=19), + arg( + 'list', + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'placeholder_7', + Load(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=16), + [ + comprehension( + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=25), + Name( + 'list', + Load(), + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=33), + [ + Call( + Name( + 'placeholder_6', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=45), + [ + Name( + 'placeholder_7', + Load(), + lineno=10, + col_offset=46, + end_lineno=10, + end_col_offset=50)], + [], + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=51)], + 0)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=52), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=52)], + [], + lineno=9, + col_offset=0, + end_lineno=10, + end_col_offset=52), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'list', + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + [ + GeneratorExp( + Constant( + 1, + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=16), + [ + comprehension( + Name( + 'placeholder_9', + Store(), + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=22), + Name( + 'list', + Load(), + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=30), + [], + 0)], + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=31)], + [], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=31), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=31)], + [], + lineno=13, + col_offset=0, + end_lineno=14, + end_col_offset=31), + FunctionDef( + 'map', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=16), + arg( + 'list', + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'placeholder_6', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=20), + [ + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=28)], + [], + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=29), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=41), + Name( + 'list', + Load(), + lineno=18, + col_offset=45, + end_lineno=18, + end_col_offset=49), + [], + 0)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=50), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=50)], + [], + lineno=17, + col_offset=0, + end_lineno=18, + end_col_offset=50), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=18), + arg( + 'list', + lineno=21, + col_offset=20, + end_lineno=21, + end_col_offset=24), + arg( + 'placeholder_11', + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=10), + [ + Name( + 'list', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=15)], + [], + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 0, + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=21)], + lineno=22, + col_offset=7, + end_lineno=22, + end_col_offset=21), + [ + Return( + Name( + 'placeholder_11', + Load(), + lineno=23, + col_offset=15, + end_lineno=23, + end_col_offset=22), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=22)], + [ + Return( + Call( + Name( + 'placeholder_10', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=20), + [ + Name( + 'placeholder_6', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=29), + Subscript( + Name( + 'list', + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=35), + Slice( + Constant( + 1, + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=37), + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=38), + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=39), + Call( + Name( + 'placeholder_6', + Load(), + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=49), + [ + Name( + 'placeholder_11', + Load(), + lineno=25, + col_offset=50, + end_lineno=25, + end_col_offset=57), + Subscript( + Name( + 'list', + Load(), + lineno=25, + col_offset=59, + end_lineno=25, + end_col_offset=63), + Constant( + 0, + lineno=25, + col_offset=64, + end_lineno=25, + end_col_offset=65), + Load(), + lineno=25, + col_offset=59, + end_lineno=25, + end_col_offset=66)], + [], + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=67)], + [], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=68), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=68)], + lineno=22, + col_offset=4, + end_lineno=25, + end_col_offset=68)], + [], + lineno=21, + col_offset=0, + end_lineno=25, + end_col_offset=68), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=28, + col_offset=10, + end_lineno=28, + end_col_offset=18), + arg( + 'list', + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=24), + arg( + 'placeholder_11', + lineno=28, + col_offset=26, + end_lineno=28, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=10), + [ + Name( + 'list', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=15)], + [], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 0, + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=21)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=21), + [ + Return( + Name( + 'placeholder_11', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=22), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=22)], + [ + Return( + Call( + Name( + 'placeholder_6', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=23), + [ + Call( + Name( + 'placeholder_12', + Load(), + lineno=32, + col_offset=24, + end_lineno=32, + end_col_offset=29), + [ + Name( + 'placeholder_6', + Load(), + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=38), + Subscript( + Name( + 'list', + Load(), + lineno=32, + col_offset=40, + end_lineno=32, + end_col_offset=44), + Slice( + Constant( + 1, + lineno=32, + col_offset=45, + end_lineno=32, + end_col_offset=46), + lineno=32, + col_offset=45, + end_lineno=32, + end_col_offset=47), + Load(), + lineno=32, + col_offset=40, + end_lineno=32, + end_col_offset=48), + Name( + 'placeholder_11', + Load(), + lineno=32, + col_offset=50, + end_lineno=32, + end_col_offset=57)], + [], + lineno=32, + col_offset=24, + end_lineno=32, + end_col_offset=58), + Subscript( + Name( + 'list', + Load(), + lineno=32, + col_offset=60, + end_lineno=32, + end_col_offset=64), + Constant( + 0, + lineno=32, + col_offset=65, + end_lineno=32, + end_col_offset=66), + Load(), + lineno=32, + col_offset=60, + end_lineno=32, + end_col_offset=67)], + [], + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=68), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=68)], + lineno=29, + col_offset=4, + end_lineno=32, + end_col_offset=68)], + [], + lineno=28, + col_offset=0, + end_lineno=32, + end_col_offset=68), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'list', + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Name( + 'list', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=15), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=20), + lineno=36, + col_offset=18, + end_lineno=36, + end_col_offset=20), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=20), + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=21), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=21)], + [], + lineno=35, + col_offset=0, + end_lineno=36, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-list-ops/representation.txt b/test/practice-list-ops/representation.txt new file mode 100644 index 0000000..d25ef8e --- /dev/null +++ b/test/practice-list-ops/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=11, end_lineno=1, end_col_offset=16), arg('placeholder_2', lineno=1, col_offset=18, end_lineno=1, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('concat', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=17), [List([Name('placeholder_1', Load(), lineno=2, col_offset=19, end_lineno=2, end_col_offset=24), Name('placeholder_2', Load(), lineno=2, col_offset=26, end_lineno=2, end_col_offset=31)], Load(), lineno=2, col_offset=18, end_lineno=2, end_col_offset=32)], [], lineno=2, col_offset=11, end_lineno=2, end_col_offset=33), lineno=2, col_offset=4, end_lineno=2, end_col_offset=33)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=33), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=5, col_offset=11, end_lineno=5, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Name('placeholder_5', Load(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=19), [comprehension(Name('list', Store(), lineno=6, col_offset=24, end_lineno=6, end_col_offset=28), Name('placeholder_4', Load(), lineno=6, col_offset=32, end_lineno=6, end_col_offset=37), [], 0), comprehension(Name('placeholder_5', Store(), lineno=6, col_offset=42, end_lineno=6, end_col_offset=49), Name('list', Load(), lineno=6, col_offset=53, end_lineno=6, end_col_offset=57), [], 0)], lineno=6, col_offset=11, end_lineno=6, end_col_offset=58), lineno=6, col_offset=4, end_lineno=6, end_col_offset=58)], [], lineno=5, col_offset=0, end_lineno=6, end_col_offset=58), FunctionDef('filter', arguments([], [arg('placeholder_6', lineno=9, col_offset=11, end_lineno=9, end_col_offset=19), arg('list', lineno=9, col_offset=21, end_lineno=9, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Name('placeholder_7', Load(), lineno=10, col_offset=12, end_lineno=10, end_col_offset=16), [comprehension(Name('placeholder_7', Store(), lineno=10, col_offset=21, end_lineno=10, end_col_offset=25), Name('list', Load(), lineno=10, col_offset=29, end_lineno=10, end_col_offset=33), [Call(Name('placeholder_6', Load(), lineno=10, col_offset=37, end_lineno=10, end_col_offset=45), [Name('placeholder_7', Load(), lineno=10, col_offset=46, end_lineno=10, end_col_offset=50)], [], lineno=10, col_offset=37, end_lineno=10, end_col_offset=51)], 0)], lineno=10, col_offset=11, end_lineno=10, end_col_offset=52), lineno=10, col_offset=4, end_lineno=10, end_col_offset=52)], [], lineno=9, col_offset=0, end_lineno=10, end_col_offset=52), FunctionDef('placeholder_8', arguments([], [arg('list', lineno=13, col_offset=11, end_lineno=13, end_col_offset=15)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sum', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=14), [GeneratorExp(Constant(1, lineno=14, col_offset=15, end_lineno=14, end_col_offset=16), [comprehension(Name('placeholder_9', Store(), lineno=14, col_offset=21, end_lineno=14, end_col_offset=22), Name('list', Load(), lineno=14, col_offset=26, end_lineno=14, end_col_offset=30), [], 0)], lineno=14, col_offset=14, end_lineno=14, end_col_offset=31)], [], lineno=14, col_offset=11, end_lineno=14, end_col_offset=31), lineno=14, col_offset=4, end_lineno=14, end_col_offset=31)], [], lineno=13, col_offset=0, end_lineno=14, end_col_offset=31), FunctionDef('map', arguments([], [arg('placeholder_6', lineno=17, col_offset=8, end_lineno=17, end_col_offset=16), arg('list', lineno=17, col_offset=18, end_lineno=17, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Call(Name('placeholder_6', Load(), lineno=18, col_offset=12, end_lineno=18, end_col_offset=20), [Name('placeholder_5', Load(), lineno=18, col_offset=21, end_lineno=18, end_col_offset=28)], [], lineno=18, col_offset=12, end_lineno=18, end_col_offset=29), [comprehension(Name('placeholder_5', Store(), lineno=18, col_offset=34, end_lineno=18, end_col_offset=41), Name('list', Load(), lineno=18, col_offset=45, end_lineno=18, end_col_offset=49), [], 0)], lineno=18, col_offset=11, end_lineno=18, end_col_offset=50), lineno=18, col_offset=4, end_lineno=18, end_col_offset=50)], [], lineno=17, col_offset=0, end_lineno=18, end_col_offset=50), FunctionDef('placeholder_10', arguments([], [arg('placeholder_6', lineno=21, col_offset=10, end_lineno=21, end_col_offset=18), arg('list', lineno=21, col_offset=20, end_lineno=21, end_col_offset=24), arg('placeholder_11', lineno=21, col_offset=26, end_lineno=21, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=22, col_offset=7, end_lineno=22, end_col_offset=10), [Name('list', Load(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=15)], [], lineno=22, col_offset=7, end_lineno=22, end_col_offset=16), [Eq()], [Constant(0, lineno=22, col_offset=20, end_lineno=22, end_col_offset=21)], lineno=22, col_offset=7, end_lineno=22, end_col_offset=21), [Return(Name('placeholder_11', Load(), lineno=23, col_offset=15, end_lineno=23, end_col_offset=22), lineno=23, col_offset=8, end_lineno=23, end_col_offset=22)], [Return(Call(Name('placeholder_10', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=20), [Name('placeholder_6', Load(), lineno=25, col_offset=21, end_lineno=25, end_col_offset=29), Subscript(Name('list', Load(), lineno=25, col_offset=31, end_lineno=25, end_col_offset=35), Slice(Constant(1, lineno=25, col_offset=36, end_lineno=25, end_col_offset=37), lineno=25, col_offset=36, end_lineno=25, end_col_offset=38), Load(), lineno=25, col_offset=31, end_lineno=25, end_col_offset=39), Call(Name('placeholder_6', Load(), lineno=25, col_offset=41, end_lineno=25, end_col_offset=49), [Name('placeholder_11', Load(), lineno=25, col_offset=50, end_lineno=25, end_col_offset=57), Subscript(Name('list', Load(), lineno=25, col_offset=59, end_lineno=25, end_col_offset=63), Constant(0, lineno=25, col_offset=64, end_lineno=25, end_col_offset=65), Load(), lineno=25, col_offset=59, end_lineno=25, end_col_offset=66)], [], lineno=25, col_offset=41, end_lineno=25, end_col_offset=67)], [], lineno=25, col_offset=15, end_lineno=25, end_col_offset=68), lineno=25, col_offset=8, end_lineno=25, end_col_offset=68)], lineno=22, col_offset=4, end_lineno=25, end_col_offset=68)], [], lineno=21, col_offset=0, end_lineno=25, end_col_offset=68), FunctionDef('placeholder_12', arguments([], [arg('placeholder_6', lineno=28, col_offset=10, end_lineno=28, end_col_offset=18), arg('list', lineno=28, col_offset=20, end_lineno=28, end_col_offset=24), arg('placeholder_11', lineno=28, col_offset=26, end_lineno=28, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=29, col_offset=7, end_lineno=29, end_col_offset=10), [Name('list', Load(), lineno=29, col_offset=11, end_lineno=29, end_col_offset=15)], [], lineno=29, col_offset=7, end_lineno=29, end_col_offset=16), [Eq()], [Constant(0, lineno=29, col_offset=20, end_lineno=29, end_col_offset=21)], lineno=29, col_offset=7, end_lineno=29, end_col_offset=21), [Return(Name('placeholder_11', Load(), lineno=30, col_offset=15, end_lineno=30, end_col_offset=22), lineno=30, col_offset=8, end_lineno=30, end_col_offset=22)], [Return(Call(Name('placeholder_6', Load(), lineno=32, col_offset=15, end_lineno=32, end_col_offset=23), [Call(Name('placeholder_12', Load(), lineno=32, col_offset=24, end_lineno=32, end_col_offset=29), [Name('placeholder_6', Load(), lineno=32, col_offset=30, end_lineno=32, end_col_offset=38), Subscript(Name('list', Load(), lineno=32, col_offset=40, end_lineno=32, end_col_offset=44), Slice(Constant(1, lineno=32, col_offset=45, end_lineno=32, end_col_offset=46), lineno=32, col_offset=45, end_lineno=32, end_col_offset=47), Load(), lineno=32, col_offset=40, end_lineno=32, end_col_offset=48), Name('placeholder_11', Load(), lineno=32, col_offset=50, end_lineno=32, end_col_offset=57)], [], lineno=32, col_offset=24, end_lineno=32, end_col_offset=58), Subscript(Name('list', Load(), lineno=32, col_offset=60, end_lineno=32, end_col_offset=64), Constant(0, lineno=32, col_offset=65, end_lineno=32, end_col_offset=66), Load(), lineno=32, col_offset=60, end_lineno=32, end_col_offset=67)], [], lineno=32, col_offset=15, end_lineno=32, end_col_offset=68), lineno=32, col_offset=8, end_lineno=32, end_col_offset=68)], lineno=29, col_offset=4, end_lineno=32, end_col_offset=68)], [], lineno=28, col_offset=0, end_lineno=32, end_col_offset=68), FunctionDef('placeholder_13', arguments([], [arg('list', lineno=35, col_offset=12, end_lineno=35, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Subscript(Name('list', Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=15), Slice(step=UnaryOp(USub(), Constant(1, lineno=36, col_offset=19, end_lineno=36, end_col_offset=20), lineno=36, col_offset=18, end_lineno=36, end_col_offset=20), lineno=36, col_offset=16, end_lineno=36, end_col_offset=20), Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=21), lineno=36, col_offset=4, end_lineno=36, end_col_offset=21)], [], lineno=35, col_offset=0, end_lineno=36, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-luhn/.meta/config.json b/test/practice-luhn/.meta/config.json new file mode 100644 index 0000000..c9a7c18 --- /dev/null +++ b/test/practice-luhn/.meta/config.json @@ -0,0 +1,39 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "AnAccountForReportingBugs", + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "Grociu", + "ikhadykin", + "kytrinyx", + "mambocab", + "N-Parsons", + "Nishant23", + "olufotebig", + "pheanex", + "rootulp", + "thomasjpfan", + "tqa236", + "xitanggg", + "yawpitch" + ], + "files": { + "solution": [ + "luhn.py" + ], + "test": [ + "luhn_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a number determine whether or not it is valid per the Luhn formula.", + "source": "The Luhn Algorithm on Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Luhn_algorithm" +} diff --git a/test/practice-luhn/luhn.py b/test/practice-luhn/luhn.py new file mode 100644 index 0000000..32a4dbc --- /dev/null +++ b/test/practice-luhn/luhn.py @@ -0,0 +1,19 @@ +class Luhn: + def __init__(self, card_num): + self.card_num = card_num + self.checksum = -1 + digits = card_num.replace(' ', '') + length = len(digits) + if digits.isdigit() and length > 1: + self.checksum = 0 + cadence = length % 2 + for idx, digit in enumerate(digits): + num = int(digit) + if idx % 2 == cadence: + num *= 2 + if num > 9: + num -= 9 + self.checksum += num + + def valid(self): + return self.checksum % 10 == 0 diff --git a/test/practice-luhn/mapping.json b/test/practice-luhn/mapping.json new file mode 100644 index 0000000..8bc937f --- /dev/null +++ b/test/practice-luhn/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "Luhn", + "placeholder_1": "__init__", + "placeholder_2": "card_num", + "placeholder_3": "checksum", + "placeholder_4": "digits", + "placeholder_5": "length", + "placeholder_6": "cadence", + "placeholder_7": "idx", + "placeholder_8": "digit", + "placeholder_9": "num", + "placeholder_10": "valid" +} \ No newline at end of file diff --git a/test/practice-luhn/representation.json b/test/practice-luhn/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-luhn/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-luhn/representation.out b/test/practice-luhn/representation.out new file mode 100644 index 0000000..c9ae535 --- /dev/null +++ b/test/practice-luhn/representation.out @@ -0,0 +1,1176 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = -1 + placeholder_4 = placeholder_2.replace(" ", "") + placeholder_5 = len(placeholder_4) + if placeholder_4.isdigit() and placeholder_5 > 1: + self.placeholder_3 = 0 + placeholder_6 = placeholder_5 % 2 + for placeholder_7, placeholder_8 in enumerate(placeholder_4): + placeholder_9 = int(placeholder_8) + if placeholder_7 % 2 == placeholder_6: + placeholder_9 *= 2 + if placeholder_9 > 9: + placeholder_9 -= 9 + self.placeholder_3 += placeholder_9 + + def placeholder_10(self): + return self.placeholder_3 % 10 == 0 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Luhn', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'card_num', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'card_num', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=21)], + Name( + 'card_num', + Load(), + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=32), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'checksum', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=21)], + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=26), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=26), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=26), + Assign( + [ + Name( + 'digits', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=14)], + Call( + Attribute( + Name( + 'card_num', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=25), + 'replace', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=33), + [ + Constant( + ' ', + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=37), + Constant( + '', + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=41)], + [], + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=42), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=42), + Assign( + [ + Name( + 'length', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=14)], + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=20), + [ + Name( + 'digits', + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=27)], + [], + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=28), + If( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'digits', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=17), + 'isdigit', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=25), + [], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=27), + Compare( + Name( + 'length', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=38), + [ + Gt()], + [ + Constant( + 1, + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=42)], + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=42)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=42), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=16), + 'checksum', + Store(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=25)], + Constant( + 0, + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=29), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=29), + Assign( + [ + Name( + 'cadence', + Store(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=19)], + BinOp( + Name( + 'length', + Load(), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=28), + Mod(), + Constant( + 2, + lineno=9, + col_offset=31, + end_lineno=9, + end_col_offset=32), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=32), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=32), + For( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=19), + Name( + 'digit', + Store(), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=26)], + Store(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=26), + Call( + Name( + 'enumerate', + Load(), + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=39), + [ + Name( + 'digits', + Load(), + lineno=10, + col_offset=40, + end_lineno=10, + end_col_offset=46)], + [], + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=47), + [ + Assign( + [ + Name( + 'num', + Store(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=19)], + Call( + Name( + 'int', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=25), + [ + Name( + 'digit', + Load(), + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=31)], + [], + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=32), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=32), + If( + Compare( + BinOp( + Name( + 'idx', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=22), + Mod(), + Constant( + 2, + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=26), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=26), + [ + Eq()], + [ + Name( + 'cadence', + Load(), + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=37)], + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=37), + [ + AugAssign( + Name( + 'num', + Store(), + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=23), + Mult(), + Constant( + 2, + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=28), + If( + Compare( + Name( + 'num', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=26), + [ + Gt()], + [ + Constant( + 9, + lineno=14, + col_offset=29, + end_lineno=14, + end_col_offset=30)], + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=30), + [ + AugAssign( + Name( + 'num', + Store(), + lineno=15, + col_offset=24, + end_lineno=15, + end_col_offset=27), + Sub(), + Constant( + 9, + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=32), + lineno=15, + col_offset=24, + end_lineno=15, + end_col_offset=32)], + [], + lineno=14, + col_offset=20, + end_lineno=15, + end_col_offset=32)], + [], + lineno=12, + col_offset=16, + end_lineno=15, + end_col_offset=32), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=20), + 'checksum', + Store(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=29), + Add(), + Name( + 'num', + Load(), + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=36), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=36)], + [], + lineno=10, + col_offset=12, + end_lineno=16, + end_col_offset=36)], + [], + lineno=7, + col_offset=8, + end_lineno=16, + end_col_offset=36)], + [], + lineno=2, + col_offset=4, + end_lineno=16, + end_col_offset=36), + FunctionDef( + 'valid', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + 'checksum', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=28), + Mod(), + Constant( + 10, + lineno=19, + col_offset=31, + end_lineno=19, + end_col_offset=33), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=33), + [ + Eq()], + [ + Constant( + 0, + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=38)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=38), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=38)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=38)], + [], + lineno=1, + col_offset=0, + end_lineno=19, + end_col_offset=38)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=21)], + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=24, + end_lineno=3, + end_col_offset=32), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=21)], + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=26), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=26), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=26), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=14)], + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=25), + 'replace', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=33), + [ + Constant( + ' ', + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=37), + Constant( + '', + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=41)], + [], + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=42), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=14)], + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=20), + [ + Name( + 'placeholder_4', + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=27)], + [], + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=28), + If( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=17), + 'isdigit', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=25), + [], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=27), + Compare( + Name( + 'placeholder_5', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=38), + [ + Gt()], + [ + Constant( + 1, + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=42)], + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=42)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=42), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=16), + 'placeholder_3', + Store(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=25)], + Constant( + 0, + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=29), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=29), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=19)], + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=28), + Mod(), + Constant( + 2, + lineno=9, + col_offset=31, + end_lineno=9, + end_col_offset=32), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=32), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=32), + For( + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=19), + Name( + 'placeholder_8', + Store(), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=26)], + Store(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=26), + Call( + Name( + 'enumerate', + Load(), + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=39), + [ + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=40, + end_lineno=10, + end_col_offset=46)], + [], + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=47), + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=19)], + Call( + Name( + 'int', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=25), + [ + Name( + 'placeholder_8', + Load(), + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=31)], + [], + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=32), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=32), + If( + Compare( + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=22), + Mod(), + Constant( + 2, + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=26), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=26), + [ + Eq()], + [ + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=37)], + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=37), + [ + AugAssign( + Name( + 'placeholder_9', + Store(), + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=23), + Mult(), + Constant( + 2, + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=28), + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=26), + [ + Gt()], + [ + Constant( + 9, + lineno=14, + col_offset=29, + end_lineno=14, + end_col_offset=30)], + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=30), + [ + AugAssign( + Name( + 'placeholder_9', + Store(), + lineno=15, + col_offset=24, + end_lineno=15, + end_col_offset=27), + Sub(), + Constant( + 9, + lineno=15, + col_offset=31, + end_lineno=15, + end_col_offset=32), + lineno=15, + col_offset=24, + end_lineno=15, + end_col_offset=32)], + [], + lineno=14, + col_offset=20, + end_lineno=15, + end_col_offset=32)], + [], + lineno=12, + col_offset=16, + end_lineno=15, + end_col_offset=32), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=20), + 'placeholder_3', + Store(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=29), + Add(), + Name( + 'placeholder_9', + Load(), + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=36), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=36)], + [], + lineno=10, + col_offset=12, + end_lineno=16, + end_col_offset=36)], + [], + lineno=7, + col_offset=8, + end_lineno=16, + end_col_offset=36)], + [], + lineno=2, + col_offset=4, + end_lineno=16, + end_col_offset=36), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + 'placeholder_3', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=28), + Mod(), + Constant( + 10, + lineno=19, + col_offset=31, + end_lineno=19, + end_col_offset=33), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=33), + [ + Eq()], + [ + Constant( + 0, + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=38)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=38), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=38)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=38)], + [], + lineno=1, + col_offset=0, + end_lineno=19, + end_col_offset=38)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-luhn/representation.txt b/test/practice-luhn/representation.txt new file mode 100644 index 0000000..30e7fe1 --- /dev/null +++ b/test/practice-luhn/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_2', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=21)], Name('placeholder_2', Load(), lineno=3, col_offset=24, end_lineno=3, end_col_offset=32), lineno=3, col_offset=8, end_lineno=3, end_col_offset=32), Assign([Attribute(Name('self', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=12), 'placeholder_3', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=21)], UnaryOp(USub(), Constant(1, lineno=4, col_offset=25, end_lineno=4, end_col_offset=26), lineno=4, col_offset=24, end_lineno=4, end_col_offset=26), lineno=4, col_offset=8, end_lineno=4, end_col_offset=26), Assign([Name('placeholder_4', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=14)], Call(Attribute(Name('placeholder_2', Load(), lineno=5, col_offset=17, end_lineno=5, end_col_offset=25), 'replace', Load(), lineno=5, col_offset=17, end_lineno=5, end_col_offset=33), [Constant(' ', lineno=5, col_offset=34, end_lineno=5, end_col_offset=37), Constant('', lineno=5, col_offset=39, end_lineno=5, end_col_offset=41)], [], lineno=5, col_offset=17, end_lineno=5, end_col_offset=42), lineno=5, col_offset=8, end_lineno=5, end_col_offset=42), Assign([Name('placeholder_5', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=14)], Call(Name('len', Load(), lineno=6, col_offset=17, end_lineno=6, end_col_offset=20), [Name('placeholder_4', Load(), lineno=6, col_offset=21, end_lineno=6, end_col_offset=27)], [], lineno=6, col_offset=17, end_lineno=6, end_col_offset=28), lineno=6, col_offset=8, end_lineno=6, end_col_offset=28), If(BoolOp(And(), [Call(Attribute(Name('placeholder_4', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=17), 'isdigit', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=25), [], [], lineno=7, col_offset=11, end_lineno=7, end_col_offset=27), Compare(Name('placeholder_5', Load(), lineno=7, col_offset=32, end_lineno=7, end_col_offset=38), [Gt()], [Constant(1, lineno=7, col_offset=41, end_lineno=7, end_col_offset=42)], lineno=7, col_offset=32, end_lineno=7, end_col_offset=42)], lineno=7, col_offset=11, end_lineno=7, end_col_offset=42), [Assign([Attribute(Name('self', Load(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=16), 'placeholder_3', Store(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=25)], Constant(0, lineno=8, col_offset=28, end_lineno=8, end_col_offset=29), lineno=8, col_offset=12, end_lineno=8, end_col_offset=29), Assign([Name('placeholder_6', Store(), lineno=9, col_offset=12, end_lineno=9, end_col_offset=19)], BinOp(Name('placeholder_5', Load(), lineno=9, col_offset=22, end_lineno=9, end_col_offset=28), Mod(), Constant(2, lineno=9, col_offset=31, end_lineno=9, end_col_offset=32), lineno=9, col_offset=22, end_lineno=9, end_col_offset=32), lineno=9, col_offset=12, end_lineno=9, end_col_offset=32), For(Tuple([Name('placeholder_7', Store(), lineno=10, col_offset=16, end_lineno=10, end_col_offset=19), Name('placeholder_8', Store(), lineno=10, col_offset=21, end_lineno=10, end_col_offset=26)], Store(), lineno=10, col_offset=16, end_lineno=10, end_col_offset=26), Call(Name('enumerate', Load(), lineno=10, col_offset=30, end_lineno=10, end_col_offset=39), [Name('placeholder_4', Load(), lineno=10, col_offset=40, end_lineno=10, end_col_offset=46)], [], lineno=10, col_offset=30, end_lineno=10, end_col_offset=47), [Assign([Name('placeholder_9', Store(), lineno=11, col_offset=16, end_lineno=11, end_col_offset=19)], Call(Name('int', Load(), lineno=11, col_offset=22, end_lineno=11, end_col_offset=25), [Name('placeholder_8', Load(), lineno=11, col_offset=26, end_lineno=11, end_col_offset=31)], [], lineno=11, col_offset=22, end_lineno=11, end_col_offset=32), lineno=11, col_offset=16, end_lineno=11, end_col_offset=32), If(Compare(BinOp(Name('placeholder_7', Load(), lineno=12, col_offset=19, end_lineno=12, end_col_offset=22), Mod(), Constant(2, lineno=12, col_offset=25, end_lineno=12, end_col_offset=26), lineno=12, col_offset=19, end_lineno=12, end_col_offset=26), [Eq()], [Name('placeholder_6', Load(), lineno=12, col_offset=30, end_lineno=12, end_col_offset=37)], lineno=12, col_offset=19, end_lineno=12, end_col_offset=37), [AugAssign(Name('placeholder_9', Store(), lineno=13, col_offset=20, end_lineno=13, end_col_offset=23), Mult(), Constant(2, lineno=13, col_offset=27, end_lineno=13, end_col_offset=28), lineno=13, col_offset=20, end_lineno=13, end_col_offset=28), If(Compare(Name('placeholder_9', Load(), lineno=14, col_offset=23, end_lineno=14, end_col_offset=26), [Gt()], [Constant(9, lineno=14, col_offset=29, end_lineno=14, end_col_offset=30)], lineno=14, col_offset=23, end_lineno=14, end_col_offset=30), [AugAssign(Name('placeholder_9', Store(), lineno=15, col_offset=24, end_lineno=15, end_col_offset=27), Sub(), Constant(9, lineno=15, col_offset=31, end_lineno=15, end_col_offset=32), lineno=15, col_offset=24, end_lineno=15, end_col_offset=32)], [], lineno=14, col_offset=20, end_lineno=15, end_col_offset=32)], [], lineno=12, col_offset=16, end_lineno=15, end_col_offset=32), AugAssign(Attribute(Name('self', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=20), 'placeholder_3', Store(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=29), Add(), Name('placeholder_9', Load(), lineno=16, col_offset=33, end_lineno=16, end_col_offset=36), lineno=16, col_offset=16, end_lineno=16, end_col_offset=36)], [], lineno=10, col_offset=12, end_lineno=16, end_col_offset=36)], [], lineno=7, col_offset=8, end_lineno=16, end_col_offset=36)], [], lineno=2, col_offset=4, end_lineno=16, end_col_offset=36), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=18, col_offset=14, end_lineno=18, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(BinOp(Attribute(Name('self', Load(), lineno=19, col_offset=15, end_lineno=19, end_col_offset=19), 'placeholder_3', Load(), lineno=19, col_offset=15, end_lineno=19, end_col_offset=28), Mod(), Constant(10, lineno=19, col_offset=31, end_lineno=19, end_col_offset=33), lineno=19, col_offset=15, end_lineno=19, end_col_offset=33), [Eq()], [Constant(0, lineno=19, col_offset=37, end_lineno=19, end_col_offset=38)], lineno=19, col_offset=15, end_lineno=19, end_col_offset=38), lineno=19, col_offset=8, end_lineno=19, end_col_offset=38)], [], lineno=18, col_offset=4, end_lineno=19, end_col_offset=38)], [], lineno=1, col_offset=0, end_lineno=19, end_col_offset=38)], []) \ No newline at end of file diff --git a/test/practice-markdown/.meta/config.json b/test/practice-markdown/.meta/config.json new file mode 100644 index 0000000..012bed8 --- /dev/null +++ b/test/practice-markdown/.meta/config.json @@ -0,0 +1,26 @@ +{ + "authors": [ + "Paul-Ilyin" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "N-Parsons", + "thomasjpfan", + "tqa236", + "xitanggg" + ], + "files": { + "solution": [ + "markdown.py" + ], + "test": [ + "markdown_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Refactor a Markdown parser." +} diff --git a/test/practice-markdown/mapping.json b/test/practice-markdown/mapping.json new file mode 100644 index 0000000..3fcfc4a --- /dev/null +++ b/test/practice-markdown/mapping.json @@ -0,0 +1,23 @@ +{ + "placeholder_0": "parse", + "placeholder_1": "markdown", + "placeholder_2": "lines", + "placeholder_3": "html", + "placeholder_4": "in_list", + "placeholder_5": "in_list_append", + "placeholder_6": "line", + "placeholder_7": "result", + "placeholder_8": "wrap", + "placeholder_9": "tag", + "placeholder_10": "check_headers", + "placeholder_11": "pattern", + "placeholder_12": "index", + "placeholder_13": "check_bold", + "placeholder_14": "bold_pattern", + "placeholder_15": "bold_match", + "placeholder_16": "check_italic", + "placeholder_17": "italic_pattern", + "placeholder_18": "italic_match", + "placeholder_19": "parse_line", + "placeholder_20": "list_match" +} \ No newline at end of file diff --git a/test/practice-markdown/markdown.py b/test/practice-markdown/markdown.py new file mode 100644 index 0000000..1c9d04c --- /dev/null +++ b/test/practice-markdown/markdown.py @@ -0,0 +1,88 @@ +import re + + +def parse(markdown): + lines = markdown.split('\n') + html = '' + in_list = False + in_list_append = False + for line in lines: + result = parse_line(line, in_list, in_list_append) + html += result['line'] + in_list = result['in_list'] + in_list_append = result['in_list_append'] + if in_list: + html += '' + return html + + +def wrap(line, tag): + return '<{tag}>{line}'.format(line=line, tag=tag) + + +def check_headers(line): + pattern = '# (.*)' + for index in range(6): + if re.match(pattern, line): + return wrap(line[(index + 2):], 'h' + str(index + 1)) + pattern = '#' + pattern + return line + + +def check_bold(line): + bold_pattern = '(.*)__(.*)__(.*)' + bold_match = re.match(bold_pattern, line) + if bold_match: + return bold_match.group(1) + wrap(bold_match.group(2), 'strong')\ + + bold_match.group(3) + else: + return None + + +def check_italic(line): + italic_pattern = '(.*)_(.*)_(.*)' + italic_match = re.match(italic_pattern, line) + if italic_match: + return italic_match.group(1) + wrap(italic_match.group(2), 'em')\ + + italic_match.group(3) + else: + return None + + +def parse_line(line, in_list, in_list_append): + result = check_headers(line) + + list_match = re.match(r'\* (.*)', result) + + if list_match: + if not in_list: + result = '
    ' + wrap(list_match.group(1), 'li') + in_list = True + else: + result = wrap(list_match.group(1), 'li') + else: + if in_list: + in_list_append = True + in_list = False + + if not re.match(')(.*)()(.*)', + r'\1\2

    \3

    \4\5', result) + + while check_bold(result): + result = check_bold(result) + while check_italic(result): + result = check_italic(result) + + if in_list_append: + result = '
' + result + in_list_append = False + + return { + 'line': result, + 'in_list': in_list, + 'in_list_append': in_list_append + } diff --git a/test/practice-markdown/representation.json b/test/practice-markdown/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-markdown/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-markdown/representation.out b/test/practice-markdown/representation.out new file mode 100644 index 0000000..3af1dfb --- /dev/null +++ b/test/practice-markdown/representation.out @@ -0,0 +1,3894 @@ +## BEGIN NORMALIZED CODE ## +import re + + +def placeholder_0(placeholder_1): + placeholder_2 = placeholder_1.split("\n") + placeholder_3 = "" + placeholder_4 = False + placeholder_5 = False + for placeholder_6 in placeholder_2: + placeholder_7 = parse_line(placeholder_6, placeholder_4, placeholder_5) + placeholder_3 += placeholder_7["line"] + placeholder_4 = placeholder_7["in_list"] + placeholder_5 = placeholder_7["in_list_append"] + if placeholder_4: + placeholder_3 += "" + return placeholder_3 + + +def placeholder_8(placeholder_6, placeholder_9): + return "<{tag}>{line}".format( + placeholder_6=placeholder_6, placeholder_9=placeholder_9 + ) + + +def placeholder_10(placeholder_6): + placeholder_11 = "# (.*)" + for placeholder_12 in range(6): + if re.match(placeholder_11, placeholder_6): + return placeholder_8( + placeholder_6[placeholder_12 + 2 :], "h" + str(placeholder_12 + 1) + ) + placeholder_11 = "#" + placeholder_11 + return placeholder_6 + + +def placeholder_13(placeholder_6): + placeholder_14 = "(.*)__(.*)__(.*)" + placeholder_15 = re.match(placeholder_14, placeholder_6) + if placeholder_15: + return ( + placeholder_15.group(1) + + placeholder_8(placeholder_15.group(2), "strong") + + placeholder_15.group(3) + ) + else: + return None + + +def placeholder_16(placeholder_6): + placeholder_17 = "(.*)_(.*)_(.*)" + placeholder_18 = re.match(placeholder_17, placeholder_6) + if placeholder_18: + return ( + placeholder_18.group(1) + + placeholder_8(placeholder_18.group(2), "em") + + placeholder_18.group(3) + ) + else: + return None + + +def placeholder_19(placeholder_6, placeholder_4, placeholder_5): + placeholder_7 = placeholder_10(placeholder_6) + placeholder_20 = re.match("\\* (.*)", placeholder_7) + if placeholder_20: + if not placeholder_4: + placeholder_7 = "
    " + placeholder_8(placeholder_20.group(1), "li") + placeholder_4 = True + else: + placeholder_7 = placeholder_8(placeholder_20.group(1), "li") + elif placeholder_4: + placeholder_5 = True + placeholder_4 = False + if not re.match(")(.*)()(.*)", "\\1\\2

    \\3

    \\4\\5", placeholder_7 + ) + while placeholder_13(placeholder_7): + placeholder_7 = placeholder_13(placeholder_7) + while placeholder_16(placeholder_7): + placeholder_7 = placeholder_16(placeholder_7) + if placeholder_5: + placeholder_7 = "
" + placeholder_7 + placeholder_5 = False + return { + "line": placeholder_7, + "in_list": placeholder_4, + "in_list_append": placeholder_5, + } + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + FunctionDef( + 'parse', + arguments( + [], + [ + arg( + 'markdown', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'lines', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=9)], + Call( + Attribute( + Name( + 'markdown', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=20), + 'split', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=26), + [ + Constant( + '\n', + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=31)], + [], + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=32), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=32), + Assign( + [ + Name( + 'html', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=8)], + Constant( + '', + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=13), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=13), + Assign( + [ + Name( + 'in_list', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11)], + Constant( + False, + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=19), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=19), + Assign( + [ + Name( + 'in_list_append', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=18)], + Constant( + False, + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=26), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=26), + For( + Name( + 'line', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + Name( + 'lines', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=21), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14)], + Call( + Name( + 'parse_line', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=27), + [ + Name( + 'line', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=32), + Name( + 'in_list', + Load(), + lineno=10, + col_offset=34, + end_lineno=10, + end_col_offset=41), + Name( + 'in_list_append', + Load(), + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=57)], + [], + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=58), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=58), + AugAssign( + Name( + 'html', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + Add(), + Subscript( + Name( + 'result', + Load(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=22), + Constant( + 'line', + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=29), + Load(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=30), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=30), + Assign( + [ + Name( + 'in_list', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=15)], + Subscript( + Name( + 'result', + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=24), + Constant( + 'in_list', + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=34), + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=35), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=35), + Assign( + [ + Name( + 'in_list_append', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + Subscript( + Name( + 'result', + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=31), + Constant( + 'in_list_append', + lineno=13, + col_offset=32, + end_lineno=13, + end_col_offset=48), + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=49), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=49)], + [], + lineno=9, + col_offset=4, + end_lineno=13, + end_col_offset=49), + If( + Name( + 'in_list', + Load(), + lineno=14, + col_offset=7, + end_lineno=14, + end_col_offset=14), + [ + AugAssign( + Name( + 'html', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + Add(), + Constant( + '', + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=23), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=23)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=23), + Return( + Name( + 'html', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=15), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=15)], + [], + lineno=4, + col_offset=0, + end_lineno=16, + end_col_offset=15), + FunctionDef( + 'wrap', + arguments( + [], + [ + arg( + 'line', + lineno=19, + col_offset=9, + end_lineno=19, + end_col_offset=13), + arg( + 'tag', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '<{tag}>{line}', + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=34), + 'format', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=41), + [], + [ + keyword( + 'line', + Name( + 'line', + Load(), + lineno=20, + col_offset=47, + end_lineno=20, + end_col_offset=51), + lineno=20, + col_offset=42, + end_lineno=20, + end_col_offset=51), + keyword( + 'tag', + Name( + 'tag', + Load(), + lineno=20, + col_offset=57, + end_lineno=20, + end_col_offset=60), + lineno=20, + col_offset=53, + end_lineno=20, + end_col_offset=60)], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=61), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=61)], + [], + lineno=19, + col_offset=0, + end_lineno=20, + end_col_offset=61), + FunctionDef( + 'check_headers', + arguments( + [], + [ + arg( + 'line', + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'pattern', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=11)], + Constant( + '# (.*)', + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=22), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=22), + For( + Name( + 'index', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=22), + [ + Constant( + 6, + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=24)], + [], + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=25), + [ + If( + Call( + Attribute( + Name( + 're', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=13), + 'match', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=19), + [ + Name( + 'pattern', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=27), + Name( + 'line', + Load(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=33)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=34), + [ + Return( + Call( + Name( + 'wrap', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=23), + [ + Subscript( + Name( + 'line', + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=28), + Slice( + BinOp( + Name( + 'index', + Load(), + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=35), + Add(), + Constant( + 2, + lineno=27, + col_offset=38, + end_lineno=27, + end_col_offset=39), + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=39), + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=41), + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=42), + BinOp( + Constant( + 'h', + lineno=27, + col_offset=44, + end_lineno=27, + end_col_offset=47), + Add(), + Call( + Name( + 'str', + Load(), + lineno=27, + col_offset=50, + end_lineno=27, + end_col_offset=53), + [ + BinOp( + Name( + 'index', + Load(), + lineno=27, + col_offset=54, + end_lineno=27, + end_col_offset=59), + Add(), + Constant( + 1, + lineno=27, + col_offset=62, + end_lineno=27, + end_col_offset=63), + lineno=27, + col_offset=54, + end_lineno=27, + end_col_offset=63)], + [], + lineno=27, + col_offset=50, + end_lineno=27, + end_col_offset=64), + lineno=27, + col_offset=44, + end_lineno=27, + end_col_offset=64)], + [], + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=65), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=65)], + [], + lineno=26, + col_offset=8, + end_lineno=27, + end_col_offset=65), + Assign( + [ + Name( + 'pattern', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=15)], + BinOp( + Constant( + '#', + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=21), + Add(), + Name( + 'pattern', + Load(), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=31), + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=31), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=31)], + [], + lineno=25, + col_offset=4, + end_lineno=28, + end_col_offset=31), + Return( + Name( + 'line', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=15), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=15)], + [], + lineno=23, + col_offset=0, + end_lineno=29, + end_col_offset=15), + FunctionDef( + 'check_bold', + arguments( + [], + [ + arg( + 'line', + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'bold_pattern', + Store(), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=16)], + Constant( + '(.*)__(.*)__(.*)', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=37), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=37), + Assign( + [ + Name( + 'bold_match', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=14)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=19), + 'match', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=25), + [ + Name( + 'bold_pattern', + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=38), + Name( + 'line', + Load(), + lineno=34, + col_offset=40, + end_lineno=34, + end_col_offset=44)], + [], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=45), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=45), + If( + Name( + 'bold_match', + Load(), + lineno=35, + col_offset=7, + end_lineno=35, + end_col_offset=17), + [ + Return( + BinOp( + BinOp( + Call( + Attribute( + Name( + 'bold_match', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=25), + 'group', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=31), + [ + Constant( + 1, + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=33)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=34), + Add(), + Call( + Name( + 'wrap', + Load(), + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=41), + [ + Call( + Attribute( + Name( + 'bold_match', + Load(), + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=52), + 'group', + Load(), + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=58), + [ + Constant( + 2, + lineno=36, + col_offset=59, + end_lineno=36, + end_col_offset=60)], + [], + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=61), + Constant( + 'strong', + lineno=36, + col_offset=63, + end_lineno=36, + end_col_offset=71)], + [], + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=72), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=72), + Add(), + Call( + Attribute( + Name( + 'bold_match', + Load(), + lineno=37, + col_offset=14, + end_lineno=37, + end_col_offset=24), + 'group', + Load(), + lineno=37, + col_offset=14, + end_lineno=37, + end_col_offset=30), + [ + Constant( + 3, + lineno=37, + col_offset=31, + end_lineno=37, + end_col_offset=32)], + [], + lineno=37, + col_offset=14, + end_lineno=37, + end_col_offset=33), + lineno=36, + col_offset=15, + end_lineno=37, + end_col_offset=33), + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=33)], + [ + Return( + Constant( + None, + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=19), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=19)], + lineno=35, + col_offset=4, + end_lineno=39, + end_col_offset=19)], + [], + lineno=32, + col_offset=0, + end_lineno=39, + end_col_offset=19), + FunctionDef( + 'check_italic', + arguments( + [], + [ + arg( + 'line', + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'italic_pattern', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=18)], + Constant( + '(.*)_(.*)_(.*)', + lineno=43, + col_offset=21, + end_lineno=43, + end_col_offset=37), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=37), + Assign( + [ + Name( + 'italic_match', + Store(), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=16)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=21), + 'match', + Load(), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=27), + [ + Name( + 'italic_pattern', + Load(), + lineno=44, + col_offset=28, + end_lineno=44, + end_col_offset=42), + Name( + 'line', + Load(), + lineno=44, + col_offset=44, + end_lineno=44, + end_col_offset=48)], + [], + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=49), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=49), + If( + Name( + 'italic_match', + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=19), + [ + Return( + BinOp( + BinOp( + Call( + Attribute( + Name( + 'italic_match', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=27), + 'group', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=33), + [ + Constant( + 1, + lineno=46, + col_offset=34, + end_lineno=46, + end_col_offset=35)], + [], + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=36), + Add(), + Call( + Name( + 'wrap', + Load(), + lineno=46, + col_offset=39, + end_lineno=46, + end_col_offset=43), + [ + Call( + Attribute( + Name( + 'italic_match', + Load(), + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=56), + 'group', + Load(), + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=62), + [ + Constant( + 2, + lineno=46, + col_offset=63, + end_lineno=46, + end_col_offset=64)], + [], + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=65), + Constant( + 'em', + lineno=46, + col_offset=67, + end_lineno=46, + end_col_offset=71)], + [], + lineno=46, + col_offset=39, + end_lineno=46, + end_col_offset=72), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=72), + Add(), + Call( + Attribute( + Name( + 'italic_match', + Load(), + lineno=47, + col_offset=14, + end_lineno=47, + end_col_offset=26), + 'group', + Load(), + lineno=47, + col_offset=14, + end_lineno=47, + end_col_offset=32), + [ + Constant( + 3, + lineno=47, + col_offset=33, + end_lineno=47, + end_col_offset=34)], + [], + lineno=47, + col_offset=14, + end_lineno=47, + end_col_offset=35), + lineno=46, + col_offset=15, + end_lineno=47, + end_col_offset=35), + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=35)], + [ + Return( + Constant( + None, + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=19), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=19)], + lineno=45, + col_offset=4, + end_lineno=49, + end_col_offset=19)], + [], + lineno=42, + col_offset=0, + end_lineno=49, + end_col_offset=19), + FunctionDef( + 'parse_line', + arguments( + [], + [ + arg( + 'line', + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=19), + arg( + 'in_list', + lineno=52, + col_offset=21, + end_lineno=52, + end_col_offset=28), + arg( + 'in_list_append', + lineno=52, + col_offset=30, + end_lineno=52, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=10)], + Call( + Name( + 'check_headers', + Load(), + lineno=53, + col_offset=13, + end_lineno=53, + end_col_offset=26), + [ + Name( + 'line', + Load(), + lineno=53, + col_offset=27, + end_lineno=53, + end_col_offset=31)], + [], + lineno=53, + col_offset=13, + end_lineno=53, + end_col_offset=32), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=32), + Assign( + [ + Name( + 'list_match', + Store(), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=14)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=19), + 'match', + Load(), + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=25), + [ + Constant( + '\\* (.*)', + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=36), + Name( + 'result', + Load(), + lineno=55, + col_offset=38, + end_lineno=55, + end_col_offset=44)], + [], + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=45), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=45), + If( + Name( + 'list_match', + Load(), + lineno=57, + col_offset=7, + end_lineno=57, + end_col_offset=17), + [ + If( + UnaryOp( + Not(), + Name( + 'in_list', + Load(), + lineno=58, + col_offset=15, + end_lineno=58, + end_col_offset=22), + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=22), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=59, + col_offset=12, + end_lineno=59, + end_col_offset=18)], + BinOp( + Constant( + '
    ', + lineno=59, + col_offset=21, + end_lineno=59, + end_col_offset=27), + Add(), + Call( + Name( + 'wrap', + Load(), + lineno=59, + col_offset=30, + end_lineno=59, + end_col_offset=34), + [ + Call( + Attribute( + Name( + 'list_match', + Load(), + lineno=59, + col_offset=35, + end_lineno=59, + end_col_offset=45), + 'group', + Load(), + lineno=59, + col_offset=35, + end_lineno=59, + end_col_offset=51), + [ + Constant( + 1, + lineno=59, + col_offset=52, + end_lineno=59, + end_col_offset=53)], + [], + lineno=59, + col_offset=35, + end_lineno=59, + end_col_offset=54), + Constant( + 'li', + lineno=59, + col_offset=56, + end_lineno=59, + end_col_offset=60)], + [], + lineno=59, + col_offset=30, + end_lineno=59, + end_col_offset=61), + lineno=59, + col_offset=21, + end_lineno=59, + end_col_offset=61), + lineno=59, + col_offset=12, + end_lineno=59, + end_col_offset=61), + Assign( + [ + Name( + 'in_list', + Store(), + lineno=60, + col_offset=12, + end_lineno=60, + end_col_offset=19)], + Constant( + True, + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=26), + lineno=60, + col_offset=12, + end_lineno=60, + end_col_offset=26)], + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=62, + col_offset=12, + end_lineno=62, + end_col_offset=18)], + Call( + Name( + 'wrap', + Load(), + lineno=62, + col_offset=21, + end_lineno=62, + end_col_offset=25), + [ + Call( + Attribute( + Name( + 'list_match', + Load(), + lineno=62, + col_offset=26, + end_lineno=62, + end_col_offset=36), + 'group', + Load(), + lineno=62, + col_offset=26, + end_lineno=62, + end_col_offset=42), + [ + Constant( + 1, + lineno=62, + col_offset=43, + end_lineno=62, + end_col_offset=44)], + [], + lineno=62, + col_offset=26, + end_lineno=62, + end_col_offset=45), + Constant( + 'li', + lineno=62, + col_offset=47, + end_lineno=62, + end_col_offset=51)], + [], + lineno=62, + col_offset=21, + end_lineno=62, + end_col_offset=52), + lineno=62, + col_offset=12, + end_lineno=62, + end_col_offset=52)], + lineno=58, + col_offset=8, + end_lineno=62, + end_col_offset=52)], + [ + If( + Name( + 'in_list', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=18), + [ + Assign( + [ + Name( + 'in_list_append', + Store(), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=26)], + Constant( + True, + lineno=65, + col_offset=29, + end_lineno=65, + end_col_offset=33), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=33), + Assign( + [ + Name( + 'in_list', + Store(), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=19)], + Constant( + False, + lineno=66, + col_offset=22, + end_lineno=66, + end_col_offset=27), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=27)], + [], + lineno=64, + col_offset=8, + end_lineno=66, + end_col_offset=27)], + lineno=57, + col_offset=4, + end_lineno=66, + end_col_offset=27), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 're', + Load(), + lineno=68, + col_offset=11, + end_lineno=68, + end_col_offset=13), + 'match', + Load(), + lineno=68, + col_offset=11, + end_lineno=68, + end_col_offset=19), + [ + Constant( + ')(.*)()(.*)', + lineno=72, + col_offset=24, + end_lineno=72, + end_col_offset=51), + Constant( + '\\1\\2

    \\3

    \\4\\5', + lineno=73, + col_offset=24, + end_lineno=73, + end_col_offset=44), + Name( + 'result', + Load(), + lineno=73, + col_offset=46, + end_lineno=73, + end_col_offset=52)], + [], + lineno=72, + col_offset=17, + end_lineno=73, + end_col_offset=53), + lineno=72, + col_offset=8, + end_lineno=73, + end_col_offset=53)], + [], + lineno=71, + col_offset=4, + end_lineno=73, + end_col_offset=53), + While( + Call( + Name( + 'check_bold', + Load(), + lineno=75, + col_offset=10, + end_lineno=75, + end_col_offset=20), + [ + Name( + 'result', + Load(), + lineno=75, + col_offset=21, + end_lineno=75, + end_col_offset=27)], + [], + lineno=75, + col_offset=10, + end_lineno=75, + end_col_offset=28), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=14)], + Call( + Name( + 'check_bold', + Load(), + lineno=76, + col_offset=17, + end_lineno=76, + end_col_offset=27), + [ + Name( + 'result', + Load(), + lineno=76, + col_offset=28, + end_lineno=76, + end_col_offset=34)], + [], + lineno=76, + col_offset=17, + end_lineno=76, + end_col_offset=35), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=35)], + [], + lineno=75, + col_offset=4, + end_lineno=76, + end_col_offset=35), + While( + Call( + Name( + 'check_italic', + Load(), + lineno=77, + col_offset=10, + end_lineno=77, + end_col_offset=22), + [ + Name( + 'result', + Load(), + lineno=77, + col_offset=23, + end_lineno=77, + end_col_offset=29)], + [], + lineno=77, + col_offset=10, + end_lineno=77, + end_col_offset=30), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=14)], + Call( + Name( + 'check_italic', + Load(), + lineno=78, + col_offset=17, + end_lineno=78, + end_col_offset=29), + [ + Name( + 'result', + Load(), + lineno=78, + col_offset=30, + end_lineno=78, + end_col_offset=36)], + [], + lineno=78, + col_offset=17, + end_lineno=78, + end_col_offset=37), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=37)], + [], + lineno=77, + col_offset=4, + end_lineno=78, + end_col_offset=37), + If( + Name( + 'in_list_append', + Load(), + lineno=80, + col_offset=7, + end_lineno=80, + end_col_offset=21), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=14)], + BinOp( + Constant( + '
', + lineno=81, + col_offset=17, + end_lineno=81, + end_col_offset=24), + Add(), + Name( + 'result', + Load(), + lineno=81, + col_offset=27, + end_lineno=81, + end_col_offset=33), + lineno=81, + col_offset=17, + end_lineno=81, + end_col_offset=33), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=33), + Assign( + [ + Name( + 'in_list_append', + Store(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=22)], + Constant( + False, + lineno=82, + col_offset=25, + end_lineno=82, + end_col_offset=30), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=30)], + [], + lineno=80, + col_offset=4, + end_lineno=82, + end_col_offset=30), + Return( + Dict( + [ + Constant( + 'line', + lineno=85, + col_offset=8, + end_lineno=85, + end_col_offset=14), + Constant( + 'in_list', + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=17), + Constant( + 'in_list_append', + lineno=87, + col_offset=8, + end_lineno=87, + end_col_offset=24)], + [ + Name( + 'result', + Load(), + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=22), + Name( + 'in_list', + Load(), + lineno=86, + col_offset=19, + end_lineno=86, + end_col_offset=26), + Name( + 'in_list_append', + Load(), + lineno=87, + col_offset=26, + end_lineno=87, + end_col_offset=40)], + lineno=84, + col_offset=11, + end_lineno=88, + end_col_offset=5), + lineno=84, + col_offset=4, + end_lineno=88, + end_col_offset=5)], + [], + lineno=52, + col_offset=0, + end_lineno=88, + end_col_offset=5)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=9)], + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=20), + 'split', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=26), + [ + Constant( + '\n', + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=31)], + [], + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=32), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=8)], + Constant( + '', + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=13), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11)], + Constant( + False, + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=19), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=19), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=18)], + Constant( + False, + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=26), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=26), + For( + Name( + 'placeholder_6', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=21), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14)], + Call( + Name( + 'parse_line', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=27), + [ + Name( + 'placeholder_6', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=32), + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=34, + end_lineno=10, + end_col_offset=41), + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=43, + end_lineno=10, + end_col_offset=57)], + [], + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=58), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=58), + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + Add(), + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=22), + Constant( + 'line', + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=29), + Load(), + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=30), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=15)], + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=24), + Constant( + 'in_list', + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=34), + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=35), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=35), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=31), + Constant( + 'in_list_append', + lineno=13, + col_offset=32, + end_lineno=13, + end_col_offset=48), + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=49), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=49)], + [], + lineno=9, + col_offset=4, + end_lineno=13, + end_col_offset=49), + If( + Name( + 'placeholder_4', + Load(), + lineno=14, + col_offset=7, + end_lineno=14, + end_col_offset=14), + [ + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + Add(), + Constant( + '', + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=23), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=23)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=23), + Return( + Name( + 'placeholder_3', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=15), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=15)], + [], + lineno=4, + col_offset=0, + end_lineno=16, + end_col_offset=15), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=19, + col_offset=9, + end_lineno=19, + end_col_offset=13), + arg( + 'placeholder_9', + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '<{tag}>{line}', + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=34), + 'format', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=41), + [], + [ + keyword( + 'placeholder_6', + Name( + 'placeholder_6', + Load(), + lineno=20, + col_offset=47, + end_lineno=20, + end_col_offset=51), + lineno=20, + col_offset=42, + end_lineno=20, + end_col_offset=51), + keyword( + 'placeholder_9', + Name( + 'placeholder_9', + Load(), + lineno=20, + col_offset=57, + end_lineno=20, + end_col_offset=60), + lineno=20, + col_offset=53, + end_lineno=20, + end_col_offset=60)], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=61), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=61)], + [], + lineno=19, + col_offset=0, + end_lineno=20, + end_col_offset=61), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=11)], + Constant( + '# (.*)', + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=22), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=22), + For( + Name( + 'placeholder_12', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=22), + [ + Constant( + 6, + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=24)], + [], + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=25), + [ + If( + Call( + Attribute( + Name( + 're', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=13), + 'match', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=19), + [ + Name( + 'placeholder_11', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=27), + Name( + 'placeholder_6', + Load(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=33)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=34), + [ + Return( + Call( + Name( + 'placeholder_8', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=23), + [ + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=28), + Slice( + BinOp( + Name( + 'placeholder_12', + Load(), + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=35), + Add(), + Constant( + 2, + lineno=27, + col_offset=38, + end_lineno=27, + end_col_offset=39), + lineno=27, + col_offset=30, + end_lineno=27, + end_col_offset=39), + lineno=27, + col_offset=29, + end_lineno=27, + end_col_offset=41), + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=42), + BinOp( + Constant( + 'h', + lineno=27, + col_offset=44, + end_lineno=27, + end_col_offset=47), + Add(), + Call( + Name( + 'str', + Load(), + lineno=27, + col_offset=50, + end_lineno=27, + end_col_offset=53), + [ + BinOp( + Name( + 'placeholder_12', + Load(), + lineno=27, + col_offset=54, + end_lineno=27, + end_col_offset=59), + Add(), + Constant( + 1, + lineno=27, + col_offset=62, + end_lineno=27, + end_col_offset=63), + lineno=27, + col_offset=54, + end_lineno=27, + end_col_offset=63)], + [], + lineno=27, + col_offset=50, + end_lineno=27, + end_col_offset=64), + lineno=27, + col_offset=44, + end_lineno=27, + end_col_offset=64)], + [], + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=65), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=65)], + [], + lineno=26, + col_offset=8, + end_lineno=27, + end_col_offset=65), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=15)], + BinOp( + Constant( + '#', + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=21), + Add(), + Name( + 'placeholder_11', + Load(), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=31), + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=31), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=31)], + [], + lineno=25, + col_offset=4, + end_lineno=28, + end_col_offset=31), + Return( + Name( + 'placeholder_6', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=15), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=15)], + [], + lineno=23, + col_offset=0, + end_lineno=29, + end_col_offset=15), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=16)], + Constant( + '(.*)__(.*)__(.*)', + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=37), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=37), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=14)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=19), + 'match', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=25), + [ + Name( + 'placeholder_14', + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=38), + Name( + 'placeholder_6', + Load(), + lineno=34, + col_offset=40, + end_lineno=34, + end_col_offset=44)], + [], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=45), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=45), + If( + Name( + 'placeholder_15', + Load(), + lineno=35, + col_offset=7, + end_lineno=35, + end_col_offset=17), + [ + Return( + BinOp( + BinOp( + Call( + Attribute( + Name( + 'placeholder_15', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=25), + 'group', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=31), + [ + Constant( + 1, + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=33)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=34), + Add(), + Call( + Name( + 'placeholder_8', + Load(), + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=41), + [ + Call( + Attribute( + Name( + 'placeholder_15', + Load(), + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=52), + 'group', + Load(), + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=58), + [ + Constant( + 2, + lineno=36, + col_offset=59, + end_lineno=36, + end_col_offset=60)], + [], + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=61), + Constant( + 'strong', + lineno=36, + col_offset=63, + end_lineno=36, + end_col_offset=71)], + [], + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=72), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=72), + Add(), + Call( + Attribute( + Name( + 'placeholder_15', + Load(), + lineno=37, + col_offset=14, + end_lineno=37, + end_col_offset=24), + 'group', + Load(), + lineno=37, + col_offset=14, + end_lineno=37, + end_col_offset=30), + [ + Constant( + 3, + lineno=37, + col_offset=31, + end_lineno=37, + end_col_offset=32)], + [], + lineno=37, + col_offset=14, + end_lineno=37, + end_col_offset=33), + lineno=36, + col_offset=15, + end_lineno=37, + end_col_offset=33), + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=33)], + [ + Return( + Constant( + None, + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=19), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=19)], + lineno=35, + col_offset=4, + end_lineno=39, + end_col_offset=19)], + [], + lineno=32, + col_offset=0, + end_lineno=39, + end_col_offset=19), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=18)], + Constant( + '(.*)_(.*)_(.*)', + lineno=43, + col_offset=21, + end_lineno=43, + end_col_offset=37), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=37), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=16)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=21), + 'match', + Load(), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=27), + [ + Name( + 'placeholder_17', + Load(), + lineno=44, + col_offset=28, + end_lineno=44, + end_col_offset=42), + Name( + 'placeholder_6', + Load(), + lineno=44, + col_offset=44, + end_lineno=44, + end_col_offset=48)], + [], + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=49), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=49), + If( + Name( + 'placeholder_18', + Load(), + lineno=45, + col_offset=7, + end_lineno=45, + end_col_offset=19), + [ + Return( + BinOp( + BinOp( + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=27), + 'group', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=33), + [ + Constant( + 1, + lineno=46, + col_offset=34, + end_lineno=46, + end_col_offset=35)], + [], + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=36), + Add(), + Call( + Name( + 'placeholder_8', + Load(), + lineno=46, + col_offset=39, + end_lineno=46, + end_col_offset=43), + [ + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=56), + 'group', + Load(), + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=62), + [ + Constant( + 2, + lineno=46, + col_offset=63, + end_lineno=46, + end_col_offset=64)], + [], + lineno=46, + col_offset=44, + end_lineno=46, + end_col_offset=65), + Constant( + 'em', + lineno=46, + col_offset=67, + end_lineno=46, + end_col_offset=71)], + [], + lineno=46, + col_offset=39, + end_lineno=46, + end_col_offset=72), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=72), + Add(), + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=47, + col_offset=14, + end_lineno=47, + end_col_offset=26), + 'group', + Load(), + lineno=47, + col_offset=14, + end_lineno=47, + end_col_offset=32), + [ + Constant( + 3, + lineno=47, + col_offset=33, + end_lineno=47, + end_col_offset=34)], + [], + lineno=47, + col_offset=14, + end_lineno=47, + end_col_offset=35), + lineno=46, + col_offset=15, + end_lineno=47, + end_col_offset=35), + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=35)], + [ + Return( + Constant( + None, + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=19), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=19)], + lineno=45, + col_offset=4, + end_lineno=49, + end_col_offset=19)], + [], + lineno=42, + col_offset=0, + end_lineno=49, + end_col_offset=19), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=19), + arg( + 'placeholder_4', + lineno=52, + col_offset=21, + end_lineno=52, + end_col_offset=28), + arg( + 'placeholder_5', + lineno=52, + col_offset=30, + end_lineno=52, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=10)], + Call( + Name( + 'placeholder_10', + Load(), + lineno=53, + col_offset=13, + end_lineno=53, + end_col_offset=26), + [ + Name( + 'placeholder_6', + Load(), + lineno=53, + col_offset=27, + end_lineno=53, + end_col_offset=31)], + [], + lineno=53, + col_offset=13, + end_lineno=53, + end_col_offset=32), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_20', + Store(), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=14)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=19), + 'match', + Load(), + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=25), + [ + Constant( + '\\* (.*)', + lineno=55, + col_offset=26, + end_lineno=55, + end_col_offset=36), + Name( + 'placeholder_7', + Load(), + lineno=55, + col_offset=38, + end_lineno=55, + end_col_offset=44)], + [], + lineno=55, + col_offset=17, + end_lineno=55, + end_col_offset=45), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=45), + If( + Name( + 'placeholder_20', + Load(), + lineno=57, + col_offset=7, + end_lineno=57, + end_col_offset=17), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_4', + Load(), + lineno=58, + col_offset=15, + end_lineno=58, + end_col_offset=22), + lineno=58, + col_offset=11, + end_lineno=58, + end_col_offset=22), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=59, + col_offset=12, + end_lineno=59, + end_col_offset=18)], + BinOp( + Constant( + '
    ', + lineno=59, + col_offset=21, + end_lineno=59, + end_col_offset=27), + Add(), + Call( + Name( + 'placeholder_8', + Load(), + lineno=59, + col_offset=30, + end_lineno=59, + end_col_offset=34), + [ + Call( + Attribute( + Name( + 'placeholder_20', + Load(), + lineno=59, + col_offset=35, + end_lineno=59, + end_col_offset=45), + 'group', + Load(), + lineno=59, + col_offset=35, + end_lineno=59, + end_col_offset=51), + [ + Constant( + 1, + lineno=59, + col_offset=52, + end_lineno=59, + end_col_offset=53)], + [], + lineno=59, + col_offset=35, + end_lineno=59, + end_col_offset=54), + Constant( + 'li', + lineno=59, + col_offset=56, + end_lineno=59, + end_col_offset=60)], + [], + lineno=59, + col_offset=30, + end_lineno=59, + end_col_offset=61), + lineno=59, + col_offset=21, + end_lineno=59, + end_col_offset=61), + lineno=59, + col_offset=12, + end_lineno=59, + end_col_offset=61), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=60, + col_offset=12, + end_lineno=60, + end_col_offset=19)], + Constant( + True, + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=26), + lineno=60, + col_offset=12, + end_lineno=60, + end_col_offset=26)], + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=62, + col_offset=12, + end_lineno=62, + end_col_offset=18)], + Call( + Name( + 'placeholder_8', + Load(), + lineno=62, + col_offset=21, + end_lineno=62, + end_col_offset=25), + [ + Call( + Attribute( + Name( + 'placeholder_20', + Load(), + lineno=62, + col_offset=26, + end_lineno=62, + end_col_offset=36), + 'group', + Load(), + lineno=62, + col_offset=26, + end_lineno=62, + end_col_offset=42), + [ + Constant( + 1, + lineno=62, + col_offset=43, + end_lineno=62, + end_col_offset=44)], + [], + lineno=62, + col_offset=26, + end_lineno=62, + end_col_offset=45), + Constant( + 'li', + lineno=62, + col_offset=47, + end_lineno=62, + end_col_offset=51)], + [], + lineno=62, + col_offset=21, + end_lineno=62, + end_col_offset=52), + lineno=62, + col_offset=12, + end_lineno=62, + end_col_offset=52)], + lineno=58, + col_offset=8, + end_lineno=62, + end_col_offset=52)], + [ + If( + Name( + 'placeholder_4', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=18), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=26)], + Constant( + True, + lineno=65, + col_offset=29, + end_lineno=65, + end_col_offset=33), + lineno=65, + col_offset=12, + end_lineno=65, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=19)], + Constant( + False, + lineno=66, + col_offset=22, + end_lineno=66, + end_col_offset=27), + lineno=66, + col_offset=12, + end_lineno=66, + end_col_offset=27)], + [], + lineno=64, + col_offset=8, + end_lineno=66, + end_col_offset=27)], + lineno=57, + col_offset=4, + end_lineno=66, + end_col_offset=27), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 're', + Load(), + lineno=68, + col_offset=11, + end_lineno=68, + end_col_offset=13), + 'match', + Load(), + lineno=68, + col_offset=11, + end_lineno=68, + end_col_offset=19), + [ + Constant( + ')(.*)()(.*)', + lineno=72, + col_offset=24, + end_lineno=72, + end_col_offset=51), + Constant( + '\\1\\2

    \\3

    \\4\\5', + lineno=73, + col_offset=24, + end_lineno=73, + end_col_offset=44), + Name( + 'placeholder_7', + Load(), + lineno=73, + col_offset=46, + end_lineno=73, + end_col_offset=52)], + [], + lineno=72, + col_offset=17, + end_lineno=73, + end_col_offset=53), + lineno=72, + col_offset=8, + end_lineno=73, + end_col_offset=53)], + [], + lineno=71, + col_offset=4, + end_lineno=73, + end_col_offset=53), + While( + Call( + Name( + 'placeholder_13', + Load(), + lineno=75, + col_offset=10, + end_lineno=75, + end_col_offset=20), + [ + Name( + 'placeholder_7', + Load(), + lineno=75, + col_offset=21, + end_lineno=75, + end_col_offset=27)], + [], + lineno=75, + col_offset=10, + end_lineno=75, + end_col_offset=28), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=14)], + Call( + Name( + 'placeholder_13', + Load(), + lineno=76, + col_offset=17, + end_lineno=76, + end_col_offset=27), + [ + Name( + 'placeholder_7', + Load(), + lineno=76, + col_offset=28, + end_lineno=76, + end_col_offset=34)], + [], + lineno=76, + col_offset=17, + end_lineno=76, + end_col_offset=35), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=35)], + [], + lineno=75, + col_offset=4, + end_lineno=76, + end_col_offset=35), + While( + Call( + Name( + 'placeholder_16', + Load(), + lineno=77, + col_offset=10, + end_lineno=77, + end_col_offset=22), + [ + Name( + 'placeholder_7', + Load(), + lineno=77, + col_offset=23, + end_lineno=77, + end_col_offset=29)], + [], + lineno=77, + col_offset=10, + end_lineno=77, + end_col_offset=30), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=14)], + Call( + Name( + 'placeholder_16', + Load(), + lineno=78, + col_offset=17, + end_lineno=78, + end_col_offset=29), + [ + Name( + 'placeholder_7', + Load(), + lineno=78, + col_offset=30, + end_lineno=78, + end_col_offset=36)], + [], + lineno=78, + col_offset=17, + end_lineno=78, + end_col_offset=37), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=37)], + [], + lineno=77, + col_offset=4, + end_lineno=78, + end_col_offset=37), + If( + Name( + 'placeholder_5', + Load(), + lineno=80, + col_offset=7, + end_lineno=80, + end_col_offset=21), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=14)], + BinOp( + Constant( + '
', + lineno=81, + col_offset=17, + end_lineno=81, + end_col_offset=24), + Add(), + Name( + 'placeholder_7', + Load(), + lineno=81, + col_offset=27, + end_lineno=81, + end_col_offset=33), + lineno=81, + col_offset=17, + end_lineno=81, + end_col_offset=33), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=22)], + Constant( + False, + lineno=82, + col_offset=25, + end_lineno=82, + end_col_offset=30), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=30)], + [], + lineno=80, + col_offset=4, + end_lineno=82, + end_col_offset=30), + Return( + Dict( + [ + Constant( + 'line', + lineno=85, + col_offset=8, + end_lineno=85, + end_col_offset=14), + Constant( + 'in_list', + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=17), + Constant( + 'in_list_append', + lineno=87, + col_offset=8, + end_lineno=87, + end_col_offset=24)], + [ + Name( + 'placeholder_7', + Load(), + lineno=85, + col_offset=16, + end_lineno=85, + end_col_offset=22), + Name( + 'placeholder_4', + Load(), + lineno=86, + col_offset=19, + end_lineno=86, + end_col_offset=26), + Name( + 'placeholder_5', + Load(), + lineno=87, + col_offset=26, + end_lineno=87, + end_col_offset=40)], + lineno=84, + col_offset=11, + end_lineno=88, + end_col_offset=5), + lineno=84, + col_offset=4, + end_lineno=88, + end_col_offset=5)], + [], + lineno=52, + col_offset=0, + end_lineno=88, + end_col_offset=5)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-markdown/representation.txt b/test/practice-markdown/representation.txt new file mode 100644 index 0000000..a99945b --- /dev/null +++ b/test/practice-markdown/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('re', lineno=1, col_offset=7, end_lineno=1, end_col_offset=9)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=9), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=10, end_lineno=4, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=9)], Call(Attribute(Name('placeholder_1', Load(), lineno=5, col_offset=12, end_lineno=5, end_col_offset=20), 'split', Load(), lineno=5, col_offset=12, end_lineno=5, end_col_offset=26), [Constant('\n', lineno=5, col_offset=27, end_lineno=5, end_col_offset=31)], [], lineno=5, col_offset=12, end_lineno=5, end_col_offset=32), lineno=5, col_offset=4, end_lineno=5, end_col_offset=32), Assign([Name('placeholder_3', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=8)], Constant('', lineno=6, col_offset=11, end_lineno=6, end_col_offset=13), lineno=6, col_offset=4, end_lineno=6, end_col_offset=13), Assign([Name('placeholder_4', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=11)], Constant(False, lineno=7, col_offset=14, end_lineno=7, end_col_offset=19), lineno=7, col_offset=4, end_lineno=7, end_col_offset=19), Assign([Name('placeholder_5', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=18)], Constant(False, lineno=8, col_offset=21, end_lineno=8, end_col_offset=26), lineno=8, col_offset=4, end_lineno=8, end_col_offset=26), For(Name('placeholder_6', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), Name('placeholder_2', Load(), lineno=9, col_offset=16, end_lineno=9, end_col_offset=21), [Assign([Name('placeholder_7', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=14)], Call(Name('parse_line', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=27), [Name('placeholder_6', Load(), lineno=10, col_offset=28, end_lineno=10, end_col_offset=32), Name('placeholder_4', Load(), lineno=10, col_offset=34, end_lineno=10, end_col_offset=41), Name('placeholder_5', Load(), lineno=10, col_offset=43, end_lineno=10, end_col_offset=57)], [], lineno=10, col_offset=17, end_lineno=10, end_col_offset=58), lineno=10, col_offset=8, end_lineno=10, end_col_offset=58), AugAssign(Name('placeholder_3', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), Add(), Subscript(Name('placeholder_7', Load(), lineno=11, col_offset=16, end_lineno=11, end_col_offset=22), Constant('line', lineno=11, col_offset=23, end_lineno=11, end_col_offset=29), Load(), lineno=11, col_offset=16, end_lineno=11, end_col_offset=30), lineno=11, col_offset=8, end_lineno=11, end_col_offset=30), Assign([Name('placeholder_4', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=15)], Subscript(Name('placeholder_7', Load(), lineno=12, col_offset=18, end_lineno=12, end_col_offset=24), Constant('in_list', lineno=12, col_offset=25, end_lineno=12, end_col_offset=34), Load(), lineno=12, col_offset=18, end_lineno=12, end_col_offset=35), lineno=12, col_offset=8, end_lineno=12, end_col_offset=35), Assign([Name('placeholder_5', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=22)], Subscript(Name('placeholder_7', Load(), lineno=13, col_offset=25, end_lineno=13, end_col_offset=31), Constant('in_list_append', lineno=13, col_offset=32, end_lineno=13, end_col_offset=48), Load(), lineno=13, col_offset=25, end_lineno=13, end_col_offset=49), lineno=13, col_offset=8, end_lineno=13, end_col_offset=49)], [], lineno=9, col_offset=4, end_lineno=13, end_col_offset=49), If(Name('placeholder_4', Load(), lineno=14, col_offset=7, end_lineno=14, end_col_offset=14), [AugAssign(Name('placeholder_3', Store(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=12), Add(), Constant('', lineno=15, col_offset=16, end_lineno=15, end_col_offset=23), lineno=15, col_offset=8, end_lineno=15, end_col_offset=23)], [], lineno=14, col_offset=4, end_lineno=15, end_col_offset=23), Return(Name('placeholder_3', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=15), lineno=16, col_offset=4, end_lineno=16, end_col_offset=15)], [], lineno=4, col_offset=0, end_lineno=16, end_col_offset=15), FunctionDef('placeholder_8', arguments([], [arg('placeholder_6', lineno=19, col_offset=9, end_lineno=19, end_col_offset=13), arg('placeholder_9', lineno=19, col_offset=15, end_lineno=19, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Constant('<{tag}>{line}', lineno=20, col_offset=11, end_lineno=20, end_col_offset=34), 'format', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=41), [], [keyword('placeholder_6', Name('placeholder_6', Load(), lineno=20, col_offset=47, end_lineno=20, end_col_offset=51), lineno=20, col_offset=42, end_lineno=20, end_col_offset=51), keyword('placeholder_9', Name('placeholder_9', Load(), lineno=20, col_offset=57, end_lineno=20, end_col_offset=60), lineno=20, col_offset=53, end_lineno=20, end_col_offset=60)], lineno=20, col_offset=11, end_lineno=20, end_col_offset=61), lineno=20, col_offset=4, end_lineno=20, end_col_offset=61)], [], lineno=19, col_offset=0, end_lineno=20, end_col_offset=61), FunctionDef('placeholder_10', arguments([], [arg('placeholder_6', lineno=23, col_offset=18, end_lineno=23, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_11', Store(), lineno=24, col_offset=4, end_lineno=24, end_col_offset=11)], Constant('# (.*)', lineno=24, col_offset=14, end_lineno=24, end_col_offset=22), lineno=24, col_offset=4, end_lineno=24, end_col_offset=22), For(Name('placeholder_12', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=13), Call(Name('range', Load(), lineno=25, col_offset=17, end_lineno=25, end_col_offset=22), [Constant(6, lineno=25, col_offset=23, end_lineno=25, end_col_offset=24)], [], lineno=25, col_offset=17, end_lineno=25, end_col_offset=25), [If(Call(Attribute(Name('re', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=13), 'match', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=19), [Name('placeholder_11', Load(), lineno=26, col_offset=20, end_lineno=26, end_col_offset=27), Name('placeholder_6', Load(), lineno=26, col_offset=29, end_lineno=26, end_col_offset=33)], [], lineno=26, col_offset=11, end_lineno=26, end_col_offset=34), [Return(Call(Name('placeholder_8', Load(), lineno=27, col_offset=19, end_lineno=27, end_col_offset=23), [Subscript(Name('placeholder_6', Load(), lineno=27, col_offset=24, end_lineno=27, end_col_offset=28), Slice(BinOp(Name('placeholder_12', Load(), lineno=27, col_offset=30, end_lineno=27, end_col_offset=35), Add(), Constant(2, lineno=27, col_offset=38, end_lineno=27, end_col_offset=39), lineno=27, col_offset=30, end_lineno=27, end_col_offset=39), lineno=27, col_offset=29, end_lineno=27, end_col_offset=41), Load(), lineno=27, col_offset=24, end_lineno=27, end_col_offset=42), BinOp(Constant('h', lineno=27, col_offset=44, end_lineno=27, end_col_offset=47), Add(), Call(Name('str', Load(), lineno=27, col_offset=50, end_lineno=27, end_col_offset=53), [BinOp(Name('placeholder_12', Load(), lineno=27, col_offset=54, end_lineno=27, end_col_offset=59), Add(), Constant(1, lineno=27, col_offset=62, end_lineno=27, end_col_offset=63), lineno=27, col_offset=54, end_lineno=27, end_col_offset=63)], [], lineno=27, col_offset=50, end_lineno=27, end_col_offset=64), lineno=27, col_offset=44, end_lineno=27, end_col_offset=64)], [], lineno=27, col_offset=19, end_lineno=27, end_col_offset=65), lineno=27, col_offset=12, end_lineno=27, end_col_offset=65)], [], lineno=26, col_offset=8, end_lineno=27, end_col_offset=65), Assign([Name('placeholder_11', Store(), lineno=28, col_offset=8, end_lineno=28, end_col_offset=15)], BinOp(Constant('#', lineno=28, col_offset=18, end_lineno=28, end_col_offset=21), Add(), Name('placeholder_11', Load(), lineno=28, col_offset=24, end_lineno=28, end_col_offset=31), lineno=28, col_offset=18, end_lineno=28, end_col_offset=31), lineno=28, col_offset=8, end_lineno=28, end_col_offset=31)], [], lineno=25, col_offset=4, end_lineno=28, end_col_offset=31), Return(Name('placeholder_6', Load(), lineno=29, col_offset=11, end_lineno=29, end_col_offset=15), lineno=29, col_offset=4, end_lineno=29, end_col_offset=15)], [], lineno=23, col_offset=0, end_lineno=29, end_col_offset=15), FunctionDef('placeholder_13', arguments([], [arg('placeholder_6', lineno=32, col_offset=15, end_lineno=32, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=33, col_offset=4, end_lineno=33, end_col_offset=16)], Constant('(.*)__(.*)__(.*)', lineno=33, col_offset=19, end_lineno=33, end_col_offset=37), lineno=33, col_offset=4, end_lineno=33, end_col_offset=37), Assign([Name('placeholder_15', Store(), lineno=34, col_offset=4, end_lineno=34, end_col_offset=14)], Call(Attribute(Name('re', Load(), lineno=34, col_offset=17, end_lineno=34, end_col_offset=19), 'match', Load(), lineno=34, col_offset=17, end_lineno=34, end_col_offset=25), [Name('placeholder_14', Load(), lineno=34, col_offset=26, end_lineno=34, end_col_offset=38), Name('placeholder_6', Load(), lineno=34, col_offset=40, end_lineno=34, end_col_offset=44)], [], lineno=34, col_offset=17, end_lineno=34, end_col_offset=45), lineno=34, col_offset=4, end_lineno=34, end_col_offset=45), If(Name('placeholder_15', Load(), lineno=35, col_offset=7, end_lineno=35, end_col_offset=17), [Return(BinOp(BinOp(Call(Attribute(Name('placeholder_15', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=25), 'group', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=31), [Constant(1, lineno=36, col_offset=32, end_lineno=36, end_col_offset=33)], [], lineno=36, col_offset=15, end_lineno=36, end_col_offset=34), Add(), Call(Name('placeholder_8', Load(), lineno=36, col_offset=37, end_lineno=36, end_col_offset=41), [Call(Attribute(Name('placeholder_15', Load(), lineno=36, col_offset=42, end_lineno=36, end_col_offset=52), 'group', Load(), lineno=36, col_offset=42, end_lineno=36, end_col_offset=58), [Constant(2, lineno=36, col_offset=59, end_lineno=36, end_col_offset=60)], [], lineno=36, col_offset=42, end_lineno=36, end_col_offset=61), Constant('strong', lineno=36, col_offset=63, end_lineno=36, end_col_offset=71)], [], lineno=36, col_offset=37, end_lineno=36, end_col_offset=72), lineno=36, col_offset=15, end_lineno=36, end_col_offset=72), Add(), Call(Attribute(Name('placeholder_15', Load(), lineno=37, col_offset=14, end_lineno=37, end_col_offset=24), 'group', Load(), lineno=37, col_offset=14, end_lineno=37, end_col_offset=30), [Constant(3, lineno=37, col_offset=31, end_lineno=37, end_col_offset=32)], [], lineno=37, col_offset=14, end_lineno=37, end_col_offset=33), lineno=36, col_offset=15, end_lineno=37, end_col_offset=33), lineno=36, col_offset=8, end_lineno=37, end_col_offset=33)], [Return(Constant(None, lineno=39, col_offset=15, end_lineno=39, end_col_offset=19), lineno=39, col_offset=8, end_lineno=39, end_col_offset=19)], lineno=35, col_offset=4, end_lineno=39, end_col_offset=19)], [], lineno=32, col_offset=0, end_lineno=39, end_col_offset=19), FunctionDef('placeholder_16', arguments([], [arg('placeholder_6', lineno=42, col_offset=17, end_lineno=42, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_17', Store(), lineno=43, col_offset=4, end_lineno=43, end_col_offset=18)], Constant('(.*)_(.*)_(.*)', lineno=43, col_offset=21, end_lineno=43, end_col_offset=37), lineno=43, col_offset=4, end_lineno=43, end_col_offset=37), Assign([Name('placeholder_18', Store(), lineno=44, col_offset=4, end_lineno=44, end_col_offset=16)], Call(Attribute(Name('re', Load(), lineno=44, col_offset=19, end_lineno=44, end_col_offset=21), 'match', Load(), lineno=44, col_offset=19, end_lineno=44, end_col_offset=27), [Name('placeholder_17', Load(), lineno=44, col_offset=28, end_lineno=44, end_col_offset=42), Name('placeholder_6', Load(), lineno=44, col_offset=44, end_lineno=44, end_col_offset=48)], [], lineno=44, col_offset=19, end_lineno=44, end_col_offset=49), lineno=44, col_offset=4, end_lineno=44, end_col_offset=49), If(Name('placeholder_18', Load(), lineno=45, col_offset=7, end_lineno=45, end_col_offset=19), [Return(BinOp(BinOp(Call(Attribute(Name('placeholder_18', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=27), 'group', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=33), [Constant(1, lineno=46, col_offset=34, end_lineno=46, end_col_offset=35)], [], lineno=46, col_offset=15, end_lineno=46, end_col_offset=36), Add(), Call(Name('placeholder_8', Load(), lineno=46, col_offset=39, end_lineno=46, end_col_offset=43), [Call(Attribute(Name('placeholder_18', Load(), lineno=46, col_offset=44, end_lineno=46, end_col_offset=56), 'group', Load(), lineno=46, col_offset=44, end_lineno=46, end_col_offset=62), [Constant(2, lineno=46, col_offset=63, end_lineno=46, end_col_offset=64)], [], lineno=46, col_offset=44, end_lineno=46, end_col_offset=65), Constant('em', lineno=46, col_offset=67, end_lineno=46, end_col_offset=71)], [], lineno=46, col_offset=39, end_lineno=46, end_col_offset=72), lineno=46, col_offset=15, end_lineno=46, end_col_offset=72), Add(), Call(Attribute(Name('placeholder_18', Load(), lineno=47, col_offset=14, end_lineno=47, end_col_offset=26), 'group', Load(), lineno=47, col_offset=14, end_lineno=47, end_col_offset=32), [Constant(3, lineno=47, col_offset=33, end_lineno=47, end_col_offset=34)], [], lineno=47, col_offset=14, end_lineno=47, end_col_offset=35), lineno=46, col_offset=15, end_lineno=47, end_col_offset=35), lineno=46, col_offset=8, end_lineno=47, end_col_offset=35)], [Return(Constant(None, lineno=49, col_offset=15, end_lineno=49, end_col_offset=19), lineno=49, col_offset=8, end_lineno=49, end_col_offset=19)], lineno=45, col_offset=4, end_lineno=49, end_col_offset=19)], [], lineno=42, col_offset=0, end_lineno=49, end_col_offset=19), FunctionDef('placeholder_19', arguments([], [arg('placeholder_6', lineno=52, col_offset=15, end_lineno=52, end_col_offset=19), arg('placeholder_4', lineno=52, col_offset=21, end_lineno=52, end_col_offset=28), arg('placeholder_5', lineno=52, col_offset=30, end_lineno=52, end_col_offset=44)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=53, col_offset=4, end_lineno=53, end_col_offset=10)], Call(Name('placeholder_10', Load(), lineno=53, col_offset=13, end_lineno=53, end_col_offset=26), [Name('placeholder_6', Load(), lineno=53, col_offset=27, end_lineno=53, end_col_offset=31)], [], lineno=53, col_offset=13, end_lineno=53, end_col_offset=32), lineno=53, col_offset=4, end_lineno=53, end_col_offset=32), Assign([Name('placeholder_20', Store(), lineno=55, col_offset=4, end_lineno=55, end_col_offset=14)], Call(Attribute(Name('re', Load(), lineno=55, col_offset=17, end_lineno=55, end_col_offset=19), 'match', Load(), lineno=55, col_offset=17, end_lineno=55, end_col_offset=25), [Constant('\\* (.*)', lineno=55, col_offset=26, end_lineno=55, end_col_offset=36), Name('placeholder_7', Load(), lineno=55, col_offset=38, end_lineno=55, end_col_offset=44)], [], lineno=55, col_offset=17, end_lineno=55, end_col_offset=45), lineno=55, col_offset=4, end_lineno=55, end_col_offset=45), If(Name('placeholder_20', Load(), lineno=57, col_offset=7, end_lineno=57, end_col_offset=17), [If(UnaryOp(Not(), Name('placeholder_4', Load(), lineno=58, col_offset=15, end_lineno=58, end_col_offset=22), lineno=58, col_offset=11, end_lineno=58, end_col_offset=22), [Assign([Name('placeholder_7', Store(), lineno=59, col_offset=12, end_lineno=59, end_col_offset=18)], BinOp(Constant('
    ', lineno=59, col_offset=21, end_lineno=59, end_col_offset=27), Add(), Call(Name('placeholder_8', Load(), lineno=59, col_offset=30, end_lineno=59, end_col_offset=34), [Call(Attribute(Name('placeholder_20', Load(), lineno=59, col_offset=35, end_lineno=59, end_col_offset=45), 'group', Load(), lineno=59, col_offset=35, end_lineno=59, end_col_offset=51), [Constant(1, lineno=59, col_offset=52, end_lineno=59, end_col_offset=53)], [], lineno=59, col_offset=35, end_lineno=59, end_col_offset=54), Constant('li', lineno=59, col_offset=56, end_lineno=59, end_col_offset=60)], [], lineno=59, col_offset=30, end_lineno=59, end_col_offset=61), lineno=59, col_offset=21, end_lineno=59, end_col_offset=61), lineno=59, col_offset=12, end_lineno=59, end_col_offset=61), Assign([Name('placeholder_4', Store(), lineno=60, col_offset=12, end_lineno=60, end_col_offset=19)], Constant(True, lineno=60, col_offset=22, end_lineno=60, end_col_offset=26), lineno=60, col_offset=12, end_lineno=60, end_col_offset=26)], [Assign([Name('placeholder_7', Store(), lineno=62, col_offset=12, end_lineno=62, end_col_offset=18)], Call(Name('placeholder_8', Load(), lineno=62, col_offset=21, end_lineno=62, end_col_offset=25), [Call(Attribute(Name('placeholder_20', Load(), lineno=62, col_offset=26, end_lineno=62, end_col_offset=36), 'group', Load(), lineno=62, col_offset=26, end_lineno=62, end_col_offset=42), [Constant(1, lineno=62, col_offset=43, end_lineno=62, end_col_offset=44)], [], lineno=62, col_offset=26, end_lineno=62, end_col_offset=45), Constant('li', lineno=62, col_offset=47, end_lineno=62, end_col_offset=51)], [], lineno=62, col_offset=21, end_lineno=62, end_col_offset=52), lineno=62, col_offset=12, end_lineno=62, end_col_offset=52)], lineno=58, col_offset=8, end_lineno=62, end_col_offset=52)], [If(Name('placeholder_4', Load(), lineno=64, col_offset=11, end_lineno=64, end_col_offset=18), [Assign([Name('placeholder_5', Store(), lineno=65, col_offset=12, end_lineno=65, end_col_offset=26)], Constant(True, lineno=65, col_offset=29, end_lineno=65, end_col_offset=33), lineno=65, col_offset=12, end_lineno=65, end_col_offset=33), Assign([Name('placeholder_4', Store(), lineno=66, col_offset=12, end_lineno=66, end_col_offset=19)], Constant(False, lineno=66, col_offset=22, end_lineno=66, end_col_offset=27), lineno=66, col_offset=12, end_lineno=66, end_col_offset=27)], [], lineno=64, col_offset=8, end_lineno=66, end_col_offset=27)], lineno=57, col_offset=4, end_lineno=66, end_col_offset=27), If(UnaryOp(Not(), Call(Attribute(Name('re', Load(), lineno=68, col_offset=11, end_lineno=68, end_col_offset=13), 'match', Load(), lineno=68, col_offset=11, end_lineno=68, end_col_offset=19), [Constant(')(.*)()(.*)', lineno=72, col_offset=24, end_lineno=72, end_col_offset=51), Constant('\\1\\2

    \\3

    \\4\\5', lineno=73, col_offset=24, end_lineno=73, end_col_offset=44), Name('placeholder_7', Load(), lineno=73, col_offset=46, end_lineno=73, end_col_offset=52)], [], lineno=72, col_offset=17, end_lineno=73, end_col_offset=53), lineno=72, col_offset=8, end_lineno=73, end_col_offset=53)], [], lineno=71, col_offset=4, end_lineno=73, end_col_offset=53), While(Call(Name('placeholder_13', Load(), lineno=75, col_offset=10, end_lineno=75, end_col_offset=20), [Name('placeholder_7', Load(), lineno=75, col_offset=21, end_lineno=75, end_col_offset=27)], [], lineno=75, col_offset=10, end_lineno=75, end_col_offset=28), [Assign([Name('placeholder_7', Store(), lineno=76, col_offset=8, end_lineno=76, end_col_offset=14)], Call(Name('placeholder_13', Load(), lineno=76, col_offset=17, end_lineno=76, end_col_offset=27), [Name('placeholder_7', Load(), lineno=76, col_offset=28, end_lineno=76, end_col_offset=34)], [], lineno=76, col_offset=17, end_lineno=76, end_col_offset=35), lineno=76, col_offset=8, end_lineno=76, end_col_offset=35)], [], lineno=75, col_offset=4, end_lineno=76, end_col_offset=35), While(Call(Name('placeholder_16', Load(), lineno=77, col_offset=10, end_lineno=77, end_col_offset=22), [Name('placeholder_7', Load(), lineno=77, col_offset=23, end_lineno=77, end_col_offset=29)], [], lineno=77, col_offset=10, end_lineno=77, end_col_offset=30), [Assign([Name('placeholder_7', Store(), lineno=78, col_offset=8, end_lineno=78, end_col_offset=14)], Call(Name('placeholder_16', Load(), lineno=78, col_offset=17, end_lineno=78, end_col_offset=29), [Name('placeholder_7', Load(), lineno=78, col_offset=30, end_lineno=78, end_col_offset=36)], [], lineno=78, col_offset=17, end_lineno=78, end_col_offset=37), lineno=78, col_offset=8, end_lineno=78, end_col_offset=37)], [], lineno=77, col_offset=4, end_lineno=78, end_col_offset=37), If(Name('placeholder_5', Load(), lineno=80, col_offset=7, end_lineno=80, end_col_offset=21), [Assign([Name('placeholder_7', Store(), lineno=81, col_offset=8, end_lineno=81, end_col_offset=14)], BinOp(Constant('
', lineno=81, col_offset=17, end_lineno=81, end_col_offset=24), Add(), Name('placeholder_7', Load(), lineno=81, col_offset=27, end_lineno=81, end_col_offset=33), lineno=81, col_offset=17, end_lineno=81, end_col_offset=33), lineno=81, col_offset=8, end_lineno=81, end_col_offset=33), Assign([Name('placeholder_5', Store(), lineno=82, col_offset=8, end_lineno=82, end_col_offset=22)], Constant(False, lineno=82, col_offset=25, end_lineno=82, end_col_offset=30), lineno=82, col_offset=8, end_lineno=82, end_col_offset=30)], [], lineno=80, col_offset=4, end_lineno=82, end_col_offset=30), Return(Dict([Constant('line', lineno=85, col_offset=8, end_lineno=85, end_col_offset=14), Constant('in_list', lineno=86, col_offset=8, end_lineno=86, end_col_offset=17), Constant('in_list_append', lineno=87, col_offset=8, end_lineno=87, end_col_offset=24)], [Name('placeholder_7', Load(), lineno=85, col_offset=16, end_lineno=85, end_col_offset=22), Name('placeholder_4', Load(), lineno=86, col_offset=19, end_lineno=86, end_col_offset=26), Name('placeholder_5', Load(), lineno=87, col_offset=26, end_lineno=87, end_col_offset=40)], lineno=84, col_offset=11, end_lineno=88, end_col_offset=5), lineno=84, col_offset=4, end_lineno=88, end_col_offset=5)], [], lineno=52, col_offset=0, end_lineno=88, end_col_offset=5)], []) \ No newline at end of file diff --git a/test/practice-matching-brackets/.meta/config.json b/test/practice-matching-brackets/.meta/config.json new file mode 100644 index 0000000..b07c1ab --- /dev/null +++ b/test/practice-matching-brackets/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "atg-abhishek", + "BethanyG", + "cmccandless", + "Dog", + "ikhadykin", + "kylecjo", + "N-Parsons", + "Nishant23", + "pheanex", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "matching_brackets.py" + ], + "test": [ + "matching_brackets_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Make sure the brackets and braces all match.", + "source": "Ginna Baker" +} diff --git a/test/practice-matching-brackets/mapping.json b/test/practice-matching-brackets/mapping.json new file mode 100644 index 0000000..6144f3e --- /dev/null +++ b/test/practice-matching-brackets/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "is_paired", + "placeholder_1": "input_string", + "placeholder_2": "counterparts", + "placeholder_3": "stack", + "placeholder_4": "char" +} \ No newline at end of file diff --git a/test/practice-matching-brackets/matching_brackets.py b/test/practice-matching-brackets/matching_brackets.py new file mode 100644 index 0000000..b37f132 --- /dev/null +++ b/test/practice-matching-brackets/matching_brackets.py @@ -0,0 +1,13 @@ +def is_paired(input_string): + counterparts = {')': '(', '}': '{', ']': '['} + + stack = [] + for char in input_string: + if char in counterparts.values(): + stack.append(char) + elif char in counterparts: + if not stack: + return False + if stack.pop() != counterparts[char]: + return False + return not stack diff --git a/test/practice-matching-brackets/representation.json b/test/practice-matching-brackets/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-matching-brackets/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-matching-brackets/representation.out b/test/practice-matching-brackets/representation.out new file mode 100644 index 0000000..471253c --- /dev/null +++ b/test/practice-matching-brackets/representation.out @@ -0,0 +1,703 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = {")": "(", "}": "{", "]": "["} + placeholder_3 = [] + for placeholder_4 in placeholder_1: + if placeholder_4 in placeholder_2.values(): + placeholder_3.append(placeholder_4) + elif placeholder_4 in placeholder_2: + if not placeholder_3: + return False + if placeholder_3.pop() != placeholder_2[placeholder_4]: + return False + return not placeholder_3 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'is_paired', + arguments( + [], + [ + arg( + 'input_string', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'counterparts', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=16)], + Dict( + [ + Constant( + ')', + lineno=2, + col_offset=20, + end_lineno=2, + end_col_offset=23), + Constant( + '}', + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=33), + Constant( + ']', + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=43)], + [ + Constant( + '(', + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=28), + Constant( + '{', + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=38), + Constant( + '[', + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=48)], + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=49), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=49), + Assign( + [ + Name( + 'stack', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=9)], + List( + [], + Load(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=14), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=14), + For( + Name( + 'char', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + Name( + 'input_string', + Load(), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=28), + [ + If( + Compare( + Name( + 'char', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=15), + [ + In()], + [ + Call( + Attribute( + Name( + 'counterparts', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=31), + 'values', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=38), + [], + [], + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=40)], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=40), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=17), + 'append', + Load(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=24), + [ + Name( + 'char', + Load(), + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=29)], + [], + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=30), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=30)], + [ + If( + Compare( + Name( + 'char', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=17), + [ + In()], + [ + Name( + 'counterparts', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=33)], + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=33), + [ + If( + UnaryOp( + Not(), + Name( + 'stack', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=24), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=24), + [ + Return( + Constant( + False, + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=28), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=28)], + [], + lineno=9, + col_offset=12, + end_lineno=10, + end_col_offset=28), + If( + Compare( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=20), + 'pop', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + [], + [], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=26), + [ + NotEq()], + [ + Subscript( + Name( + 'counterparts', + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=42), + Name( + 'char', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=47), + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=48)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=48), + [ + Return( + Constant( + False, + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=28), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=28)], + [], + lineno=11, + col_offset=12, + end_lineno=12, + end_col_offset=28)], + [], + lineno=8, + col_offset=8, + end_lineno=12, + end_col_offset=28)], + lineno=6, + col_offset=8, + end_lineno=12, + end_col_offset=28)], + [], + lineno=5, + col_offset=4, + end_lineno=12, + end_col_offset=28), + Return( + UnaryOp( + Not(), + Name( + 'stack', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=20), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=20), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=20)], + [], + lineno=1, + col_offset=0, + end_lineno=13, + end_col_offset=20)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=16)], + Dict( + [ + Constant( + ')', + lineno=2, + col_offset=20, + end_lineno=2, + end_col_offset=23), + Constant( + '}', + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=33), + Constant( + ']', + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=43)], + [ + Constant( + '(', + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=28), + Constant( + '{', + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=38), + Constant( + '[', + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=48)], + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=49), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=49), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=9)], + List( + [], + Load(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=14), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=14), + For( + Name( + 'placeholder_4', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=28), + [ + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=15), + [ + In()], + [ + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=31), + 'values', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=38), + [], + [], + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=40)], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=40), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=17), + 'append', + Load(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=24), + [ + Name( + 'placeholder_4', + Load(), + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=29)], + [], + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=30), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=30)], + [ + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=17), + [ + In()], + [ + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=33)], + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=33), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=24), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=24), + [ + Return( + Constant( + False, + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=28), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=28)], + [], + lineno=9, + col_offset=12, + end_lineno=10, + end_col_offset=28), + If( + Compare( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=20), + 'pop', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + [], + [], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=26), + [ + NotEq()], + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=42), + Name( + 'placeholder_4', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=47), + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=48)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=48), + [ + Return( + Constant( + False, + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=28), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=28)], + [], + lineno=11, + col_offset=12, + end_lineno=12, + end_col_offset=28)], + [], + lineno=8, + col_offset=8, + end_lineno=12, + end_col_offset=28)], + lineno=6, + col_offset=8, + end_lineno=12, + end_col_offset=28)], + [], + lineno=5, + col_offset=4, + end_lineno=12, + end_col_offset=28), + Return( + UnaryOp( + Not(), + Name( + 'placeholder_3', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=20), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=20), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=20)], + [], + lineno=1, + col_offset=0, + end_lineno=13, + end_col_offset=20)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-matching-brackets/representation.txt b/test/practice-matching-brackets/representation.txt new file mode 100644 index 0000000..b9bf55a --- /dev/null +++ b/test/practice-matching-brackets/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=14, end_lineno=1, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=16)], Dict([Constant(')', lineno=2, col_offset=20, end_lineno=2, end_col_offset=23), Constant('}', lineno=2, col_offset=30, end_lineno=2, end_col_offset=33), Constant(']', lineno=2, col_offset=40, end_lineno=2, end_col_offset=43)], [Constant('(', lineno=2, col_offset=25, end_lineno=2, end_col_offset=28), Constant('{', lineno=2, col_offset=35, end_lineno=2, end_col_offset=38), Constant('[', lineno=2, col_offset=45, end_lineno=2, end_col_offset=48)], lineno=2, col_offset=19, end_lineno=2, end_col_offset=49), lineno=2, col_offset=4, end_lineno=2, end_col_offset=49), Assign([Name('placeholder_3', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=9)], List([], Load(), lineno=4, col_offset=12, end_lineno=4, end_col_offset=14), lineno=4, col_offset=4, end_lineno=4, end_col_offset=14), For(Name('placeholder_4', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=12), Name('placeholder_1', Load(), lineno=5, col_offset=16, end_lineno=5, end_col_offset=28), [If(Compare(Name('placeholder_4', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=15), [In()], [Call(Attribute(Name('placeholder_2', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=31), 'values', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=38), [], [], lineno=6, col_offset=19, end_lineno=6, end_col_offset=40)], lineno=6, col_offset=11, end_lineno=6, end_col_offset=40), [Expr(Call(Attribute(Name('placeholder_3', Load(), lineno=7, col_offset=12, end_lineno=7, end_col_offset=17), 'append', Load(), lineno=7, col_offset=12, end_lineno=7, end_col_offset=24), [Name('placeholder_4', Load(), lineno=7, col_offset=25, end_lineno=7, end_col_offset=29)], [], lineno=7, col_offset=12, end_lineno=7, end_col_offset=30), lineno=7, col_offset=12, end_lineno=7, end_col_offset=30)], [If(Compare(Name('placeholder_4', Load(), lineno=8, col_offset=13, end_lineno=8, end_col_offset=17), [In()], [Name('placeholder_2', Load(), lineno=8, col_offset=21, end_lineno=8, end_col_offset=33)], lineno=8, col_offset=13, end_lineno=8, end_col_offset=33), [If(UnaryOp(Not(), Name('placeholder_3', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=24), lineno=9, col_offset=15, end_lineno=9, end_col_offset=24), [Return(Constant(False, lineno=10, col_offset=23, end_lineno=10, end_col_offset=28), lineno=10, col_offset=16, end_lineno=10, end_col_offset=28)], [], lineno=9, col_offset=12, end_lineno=10, end_col_offset=28), If(Compare(Call(Attribute(Name('placeholder_3', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=20), 'pop', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=24), [], [], lineno=11, col_offset=15, end_lineno=11, end_col_offset=26), [NotEq()], [Subscript(Name('placeholder_2', Load(), lineno=11, col_offset=30, end_lineno=11, end_col_offset=42), Name('placeholder_4', Load(), lineno=11, col_offset=43, end_lineno=11, end_col_offset=47), Load(), lineno=11, col_offset=30, end_lineno=11, end_col_offset=48)], lineno=11, col_offset=15, end_lineno=11, end_col_offset=48), [Return(Constant(False, lineno=12, col_offset=23, end_lineno=12, end_col_offset=28), lineno=12, col_offset=16, end_lineno=12, end_col_offset=28)], [], lineno=11, col_offset=12, end_lineno=12, end_col_offset=28)], [], lineno=8, col_offset=8, end_lineno=12, end_col_offset=28)], lineno=6, col_offset=8, end_lineno=12, end_col_offset=28)], [], lineno=5, col_offset=4, end_lineno=12, end_col_offset=28), Return(UnaryOp(Not(), Name('placeholder_3', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=20), lineno=13, col_offset=11, end_lineno=13, end_col_offset=20), lineno=13, col_offset=4, end_lineno=13, end_col_offset=20)], [], lineno=1, col_offset=0, end_lineno=13, end_col_offset=20)], []) \ No newline at end of file diff --git a/test/practice-matrix/.meta/config.json b/test/practice-matrix/.meta/config.json new file mode 100644 index 0000000..544b7bb --- /dev/null +++ b/test/practice-matrix/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "AnAccountForReportingBugs", + "behrtam", + "BethanyG", + "cmccandless", + "danishprakash", + "Dog", + "kytrinyx", + "N-Parsons", + "pheanex", + "simmol", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "matrix.py" + ], + "test": [ + "matrix_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a string representing a matrix of numbers, return the rows and columns of that matrix.", + "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", + "source_url": "https://turing.edu" +} diff --git a/test/practice-matrix/mapping.json b/test/practice-matrix/mapping.json new file mode 100644 index 0000000..833fd44 --- /dev/null +++ b/test/practice-matrix/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "Matrix", + "placeholder_1": "__init__", + "placeholder_2": "matrix_string", + "placeholder_3": "rows", + "placeholder_4": "number", + "placeholder_5": "row", + "placeholder_6": "placeholder_4", + "placeholder_7": "columns", + "placeholder_8": "tup", + "placeholder_9": "index", + "placeholder_10": "column" +} \ No newline at end of file diff --git a/test/practice-matrix/matrix.py b/test/practice-matrix/matrix.py new file mode 100644 index 0000000..3c89844 --- /dev/null +++ b/test/practice-matrix/matrix.py @@ -0,0 +1,11 @@ +class Matrix: + def __init__(self, matrix_string): + self.rows = [[int(number) for number in row.split()] + for row in matrix_string.split('\n')] + self.columns = [list(tup) for tup in zip(*self.rows)] + + def row(self, index): + return self.rows[index - 1] + + def column(self, index): + return self.columns[index - 1] diff --git a/test/practice-matrix/representation.json b/test/practice-matrix/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-matrix/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-matrix/representation.out b/test/practice-matrix/representation.out new file mode 100644 index 0000000..165090e --- /dev/null +++ b/test/practice-matrix/representation.out @@ -0,0 +1,806 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2): + self.placeholder_3 = [ + [int(placeholder_6) for placeholder_6 in placeholder_5.split()] + for placeholder_5 in placeholder_2.split("\n") + ] + self.placeholder_7 = [ + list(placeholder_8) for placeholder_8 in zip(*self.placeholder_3) + ] + + def placeholder_5(self, placeholder_9): + return self.placeholder_3[placeholder_9 - 1] + + def placeholder_10(self, placeholder_9): + return self.placeholder_7[placeholder_9 - 1] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Matrix', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'matrix_string', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'rows', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=17)], + ListComp( + ListComp( + Call( + Name( + 'int', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=25), + [ + Name( + 'number', + Load(), + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=32)], + [], + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=33), + [ + comprehension( + Name( + 'number', + Store(), + lineno=3, + col_offset=38, + end_lineno=3, + end_col_offset=44), + Call( + Attribute( + Name( + 'row', + Load(), + lineno=3, + col_offset=48, + end_lineno=3, + end_col_offset=51), + 'split', + Load(), + lineno=3, + col_offset=48, + end_lineno=3, + end_col_offset=57), + [], + [], + lineno=3, + col_offset=48, + end_lineno=3, + end_col_offset=59), + [], + 0)], + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=60), + [ + comprehension( + Name( + 'row', + Store(), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=28), + Call( + Attribute( + Name( + 'matrix_string', + Load(), + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=45), + 'split', + Load(), + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=51), + [ + Constant( + '\n', + lineno=4, + col_offset=52, + end_lineno=4, + end_col_offset=56)], + [], + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=57), + [], + 0)], + lineno=3, + col_offset=20, + end_lineno=4, + end_col_offset=58), + lineno=3, + col_offset=8, + end_lineno=4, + end_col_offset=58), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'columns', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=20)], + ListComp( + Call( + Name( + 'list', + Load(), + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=28), + [ + Name( + 'tup', + Load(), + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=32)], + [], + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=33), + [ + comprehension( + Name( + 'tup', + Store(), + lineno=5, + col_offset=38, + end_lineno=5, + end_col_offset=41), + Call( + Name( + 'zip', + Load(), + lineno=5, + col_offset=45, + end_lineno=5, + end_col_offset=48), + [ + Starred( + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=50, + end_lineno=5, + end_col_offset=54), + 'rows', + Load(), + lineno=5, + col_offset=50, + end_lineno=5, + end_col_offset=59), + Load(), + lineno=5, + col_offset=49, + end_lineno=5, + end_col_offset=59)], + [], + lineno=5, + col_offset=45, + end_lineno=5, + end_col_offset=60), + [], + 0)], + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=61), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=61)], + [], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=61), + FunctionDef( + 'row', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=16), + arg( + 'index', + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=19), + 'rows', + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=24), + BinOp( + Name( + 'index', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=30), + Sub(), + Constant( + 1, + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=34), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=34), + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=35), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=35)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=35), + FunctionDef( + 'column', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=19), + arg( + 'index', + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=19), + 'columns', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=27), + BinOp( + Name( + 'index', + Load(), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=33), + Sub(), + Constant( + 1, + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=37), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=37), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=38), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=38)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=38)], + [], + lineno=1, + col_offset=0, + end_lineno=11, + end_col_offset=38)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=17)], + ListComp( + ListComp( + Call( + Name( + 'int', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=25), + [ + Name( + 'placeholder_6', + Load(), + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=32)], + [], + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=33), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=3, + col_offset=38, + end_lineno=3, + end_col_offset=44), + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=3, + col_offset=48, + end_lineno=3, + end_col_offset=51), + 'split', + Load(), + lineno=3, + col_offset=48, + end_lineno=3, + end_col_offset=57), + [], + [], + lineno=3, + col_offset=48, + end_lineno=3, + end_col_offset=59), + [], + 0)], + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=60), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=28), + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=45), + 'split', + Load(), + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=51), + [ + Constant( + '\n', + lineno=4, + col_offset=52, + end_lineno=4, + end_col_offset=56)], + [], + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=57), + [], + 0)], + lineno=3, + col_offset=20, + end_lineno=4, + end_col_offset=58), + lineno=3, + col_offset=8, + end_lineno=4, + end_col_offset=58), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=20)], + ListComp( + Call( + Name( + 'list', + Load(), + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=28), + [ + Name( + 'placeholder_8', + Load(), + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=32)], + [], + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=33), + [ + comprehension( + Name( + 'placeholder_8', + Store(), + lineno=5, + col_offset=38, + end_lineno=5, + end_col_offset=41), + Call( + Name( + 'zip', + Load(), + lineno=5, + col_offset=45, + end_lineno=5, + end_col_offset=48), + [ + Starred( + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=50, + end_lineno=5, + end_col_offset=54), + 'placeholder_3', + Load(), + lineno=5, + col_offset=50, + end_lineno=5, + end_col_offset=59), + Load(), + lineno=5, + col_offset=49, + end_lineno=5, + end_col_offset=59)], + [], + lineno=5, + col_offset=45, + end_lineno=5, + end_col_offset=60), + [], + 0)], + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=61), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=61)], + [], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=61), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=16), + arg( + 'placeholder_9', + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=19), + 'placeholder_3', + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=24), + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=30), + Sub(), + Constant( + 1, + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=34), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=34), + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=35), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=35)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=35), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=19), + arg( + 'placeholder_9', + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=27), + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=33), + Sub(), + Constant( + 1, + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=37), + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=37), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=38), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=38)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=38)], + [], + lineno=1, + col_offset=0, + end_lineno=11, + end_col_offset=38)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-matrix/representation.txt b/test/practice-matrix/representation.txt new file mode 100644 index 0000000..9ca163c --- /dev/null +++ b/test/practice-matrix/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=36)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_3', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=17)], ListComp(ListComp(Call(Name('int', Load(), lineno=3, col_offset=22, end_lineno=3, end_col_offset=25), [Name('placeholder_6', Load(), lineno=3, col_offset=26, end_lineno=3, end_col_offset=32)], [], lineno=3, col_offset=22, end_lineno=3, end_col_offset=33), [comprehension(Name('placeholder_6', Store(), lineno=3, col_offset=38, end_lineno=3, end_col_offset=44), Call(Attribute(Name('placeholder_5', Load(), lineno=3, col_offset=48, end_lineno=3, end_col_offset=51), 'split', Load(), lineno=3, col_offset=48, end_lineno=3, end_col_offset=57), [], [], lineno=3, col_offset=48, end_lineno=3, end_col_offset=59), [], 0)], lineno=3, col_offset=21, end_lineno=3, end_col_offset=60), [comprehension(Name('placeholder_5', Store(), lineno=4, col_offset=25, end_lineno=4, end_col_offset=28), Call(Attribute(Name('placeholder_2', Load(), lineno=4, col_offset=32, end_lineno=4, end_col_offset=45), 'split', Load(), lineno=4, col_offset=32, end_lineno=4, end_col_offset=51), [Constant('\n', lineno=4, col_offset=52, end_lineno=4, end_col_offset=56)], [], lineno=4, col_offset=32, end_lineno=4, end_col_offset=57), [], 0)], lineno=3, col_offset=20, end_lineno=4, end_col_offset=58), lineno=3, col_offset=8, end_lineno=4, end_col_offset=58), Assign([Attribute(Name('self', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=12), 'placeholder_7', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=20)], ListComp(Call(Name('list', Load(), lineno=5, col_offset=24, end_lineno=5, end_col_offset=28), [Name('placeholder_8', Load(), lineno=5, col_offset=29, end_lineno=5, end_col_offset=32)], [], lineno=5, col_offset=24, end_lineno=5, end_col_offset=33), [comprehension(Name('placeholder_8', Store(), lineno=5, col_offset=38, end_lineno=5, end_col_offset=41), Call(Name('zip', Load(), lineno=5, col_offset=45, end_lineno=5, end_col_offset=48), [Starred(Attribute(Name('self', Load(), lineno=5, col_offset=50, end_lineno=5, end_col_offset=54), 'placeholder_3', Load(), lineno=5, col_offset=50, end_lineno=5, end_col_offset=59), Load(), lineno=5, col_offset=49, end_lineno=5, end_col_offset=59)], [], lineno=5, col_offset=45, end_lineno=5, end_col_offset=60), [], 0)], lineno=5, col_offset=23, end_lineno=5, end_col_offset=61), lineno=5, col_offset=8, end_lineno=5, end_col_offset=61)], [], lineno=2, col_offset=4, end_lineno=5, end_col_offset=61), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=7, col_offset=12, end_lineno=7, end_col_offset=16), arg('placeholder_9', lineno=7, col_offset=18, end_lineno=7, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Subscript(Attribute(Name('self', Load(), lineno=8, col_offset=15, end_lineno=8, end_col_offset=19), 'placeholder_3', Load(), lineno=8, col_offset=15, end_lineno=8, end_col_offset=24), BinOp(Name('placeholder_9', Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=30), Sub(), Constant(1, lineno=8, col_offset=33, end_lineno=8, end_col_offset=34), lineno=8, col_offset=25, end_lineno=8, end_col_offset=34), Load(), lineno=8, col_offset=15, end_lineno=8, end_col_offset=35), lineno=8, col_offset=8, end_lineno=8, end_col_offset=35)], [], lineno=7, col_offset=4, end_lineno=8, end_col_offset=35), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=10, col_offset=15, end_lineno=10, end_col_offset=19), arg('placeholder_9', lineno=10, col_offset=21, end_lineno=10, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Subscript(Attribute(Name('self', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=19), 'placeholder_7', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=27), BinOp(Name('placeholder_9', Load(), lineno=11, col_offset=28, end_lineno=11, end_col_offset=33), Sub(), Constant(1, lineno=11, col_offset=36, end_lineno=11, end_col_offset=37), lineno=11, col_offset=28, end_lineno=11, end_col_offset=37), Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=38), lineno=11, col_offset=8, end_lineno=11, end_col_offset=38)], [], lineno=10, col_offset=4, end_lineno=11, end_col_offset=38)], [], lineno=1, col_offset=0, end_lineno=11, end_col_offset=38)], []) \ No newline at end of file diff --git a/test/practice-meetup/.meta/additional_tests.json b/test/practice-meetup/.meta/additional_tests.json new file mode 100644 index 0000000..67b4251 --- /dev/null +++ b/test/practice-meetup/.meta/additional_tests.json @@ -0,0 +1,92 @@ +{ + "cases": [ + { + "description": "fifth Monday of March 2015", + "property": "meetup", + "input": { + "year": 2015, + "month": 3, + "week": "fifth", + "dayofweek": "Monday" + }, + "expected": "2015-03-30" + }, + { + "description": "fifth Thursday of February 2024", + "property": "meetup", + "input": { + "year": 2024, + "month": 2, + "week": "fifth", + "dayofweek": "Thursday" + }, + "expected": "2024-02-29" + }, + { + "description": "fifth Saturday of February 2020", + "property": "meetup", + "input": { + "year": 2020, + "month": 2, + "week": "fifth", + "dayofweek": "Saturday" + }, + "expected": "2020-02-29" + }, + { + "description": "last Sunday of June 2024", + "property": "meetup", + "input": { + "year": 2024, + "month": 6, + "week": "last", + "dayofweek": "Sunday" + }, + "expected": "2024-06-30" + }, + { + "description": "teenth Friday of May 2022", + "property": "meetup", + "input": { + "year": 2022, + "month": 5, + "week": "teenth", + "dayofweek": "Friday" + }, + "expected": "2022-05-13" + }, + { + "description": "nonexistent fifth Monday of February 2022", + "property": "meetup", + "input": { + "year": 2022, + "month": 2, + "week": "fifth", + "dayofweek": "Monday" + }, + "expected": {"error": "That day does not exist."} + }, + { + "description": "nonexistent fifth Friday of August 2022", + "property": "meetup", + "input": { + "year": 2022, + "month": 8, + "week": "fifth", + "dayofweek": "Friday" + }, + "expected": {"error": "That day does not exist."} + }, + { + "description": "nonexistent fifth Thursday of May 2023", + "property": "meetup", + "input": { + "year": 2023, + "month": 5, + "week": "fifth", + "dayofweek": "Thursday" + }, + "expected": {"error": "That day does not exist."} + } + ] +} diff --git a/test/practice-meetup/.meta/config.json b/test/practice-meetup/.meta/config.json new file mode 100644 index 0000000..9a08a5d --- /dev/null +++ b/test/practice-meetup/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "acedrew", + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "dvermd", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "Peque", + "pheanex", + "tqa236", + "ZacharyRSmith" + ], + "files": { + "solution": [ + "meetup.py" + ], + "test": [ + "meetup_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Calculate the date of meetups.", + "source": "Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month", + "source_url": "http://www.copiousfreetime.org/" +} diff --git a/test/practice-meetup/mapping.json b/test/practice-meetup/mapping.json new file mode 100644 index 0000000..8649cff --- /dev/null +++ b/test/practice-meetup/mapping.json @@ -0,0 +1,17 @@ +{ + "placeholder_0": "meetup", + "placeholder_1": "year", + "placeholder_2": "month", + "placeholder_3": "week", + "placeholder_4": "day_of_week", + "placeholder_5": "candidates", + "placeholder_6": "date", + "placeholder_7": "_choice", + "placeholder_8": "dates", + "placeholder_9": "ordinals", + "placeholder_10": "day", + "placeholder_11": "_func", + "placeholder_12": "MeetupDayException", + "placeholder_13": "__init__", + "placeholder_14": "message" +} \ No newline at end of file diff --git a/test/practice-meetup/meetup.py b/test/practice-meetup/meetup.py new file mode 100644 index 0000000..d547107 --- /dev/null +++ b/test/practice-meetup/meetup.py @@ -0,0 +1,34 @@ +from calendar import Calendar + + +def meetup(year, month, week, day_of_week): + candidates = [date + for date in Calendar().itermonthdates(year, month) + if date.month == month + if date.strftime('%A') == day_of_week] + return _choice(week)(candidates) + + +def _choice(week): + if week == 'teenth': + return lambda dates: next(date for date in dates if + 13 <= date.day <= 19) + + ordinals = ('first', 'second', 'third', 'fourth', 'fifth', 'sixth') + day = -1 if (week == 'last') else (ordinals.index(week)) + + def _func(dates): + if day < len(dates): + return dates[day] + raise MeetupDayException('That day does not exist.') + return _func + + +class MeetupDayException(ValueError): + """Exception raised when the Meetup weekday and count do not result in a valid date. + + message: explanation of the error. + + """ + def __init__(self, message): + self.message = message diff --git a/test/practice-meetup/representation.json b/test/practice-meetup/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-meetup/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-meetup/representation.out b/test/practice-meetup/representation.out new file mode 100644 index 0000000..3a49841 --- /dev/null +++ b/test/practice-meetup/representation.out @@ -0,0 +1,1504 @@ +## BEGIN NORMALIZED CODE ## +from calendar import Calendar + + +def placeholder_0(placeholder_1, placeholder_2, placeholder_3, placeholder_4): + placeholder_5 = [ + placeholder_6 + for placeholder_6 in Calendar().itermonthdates(placeholder_1, placeholder_2) + if placeholder_6.placeholder_2 == placeholder_2 + if placeholder_6.strftime("%A") == placeholder_4 + ] + return _choice(placeholder_3)(placeholder_5) + + +def placeholder_7(placeholder_3): + if placeholder_3 == "teenth": + return lambda placeholder_8: next( + ( + placeholder_6 + for placeholder_6 in placeholder_8 + if 13 <= placeholder_6.day <= 19 + ) + ) + placeholder_9 = ("first", "second", "third", "fourth", "fifth", "sixth") + placeholder_10 = ( + -1 if placeholder_3 == "last" else placeholder_9.index(placeholder_3) + ) + + def placeholder_11(placeholder_8): + if placeholder_10 < len(placeholder_8): + return placeholder_8[placeholder_10] + raise MeetupDayException("That day does not exist.") + + return placeholder_11 + + +class placeholder_12(ValueError): + def placeholder_13(self, placeholder_14): + self.placeholder_14 = placeholder_14 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'calendar', + [ + alias( + 'Calendar', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=29)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=29), + FunctionDef( + 'meetup', + arguments( + [], + [ + arg( + 'year', + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=15), + arg( + 'month', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=22), + arg( + 'week', + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=28), + arg( + 'day_of_week', + lineno=4, + col_offset=30, + end_lineno=4, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'candidates', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=14)], + ListComp( + Name( + 'date', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=22), + [ + comprehension( + Name( + 'date', + Store(), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=26), + Call( + Attribute( + Call( + Name( + 'Calendar', + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=38), + [], + [], + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=40), + 'itermonthdates', + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=55), + [ + Name( + 'year', + Load(), + lineno=6, + col_offset=56, + end_lineno=6, + end_col_offset=60), + Name( + 'month', + Load(), + lineno=6, + col_offset=62, + end_lineno=6, + end_col_offset=67)], + [], + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=68), + [ + Compare( + Attribute( + Name( + 'date', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=25), + 'month', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=31), + [ + Eq()], + [ + Name( + 'month', + Load(), + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=40)], + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=40), + Compare( + Call( + Attribute( + Name( + 'date', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=25), + 'strftime', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=34), + [ + Constant( + '%A', + lineno=8, + col_offset=35, + end_lineno=8, + end_col_offset=39)], + [], + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=40), + [ + Eq()], + [ + Name( + 'day_of_week', + Load(), + lineno=8, + col_offset=44, + end_lineno=8, + end_col_offset=55)], + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=55)], + 0)], + lineno=5, + col_offset=17, + end_lineno=8, + end_col_offset=56), + lineno=5, + col_offset=4, + end_lineno=8, + end_col_offset=56), + Return( + Call( + Call( + Name( + '_choice', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + [ + Name( + 'week', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=23)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=24), + [ + Name( + 'candidates', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=35)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=36)], + [], + lineno=4, + col_offset=0, + end_lineno=9, + end_col_offset=36), + FunctionDef( + '_choice', + arguments( + [], + [ + arg( + 'week', + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'week', + Load(), + lineno=13, + col_offset=7, + end_lineno=13, + end_col_offset=11), + [ + Eq()], + [ + Constant( + 'teenth', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=23)], + lineno=13, + col_offset=7, + end_lineno=13, + end_col_offset=23), + [ + Return( + Lambda( + arguments( + [], + [ + arg( + 'dates', + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'next', + Load(), + lineno=14, + col_offset=29, + end_lineno=14, + end_col_offset=33), + [ + GeneratorExp( + Name( + 'date', + Load(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=38), + [ + comprehension( + Name( + 'date', + Store(), + lineno=14, + col_offset=43, + end_lineno=14, + end_col_offset=47), + Name( + 'dates', + Load(), + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=56), + [ + Compare( + Constant( + 13, + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=36), + [ + LtE(), + LtE()], + [ + Attribute( + Name( + 'date', + Load(), + lineno=15, + col_offset=40, + end_lineno=15, + end_col_offset=44), + 'day', + Load(), + lineno=15, + col_offset=40, + end_lineno=15, + end_col_offset=48), + Constant( + 19, + lineno=15, + col_offset=52, + end_lineno=15, + end_col_offset=54)], + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=54)], + 0)], + lineno=14, + col_offset=33, + end_lineno=15, + end_col_offset=55)], + [], + lineno=14, + col_offset=29, + end_lineno=15, + end_col_offset=55), + lineno=14, + col_offset=15, + end_lineno=15, + end_col_offset=55), + lineno=14, + col_offset=8, + end_lineno=15, + end_col_offset=55)], + [], + lineno=13, + col_offset=4, + end_lineno=15, + end_col_offset=55), + Assign( + [ + Name( + 'ordinals', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=12)], + Tuple( + [ + Constant( + 'first', + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=23), + Constant( + 'second', + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=33), + Constant( + 'third', + lineno=17, + col_offset=35, + end_lineno=17, + end_col_offset=42), + Constant( + 'fourth', + lineno=17, + col_offset=44, + end_lineno=17, + end_col_offset=52), + Constant( + 'fifth', + lineno=17, + col_offset=54, + end_lineno=17, + end_col_offset=61), + Constant( + 'sixth', + lineno=17, + col_offset=63, + end_lineno=17, + end_col_offset=70)], + Load(), + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=71), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=71), + Assign( + [ + Name( + 'day', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=7)], + IfExp( + Compare( + Name( + 'week', + Load(), + lineno=18, + col_offset=17, + end_lineno=18, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'last', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=31)], + lineno=18, + col_offset=17, + end_lineno=18, + end_col_offset=31), + UnaryOp( + USub(), + Constant( + 1, + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=12), + lineno=18, + col_offset=10, + end_lineno=18, + end_col_offset=12), + Call( + Attribute( + Name( + 'ordinals', + Load(), + lineno=18, + col_offset=39, + end_lineno=18, + end_col_offset=47), + 'index', + Load(), + lineno=18, + col_offset=39, + end_lineno=18, + end_col_offset=53), + [ + Name( + 'week', + Load(), + lineno=18, + col_offset=54, + end_lineno=18, + end_col_offset=58)], + [], + lineno=18, + col_offset=39, + end_lineno=18, + end_col_offset=59), + lineno=18, + col_offset=10, + end_lineno=18, + end_col_offset=60), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=60), + FunctionDef( + '_func', + arguments( + [], + [ + arg( + 'dates', + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'day', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=14), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=20), + [ + Name( + 'dates', + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=26)], + [], + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=27)], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=27), + [ + Return( + Subscript( + Name( + 'dates', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=24), + Name( + 'day', + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=28), + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=29), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=29)], + [], + lineno=21, + col_offset=8, + end_lineno=22, + end_col_offset=29), + Raise( + Call( + Name( + 'MeetupDayException', + Load(), + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=32), + [ + Constant( + 'That day does not exist.', + lineno=23, + col_offset=33, + end_lineno=23, + end_col_offset=59)], + [], + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=60), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=60)], + [], + lineno=20, + col_offset=4, + end_lineno=23, + end_col_offset=60), + Return( + Name( + '_func', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=16), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=16)], + [], + lineno=12, + col_offset=0, + end_lineno=24, + end_col_offset=16), + ClassDef( + 'MeetupDayException', + [ + Name( + 'ValueError', + Load(), + lineno=27, + col_offset=25, + end_lineno=27, + end_col_offset=35)], + [], + [ + Expr( + Constant( + 'Exception raised when the Meetup weekday and count do not result in a valid date.\n\n message: explanation of the error.\n\n ', + lineno=28, + col_offset=4, + end_lineno=32, + end_col_offset=7), + lineno=28, + col_offset=4, + end_lineno=32, + end_col_offset=7), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=21), + arg( + 'message', + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'message', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=20)], + Name( + 'message', + Load(), + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=30), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=30)], + [], + lineno=33, + col_offset=4, + end_lineno=34, + end_col_offset=30)], + [], + lineno=27, + col_offset=0, + end_lineno=34, + end_col_offset=30)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'calendar', + [ + alias( + 'Calendar', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=29)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=29), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=15), + arg( + 'placeholder_2', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=22), + arg( + 'placeholder_3', + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=28), + arg( + 'placeholder_4', + lineno=4, + col_offset=30, + end_lineno=4, + end_col_offset=41)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=14)], + ListComp( + Name( + 'placeholder_6', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=22), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=26), + Call( + Attribute( + Call( + Name( + 'Calendar', + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=38), + [], + [], + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=40), + 'itermonthdates', + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=55), + [ + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=56, + end_lineno=6, + end_col_offset=60), + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=62, + end_lineno=6, + end_col_offset=67)], + [], + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=68), + [ + Compare( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=25), + 'placeholder_2', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=31), + [ + Eq()], + [ + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=40)], + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=40), + Compare( + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=25), + 'strftime', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=34), + [ + Constant( + '%A', + lineno=8, + col_offset=35, + end_lineno=8, + end_col_offset=39)], + [], + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=40), + [ + Eq()], + [ + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=44, + end_lineno=8, + end_col_offset=55)], + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=55)], + 0)], + lineno=5, + col_offset=17, + end_lineno=8, + end_col_offset=56), + lineno=5, + col_offset=4, + end_lineno=8, + end_col_offset=56), + Return( + Call( + Call( + Name( + '_choice', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + [ + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=23)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=24), + [ + Name( + 'placeholder_5', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=35)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=36)], + [], + lineno=4, + col_offset=0, + end_lineno=9, + end_col_offset=36), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=13, + col_offset=7, + end_lineno=13, + end_col_offset=11), + [ + Eq()], + [ + Constant( + 'teenth', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=23)], + lineno=13, + col_offset=7, + end_lineno=13, + end_col_offset=23), + [ + Return( + Lambda( + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Call( + Name( + 'next', + Load(), + lineno=14, + col_offset=29, + end_lineno=14, + end_col_offset=33), + [ + GeneratorExp( + Name( + 'placeholder_6', + Load(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=38), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=14, + col_offset=43, + end_lineno=14, + end_col_offset=47), + Name( + 'placeholder_8', + Load(), + lineno=14, + col_offset=51, + end_lineno=14, + end_col_offset=56), + [ + Compare( + Constant( + 13, + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=36), + [ + LtE(), + LtE()], + [ + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=15, + col_offset=40, + end_lineno=15, + end_col_offset=44), + 'day', + Load(), + lineno=15, + col_offset=40, + end_lineno=15, + end_col_offset=48), + Constant( + 19, + lineno=15, + col_offset=52, + end_lineno=15, + end_col_offset=54)], + lineno=15, + col_offset=34, + end_lineno=15, + end_col_offset=54)], + 0)], + lineno=14, + col_offset=33, + end_lineno=15, + end_col_offset=55)], + [], + lineno=14, + col_offset=29, + end_lineno=15, + end_col_offset=55), + lineno=14, + col_offset=15, + end_lineno=15, + end_col_offset=55), + lineno=14, + col_offset=8, + end_lineno=15, + end_col_offset=55)], + [], + lineno=13, + col_offset=4, + end_lineno=15, + end_col_offset=55), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=12)], + Tuple( + [ + Constant( + 'first', + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=23), + Constant( + 'second', + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=33), + Constant( + 'third', + lineno=17, + col_offset=35, + end_lineno=17, + end_col_offset=42), + Constant( + 'fourth', + lineno=17, + col_offset=44, + end_lineno=17, + end_col_offset=52), + Constant( + 'fifth', + lineno=17, + col_offset=54, + end_lineno=17, + end_col_offset=61), + Constant( + 'sixth', + lineno=17, + col_offset=63, + end_lineno=17, + end_col_offset=70)], + Load(), + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=71), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=71), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=7)], + IfExp( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=18, + col_offset=17, + end_lineno=18, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 'last', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=31)], + lineno=18, + col_offset=17, + end_lineno=18, + end_col_offset=31), + UnaryOp( + USub(), + Constant( + 1, + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=12), + lineno=18, + col_offset=10, + end_lineno=18, + end_col_offset=12), + Call( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=18, + col_offset=39, + end_lineno=18, + end_col_offset=47), + 'index', + Load(), + lineno=18, + col_offset=39, + end_lineno=18, + end_col_offset=53), + [ + Name( + 'placeholder_3', + Load(), + lineno=18, + col_offset=54, + end_lineno=18, + end_col_offset=58)], + [], + lineno=18, + col_offset=39, + end_lineno=18, + end_col_offset=59), + lineno=18, + col_offset=10, + end_lineno=18, + end_col_offset=60), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=60), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=14), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=20), + [ + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=26)], + [], + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=27)], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=27), + [ + Return( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=24), + Name( + 'placeholder_10', + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=28), + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=29), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=29)], + [], + lineno=21, + col_offset=8, + end_lineno=22, + end_col_offset=29), + Raise( + Call( + Name( + 'MeetupDayException', + Load(), + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=32), + [ + Constant( + 'That day does not exist.', + lineno=23, + col_offset=33, + end_lineno=23, + end_col_offset=59)], + [], + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=60), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=60)], + [], + lineno=20, + col_offset=4, + end_lineno=23, + end_col_offset=60), + Return( + Name( + 'placeholder_11', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=16), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=16)], + [], + lineno=12, + col_offset=0, + end_lineno=24, + end_col_offset=16), + ClassDef( + 'placeholder_12', + [ + Name( + 'ValueError', + Load(), + lineno=27, + col_offset=25, + end_lineno=27, + end_col_offset=35)], + [], + [ + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=21), + arg( + 'placeholder_14', + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'placeholder_14', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=20)], + Name( + 'placeholder_14', + Load(), + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=30), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=30)], + [], + lineno=33, + col_offset=4, + end_lineno=34, + end_col_offset=30)], + [], + lineno=27, + col_offset=0, + end_lineno=34, + end_col_offset=30)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-meetup/representation.txt b/test/practice-meetup/representation.txt new file mode 100644 index 0000000..5f3740a --- /dev/null +++ b/test/practice-meetup/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('calendar', [alias('Calendar', lineno=1, col_offset=21, end_lineno=1, end_col_offset=29)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=29), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=11, end_lineno=4, end_col_offset=15), arg('placeholder_2', lineno=4, col_offset=17, end_lineno=4, end_col_offset=22), arg('placeholder_3', lineno=4, col_offset=24, end_lineno=4, end_col_offset=28), arg('placeholder_4', lineno=4, col_offset=30, end_lineno=4, end_col_offset=41)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_5', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=14)], ListComp(Name('placeholder_6', Load(), lineno=5, col_offset=18, end_lineno=5, end_col_offset=22), [comprehension(Name('placeholder_6', Store(), lineno=6, col_offset=22, end_lineno=6, end_col_offset=26), Call(Attribute(Call(Name('Calendar', Load(), lineno=6, col_offset=30, end_lineno=6, end_col_offset=38), [], [], lineno=6, col_offset=30, end_lineno=6, end_col_offset=40), 'itermonthdates', Load(), lineno=6, col_offset=30, end_lineno=6, end_col_offset=55), [Name('placeholder_1', Load(), lineno=6, col_offset=56, end_lineno=6, end_col_offset=60), Name('placeholder_2', Load(), lineno=6, col_offset=62, end_lineno=6, end_col_offset=67)], [], lineno=6, col_offset=30, end_lineno=6, end_col_offset=68), [Compare(Attribute(Name('placeholder_6', Load(), lineno=7, col_offset=21, end_lineno=7, end_col_offset=25), 'placeholder_2', Load(), lineno=7, col_offset=21, end_lineno=7, end_col_offset=31), [Eq()], [Name('placeholder_2', Load(), lineno=7, col_offset=35, end_lineno=7, end_col_offset=40)], lineno=7, col_offset=21, end_lineno=7, end_col_offset=40), Compare(Call(Attribute(Name('placeholder_6', Load(), lineno=8, col_offset=21, end_lineno=8, end_col_offset=25), 'strftime', Load(), lineno=8, col_offset=21, end_lineno=8, end_col_offset=34), [Constant('%A', lineno=8, col_offset=35, end_lineno=8, end_col_offset=39)], [], lineno=8, col_offset=21, end_lineno=8, end_col_offset=40), [Eq()], [Name('placeholder_4', Load(), lineno=8, col_offset=44, end_lineno=8, end_col_offset=55)], lineno=8, col_offset=21, end_lineno=8, end_col_offset=55)], 0)], lineno=5, col_offset=17, end_lineno=8, end_col_offset=56), lineno=5, col_offset=4, end_lineno=8, end_col_offset=56), Return(Call(Call(Name('_choice', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=18), [Name('placeholder_3', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=23)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=24), [Name('placeholder_5', Load(), lineno=9, col_offset=25, end_lineno=9, end_col_offset=35)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=36), lineno=9, col_offset=4, end_lineno=9, end_col_offset=36)], [], lineno=4, col_offset=0, end_lineno=9, end_col_offset=36), FunctionDef('placeholder_7', arguments([], [arg('placeholder_3', lineno=12, col_offset=12, end_lineno=12, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_3', Load(), lineno=13, col_offset=7, end_lineno=13, end_col_offset=11), [Eq()], [Constant('teenth', lineno=13, col_offset=15, end_lineno=13, end_col_offset=23)], lineno=13, col_offset=7, end_lineno=13, end_col_offset=23), [Return(Lambda(arguments([], [arg('placeholder_8', lineno=14, col_offset=22, end_lineno=14, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), Call(Name('next', Load(), lineno=14, col_offset=29, end_lineno=14, end_col_offset=33), [GeneratorExp(Name('placeholder_6', Load(), lineno=14, col_offset=34, end_lineno=14, end_col_offset=38), [comprehension(Name('placeholder_6', Store(), lineno=14, col_offset=43, end_lineno=14, end_col_offset=47), Name('placeholder_8', Load(), lineno=14, col_offset=51, end_lineno=14, end_col_offset=56), [Compare(Constant(13, lineno=15, col_offset=34, end_lineno=15, end_col_offset=36), [LtE(), LtE()], [Attribute(Name('placeholder_6', Load(), lineno=15, col_offset=40, end_lineno=15, end_col_offset=44), 'day', Load(), lineno=15, col_offset=40, end_lineno=15, end_col_offset=48), Constant(19, lineno=15, col_offset=52, end_lineno=15, end_col_offset=54)], lineno=15, col_offset=34, end_lineno=15, end_col_offset=54)], 0)], lineno=14, col_offset=33, end_lineno=15, end_col_offset=55)], [], lineno=14, col_offset=29, end_lineno=15, end_col_offset=55), lineno=14, col_offset=15, end_lineno=15, end_col_offset=55), lineno=14, col_offset=8, end_lineno=15, end_col_offset=55)], [], lineno=13, col_offset=4, end_lineno=15, end_col_offset=55), Assign([Name('placeholder_9', Store(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=12)], Tuple([Constant('first', lineno=17, col_offset=16, end_lineno=17, end_col_offset=23), Constant('second', lineno=17, col_offset=25, end_lineno=17, end_col_offset=33), Constant('third', lineno=17, col_offset=35, end_lineno=17, end_col_offset=42), Constant('fourth', lineno=17, col_offset=44, end_lineno=17, end_col_offset=52), Constant('fifth', lineno=17, col_offset=54, end_lineno=17, end_col_offset=61), Constant('sixth', lineno=17, col_offset=63, end_lineno=17, end_col_offset=70)], Load(), lineno=17, col_offset=15, end_lineno=17, end_col_offset=71), lineno=17, col_offset=4, end_lineno=17, end_col_offset=71), Assign([Name('placeholder_10', Store(), lineno=18, col_offset=4, end_lineno=18, end_col_offset=7)], IfExp(Compare(Name('placeholder_3', Load(), lineno=18, col_offset=17, end_lineno=18, end_col_offset=21), [Eq()], [Constant('last', lineno=18, col_offset=25, end_lineno=18, end_col_offset=31)], lineno=18, col_offset=17, end_lineno=18, end_col_offset=31), UnaryOp(USub(), Constant(1, lineno=18, col_offset=11, end_lineno=18, end_col_offset=12), lineno=18, col_offset=10, end_lineno=18, end_col_offset=12), Call(Attribute(Name('placeholder_9', Load(), lineno=18, col_offset=39, end_lineno=18, end_col_offset=47), 'index', Load(), lineno=18, col_offset=39, end_lineno=18, end_col_offset=53), [Name('placeholder_3', Load(), lineno=18, col_offset=54, end_lineno=18, end_col_offset=58)], [], lineno=18, col_offset=39, end_lineno=18, end_col_offset=59), lineno=18, col_offset=10, end_lineno=18, end_col_offset=60), lineno=18, col_offset=4, end_lineno=18, end_col_offset=60), FunctionDef('placeholder_11', arguments([], [arg('placeholder_8', lineno=20, col_offset=14, end_lineno=20, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_10', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=14), [Lt()], [Call(Name('len', Load(), lineno=21, col_offset=17, end_lineno=21, end_col_offset=20), [Name('placeholder_8', Load(), lineno=21, col_offset=21, end_lineno=21, end_col_offset=26)], [], lineno=21, col_offset=17, end_lineno=21, end_col_offset=27)], lineno=21, col_offset=11, end_lineno=21, end_col_offset=27), [Return(Subscript(Name('placeholder_8', Load(), lineno=22, col_offset=19, end_lineno=22, end_col_offset=24), Name('placeholder_10', Load(), lineno=22, col_offset=25, end_lineno=22, end_col_offset=28), Load(), lineno=22, col_offset=19, end_lineno=22, end_col_offset=29), lineno=22, col_offset=12, end_lineno=22, end_col_offset=29)], [], lineno=21, col_offset=8, end_lineno=22, end_col_offset=29), Raise(Call(Name('MeetupDayException', Load(), lineno=23, col_offset=14, end_lineno=23, end_col_offset=32), [Constant('That day does not exist.', lineno=23, col_offset=33, end_lineno=23, end_col_offset=59)], [], lineno=23, col_offset=14, end_lineno=23, end_col_offset=60), lineno=23, col_offset=8, end_lineno=23, end_col_offset=60)], [], lineno=20, col_offset=4, end_lineno=23, end_col_offset=60), Return(Name('placeholder_11', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=16), lineno=24, col_offset=4, end_lineno=24, end_col_offset=16)], [], lineno=12, col_offset=0, end_lineno=24, end_col_offset=16), ClassDef('placeholder_12', [Name('ValueError', Load(), lineno=27, col_offset=25, end_lineno=27, end_col_offset=35)], [], [FunctionDef('placeholder_13', arguments([], [arg('self', lineno=33, col_offset=17, end_lineno=33, end_col_offset=21), arg('placeholder_14', lineno=33, col_offset=23, end_lineno=33, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=12), 'placeholder_14', Store(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=20)], Name('placeholder_14', Load(), lineno=34, col_offset=23, end_lineno=34, end_col_offset=30), lineno=34, col_offset=8, end_lineno=34, end_col_offset=30)], [], lineno=33, col_offset=4, end_lineno=34, end_col_offset=30)], [], lineno=27, col_offset=0, end_lineno=34, end_col_offset=30)], []) \ No newline at end of file diff --git a/test/practice-minesweeper/.meta/additional_tests.json b/test/practice-minesweeper/.meta/additional_tests.json new file mode 100644 index 0000000..84e7e53 --- /dev/null +++ b/test/practice-minesweeper/.meta/additional_tests.json @@ -0,0 +1,53 @@ +{ + "exercise": "minesweeper", + "version": "1.1.0", + "comments": [ + " The expected outputs are represented as arrays of strings to ", + " improve readability in this JSON file. ", + " Your track may choose whether to present the input as a single ", + " string (concatenating all the lines) or as the list. " + ], + "cases": [ + { + "description": "annotate 9", + "property": "annotate", + "input": { + "minefield": [ + " ", + " * ", + " ", + " ", + " * " + ] + }, + "expected": [ + " 111", + " 1*1", + " 111", + "111 ", + "1*1 " + ] + }, + { + "description": "different len", + "property": "annotate", + "input": { + "minefield": [ + " ", + "* ", + " " + ] + }, + "expected": {"error": "The board is invalid with current input."} + }, + { + "description": "invalid char", + "property": "annotate", + "input": { + "minefield": ["X * "] + }, + "expected": {"error": "The board is invalid with current input."} + + } + ] +} diff --git a/test/practice-minesweeper/.meta/config.json b/test/practice-minesweeper/.meta/config.json new file mode 100644 index 0000000..a4f6101 --- /dev/null +++ b/test/practice-minesweeper/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "alexpjohnson", + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "fluxusfrequency", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "peterblazejewicz", + "pheanex", + "sjakobi", + "smalley", + "tqa236" + ], + "files": { + "solution": [ + "minesweeper.py" + ], + "test": [ + "minesweeper_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Add the numbers to a minesweeper board." +} diff --git a/test/practice-minesweeper/mapping.json b/test/practice-minesweeper/mapping.json new file mode 100644 index 0000000..61a1fb0 --- /dev/null +++ b/test/practice-minesweeper/mapping.json @@ -0,0 +1,15 @@ +{ + "placeholder_0": "annotate", + "placeholder_1": "minefield", + "placeholder_2": "row_len", + "placeholder_3": "col_len", + "placeholder_4": "board", + "placeholder_5": "row", + "placeholder_6": "index1", + "placeholder_7": "index2", + "placeholder_8": "low", + "placeholder_9": "high", + "placeholder_10": "counts", + "placeholder_11": "verify_board", + "placeholder_12": "character_set" +} \ No newline at end of file diff --git a/test/practice-minesweeper/minesweeper.py b/test/practice-minesweeper/minesweeper.py new file mode 100644 index 0000000..4ebbc84 --- /dev/null +++ b/test/practice-minesweeper/minesweeper.py @@ -0,0 +1,40 @@ +def annotate(minefield): + if not minefield: + return [] + verify_board(minefield) + row_len = len(minefield[0]) + col_len = len(minefield) + board = [list(row) for row in minefield] + + for index1 in range(col_len): + for index2 in range(row_len): + if board[index1][index2] != ' ': + continue + + low = max(index2 - 1, 0) + high = min(index2 + 2, row_len + 2) + counts = minefield[index1][low:high].count('*') + + if index1 > 0: + counts += minefield[index1 - 1][low:high].count('*') + if index1 < col_len - 1: + counts += minefield[index1 + 1][low:high].count('*') + if counts == 0: + continue + + board[index1][index2] = str(counts) + return [''.join(row) for row in board] + + +def verify_board(minefield): + # Rows with different lengths + row_len = len(minefield[0]) + if not all(len(row) == row_len for row in minefield): + raise ValueError('The board is invalid with current input.') + + # Unknown character in board + character_set = set() + for row in minefield: + character_set.update(row) + if character_set - set(' *'): + raise ValueError('The board is invalid with current input.') diff --git a/test/practice-minesweeper/representation.json b/test/practice-minesweeper/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-minesweeper/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-minesweeper/representation.out b/test/practice-minesweeper/representation.out new file mode 100644 index 0000000..aae3351 --- /dev/null +++ b/test/practice-minesweeper/representation.out @@ -0,0 +1,2574 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + if not placeholder_1: + return [] + verify_board(placeholder_1) + placeholder_2 = len(placeholder_1[0]) + placeholder_3 = len(placeholder_1) + placeholder_4 = [list(placeholder_5) for placeholder_5 in placeholder_1] + for placeholder_6 in range(placeholder_3): + for placeholder_7 in range(placeholder_2): + if placeholder_4[placeholder_6][placeholder_7] != " ": + continue + placeholder_8 = max(placeholder_7 - 1, 0) + placeholder_9 = min(placeholder_7 + 2, placeholder_2 + 2) + placeholder_10 = placeholder_1[placeholder_6][ + placeholder_8:placeholder_9 + ].count("*") + if placeholder_6 > 0: + placeholder_10 += placeholder_1[placeholder_6 - 1][ + placeholder_8:placeholder_9 + ].count("*") + if placeholder_6 < placeholder_3 - 1: + placeholder_10 += placeholder_1[placeholder_6 + 1][ + placeholder_8:placeholder_9 + ].count("*") + if placeholder_10 == 0: + continue + placeholder_4[placeholder_6][placeholder_7] = str(placeholder_10) + return ["".join(placeholder_5) for placeholder_5 in placeholder_4] + + +def placeholder_11(placeholder_1): + placeholder_2 = len(placeholder_1[0]) + if not all( + (len(placeholder_5) == placeholder_2 for placeholder_5 in placeholder_1) + ): + raise ValueError("The board is invalid with current input.") + placeholder_12 = set() + for placeholder_5 in placeholder_1: + placeholder_12.update(placeholder_5) + if placeholder_12 - set(" *"): + raise ValueError("The board is invalid with current input.") + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'annotate', + arguments( + [], + [ + arg( + 'minefield', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'minefield', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + Return( + List( + [], + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=17), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=17)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=17), + Expr( + Call( + Name( + 'verify_board', + Load(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=16), + [ + Name( + 'minefield', + Load(), + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=26)], + [], + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=27), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=27), + Assign( + [ + Name( + 'row_len', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=17), + [ + Subscript( + Name( + 'minefield', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=27), + Constant( + 0, + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=29), + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=30)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=31), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=31), + Assign( + [ + Name( + 'col_len', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=11)], + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=17), + [ + Name( + 'minefield', + Load(), + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=27)], + [], + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=28), + Assign( + [ + Name( + 'board', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=9)], + ListComp( + Call( + Name( + 'list', + Load(), + lineno=7, + col_offset=13, + end_lineno=7, + end_col_offset=17), + [ + Name( + 'row', + Load(), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=21)], + [], + lineno=7, + col_offset=13, + end_lineno=7, + end_col_offset=22), + [ + comprehension( + Name( + 'row', + Store(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=30), + Name( + 'minefield', + Load(), + lineno=7, + col_offset=34, + end_lineno=7, + end_col_offset=43), + [], + 0)], + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=44), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=44), + For( + Name( + 'index1', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=14), + Call( + Name( + 'range', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=23), + [ + Name( + 'col_len', + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=31)], + [], + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=32), + [ + For( + Name( + 'index2', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=18), + Call( + Name( + 'range', + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=27), + [ + Name( + 'row_len', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=35)], + [], + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=36), + [ + If( + Compare( + Subscript( + Subscript( + Name( + 'board', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=20), + Name( + 'index1', + Load(), + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=27), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=28), + Name( + 'index2', + Load(), + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=35), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=36), + [ + NotEq()], + [ + Constant( + ' ', + lineno=11, + col_offset=40, + end_lineno=11, + end_col_offset=43)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=43), + [ + Continue( + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=24)], + [], + lineno=11, + col_offset=12, + end_lineno=12, + end_col_offset=24), + Assign( + [ + Name( + 'low', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=15)], + Call( + Name( + 'max', + Load(), + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=21), + [ + BinOp( + Name( + 'index2', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=28), + Sub(), + Constant( + 1, + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=32), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=32), + Constant( + 0, + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=35)], + [], + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=36), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=36), + Assign( + [ + Name( + 'high', + Store(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=16)], + Call( + Name( + 'min', + Load(), + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=22), + [ + BinOp( + Name( + 'index2', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=29), + Add(), + Constant( + 2, + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=33), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=33), + BinOp( + Name( + 'row_len', + Load(), + lineno=15, + col_offset=35, + end_lineno=15, + end_col_offset=42), + Add(), + Constant( + 2, + lineno=15, + col_offset=45, + end_lineno=15, + end_col_offset=46), + lineno=15, + col_offset=35, + end_lineno=15, + end_col_offset=46)], + [], + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=47), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=47), + Assign( + [ + Name( + 'counts', + Store(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=18)], + Call( + Attribute( + Subscript( + Subscript( + Name( + 'minefield', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=30), + Name( + 'index1', + Load(), + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=37), + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=38), + Slice( + Name( + 'low', + Load(), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=42), + Name( + 'high', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=47), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=47), + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=48), + 'count', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=54), + [ + Constant( + '*', + lineno=16, + col_offset=55, + end_lineno=16, + end_col_offset=58)], + [], + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=59), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=59), + If( + Compare( + Name( + 'index1', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=21), + [ + Gt()], + [ + Constant( + 0, + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=25)], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=25), + [ + AugAssign( + Name( + 'counts', + Store(), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=22), + Add(), + Call( + Attribute( + Subscript( + Subscript( + Name( + 'minefield', + Load(), + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=35), + BinOp( + Name( + 'index1', + Load(), + lineno=19, + col_offset=36, + end_lineno=19, + end_col_offset=42), + Sub(), + Constant( + 1, + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=46), + lineno=19, + col_offset=36, + end_lineno=19, + end_col_offset=46), + Load(), + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=47), + Slice( + Name( + 'low', + Load(), + lineno=19, + col_offset=48, + end_lineno=19, + end_col_offset=51), + Name( + 'high', + Load(), + lineno=19, + col_offset=52, + end_lineno=19, + end_col_offset=56), + lineno=19, + col_offset=48, + end_lineno=19, + end_col_offset=56), + Load(), + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=57), + 'count', + Load(), + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=63), + [ + Constant( + '*', + lineno=19, + col_offset=64, + end_lineno=19, + end_col_offset=67)], + [], + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=68), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=68)], + [], + lineno=18, + col_offset=12, + end_lineno=19, + end_col_offset=68), + If( + Compare( + Name( + 'index1', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=21), + [ + Lt()], + [ + BinOp( + Name( + 'col_len', + Load(), + lineno=20, + col_offset=24, + end_lineno=20, + end_col_offset=31), + Sub(), + Constant( + 1, + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=35), + lineno=20, + col_offset=24, + end_lineno=20, + end_col_offset=35)], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=35), + [ + AugAssign( + Name( + 'counts', + Store(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=22), + Add(), + Call( + Attribute( + Subscript( + Subscript( + Name( + 'minefield', + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=35), + BinOp( + Name( + 'index1', + Load(), + lineno=21, + col_offset=36, + end_lineno=21, + end_col_offset=42), + Add(), + Constant( + 1, + lineno=21, + col_offset=45, + end_lineno=21, + end_col_offset=46), + lineno=21, + col_offset=36, + end_lineno=21, + end_col_offset=46), + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=47), + Slice( + Name( + 'low', + Load(), + lineno=21, + col_offset=48, + end_lineno=21, + end_col_offset=51), + Name( + 'high', + Load(), + lineno=21, + col_offset=52, + end_lineno=21, + end_col_offset=56), + lineno=21, + col_offset=48, + end_lineno=21, + end_col_offset=56), + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=57), + 'count', + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=63), + [ + Constant( + '*', + lineno=21, + col_offset=64, + end_lineno=21, + end_col_offset=67)], + [], + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=68), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=68)], + [], + lineno=20, + col_offset=12, + end_lineno=21, + end_col_offset=68), + If( + Compare( + Name( + 'counts', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 0, + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=26)], + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=26), + [ + Continue( + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=24)], + [], + lineno=22, + col_offset=12, + end_lineno=23, + end_col_offset=24), + Assign( + [ + Subscript( + Subscript( + Name( + 'board', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=17), + Name( + 'index1', + Load(), + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=24), + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=25), + Name( + 'index2', + Load(), + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=32), + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=33)], + Call( + Name( + 'str', + Load(), + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=39), + [ + Name( + 'counts', + Load(), + lineno=25, + col_offset=40, + end_lineno=25, + end_col_offset=46)], + [], + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=47), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=47)], + [], + lineno=10, + col_offset=8, + end_lineno=25, + end_col_offset=47)], + [], + lineno=9, + col_offset=4, + end_lineno=25, + end_col_offset=47), + Return( + ListComp( + Call( + Attribute( + Constant( + '', + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=14), + 'join', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=19), + [ + Name( + 'row', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=23)], + [], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=24), + [ + comprehension( + Name( + 'row', + Store(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=32), + Name( + 'board', + Load(), + lineno=26, + col_offset=36, + end_lineno=26, + end_col_offset=41), + [], + 0)], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=42), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=42)], + [], + lineno=1, + col_offset=0, + end_lineno=26, + end_col_offset=42), + FunctionDef( + 'verify_board', + arguments( + [], + [ + arg( + 'minefield', + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'row_len', + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=11)], + Call( + Name( + 'len', + Load(), + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=17), + [ + Subscript( + Name( + 'minefield', + Load(), + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=27), + Constant( + 0, + lineno=31, + col_offset=28, + end_lineno=31, + end_col_offset=29), + Load(), + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=30)], + [], + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=31), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=31), + If( + UnaryOp( + Not(), + Call( + Name( + 'all', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=14), + [ + GeneratorExp( + Compare( + Call( + Name( + 'len', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=18), + [ + Name( + 'row', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=22)], + [], + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=23), + [ + Eq()], + [ + Name( + 'row_len', + Load(), + lineno=32, + col_offset=27, + end_lineno=32, + end_col_offset=34)], + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=34), + [ + comprehension( + Name( + 'row', + Store(), + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=42), + Name( + 'minefield', + Load(), + lineno=32, + col_offset=46, + end_lineno=32, + end_col_offset=55), + [], + 0)], + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=56)], + [], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=56), + lineno=32, + col_offset=7, + end_lineno=32, + end_col_offset=56), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=24), + [ + Constant( + 'The board is invalid with current input.', + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=67)], + [], + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=68), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=68)], + [], + lineno=32, + col_offset=4, + end_lineno=33, + end_col_offset=68), + Assign( + [ + Name( + 'character_set', + Store(), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=17)], + Call( + Name( + 'set', + Load(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=23), + [], + [], + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=25), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=25), + For( + Name( + 'row', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=11), + Name( + 'minefield', + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'character_set', + Load(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=21), + 'update', + Load(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=28), + [ + Name( + 'row', + Load(), + lineno=38, + col_offset=29, + end_lineno=38, + end_col_offset=32)], + [], + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=33), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=33)], + [], + lineno=37, + col_offset=4, + end_lineno=38, + end_col_offset=33), + If( + BinOp( + Name( + 'character_set', + Load(), + lineno=39, + col_offset=7, + end_lineno=39, + end_col_offset=20), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=39, + col_offset=23, + end_lineno=39, + end_col_offset=26), + [ + Constant( + ' *', + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=31)], + [], + lineno=39, + col_offset=23, + end_lineno=39, + end_col_offset=32), + lineno=39, + col_offset=7, + end_lineno=39, + end_col_offset=32), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=40, + col_offset=14, + end_lineno=40, + end_col_offset=24), + [ + Constant( + 'The board is invalid with current input.', + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=67)], + [], + lineno=40, + col_offset=14, + end_lineno=40, + end_col_offset=68), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=68)], + [], + lineno=39, + col_offset=4, + end_lineno=40, + end_col_offset=68)], + [], + lineno=29, + col_offset=0, + end_lineno=40, + end_col_offset=68)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + Return( + List( + [], + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=17), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=17)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=17), + Expr( + Call( + Name( + 'verify_board', + Load(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=16), + [ + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=26)], + [], + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=27), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=17), + [ + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=27), + Constant( + 0, + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=29), + Load(), + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=30)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=31), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=31), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=11)], + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=17), + [ + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=27)], + [], + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=28), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=9)], + ListComp( + Call( + Name( + 'list', + Load(), + lineno=7, + col_offset=13, + end_lineno=7, + end_col_offset=17), + [ + Name( + 'placeholder_5', + Load(), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=21)], + [], + lineno=7, + col_offset=13, + end_lineno=7, + end_col_offset=22), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=30), + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=34, + end_lineno=7, + end_col_offset=43), + [], + 0)], + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=44), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=44), + For( + Name( + 'placeholder_6', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=14), + Call( + Name( + 'range', + Load(), + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=23), + [ + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=24, + end_lineno=9, + end_col_offset=31)], + [], + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=32), + [ + For( + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=18), + Call( + Name( + 'range', + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=27), + [ + Name( + 'placeholder_2', + Load(), + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=35)], + [], + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=36), + [ + If( + Compare( + Subscript( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=20), + Name( + 'placeholder_6', + Load(), + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=27), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=28), + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=35), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=36), + [ + NotEq()], + [ + Constant( + ' ', + lineno=11, + col_offset=40, + end_lineno=11, + end_col_offset=43)], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=43), + [ + Continue( + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=24)], + [], + lineno=11, + col_offset=12, + end_lineno=12, + end_col_offset=24), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=15)], + Call( + Name( + 'max', + Load(), + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=21), + [ + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=28), + Sub(), + Constant( + 1, + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=32), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=32), + Constant( + 0, + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=35)], + [], + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=36), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=36), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=16)], + Call( + Name( + 'min', + Load(), + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=22), + [ + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=29), + Add(), + Constant( + 2, + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=33), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=33), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=15, + col_offset=35, + end_lineno=15, + end_col_offset=42), + Add(), + Constant( + 2, + lineno=15, + col_offset=45, + end_lineno=15, + end_col_offset=46), + lineno=15, + col_offset=35, + end_lineno=15, + end_col_offset=46)], + [], + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=47), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=47), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=18)], + Call( + Attribute( + Subscript( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=30), + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=37), + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=38), + Slice( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=42), + Name( + 'placeholder_9', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=47), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=47), + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=48), + 'count', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=54), + [ + Constant( + '*', + lineno=16, + col_offset=55, + end_lineno=16, + end_col_offset=58)], + [], + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=59), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=59), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=21), + [ + Gt()], + [ + Constant( + 0, + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=25)], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=25), + [ + AugAssign( + Name( + 'placeholder_10', + Store(), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=22), + Add(), + Call( + Attribute( + Subscript( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=35), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=36, + end_lineno=19, + end_col_offset=42), + Sub(), + Constant( + 1, + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=46), + lineno=19, + col_offset=36, + end_lineno=19, + end_col_offset=46), + Load(), + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=47), + Slice( + Name( + 'placeholder_8', + Load(), + lineno=19, + col_offset=48, + end_lineno=19, + end_col_offset=51), + Name( + 'placeholder_9', + Load(), + lineno=19, + col_offset=52, + end_lineno=19, + end_col_offset=56), + lineno=19, + col_offset=48, + end_lineno=19, + end_col_offset=56), + Load(), + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=57), + 'count', + Load(), + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=63), + [ + Constant( + '*', + lineno=19, + col_offset=64, + end_lineno=19, + end_col_offset=67)], + [], + lineno=19, + col_offset=26, + end_lineno=19, + end_col_offset=68), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=68)], + [], + lineno=18, + col_offset=12, + end_lineno=19, + end_col_offset=68), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=21), + [ + Lt()], + [ + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=20, + col_offset=24, + end_lineno=20, + end_col_offset=31), + Sub(), + Constant( + 1, + lineno=20, + col_offset=34, + end_lineno=20, + end_col_offset=35), + lineno=20, + col_offset=24, + end_lineno=20, + end_col_offset=35)], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=35), + [ + AugAssign( + Name( + 'placeholder_10', + Store(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=22), + Add(), + Call( + Attribute( + Subscript( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=35), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=21, + col_offset=36, + end_lineno=21, + end_col_offset=42), + Add(), + Constant( + 1, + lineno=21, + col_offset=45, + end_lineno=21, + end_col_offset=46), + lineno=21, + col_offset=36, + end_lineno=21, + end_col_offset=46), + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=47), + Slice( + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=48, + end_lineno=21, + end_col_offset=51), + Name( + 'placeholder_9', + Load(), + lineno=21, + col_offset=52, + end_lineno=21, + end_col_offset=56), + lineno=21, + col_offset=48, + end_lineno=21, + end_col_offset=56), + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=57), + 'count', + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=63), + [ + Constant( + '*', + lineno=21, + col_offset=64, + end_lineno=21, + end_col_offset=67)], + [], + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=68), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=68)], + [], + lineno=20, + col_offset=12, + end_lineno=21, + end_col_offset=68), + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 0, + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=26)], + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=26), + [ + Continue( + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=24)], + [], + lineno=22, + col_offset=12, + end_lineno=23, + end_col_offset=24), + Assign( + [ + Subscript( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=17), + Name( + 'placeholder_6', + Load(), + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=24), + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=25), + Name( + 'placeholder_7', + Load(), + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=32), + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=33)], + Call( + Name( + 'str', + Load(), + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=39), + [ + Name( + 'placeholder_10', + Load(), + lineno=25, + col_offset=40, + end_lineno=25, + end_col_offset=46)], + [], + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=47), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=47)], + [], + lineno=10, + col_offset=8, + end_lineno=25, + end_col_offset=47)], + [], + lineno=9, + col_offset=4, + end_lineno=25, + end_col_offset=47), + Return( + ListComp( + Call( + Attribute( + Constant( + '', + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=14), + 'join', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=19), + [ + Name( + 'placeholder_5', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=23)], + [], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=24), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=32), + Name( + 'placeholder_4', + Load(), + lineno=26, + col_offset=36, + end_lineno=26, + end_col_offset=41), + [], + 0)], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=42), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=42)], + [], + lineno=1, + col_offset=0, + end_lineno=26, + end_col_offset=42), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=11)], + Call( + Name( + 'len', + Load(), + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=17), + [ + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=27), + Constant( + 0, + lineno=31, + col_offset=28, + end_lineno=31, + end_col_offset=29), + Load(), + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=30)], + [], + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=31), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=31), + If( + UnaryOp( + Not(), + Call( + Name( + 'all', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=14), + [ + GeneratorExp( + Compare( + Call( + Name( + 'len', + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=18), + [ + Name( + 'placeholder_5', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=22)], + [], + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=23), + [ + Eq()], + [ + Name( + 'placeholder_2', + Load(), + lineno=32, + col_offset=27, + end_lineno=32, + end_col_offset=34)], + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=34), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=42), + Name( + 'placeholder_1', + Load(), + lineno=32, + col_offset=46, + end_lineno=32, + end_col_offset=55), + [], + 0)], + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=56)], + [], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=56), + lineno=32, + col_offset=7, + end_lineno=32, + end_col_offset=56), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=24), + [ + Constant( + 'The board is invalid with current input.', + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=67)], + [], + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=68), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=68)], + [], + lineno=32, + col_offset=4, + end_lineno=33, + end_col_offset=68), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=17)], + Call( + Name( + 'set', + Load(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=23), + [], + [], + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=25), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=25), + For( + Name( + 'placeholder_5', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=11), + Name( + 'placeholder_1', + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=24), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=21), + 'update', + Load(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=28), + [ + Name( + 'placeholder_5', + Load(), + lineno=38, + col_offset=29, + end_lineno=38, + end_col_offset=32)], + [], + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=33), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=33)], + [], + lineno=37, + col_offset=4, + end_lineno=38, + end_col_offset=33), + If( + BinOp( + Name( + 'placeholder_12', + Load(), + lineno=39, + col_offset=7, + end_lineno=39, + end_col_offset=20), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=39, + col_offset=23, + end_lineno=39, + end_col_offset=26), + [ + Constant( + ' *', + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=31)], + [], + lineno=39, + col_offset=23, + end_lineno=39, + end_col_offset=32), + lineno=39, + col_offset=7, + end_lineno=39, + end_col_offset=32), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=40, + col_offset=14, + end_lineno=40, + end_col_offset=24), + [ + Constant( + 'The board is invalid with current input.', + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=67)], + [], + lineno=40, + col_offset=14, + end_lineno=40, + end_col_offset=68), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=68)], + [], + lineno=39, + col_offset=4, + end_lineno=40, + end_col_offset=68)], + [], + lineno=29, + col_offset=0, + end_lineno=40, + end_col_offset=68)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-minesweeper/representation.txt b/test/practice-minesweeper/representation.txt new file mode 100644 index 0000000..323f6ce --- /dev/null +++ b/test/practice-minesweeper/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=13, end_lineno=1, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=20), lineno=2, col_offset=7, end_lineno=2, end_col_offset=20), [Return(List([], Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=17), lineno=3, col_offset=8, end_lineno=3, end_col_offset=17)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=17), Expr(Call(Name('verify_board', Load(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=16), [Name('placeholder_1', Load(), lineno=4, col_offset=17, end_lineno=4, end_col_offset=26)], [], lineno=4, col_offset=4, end_lineno=4, end_col_offset=27), lineno=4, col_offset=4, end_lineno=4, end_col_offset=27), Assign([Name('placeholder_2', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=11)], Call(Name('len', Load(), lineno=5, col_offset=14, end_lineno=5, end_col_offset=17), [Subscript(Name('placeholder_1', Load(), lineno=5, col_offset=18, end_lineno=5, end_col_offset=27), Constant(0, lineno=5, col_offset=28, end_lineno=5, end_col_offset=29), Load(), lineno=5, col_offset=18, end_lineno=5, end_col_offset=30)], [], lineno=5, col_offset=14, end_lineno=5, end_col_offset=31), lineno=5, col_offset=4, end_lineno=5, end_col_offset=31), Assign([Name('placeholder_3', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=11)], Call(Name('len', Load(), lineno=6, col_offset=14, end_lineno=6, end_col_offset=17), [Name('placeholder_1', Load(), lineno=6, col_offset=18, end_lineno=6, end_col_offset=27)], [], lineno=6, col_offset=14, end_lineno=6, end_col_offset=28), lineno=6, col_offset=4, end_lineno=6, end_col_offset=28), Assign([Name('placeholder_4', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=9)], ListComp(Call(Name('list', Load(), lineno=7, col_offset=13, end_lineno=7, end_col_offset=17), [Name('placeholder_5', Load(), lineno=7, col_offset=18, end_lineno=7, end_col_offset=21)], [], lineno=7, col_offset=13, end_lineno=7, end_col_offset=22), [comprehension(Name('placeholder_5', Store(), lineno=7, col_offset=27, end_lineno=7, end_col_offset=30), Name('placeholder_1', Load(), lineno=7, col_offset=34, end_lineno=7, end_col_offset=43), [], 0)], lineno=7, col_offset=12, end_lineno=7, end_col_offset=44), lineno=7, col_offset=4, end_lineno=7, end_col_offset=44), For(Name('placeholder_6', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=14), Call(Name('range', Load(), lineno=9, col_offset=18, end_lineno=9, end_col_offset=23), [Name('placeholder_3', Load(), lineno=9, col_offset=24, end_lineno=9, end_col_offset=31)], [], lineno=9, col_offset=18, end_lineno=9, end_col_offset=32), [For(Name('placeholder_7', Store(), lineno=10, col_offset=12, end_lineno=10, end_col_offset=18), Call(Name('range', Load(), lineno=10, col_offset=22, end_lineno=10, end_col_offset=27), [Name('placeholder_2', Load(), lineno=10, col_offset=28, end_lineno=10, end_col_offset=35)], [], lineno=10, col_offset=22, end_lineno=10, end_col_offset=36), [If(Compare(Subscript(Subscript(Name('placeholder_4', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=20), Name('placeholder_6', Load(), lineno=11, col_offset=21, end_lineno=11, end_col_offset=27), Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=28), Name('placeholder_7', Load(), lineno=11, col_offset=29, end_lineno=11, end_col_offset=35), Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=36), [NotEq()], [Constant(' ', lineno=11, col_offset=40, end_lineno=11, end_col_offset=43)], lineno=11, col_offset=15, end_lineno=11, end_col_offset=43), [Continue(lineno=12, col_offset=16, end_lineno=12, end_col_offset=24)], [], lineno=11, col_offset=12, end_lineno=12, end_col_offset=24), Assign([Name('placeholder_8', Store(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=15)], Call(Name('max', Load(), lineno=14, col_offset=18, end_lineno=14, end_col_offset=21), [BinOp(Name('placeholder_7', Load(), lineno=14, col_offset=22, end_lineno=14, end_col_offset=28), Sub(), Constant(1, lineno=14, col_offset=31, end_lineno=14, end_col_offset=32), lineno=14, col_offset=22, end_lineno=14, end_col_offset=32), Constant(0, lineno=14, col_offset=34, end_lineno=14, end_col_offset=35)], [], lineno=14, col_offset=18, end_lineno=14, end_col_offset=36), lineno=14, col_offset=12, end_lineno=14, end_col_offset=36), Assign([Name('placeholder_9', Store(), lineno=15, col_offset=12, end_lineno=15, end_col_offset=16)], Call(Name('min', Load(), lineno=15, col_offset=19, end_lineno=15, end_col_offset=22), [BinOp(Name('placeholder_7', Load(), lineno=15, col_offset=23, end_lineno=15, end_col_offset=29), Add(), Constant(2, lineno=15, col_offset=32, end_lineno=15, end_col_offset=33), lineno=15, col_offset=23, end_lineno=15, end_col_offset=33), BinOp(Name('placeholder_2', Load(), lineno=15, col_offset=35, end_lineno=15, end_col_offset=42), Add(), Constant(2, lineno=15, col_offset=45, end_lineno=15, end_col_offset=46), lineno=15, col_offset=35, end_lineno=15, end_col_offset=46)], [], lineno=15, col_offset=19, end_lineno=15, end_col_offset=47), lineno=15, col_offset=12, end_lineno=15, end_col_offset=47), Assign([Name('placeholder_10', Store(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=18)], Call(Attribute(Subscript(Subscript(Name('placeholder_1', Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=30), Name('placeholder_6', Load(), lineno=16, col_offset=31, end_lineno=16, end_col_offset=37), Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=38), Slice(Name('placeholder_8', Load(), lineno=16, col_offset=39, end_lineno=16, end_col_offset=42), Name('placeholder_9', Load(), lineno=16, col_offset=43, end_lineno=16, end_col_offset=47), lineno=16, col_offset=39, end_lineno=16, end_col_offset=47), Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=48), 'count', Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=54), [Constant('*', lineno=16, col_offset=55, end_lineno=16, end_col_offset=58)], [], lineno=16, col_offset=21, end_lineno=16, end_col_offset=59), lineno=16, col_offset=12, end_lineno=16, end_col_offset=59), If(Compare(Name('placeholder_6', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=21), [Gt()], [Constant(0, lineno=18, col_offset=24, end_lineno=18, end_col_offset=25)], lineno=18, col_offset=15, end_lineno=18, end_col_offset=25), [AugAssign(Name('placeholder_10', Store(), lineno=19, col_offset=16, end_lineno=19, end_col_offset=22), Add(), Call(Attribute(Subscript(Subscript(Name('placeholder_1', Load(), lineno=19, col_offset=26, end_lineno=19, end_col_offset=35), BinOp(Name('placeholder_6', Load(), lineno=19, col_offset=36, end_lineno=19, end_col_offset=42), Sub(), Constant(1, lineno=19, col_offset=45, end_lineno=19, end_col_offset=46), lineno=19, col_offset=36, end_lineno=19, end_col_offset=46), Load(), lineno=19, col_offset=26, end_lineno=19, end_col_offset=47), Slice(Name('placeholder_8', Load(), lineno=19, col_offset=48, end_lineno=19, end_col_offset=51), Name('placeholder_9', Load(), lineno=19, col_offset=52, end_lineno=19, end_col_offset=56), lineno=19, col_offset=48, end_lineno=19, end_col_offset=56), Load(), lineno=19, col_offset=26, end_lineno=19, end_col_offset=57), 'count', Load(), lineno=19, col_offset=26, end_lineno=19, end_col_offset=63), [Constant('*', lineno=19, col_offset=64, end_lineno=19, end_col_offset=67)], [], lineno=19, col_offset=26, end_lineno=19, end_col_offset=68), lineno=19, col_offset=16, end_lineno=19, end_col_offset=68)], [], lineno=18, col_offset=12, end_lineno=19, end_col_offset=68), If(Compare(Name('placeholder_6', Load(), lineno=20, col_offset=15, end_lineno=20, end_col_offset=21), [Lt()], [BinOp(Name('placeholder_3', Load(), lineno=20, col_offset=24, end_lineno=20, end_col_offset=31), Sub(), Constant(1, lineno=20, col_offset=34, end_lineno=20, end_col_offset=35), lineno=20, col_offset=24, end_lineno=20, end_col_offset=35)], lineno=20, col_offset=15, end_lineno=20, end_col_offset=35), [AugAssign(Name('placeholder_10', Store(), lineno=21, col_offset=16, end_lineno=21, end_col_offset=22), Add(), Call(Attribute(Subscript(Subscript(Name('placeholder_1', Load(), lineno=21, col_offset=26, end_lineno=21, end_col_offset=35), BinOp(Name('placeholder_6', Load(), lineno=21, col_offset=36, end_lineno=21, end_col_offset=42), Add(), Constant(1, lineno=21, col_offset=45, end_lineno=21, end_col_offset=46), lineno=21, col_offset=36, end_lineno=21, end_col_offset=46), Load(), lineno=21, col_offset=26, end_lineno=21, end_col_offset=47), Slice(Name('placeholder_8', Load(), lineno=21, col_offset=48, end_lineno=21, end_col_offset=51), Name('placeholder_9', Load(), lineno=21, col_offset=52, end_lineno=21, end_col_offset=56), lineno=21, col_offset=48, end_lineno=21, end_col_offset=56), Load(), lineno=21, col_offset=26, end_lineno=21, end_col_offset=57), 'count', Load(), lineno=21, col_offset=26, end_lineno=21, end_col_offset=63), [Constant('*', lineno=21, col_offset=64, end_lineno=21, end_col_offset=67)], [], lineno=21, col_offset=26, end_lineno=21, end_col_offset=68), lineno=21, col_offset=16, end_lineno=21, end_col_offset=68)], [], lineno=20, col_offset=12, end_lineno=21, end_col_offset=68), If(Compare(Name('placeholder_10', Load(), lineno=22, col_offset=15, end_lineno=22, end_col_offset=21), [Eq()], [Constant(0, lineno=22, col_offset=25, end_lineno=22, end_col_offset=26)], lineno=22, col_offset=15, end_lineno=22, end_col_offset=26), [Continue(lineno=23, col_offset=16, end_lineno=23, end_col_offset=24)], [], lineno=22, col_offset=12, end_lineno=23, end_col_offset=24), Assign([Subscript(Subscript(Name('placeholder_4', Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=17), Name('placeholder_6', Load(), lineno=25, col_offset=18, end_lineno=25, end_col_offset=24), Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=25), Name('placeholder_7', Load(), lineno=25, col_offset=26, end_lineno=25, end_col_offset=32), Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=33)], Call(Name('str', Load(), lineno=25, col_offset=36, end_lineno=25, end_col_offset=39), [Name('placeholder_10', Load(), lineno=25, col_offset=40, end_lineno=25, end_col_offset=46)], [], lineno=25, col_offset=36, end_lineno=25, end_col_offset=47), lineno=25, col_offset=12, end_lineno=25, end_col_offset=47)], [], lineno=10, col_offset=8, end_lineno=25, end_col_offset=47)], [], lineno=9, col_offset=4, end_lineno=25, end_col_offset=47), Return(ListComp(Call(Attribute(Constant('', lineno=26, col_offset=12, end_lineno=26, end_col_offset=14), 'join', Load(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=19), [Name('placeholder_5', Load(), lineno=26, col_offset=20, end_lineno=26, end_col_offset=23)], [], lineno=26, col_offset=12, end_lineno=26, end_col_offset=24), [comprehension(Name('placeholder_5', Store(), lineno=26, col_offset=29, end_lineno=26, end_col_offset=32), Name('placeholder_4', Load(), lineno=26, col_offset=36, end_lineno=26, end_col_offset=41), [], 0)], lineno=26, col_offset=11, end_lineno=26, end_col_offset=42), lineno=26, col_offset=4, end_lineno=26, end_col_offset=42)], [], lineno=1, col_offset=0, end_lineno=26, end_col_offset=42), FunctionDef('placeholder_11', arguments([], [arg('placeholder_1', lineno=29, col_offset=17, end_lineno=29, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=31, col_offset=4, end_lineno=31, end_col_offset=11)], Call(Name('len', Load(), lineno=31, col_offset=14, end_lineno=31, end_col_offset=17), [Subscript(Name('placeholder_1', Load(), lineno=31, col_offset=18, end_lineno=31, end_col_offset=27), Constant(0, lineno=31, col_offset=28, end_lineno=31, end_col_offset=29), Load(), lineno=31, col_offset=18, end_lineno=31, end_col_offset=30)], [], lineno=31, col_offset=14, end_lineno=31, end_col_offset=31), lineno=31, col_offset=4, end_lineno=31, end_col_offset=31), If(UnaryOp(Not(), Call(Name('all', Load(), lineno=32, col_offset=11, end_lineno=32, end_col_offset=14), [GeneratorExp(Compare(Call(Name('len', Load(), lineno=32, col_offset=15, end_lineno=32, end_col_offset=18), [Name('placeholder_5', Load(), lineno=32, col_offset=19, end_lineno=32, end_col_offset=22)], [], lineno=32, col_offset=15, end_lineno=32, end_col_offset=23), [Eq()], [Name('placeholder_2', Load(), lineno=32, col_offset=27, end_lineno=32, end_col_offset=34)], lineno=32, col_offset=15, end_lineno=32, end_col_offset=34), [comprehension(Name('placeholder_5', Store(), lineno=32, col_offset=39, end_lineno=32, end_col_offset=42), Name('placeholder_1', Load(), lineno=32, col_offset=46, end_lineno=32, end_col_offset=55), [], 0)], lineno=32, col_offset=14, end_lineno=32, end_col_offset=56)], [], lineno=32, col_offset=11, end_lineno=32, end_col_offset=56), lineno=32, col_offset=7, end_lineno=32, end_col_offset=56), [Raise(Call(Name('ValueError', Load(), lineno=33, col_offset=14, end_lineno=33, end_col_offset=24), [Constant('The board is invalid with current input.', lineno=33, col_offset=25, end_lineno=33, end_col_offset=67)], [], lineno=33, col_offset=14, end_lineno=33, end_col_offset=68), lineno=33, col_offset=8, end_lineno=33, end_col_offset=68)], [], lineno=32, col_offset=4, end_lineno=33, end_col_offset=68), Assign([Name('placeholder_12', Store(), lineno=36, col_offset=4, end_lineno=36, end_col_offset=17)], Call(Name('set', Load(), lineno=36, col_offset=20, end_lineno=36, end_col_offset=23), [], [], lineno=36, col_offset=20, end_lineno=36, end_col_offset=25), lineno=36, col_offset=4, end_lineno=36, end_col_offset=25), For(Name('placeholder_5', Store(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=11), Name('placeholder_1', Load(), lineno=37, col_offset=15, end_lineno=37, end_col_offset=24), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=21), 'update', Load(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=28), [Name('placeholder_5', Load(), lineno=38, col_offset=29, end_lineno=38, end_col_offset=32)], [], lineno=38, col_offset=8, end_lineno=38, end_col_offset=33), lineno=38, col_offset=8, end_lineno=38, end_col_offset=33)], [], lineno=37, col_offset=4, end_lineno=38, end_col_offset=33), If(BinOp(Name('placeholder_12', Load(), lineno=39, col_offset=7, end_lineno=39, end_col_offset=20), Sub(), Call(Name('set', Load(), lineno=39, col_offset=23, end_lineno=39, end_col_offset=26), [Constant(' *', lineno=39, col_offset=27, end_lineno=39, end_col_offset=31)], [], lineno=39, col_offset=23, end_lineno=39, end_col_offset=32), lineno=39, col_offset=7, end_lineno=39, end_col_offset=32), [Raise(Call(Name('ValueError', Load(), lineno=40, col_offset=14, end_lineno=40, end_col_offset=24), [Constant('The board is invalid with current input.', lineno=40, col_offset=25, end_lineno=40, end_col_offset=67)], [], lineno=40, col_offset=14, end_lineno=40, end_col_offset=68), lineno=40, col_offset=8, end_lineno=40, end_col_offset=68)], [], lineno=39, col_offset=4, end_lineno=40, end_col_offset=68)], [], lineno=29, col_offset=0, end_lineno=40, end_col_offset=68)], []) \ No newline at end of file diff --git a/test/practice-nth-prime/.meta/additional_tests.json b/test/practice-nth-prime/.meta/additional_tests.json new file mode 100644 index 0000000..939ac3b --- /dev/null +++ b/test/practice-nth-prime/.meta/additional_tests.json @@ -0,0 +1,13 @@ +{ + "cases": [ + { + "description": "first twenty primes", + "property": "primeRange", + "input": { + "number": 20 + }, + "expected": [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, + 37, 41, 43, 47, 53, 59, 61, 67, 71] + } + ] +} \ No newline at end of file diff --git a/test/practice-nth-prime/.meta/config.json b/test/practice-nth-prime/.meta/config.json new file mode 100644 index 0000000..e4466db --- /dev/null +++ b/test/practice-nth-prime/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "ikhadykin", + "jandersoncampelo", + "kytrinyx", + "N-Parsons", + "pheanex", + "robkeim", + "smalley", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "nth_prime.py" + ], + "test": [ + "nth_prime_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a number n, determine what the nth prime is.", + "source": "A variation on Problem 7 at Project Euler", + "source_url": "https://projecteuler.net/problem=7" +} diff --git a/test/practice-nth-prime/mapping.json b/test/practice-nth-prime/mapping.json new file mode 100644 index 0000000..e0be836 --- /dev/null +++ b/test/practice-nth-prime/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "prime", + "placeholder_1": "number", + "placeholder_2": "known", + "placeholder_3": "candidates", + "placeholder_4": "is_prime", + "placeholder_5": "candidate", + "placeholder_6": "sqrt_candidate", + "placeholder_7": "item", + "placeholder_8": "next_one", + "placeholder_9": "prime_candidates" +} \ No newline at end of file diff --git a/test/practice-nth-prime/nth_prime.py b/test/practice-nth-prime/nth_prime.py new file mode 100644 index 0000000..73517c4 --- /dev/null +++ b/test/practice-nth-prime/nth_prime.py @@ -0,0 +1,34 @@ +from itertools import count +from math import sqrt + + +def prime(number): + if number < 1: + raise ValueError('there is no zeroth prime') + + known = [] + candidates = prime_candidates() + + def is_prime(candidate): + sqrt_candidate = sqrt(candidate) + for item in known: + if item > sqrt_candidate: + return True + elif candidate % item == 0: + return False + return True + + while len(known) < number: + next_one = next(candidates) + if is_prime(next_one): + known.append(next_one) + + return known[number - 1] + + +def prime_candidates(): + yield 2 + yield 3 + for number in count(6, 6): + yield number - 1 + yield number + 1 diff --git a/test/practice-nth-prime/representation.json b/test/practice-nth-prime/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-nth-prime/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-nth-prime/representation.out b/test/practice-nth-prime/representation.out new file mode 100644 index 0000000..2d83d9c --- /dev/null +++ b/test/practice-nth-prime/representation.out @@ -0,0 +1,1337 @@ +## BEGIN NORMALIZED CODE ## +from itertools import count +from math import sqrt + + +def placeholder_0(placeholder_1): + if placeholder_1 < 1: + raise ValueError("there is no zeroth prime") + placeholder_2 = [] + placeholder_3 = prime_candidates() + + def placeholder_4(placeholder_5): + placeholder_6 = sqrt(placeholder_5) + for placeholder_7 in placeholder_2: + if placeholder_7 > placeholder_6: + return True + elif placeholder_5 % placeholder_7 == 0: + return False + return True + + while len(placeholder_2) < placeholder_1: + placeholder_8 = next(placeholder_3) + if placeholder_4(placeholder_8): + placeholder_2.append(placeholder_8) + return placeholder_2[placeholder_1 - 1] + + +def placeholder_9(): + yield 2 + yield 3 + for placeholder_1 in count(6, 6): + yield (number - 1) + yield (number + 1) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'count', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=27), + ImportFrom( + 'math', + [ + alias( + 'sqrt', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=21), + FunctionDef( + 'prime', + arguments( + [], + [ + arg( + 'number', + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'number', + Load(), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 1, + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=17)], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=17), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'there is no zeroth prime', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=51)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=52), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=52)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=52), + Assign( + [ + Name( + 'known', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=9)], + List( + [], + Load(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=14), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=14), + Assign( + [ + Name( + 'candidates', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14)], + Call( + Name( + 'prime_candidates', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=33), + [], + [], + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=35), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=35), + FunctionDef( + 'is_prime', + arguments( + [], + [ + arg( + 'candidate', + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'sqrt_candidate', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + Call( + Name( + 'sqrt', + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=29), + [ + Name( + 'candidate', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=39)], + [], + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=40), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=40), + For( + Name( + 'item', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=16), + Name( + 'known', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=25), + [ + If( + Compare( + Name( + 'item', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + [ + Gt()], + [ + Name( + 'sqrt_candidate', + Load(), + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=36)], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=36), + [ + Return( + Constant( + True, + lineno=16, + col_offset=23, + end_lineno=16, + end_col_offset=27), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=27)], + [ + If( + Compare( + BinOp( + Name( + 'candidate', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=26), + Mod(), + Name( + 'item', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=33), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=33), + [ + Eq()], + [ + Constant( + 0, + lineno=17, + col_offset=37, + end_lineno=17, + end_col_offset=38)], + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=38), + [ + Return( + Constant( + False, + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=28), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=28)], + [], + lineno=17, + col_offset=12, + end_lineno=18, + end_col_offset=28)], + lineno=15, + col_offset=12, + end_lineno=18, + end_col_offset=28)], + [], + lineno=14, + col_offset=8, + end_lineno=18, + end_col_offset=28), + Return( + Constant( + True, + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=19)], + [], + lineno=12, + col_offset=4, + end_lineno=19, + end_col_offset=19), + While( + Compare( + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=13), + [ + Name( + 'known', + Load(), + lineno=21, + col_offset=14, + end_lineno=21, + end_col_offset=19)], + [], + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=20), + [ + Lt()], + [ + Name( + 'number', + Load(), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=29)], + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=29), + [ + Assign( + [ + Name( + 'next_one', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=16)], + Call( + Name( + 'next', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=23), + [ + Name( + 'candidates', + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=34)], + [], + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=35), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=35), + If( + Call( + Name( + 'is_prime', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=19), + [ + Name( + 'next_one', + Load(), + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=28)], + [], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'known', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=17), + 'append', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=24), + [ + Name( + 'next_one', + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=33)], + [], + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=34), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=34)], + [], + lineno=23, + col_offset=8, + end_lineno=24, + end_col_offset=34)], + [], + lineno=21, + col_offset=4, + end_lineno=24, + end_col_offset=34), + Return( + Subscript( + Name( + 'known', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=16), + BinOp( + Name( + 'number', + Load(), + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=23), + Sub(), + Constant( + 1, + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=27), + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=27), + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=28), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=28)], + [], + lineno=5, + col_offset=0, + end_lineno=26, + end_col_offset=28), + FunctionDef( + 'prime_candidates', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Yield( + Constant( + 2, + lineno=30, + col_offset=10, + end_lineno=30, + end_col_offset=11), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=11), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=11), + Expr( + Yield( + Constant( + 3, + lineno=31, + col_offset=10, + end_lineno=31, + end_col_offset=11), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=11), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=11), + For( + Name( + 'number', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=14), + Call( + Name( + 'count', + Load(), + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=23), + [ + Constant( + 6, + lineno=32, + col_offset=24, + end_lineno=32, + end_col_offset=25), + Constant( + 6, + lineno=32, + col_offset=27, + end_lineno=32, + end_col_offset=28)], + [], + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=29), + [ + Expr( + Yield( + BinOp( + Name( + 'number', + Load(), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=20), + Sub(), + Constant( + 1, + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=24), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=24), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=24), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=24), + Expr( + Yield( + BinOp( + Name( + 'number', + Load(), + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=20), + Add(), + Constant( + 1, + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=24), + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=24), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=24), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=24)], + [], + lineno=32, + col_offset=4, + end_lineno=34, + end_col_offset=24)], + [], + lineno=29, + col_offset=0, + end_lineno=34, + end_col_offset=24)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'count', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=27), + ImportFrom( + 'math', + [ + alias( + 'sqrt', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=21), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 1, + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=17)], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=17), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'there is no zeroth prime', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=51)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=52), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=52)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=9)], + List( + [], + Load(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=14), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14)], + Call( + Name( + 'prime_candidates', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=33), + [], + [], + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=35), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=35), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + Call( + Name( + 'sqrt', + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=29), + [ + Name( + 'placeholder_5', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=39)], + [], + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=40), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=40), + For( + Name( + 'placeholder_7', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=16), + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=25), + [ + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + [ + Gt()], + [ + Name( + 'placeholder_6', + Load(), + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=36)], + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=36), + [ + Return( + Constant( + True, + lineno=16, + col_offset=23, + end_lineno=16, + end_col_offset=27), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=27)], + [ + If( + Compare( + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=26), + Mod(), + Name( + 'placeholder_7', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=33), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=33), + [ + Eq()], + [ + Constant( + 0, + lineno=17, + col_offset=37, + end_lineno=17, + end_col_offset=38)], + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=38), + [ + Return( + Constant( + False, + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=28), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=28)], + [], + lineno=17, + col_offset=12, + end_lineno=18, + end_col_offset=28)], + lineno=15, + col_offset=12, + end_lineno=18, + end_col_offset=28)], + [], + lineno=14, + col_offset=8, + end_lineno=18, + end_col_offset=28), + Return( + Constant( + True, + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=19)], + [], + lineno=12, + col_offset=4, + end_lineno=19, + end_col_offset=19), + While( + Compare( + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=13), + [ + Name( + 'placeholder_2', + Load(), + lineno=21, + col_offset=14, + end_lineno=21, + end_col_offset=19)], + [], + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=20), + [ + Lt()], + [ + Name( + 'placeholder_1', + Load(), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=29)], + lineno=21, + col_offset=10, + end_lineno=21, + end_col_offset=29), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=16)], + Call( + Name( + 'next', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=23), + [ + Name( + 'placeholder_3', + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=34)], + [], + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=35), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=35), + If( + Call( + Name( + 'placeholder_4', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=19), + [ + Name( + 'placeholder_8', + Load(), + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=28)], + [], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=17), + 'append', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=24), + [ + Name( + 'placeholder_8', + Load(), + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=33)], + [], + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=34), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=34)], + [], + lineno=23, + col_offset=8, + end_lineno=24, + end_col_offset=34)], + [], + lineno=21, + col_offset=4, + end_lineno=24, + end_col_offset=34), + Return( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=16), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=23), + Sub(), + Constant( + 1, + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=27), + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=27), + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=28), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=28)], + [], + lineno=5, + col_offset=0, + end_lineno=26, + end_col_offset=28), + FunctionDef( + 'placeholder_9', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Yield( + Constant( + 2, + lineno=30, + col_offset=10, + end_lineno=30, + end_col_offset=11), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=11), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=11), + Expr( + Yield( + Constant( + 3, + lineno=31, + col_offset=10, + end_lineno=31, + end_col_offset=11), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=11), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=11), + For( + Name( + 'placeholder_1', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=14), + Call( + Name( + 'count', + Load(), + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=23), + [ + Constant( + 6, + lineno=32, + col_offset=24, + end_lineno=32, + end_col_offset=25), + Constant( + 6, + lineno=32, + col_offset=27, + end_lineno=32, + end_col_offset=28)], + [], + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=29), + [ + Expr( + Yield( + BinOp( + Name( + 'number', + Load(), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=20), + Sub(), + Constant( + 1, + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=24), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=24), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=24), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=24), + Expr( + Yield( + BinOp( + Name( + 'number', + Load(), + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=20), + Add(), + Constant( + 1, + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=24), + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=24), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=24), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=24)], + [], + lineno=32, + col_offset=4, + end_lineno=34, + end_col_offset=24)], + [], + lineno=29, + col_offset=0, + end_lineno=34, + end_col_offset=24)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-nth-prime/representation.txt b/test/practice-nth-prime/representation.txt new file mode 100644 index 0000000..f59c08c --- /dev/null +++ b/test/practice-nth-prime/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('itertools', [alias('count', lineno=1, col_offset=22, end_lineno=1, end_col_offset=27)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=27), ImportFrom('math', [alias('sqrt', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=21), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=10, end_lineno=5, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_1', Load(), lineno=6, col_offset=7, end_lineno=6, end_col_offset=13), [Lt()], [Constant(1, lineno=6, col_offset=16, end_lineno=6, end_col_offset=17)], lineno=6, col_offset=7, end_lineno=6, end_col_offset=17), [Raise(Call(Name('ValueError', Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=24), [Constant('there is no zeroth prime', lineno=7, col_offset=25, end_lineno=7, end_col_offset=51)], [], lineno=7, col_offset=14, end_lineno=7, end_col_offset=52), lineno=7, col_offset=8, end_lineno=7, end_col_offset=52)], [], lineno=6, col_offset=4, end_lineno=7, end_col_offset=52), Assign([Name('placeholder_2', Store(), lineno=9, col_offset=4, end_lineno=9, end_col_offset=9)], List([], Load(), lineno=9, col_offset=12, end_lineno=9, end_col_offset=14), lineno=9, col_offset=4, end_lineno=9, end_col_offset=14), Assign([Name('placeholder_3', Store(), lineno=10, col_offset=4, end_lineno=10, end_col_offset=14)], Call(Name('prime_candidates', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=33), [], [], lineno=10, col_offset=17, end_lineno=10, end_col_offset=35), lineno=10, col_offset=4, end_lineno=10, end_col_offset=35), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=12, col_offset=17, end_lineno=12, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=22)], Call(Name('sqrt', Load(), lineno=13, col_offset=25, end_lineno=13, end_col_offset=29), [Name('placeholder_5', Load(), lineno=13, col_offset=30, end_lineno=13, end_col_offset=39)], [], lineno=13, col_offset=25, end_lineno=13, end_col_offset=40), lineno=13, col_offset=8, end_lineno=13, end_col_offset=40), For(Name('placeholder_7', Store(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=16), Name('placeholder_2', Load(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=25), [If(Compare(Name('placeholder_7', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), [Gt()], [Name('placeholder_6', Load(), lineno=15, col_offset=22, end_lineno=15, end_col_offset=36)], lineno=15, col_offset=15, end_lineno=15, end_col_offset=36), [Return(Constant(True, lineno=16, col_offset=23, end_lineno=16, end_col_offset=27), lineno=16, col_offset=16, end_lineno=16, end_col_offset=27)], [If(Compare(BinOp(Name('placeholder_5', Load(), lineno=17, col_offset=17, end_lineno=17, end_col_offset=26), Mod(), Name('placeholder_7', Load(), lineno=17, col_offset=29, end_lineno=17, end_col_offset=33), lineno=17, col_offset=17, end_lineno=17, end_col_offset=33), [Eq()], [Constant(0, lineno=17, col_offset=37, end_lineno=17, end_col_offset=38)], lineno=17, col_offset=17, end_lineno=17, end_col_offset=38), [Return(Constant(False, lineno=18, col_offset=23, end_lineno=18, end_col_offset=28), lineno=18, col_offset=16, end_lineno=18, end_col_offset=28)], [], lineno=17, col_offset=12, end_lineno=18, end_col_offset=28)], lineno=15, col_offset=12, end_lineno=18, end_col_offset=28)], [], lineno=14, col_offset=8, end_lineno=18, end_col_offset=28), Return(Constant(True, lineno=19, col_offset=15, end_lineno=19, end_col_offset=19), lineno=19, col_offset=8, end_lineno=19, end_col_offset=19)], [], lineno=12, col_offset=4, end_lineno=19, end_col_offset=19), While(Compare(Call(Name('len', Load(), lineno=21, col_offset=10, end_lineno=21, end_col_offset=13), [Name('placeholder_2', Load(), lineno=21, col_offset=14, end_lineno=21, end_col_offset=19)], [], lineno=21, col_offset=10, end_lineno=21, end_col_offset=20), [Lt()], [Name('placeholder_1', Load(), lineno=21, col_offset=23, end_lineno=21, end_col_offset=29)], lineno=21, col_offset=10, end_lineno=21, end_col_offset=29), [Assign([Name('placeholder_8', Store(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=16)], Call(Name('next', Load(), lineno=22, col_offset=19, end_lineno=22, end_col_offset=23), [Name('placeholder_3', Load(), lineno=22, col_offset=24, end_lineno=22, end_col_offset=34)], [], lineno=22, col_offset=19, end_lineno=22, end_col_offset=35), lineno=22, col_offset=8, end_lineno=22, end_col_offset=35), If(Call(Name('placeholder_4', Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=19), [Name('placeholder_8', Load(), lineno=23, col_offset=20, end_lineno=23, end_col_offset=28)], [], lineno=23, col_offset=11, end_lineno=23, end_col_offset=29), [Expr(Call(Attribute(Name('placeholder_2', Load(), lineno=24, col_offset=12, end_lineno=24, end_col_offset=17), 'append', Load(), lineno=24, col_offset=12, end_lineno=24, end_col_offset=24), [Name('placeholder_8', Load(), lineno=24, col_offset=25, end_lineno=24, end_col_offset=33)], [], lineno=24, col_offset=12, end_lineno=24, end_col_offset=34), lineno=24, col_offset=12, end_lineno=24, end_col_offset=34)], [], lineno=23, col_offset=8, end_lineno=24, end_col_offset=34)], [], lineno=21, col_offset=4, end_lineno=24, end_col_offset=34), Return(Subscript(Name('placeholder_2', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=16), BinOp(Name('placeholder_1', Load(), lineno=26, col_offset=17, end_lineno=26, end_col_offset=23), Sub(), Constant(1, lineno=26, col_offset=26, end_lineno=26, end_col_offset=27), lineno=26, col_offset=17, end_lineno=26, end_col_offset=27), Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=28), lineno=26, col_offset=4, end_lineno=26, end_col_offset=28)], [], lineno=5, col_offset=0, end_lineno=26, end_col_offset=28), FunctionDef('placeholder_9', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Yield(Constant(2, lineno=30, col_offset=10, end_lineno=30, end_col_offset=11), lineno=30, col_offset=4, end_lineno=30, end_col_offset=11), lineno=30, col_offset=4, end_lineno=30, end_col_offset=11), Expr(Yield(Constant(3, lineno=31, col_offset=10, end_lineno=31, end_col_offset=11), lineno=31, col_offset=4, end_lineno=31, end_col_offset=11), lineno=31, col_offset=4, end_lineno=31, end_col_offset=11), For(Name('placeholder_1', Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=14), Call(Name('count', Load(), lineno=32, col_offset=18, end_lineno=32, end_col_offset=23), [Constant(6, lineno=32, col_offset=24, end_lineno=32, end_col_offset=25), Constant(6, lineno=32, col_offset=27, end_lineno=32, end_col_offset=28)], [], lineno=32, col_offset=18, end_lineno=32, end_col_offset=29), [Expr(Yield(BinOp(Name('number', Load(), lineno=33, col_offset=14, end_lineno=33, end_col_offset=20), Sub(), Constant(1, lineno=33, col_offset=23, end_lineno=33, end_col_offset=24), lineno=33, col_offset=14, end_lineno=33, end_col_offset=24), lineno=33, col_offset=8, end_lineno=33, end_col_offset=24), lineno=33, col_offset=8, end_lineno=33, end_col_offset=24), Expr(Yield(BinOp(Name('number', Load(), lineno=34, col_offset=14, end_lineno=34, end_col_offset=20), Add(), Constant(1, lineno=34, col_offset=23, end_lineno=34, end_col_offset=24), lineno=34, col_offset=14, end_lineno=34, end_col_offset=24), lineno=34, col_offset=8, end_lineno=34, end_col_offset=24), lineno=34, col_offset=8, end_lineno=34, end_col_offset=24)], [], lineno=32, col_offset=4, end_lineno=34, end_col_offset=24)], [], lineno=29, col_offset=0, end_lineno=34, end_col_offset=24)], []) \ No newline at end of file diff --git a/test/practice-nucleotide-count/.meta/config.json b/test/practice-nucleotide-count/.meta/config.json new file mode 100644 index 0000000..e0c108f --- /dev/null +++ b/test/practice-nucleotide-count/.meta/config.json @@ -0,0 +1,32 @@ +{ + "blurb": "Given a DNA string, compute how many times each nucleotide occurs in the string.", + "authors": [], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "lowks", + "mostlybadfly", + "N-Parsons", + "Oniwa", + "orozcoadrian", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "nucleotide_count.py" + ], + "test": [ + "nucleotide_count_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "The Calculating DNA Nucleotides_problem at Rosalind", + "source_url": "https://rosalind.info/problems/dna/" +} diff --git a/test/practice-nucleotide-count/mapping.json b/test/practice-nucleotide-count/mapping.json new file mode 100644 index 0000000..ed5e929 --- /dev/null +++ b/test/practice-nucleotide-count/mapping.json @@ -0,0 +1,9 @@ +{ + "placeholder_0": "NUCLEOTIDES", + "placeholder_1": "count", + "placeholder_2": "strand", + "placeholder_3": "abbreviation", + "placeholder_4": "nucleotide_counts", + "placeholder_5": "abbr", + "placeholder_6": "_validate" +} \ No newline at end of file diff --git a/test/practice-nucleotide-count/nucleotide_count.py b/test/practice-nucleotide-count/nucleotide_count.py new file mode 100644 index 0000000..e79a6a7 --- /dev/null +++ b/test/practice-nucleotide-count/nucleotide_count.py @@ -0,0 +1,18 @@ +NUCLEOTIDES = 'ATCG' + + +def count(strand, abbreviation): + _validate(abbreviation) + return strand.count(abbreviation) + + +def nucleotide_counts(strand): + return { + abbr: strand.count(abbr) + for abbr in NUCLEOTIDES + } + + +def _validate(abbreviation): + if abbreviation not in NUCLEOTIDES: + raise ValueError(f'{abbreviation} is not a nucleotide.') diff --git a/test/practice-nucleotide-count/representation.json b/test/practice-nucleotide-count/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-nucleotide-count/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-nucleotide-count/representation.out b/test/practice-nucleotide-count/representation.out new file mode 100644 index 0000000..99c2a3d --- /dev/null +++ b/test/practice-nucleotide-count/representation.out @@ -0,0 +1,593 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = "ATCG" + + +def placeholder_1(placeholder_2, placeholder_3): + _validate(placeholder_3) + return placeholder_2.placeholder_1(placeholder_3) + + +def placeholder_4(placeholder_2): + return { + placeholder_5: placeholder_2.placeholder_1(placeholder_5) + for placeholder_5 in placeholder_0 + } + + +def placeholder_6(placeholder_3): + if placeholder_3 not in placeholder_0: + raise ValueError(f"{placeholder_3} is not a nucleotide.") + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'NUCLEOTIDES', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11)], + Constant( + 'ATCG', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=20), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=20), + FunctionDef( + 'count', + arguments( + [], + [ + arg( + 'strand', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=16), + arg( + 'abbreviation', + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Name( + '_validate', + Load(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=13), + [ + Name( + 'abbreviation', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=26)], + [], + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=27), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=27), + Return( + Call( + Attribute( + Name( + 'strand', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=17), + 'count', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=23), + [ + Name( + 'abbreviation', + Load(), + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=36)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=37), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=37)], + [], + lineno=4, + col_offset=0, + end_lineno=6, + end_col_offset=37), + FunctionDef( + 'nucleotide_counts', + arguments( + [], + [ + arg( + 'strand', + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + DictComp( + Name( + 'abbr', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + Call( + Attribute( + Name( + 'strand', + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=20), + 'count', + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=26), + [ + Name( + 'abbr', + Load(), + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=31)], + [], + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=32), + [ + comprehension( + Name( + 'abbr', + Store(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=16), + Name( + 'NUCLEOTIDES', + Load(), + lineno=12, + col_offset=20, + end_lineno=12, + end_col_offset=31), + [], + 0)], + lineno=10, + col_offset=11, + end_lineno=13, + end_col_offset=5), + lineno=10, + col_offset=4, + end_lineno=13, + end_col_offset=5)], + [], + lineno=9, + col_offset=0, + end_lineno=13, + end_col_offset=5), + FunctionDef( + '_validate', + arguments( + [], + [ + arg( + 'abbreviation', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'abbreviation', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=19), + [ + NotIn()], + [ + Name( + 'NUCLEOTIDES', + Load(), + lineno=17, + col_offset=27, + end_lineno=17, + end_col_offset=38)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=38), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + JoinedStr( + [ + FormattedValue( + Name( + 'abbreviation', + Load(), + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=40), + -1, + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=63), + Constant( + ' is not a nucleotide.', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=63)], + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=63)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=64), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=64)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=64)], + [], + lineno=16, + col_offset=0, + end_lineno=18, + end_col_offset=64)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11)], + Constant( + 'ATCG', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=20), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=20), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=16), + arg( + 'placeholder_3', + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Name( + '_validate', + Load(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=13), + [ + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=26)], + [], + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=27), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=27), + Return( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=17), + 'placeholder_1', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=23), + [ + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=36)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=37), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=37)], + [], + lineno=4, + col_offset=0, + end_lineno=6, + end_col_offset=37), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + DictComp( + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=20), + 'placeholder_1', + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=26), + [ + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=27, + end_lineno=11, + end_col_offset=31)], + [], + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=32), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=16), + Name( + 'placeholder_0', + Load(), + lineno=12, + col_offset=20, + end_lineno=12, + end_col_offset=31), + [], + 0)], + lineno=10, + col_offset=11, + end_lineno=13, + end_col_offset=5), + lineno=10, + col_offset=4, + end_lineno=13, + end_col_offset=5)], + [], + lineno=9, + col_offset=0, + end_lineno=13, + end_col_offset=5), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=19), + [ + NotIn()], + [ + Name( + 'placeholder_0', + Load(), + lineno=17, + col_offset=27, + end_lineno=17, + end_col_offset=38)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=38), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + JoinedStr( + [ + FormattedValue( + Name( + 'placeholder_3', + Load(), + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=40), + -1, + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=63), + Constant( + ' is not a nucleotide.', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=63)], + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=63)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=64), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=64)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=64)], + [], + lineno=16, + col_offset=0, + end_lineno=18, + end_col_offset=64)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-nucleotide-count/representation.txt b/test/practice-nucleotide-count/representation.txt new file mode 100644 index 0000000..1ca34a7 --- /dev/null +++ b/test/practice-nucleotide-count/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=11)], Constant('ATCG', lineno=1, col_offset=14, end_lineno=1, end_col_offset=20), lineno=1, col_offset=0, end_lineno=1, end_col_offset=20), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=4, col_offset=10, end_lineno=4, end_col_offset=16), arg('placeholder_3', lineno=4, col_offset=18, end_lineno=4, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Name('_validate', Load(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=13), [Name('placeholder_3', Load(), lineno=5, col_offset=14, end_lineno=5, end_col_offset=26)], [], lineno=5, col_offset=4, end_lineno=5, end_col_offset=27), lineno=5, col_offset=4, end_lineno=5, end_col_offset=27), Return(Call(Attribute(Name('placeholder_2', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=17), 'placeholder_1', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=23), [Name('placeholder_3', Load(), lineno=6, col_offset=24, end_lineno=6, end_col_offset=36)], [], lineno=6, col_offset=11, end_lineno=6, end_col_offset=37), lineno=6, col_offset=4, end_lineno=6, end_col_offset=37)], [], lineno=4, col_offset=0, end_lineno=6, end_col_offset=37), FunctionDef('placeholder_4', arguments([], [arg('placeholder_2', lineno=9, col_offset=22, end_lineno=9, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(DictComp(Name('placeholder_5', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), Call(Attribute(Name('placeholder_2', Load(), lineno=11, col_offset=14, end_lineno=11, end_col_offset=20), 'placeholder_1', Load(), lineno=11, col_offset=14, end_lineno=11, end_col_offset=26), [Name('placeholder_5', Load(), lineno=11, col_offset=27, end_lineno=11, end_col_offset=31)], [], lineno=11, col_offset=14, end_lineno=11, end_col_offset=32), [comprehension(Name('placeholder_5', Store(), lineno=12, col_offset=12, end_lineno=12, end_col_offset=16), Name('placeholder_0', Load(), lineno=12, col_offset=20, end_lineno=12, end_col_offset=31), [], 0)], lineno=10, col_offset=11, end_lineno=13, end_col_offset=5), lineno=10, col_offset=4, end_lineno=13, end_col_offset=5)], [], lineno=9, col_offset=0, end_lineno=13, end_col_offset=5), FunctionDef('placeholder_6', arguments([], [arg('placeholder_3', lineno=16, col_offset=14, end_lineno=16, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_3', Load(), lineno=17, col_offset=7, end_lineno=17, end_col_offset=19), [NotIn()], [Name('placeholder_0', Load(), lineno=17, col_offset=27, end_lineno=17, end_col_offset=38)], lineno=17, col_offset=7, end_lineno=17, end_col_offset=38), [Raise(Call(Name('ValueError', Load(), lineno=18, col_offset=14, end_lineno=18, end_col_offset=24), [JoinedStr([FormattedValue(Name('placeholder_3', Load(), lineno=18, col_offset=28, end_lineno=18, end_col_offset=40), -1, lineno=18, col_offset=25, end_lineno=18, end_col_offset=63), Constant(' is not a nucleotide.', lineno=18, col_offset=25, end_lineno=18, end_col_offset=63)], lineno=18, col_offset=25, end_lineno=18, end_col_offset=63)], [], lineno=18, col_offset=14, end_lineno=18, end_col_offset=64), lineno=18, col_offset=8, end_lineno=18, end_col_offset=64)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=64)], [], lineno=16, col_offset=0, end_lineno=18, end_col_offset=64)], []) \ No newline at end of file diff --git a/test/practice-ocr-numbers/.meta/config.json b/test/practice-ocr-numbers/.meta/config.json new file mode 100644 index 0000000..b37fe0d --- /dev/null +++ b/test/practice-ocr-numbers/.meta/config.json @@ -0,0 +1,33 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cjchallis", + "cmccandless", + "Dog", + "emerali", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "parthsharma2", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "ocr_numbers.py" + ], + "test": [ + "ocr_numbers_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is represented, or whether it is garbled.", + "source": "Inspired by the Bank OCR kata", + "source_url": "https://codingdojo.org/kata/BankOCR/" +} diff --git a/test/practice-ocr-numbers/mapping.json b/test/practice-ocr-numbers/mapping.json new file mode 100644 index 0000000..91b0357 --- /dev/null +++ b/test/practice-ocr-numbers/mapping.json @@ -0,0 +1,22 @@ +{ + "placeholder_0": "NUM_ROWS", + "placeholder_1": "NUM_COLS", + "placeholder_2": "split_ocr", + "placeholder_3": "ocr", + "placeholder_4": "idx", + "placeholder_5": "jam", + "placeholder_6": "placeholder_4", + "placeholder_7": "ALL", + "placeholder_8": "OCR_LIST", + "placeholder_9": "convert", + "placeholder_10": "input_grid", + "placeholder_11": "split_indices", + "placeholder_12": "lines", + "placeholder_13": "start", + "placeholder_14": "end", + "placeholder_15": "line", + "placeholder_16": "convert_one_line", + "placeholder_17": "numbers", + "placeholder_18": "digits", + "placeholder_19": "num" +} \ No newline at end of file diff --git a/test/practice-ocr-numbers/ocr_numbers.py b/test/practice-ocr-numbers/ocr_numbers.py new file mode 100644 index 0000000..bc92648 --- /dev/null +++ b/test/practice-ocr-numbers/ocr_numbers.py @@ -0,0 +1,43 @@ +NUM_ROWS = 4 +NUM_COLS = 3 + + +def split_ocr(ocr): + return [[ocr[idx][NUM_COLS * jam:NUM_COLS * (jam + 1)] for idx in range(NUM_ROWS)] + for jam in range(len(ocr[0]) // NUM_COLS)] + + +ALL = [' _ _ _ _ _ _ _ _ ', + ' | _| _||_||_ |_ ||_||_|| |', + ' ||_ _| | _||_| ||_| _||_|', + ' '] + +OCR_LIST = split_ocr(ALL) +OCR_LIST = [OCR_LIST[-1]] + OCR_LIST[:9] + + +def convert(input_grid): + split_indices = (list(range(0, len(input_grid), NUM_ROWS)) + + [len(input_grid)]) + + lines = [input_grid[start:end] + for start, end in zip(split_indices[:-1], split_indices[1:])] + + return ','.join(convert_one_line(line) for line in lines) + + +def convert_one_line(input_grid): + if len(input_grid) != NUM_ROWS: + raise ValueError('Number of input lines is not a multiple of four') + + if len(input_grid[0]) % NUM_COLS: + raise ValueError('Number of input columns is not a multiple of three') + + numbers = split_ocr(input_grid) + digits = '' + for num in numbers: + try: + digits += str(OCR_LIST.index(num)) + except ValueError: + digits += '?' + return digits diff --git a/test/practice-ocr-numbers/representation.json b/test/practice-ocr-numbers/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-ocr-numbers/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-ocr-numbers/representation.out b/test/practice-ocr-numbers/representation.out new file mode 100644 index 0000000..20bd646 --- /dev/null +++ b/test/practice-ocr-numbers/representation.out @@ -0,0 +1,2271 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = 4 +placeholder_1 = 3 + + +def placeholder_2(placeholder_3): + return [ + [ + placeholder_3[placeholder_6][ + placeholder_1 * placeholder_5 : placeholder_1 * (placeholder_5 + 1) + ] + for placeholder_6 in range(placeholder_0) + ] + for placeholder_5 in range(len(placeholder_3[0]) // placeholder_1) + ] + + +placeholder_7 = [ + " _ _ _ _ _ _ _ _ ", + " | _| _||_||_ |_ ||_||_|| |", + " ||_ _| | _||_| ||_| _||_|", + " ", +] +placeholder_8 = placeholder_2(placeholder_7) +placeholder_8 = [placeholder_8[-1]] + placeholder_8[:9] + + +def placeholder_9(placeholder_10): + placeholder_11 = list(range(0, len(placeholder_10), placeholder_0)) + [ + len(placeholder_10) + ] + placeholder_12 = [ + placeholder_10[placeholder_13:placeholder_14] + for placeholder_13, placeholder_14 in zip( + placeholder_11[:-1], placeholder_11[1:] + ) + ] + return ",".join( + (convert_one_line(placeholder_15) for placeholder_15 in placeholder_12) + ) + + +def placeholder_16(placeholder_10): + if len(placeholder_10) != placeholder_0: + raise ValueError("Number of input lines is not a multiple of four") + if len(placeholder_10[0]) % placeholder_1: + raise ValueError("Number of input columns is not a multiple of three") + placeholder_17 = placeholder_2(placeholder_10) + placeholder_18 = "" + for placeholder_19 in placeholder_17: + try: + placeholder_18 += str(placeholder_8.index(placeholder_19)) + except ValueError: + placeholder_18 += "?" + return placeholder_18 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'NUM_ROWS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=8)], + Constant( + 4, + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=12), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=12), + Assign( + [ + Name( + 'NUM_COLS', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=8)], + Constant( + 3, + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=12), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=12), + FunctionDef( + 'split_ocr', + arguments( + [], + [ + arg( + 'ocr', + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + ListComp( + Subscript( + Subscript( + Name( + 'ocr', + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=16), + Name( + 'idx', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=20), + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=21), + Slice( + BinOp( + Name( + 'NUM_COLS', + Load(), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=30), + Mult(), + Name( + 'jam', + Load(), + lineno=6, + col_offset=33, + end_lineno=6, + end_col_offset=36), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=36), + BinOp( + Name( + 'NUM_COLS', + Load(), + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=45), + Mult(), + BinOp( + Name( + 'jam', + Load(), + lineno=6, + col_offset=49, + end_lineno=6, + end_col_offset=52), + Add(), + Constant( + 1, + lineno=6, + col_offset=55, + end_lineno=6, + end_col_offset=56), + lineno=6, + col_offset=49, + end_lineno=6, + end_col_offset=56), + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=57), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=57), + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=58), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=6, + col_offset=63, + end_lineno=6, + end_col_offset=66), + Call( + Name( + 'range', + Load(), + lineno=6, + col_offset=70, + end_lineno=6, + end_col_offset=75), + [ + Name( + 'NUM_ROWS', + Load(), + lineno=6, + col_offset=76, + end_lineno=6, + end_col_offset=84)], + [], + lineno=6, + col_offset=70, + end_lineno=6, + end_col_offset=85), + [], + 0)], + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=86), + [ + comprehension( + Name( + 'jam', + Store(), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=28), + [ + BinOp( + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=32), + [ + Subscript( + Name( + 'ocr', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=36), + Constant( + 0, + lineno=7, + col_offset=37, + end_lineno=7, + end_col_offset=38), + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=39)], + [], + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=40), + FloorDiv(), + Name( + 'NUM_COLS', + Load(), + lineno=7, + col_offset=44, + end_lineno=7, + end_col_offset=52), + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=52)], + [], + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=53), + [], + 0)], + lineno=6, + col_offset=11, + end_lineno=7, + end_col_offset=54), + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=54)], + [], + lineno=5, + col_offset=0, + end_lineno=7, + end_col_offset=54), + Assign( + [ + Name( + 'ALL', + Store(), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=3)], + List( + [ + Constant( + ' _ _ _ _ _ _ _ _ ', + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=39), + Constant( + ' | _| _||_||_ |_ ||_||_|| |', + lineno=11, + col_offset=7, + end_lineno=11, + end_col_offset=39), + Constant( + ' ||_ _| | _||_| ||_| _||_|', + lineno=12, + col_offset=7, + end_lineno=12, + end_col_offset=39), + Constant( + ' ', + lineno=13, + col_offset=7, + end_lineno=13, + end_col_offset=39)], + Load(), + lineno=10, + col_offset=6, + end_lineno=13, + end_col_offset=40), + lineno=10, + col_offset=0, + end_lineno=13, + end_col_offset=40), + Assign( + [ + Name( + 'OCR_LIST', + Store(), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=8)], + Call( + Name( + 'split_ocr', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=20), + [ + Name( + 'ALL', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=24)], + [], + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=25), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=25), + Assign( + [ + Name( + 'OCR_LIST', + Store(), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=8)], + BinOp( + List( + [ + Subscript( + Name( + 'OCR_LIST', + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=20), + UnaryOp( + USub(), + Constant( + 1, + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=23), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=23), + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=24)], + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=25), + Add(), + Subscript( + Name( + 'OCR_LIST', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=36), + Slice( + upper=Constant( + 9, + lineno=16, + col_offset=38, + end_lineno=16, + end_col_offset=39), + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=39), + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=40), + FunctionDef( + 'convert', + arguments( + [], + [ + arg( + 'input_grid', + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'split_indices', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=17)], + BinOp( + Call( + Name( + 'list', + Load(), + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=25), + [ + Call( + Name( + 'range', + Load(), + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=31), + [ + Constant( + 0, + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=33), + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=35, + end_lineno=20, + end_col_offset=38), + [ + Name( + 'input_grid', + Load(), + lineno=20, + col_offset=39, + end_lineno=20, + end_col_offset=49)], + [], + lineno=20, + col_offset=35, + end_lineno=20, + end_col_offset=50), + Name( + 'NUM_ROWS', + Load(), + lineno=20, + col_offset=52, + end_lineno=20, + end_col_offset=60)], + [], + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=61)], + [], + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=62), + Add(), + List( + [ + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=25), + [ + Name( + 'input_grid', + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=36)], + [], + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=37)], + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=38), + lineno=20, + col_offset=21, + end_lineno=21, + end_col_offset=38), + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=39), + Assign( + [ + Name( + 'lines', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=9)], + ListComp( + Subscript( + Name( + 'input_grid', + Load(), + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=23), + Slice( + Name( + 'start', + Load(), + lineno=23, + col_offset=24, + end_lineno=23, + end_col_offset=29), + Name( + 'end', + Load(), + lineno=23, + col_offset=30, + end_lineno=23, + end_col_offset=33), + lineno=23, + col_offset=24, + end_lineno=23, + end_col_offset=33), + Load(), + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=34), + [ + comprehension( + Tuple( + [ + Name( + 'start', + Store(), + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=22), + Name( + 'end', + Store(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=27)], + Store(), + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=27), + Call( + Name( + 'zip', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=34), + [ + Subscript( + Name( + 'split_indices', + Load(), + lineno=24, + col_offset=35, + end_lineno=24, + end_col_offset=48), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=24, + col_offset=51, + end_lineno=24, + end_col_offset=52), + lineno=24, + col_offset=50, + end_lineno=24, + end_col_offset=52), + lineno=24, + col_offset=49, + end_lineno=24, + end_col_offset=52), + Load(), + lineno=24, + col_offset=35, + end_lineno=24, + end_col_offset=53), + Subscript( + Name( + 'split_indices', + Load(), + lineno=24, + col_offset=55, + end_lineno=24, + end_col_offset=68), + Slice( + Constant( + 1, + lineno=24, + col_offset=69, + end_lineno=24, + end_col_offset=70), + lineno=24, + col_offset=69, + end_lineno=24, + end_col_offset=71), + Load(), + lineno=24, + col_offset=55, + end_lineno=24, + end_col_offset=72)], + [], + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=73), + [], + 0)], + lineno=23, + col_offset=12, + end_lineno=24, + end_col_offset=74), + lineno=23, + col_offset=4, + end_lineno=24, + end_col_offset=74), + Return( + Call( + Attribute( + Constant( + ',', + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=14), + 'join', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=19), + [ + GeneratorExp( + Call( + Name( + 'convert_one_line', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=36), + [ + Name( + 'line', + Load(), + lineno=26, + col_offset=37, + end_lineno=26, + end_col_offset=41)], + [], + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=42), + [ + comprehension( + Name( + 'line', + Store(), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=51), + Name( + 'lines', + Load(), + lineno=26, + col_offset=55, + end_lineno=26, + end_col_offset=60), + [], + 0)], + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=61)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=61), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=61)], + [], + lineno=19, + col_offset=0, + end_lineno=26, + end_col_offset=61), + FunctionDef( + 'convert_one_line', + arguments( + [], + [ + arg( + 'input_grid', + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=30, + col_offset=7, + end_lineno=30, + end_col_offset=10), + [ + Name( + 'input_grid', + Load(), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=21)], + [], + lineno=30, + col_offset=7, + end_lineno=30, + end_col_offset=22), + [ + NotEq()], + [ + Name( + 'NUM_ROWS', + Load(), + lineno=30, + col_offset=26, + end_lineno=30, + end_col_offset=34)], + lineno=30, + col_offset=7, + end_lineno=30, + end_col_offset=34), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=24), + [ + Constant( + 'Number of input lines is not a multiple of four', + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=74)], + [], + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=75), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=75)], + [], + lineno=30, + col_offset=4, + end_lineno=31, + end_col_offset=75), + If( + BinOp( + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=10), + [ + Subscript( + Name( + 'input_grid', + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=21), + Constant( + 0, + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=23), + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=24)], + [], + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=25), + Mod(), + Name( + 'NUM_COLS', + Load(), + lineno=33, + col_offset=28, + end_lineno=33, + end_col_offset=36), + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=24), + [ + Constant( + 'Number of input columns is not a multiple of three', + lineno=34, + col_offset=25, + end_lineno=34, + end_col_offset=77)], + [], + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=78), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=78)], + [], + lineno=33, + col_offset=4, + end_lineno=34, + end_col_offset=78), + Assign( + [ + Name( + 'numbers', + Store(), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=11)], + Call( + Name( + 'split_ocr', + Load(), + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=23), + [ + Name( + 'input_grid', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=34)], + [], + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=35), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=35), + Assign( + [ + Name( + 'digits', + Store(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=10)], + Constant( + '', + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=15), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=15), + For( + Name( + 'num', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=11), + Name( + 'numbers', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=22), + [ + Try( + [ + AugAssign( + Name( + 'digits', + Store(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=18), + Add(), + Call( + Name( + 'str', + Load(), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=25), + [ + Call( + Attribute( + Name( + 'OCR_LIST', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=34), + 'index', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=40), + [ + Name( + 'num', + Load(), + lineno=40, + col_offset=41, + end_lineno=40, + end_col_offset=44)], + [], + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=45)], + [], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=46), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=46)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=25), + body=[ + AugAssign( + Name( + 'digits', + Store(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=18), + Add(), + Constant( + '?', + lineno=42, + col_offset=22, + end_lineno=42, + end_col_offset=25), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=25)], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=25)], + [], + [], + lineno=39, + col_offset=8, + end_lineno=42, + end_col_offset=25)], + [], + lineno=38, + col_offset=4, + end_lineno=42, + end_col_offset=25), + Return( + Name( + 'digits', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=17), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=17)], + [], + lineno=29, + col_offset=0, + end_lineno=43, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=8)], + Constant( + 4, + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=12), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=12), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=8)], + Constant( + 3, + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=12), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=12), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + ListComp( + Subscript( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=16), + Name( + 'placeholder_6', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=20), + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=21), + Slice( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=30), + Mult(), + Name( + 'placeholder_5', + Load(), + lineno=6, + col_offset=33, + end_lineno=6, + end_col_offset=36), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=36), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=45), + Mult(), + BinOp( + Name( + 'placeholder_5', + Load(), + lineno=6, + col_offset=49, + end_lineno=6, + end_col_offset=52), + Add(), + Constant( + 1, + lineno=6, + col_offset=55, + end_lineno=6, + end_col_offset=56), + lineno=6, + col_offset=49, + end_lineno=6, + end_col_offset=56), + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=57), + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=57), + Load(), + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=58), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=6, + col_offset=63, + end_lineno=6, + end_col_offset=66), + Call( + Name( + 'range', + Load(), + lineno=6, + col_offset=70, + end_lineno=6, + end_col_offset=75), + [ + Name( + 'placeholder_0', + Load(), + lineno=6, + col_offset=76, + end_lineno=6, + end_col_offset=84)], + [], + lineno=6, + col_offset=70, + end_lineno=6, + end_col_offset=85), + [], + 0)], + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=86), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=28), + [ + BinOp( + Call( + Name( + 'len', + Load(), + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=32), + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=36), + Constant( + 0, + lineno=7, + col_offset=37, + end_lineno=7, + end_col_offset=38), + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=39)], + [], + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=40), + FloorDiv(), + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=44, + end_lineno=7, + end_col_offset=52), + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=52)], + [], + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=53), + [], + 0)], + lineno=6, + col_offset=11, + end_lineno=7, + end_col_offset=54), + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=54)], + [], + lineno=5, + col_offset=0, + end_lineno=7, + end_col_offset=54), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=3)], + List( + [ + Constant( + ' _ _ _ _ _ _ _ _ ', + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=39), + Constant( + ' | _| _||_||_ |_ ||_||_|| |', + lineno=11, + col_offset=7, + end_lineno=11, + end_col_offset=39), + Constant( + ' ||_ _| | _||_| ||_| _||_|', + lineno=12, + col_offset=7, + end_lineno=12, + end_col_offset=39), + Constant( + ' ', + lineno=13, + col_offset=7, + end_lineno=13, + end_col_offset=39)], + Load(), + lineno=10, + col_offset=6, + end_lineno=13, + end_col_offset=40), + lineno=10, + col_offset=0, + end_lineno=13, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=8)], + Call( + Name( + 'placeholder_2', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=20), + [ + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=24)], + [], + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=25), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=25), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=8)], + BinOp( + List( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=20), + UnaryOp( + USub(), + Constant( + 1, + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=23), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=23), + Load(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=24)], + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=25), + Add(), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=36), + Slice( + upper=Constant( + 9, + lineno=16, + col_offset=38, + end_lineno=16, + end_col_offset=39), + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=39), + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=0, + end_lineno=16, + end_col_offset=40), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=17)], + BinOp( + Call( + Name( + 'list', + Load(), + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=25), + [ + Call( + Name( + 'range', + Load(), + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=31), + [ + Constant( + 0, + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=33), + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=35, + end_lineno=20, + end_col_offset=38), + [ + Name( + 'placeholder_10', + Load(), + lineno=20, + col_offset=39, + end_lineno=20, + end_col_offset=49)], + [], + lineno=20, + col_offset=35, + end_lineno=20, + end_col_offset=50), + Name( + 'placeholder_0', + Load(), + lineno=20, + col_offset=52, + end_lineno=20, + end_col_offset=60)], + [], + lineno=20, + col_offset=26, + end_lineno=20, + end_col_offset=61)], + [], + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=62), + Add(), + List( + [ + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=25), + [ + Name( + 'placeholder_10', + Load(), + lineno=21, + col_offset=26, + end_lineno=21, + end_col_offset=36)], + [], + lineno=21, + col_offset=22, + end_lineno=21, + end_col_offset=37)], + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=38), + lineno=20, + col_offset=21, + end_lineno=21, + end_col_offset=38), + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=9)], + ListComp( + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=23), + Slice( + Name( + 'placeholder_13', + Load(), + lineno=23, + col_offset=24, + end_lineno=23, + end_col_offset=29), + Name( + 'placeholder_14', + Load(), + lineno=23, + col_offset=30, + end_lineno=23, + end_col_offset=33), + lineno=23, + col_offset=24, + end_lineno=23, + end_col_offset=33), + Load(), + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=34), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_13', + Store(), + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=22), + Name( + 'placeholder_14', + Store(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=27)], + Store(), + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=27), + Call( + Name( + 'zip', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=34), + [ + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=24, + col_offset=35, + end_lineno=24, + end_col_offset=48), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=24, + col_offset=51, + end_lineno=24, + end_col_offset=52), + lineno=24, + col_offset=50, + end_lineno=24, + end_col_offset=52), + lineno=24, + col_offset=49, + end_lineno=24, + end_col_offset=52), + Load(), + lineno=24, + col_offset=35, + end_lineno=24, + end_col_offset=53), + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=24, + col_offset=55, + end_lineno=24, + end_col_offset=68), + Slice( + Constant( + 1, + lineno=24, + col_offset=69, + end_lineno=24, + end_col_offset=70), + lineno=24, + col_offset=69, + end_lineno=24, + end_col_offset=71), + Load(), + lineno=24, + col_offset=55, + end_lineno=24, + end_col_offset=72)], + [], + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=73), + [], + 0)], + lineno=23, + col_offset=12, + end_lineno=24, + end_col_offset=74), + lineno=23, + col_offset=4, + end_lineno=24, + end_col_offset=74), + Return( + Call( + Attribute( + Constant( + ',', + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=14), + 'join', + Load(), + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=19), + [ + GeneratorExp( + Call( + Name( + 'convert_one_line', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=36), + [ + Name( + 'placeholder_15', + Load(), + lineno=26, + col_offset=37, + end_lineno=26, + end_col_offset=41)], + [], + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=42), + [ + comprehension( + Name( + 'placeholder_15', + Store(), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=51), + Name( + 'placeholder_12', + Load(), + lineno=26, + col_offset=55, + end_lineno=26, + end_col_offset=60), + [], + 0)], + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=61)], + [], + lineno=26, + col_offset=11, + end_lineno=26, + end_col_offset=61), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=61)], + [], + lineno=19, + col_offset=0, + end_lineno=26, + end_col_offset=61), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=30, + col_offset=7, + end_lineno=30, + end_col_offset=10), + [ + Name( + 'placeholder_10', + Load(), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=21)], + [], + lineno=30, + col_offset=7, + end_lineno=30, + end_col_offset=22), + [ + NotEq()], + [ + Name( + 'placeholder_0', + Load(), + lineno=30, + col_offset=26, + end_lineno=30, + end_col_offset=34)], + lineno=30, + col_offset=7, + end_lineno=30, + end_col_offset=34), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=24), + [ + Constant( + 'Number of input lines is not a multiple of four', + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=74)], + [], + lineno=31, + col_offset=14, + end_lineno=31, + end_col_offset=75), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=75)], + [], + lineno=30, + col_offset=4, + end_lineno=31, + end_col_offset=75), + If( + BinOp( + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=10), + [ + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=21), + Constant( + 0, + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=23), + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=24)], + [], + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=25), + Mod(), + Name( + 'placeholder_1', + Load(), + lineno=33, + col_offset=28, + end_lineno=33, + end_col_offset=36), + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=24), + [ + Constant( + 'Number of input columns is not a multiple of three', + lineno=34, + col_offset=25, + end_lineno=34, + end_col_offset=77)], + [], + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=78), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=78)], + [], + lineno=33, + col_offset=4, + end_lineno=34, + end_col_offset=78), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=11)], + Call( + Name( + 'placeholder_2', + Load(), + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=23), + [ + Name( + 'placeholder_10', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=34)], + [], + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=35), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=35), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=10)], + Constant( + '', + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=15), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=15), + For( + Name( + 'placeholder_19', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=11), + Name( + 'placeholder_17', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=22), + [ + Try( + [ + AugAssign( + Name( + 'placeholder_18', + Store(), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=18), + Add(), + Call( + Name( + 'str', + Load(), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=25), + [ + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=34), + 'index', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=40), + [ + Name( + 'placeholder_19', + Load(), + lineno=40, + col_offset=41, + end_lineno=40, + end_col_offset=44)], + [], + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=45)], + [], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=46), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=46)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=25), + body=[ + AugAssign( + Name( + 'placeholder_18', + Store(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=18), + Add(), + Constant( + '?', + lineno=42, + col_offset=22, + end_lineno=42, + end_col_offset=25), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=25)], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=25)], + [], + [], + lineno=39, + col_offset=8, + end_lineno=42, + end_col_offset=25)], + [], + lineno=38, + col_offset=4, + end_lineno=42, + end_col_offset=25), + Return( + Name( + 'placeholder_18', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=17), + lineno=43, + col_offset=4, + end_lineno=43, + end_col_offset=17)], + [], + lineno=29, + col_offset=0, + end_lineno=43, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-ocr-numbers/representation.txt b/test/practice-ocr-numbers/representation.txt new file mode 100644 index 0000000..56673b4 --- /dev/null +++ b/test/practice-ocr-numbers/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=8)], Constant(4, lineno=1, col_offset=11, end_lineno=1, end_col_offset=12), lineno=1, col_offset=0, end_lineno=1, end_col_offset=12), Assign([Name('placeholder_1', Store(), lineno=2, col_offset=0, end_lineno=2, end_col_offset=8)], Constant(3, lineno=2, col_offset=11, end_lineno=2, end_col_offset=12), lineno=2, col_offset=0, end_lineno=2, end_col_offset=12), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=5, col_offset=14, end_lineno=5, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(ListComp(Subscript(Subscript(Name('placeholder_3', Load(), lineno=6, col_offset=13, end_lineno=6, end_col_offset=16), Name('placeholder_6', Load(), lineno=6, col_offset=17, end_lineno=6, end_col_offset=20), Load(), lineno=6, col_offset=13, end_lineno=6, end_col_offset=21), Slice(BinOp(Name('placeholder_1', Load(), lineno=6, col_offset=22, end_lineno=6, end_col_offset=30), Mult(), Name('placeholder_5', Load(), lineno=6, col_offset=33, end_lineno=6, end_col_offset=36), lineno=6, col_offset=22, end_lineno=6, end_col_offset=36), BinOp(Name('placeholder_1', Load(), lineno=6, col_offset=37, end_lineno=6, end_col_offset=45), Mult(), BinOp(Name('placeholder_5', Load(), lineno=6, col_offset=49, end_lineno=6, end_col_offset=52), Add(), Constant(1, lineno=6, col_offset=55, end_lineno=6, end_col_offset=56), lineno=6, col_offset=49, end_lineno=6, end_col_offset=56), lineno=6, col_offset=37, end_lineno=6, end_col_offset=57), lineno=6, col_offset=22, end_lineno=6, end_col_offset=57), Load(), lineno=6, col_offset=13, end_lineno=6, end_col_offset=58), [comprehension(Name('placeholder_6', Store(), lineno=6, col_offset=63, end_lineno=6, end_col_offset=66), Call(Name('range', Load(), lineno=6, col_offset=70, end_lineno=6, end_col_offset=75), [Name('placeholder_0', Load(), lineno=6, col_offset=76, end_lineno=6, end_col_offset=84)], [], lineno=6, col_offset=70, end_lineno=6, end_col_offset=85), [], 0)], lineno=6, col_offset=12, end_lineno=6, end_col_offset=86), [comprehension(Name('placeholder_5', Store(), lineno=7, col_offset=16, end_lineno=7, end_col_offset=19), Call(Name('range', Load(), lineno=7, col_offset=23, end_lineno=7, end_col_offset=28), [BinOp(Call(Name('len', Load(), lineno=7, col_offset=29, end_lineno=7, end_col_offset=32), [Subscript(Name('placeholder_3', Load(), lineno=7, col_offset=33, end_lineno=7, end_col_offset=36), Constant(0, lineno=7, col_offset=37, end_lineno=7, end_col_offset=38), Load(), lineno=7, col_offset=33, end_lineno=7, end_col_offset=39)], [], lineno=7, col_offset=29, end_lineno=7, end_col_offset=40), FloorDiv(), Name('placeholder_1', Load(), lineno=7, col_offset=44, end_lineno=7, end_col_offset=52), lineno=7, col_offset=29, end_lineno=7, end_col_offset=52)], [], lineno=7, col_offset=23, end_lineno=7, end_col_offset=53), [], 0)], lineno=6, col_offset=11, end_lineno=7, end_col_offset=54), lineno=6, col_offset=4, end_lineno=7, end_col_offset=54)], [], lineno=5, col_offset=0, end_lineno=7, end_col_offset=54), Assign([Name('placeholder_7', Store(), lineno=10, col_offset=0, end_lineno=10, end_col_offset=3)], List([Constant(' _ _ _ _ _ _ _ _ ', lineno=10, col_offset=7, end_lineno=10, end_col_offset=39), Constant(' | _| _||_||_ |_ ||_||_|| |', lineno=11, col_offset=7, end_lineno=11, end_col_offset=39), Constant(' ||_ _| | _||_| ||_| _||_|', lineno=12, col_offset=7, end_lineno=12, end_col_offset=39), Constant(' ', lineno=13, col_offset=7, end_lineno=13, end_col_offset=39)], Load(), lineno=10, col_offset=6, end_lineno=13, end_col_offset=40), lineno=10, col_offset=0, end_lineno=13, end_col_offset=40), Assign([Name('placeholder_8', Store(), lineno=15, col_offset=0, end_lineno=15, end_col_offset=8)], Call(Name('placeholder_2', Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=20), [Name('placeholder_7', Load(), lineno=15, col_offset=21, end_lineno=15, end_col_offset=24)], [], lineno=15, col_offset=11, end_lineno=15, end_col_offset=25), lineno=15, col_offset=0, end_lineno=15, end_col_offset=25), Assign([Name('placeholder_8', Store(), lineno=16, col_offset=0, end_lineno=16, end_col_offset=8)], BinOp(List([Subscript(Name('placeholder_8', Load(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=20), UnaryOp(USub(), Constant(1, lineno=16, col_offset=22, end_lineno=16, end_col_offset=23), lineno=16, col_offset=21, end_lineno=16, end_col_offset=23), Load(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=24)], Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=25), Add(), Subscript(Name('placeholder_8', Load(), lineno=16, col_offset=28, end_lineno=16, end_col_offset=36), Slice(upper=Constant(9, lineno=16, col_offset=38, end_lineno=16, end_col_offset=39), lineno=16, col_offset=37, end_lineno=16, end_col_offset=39), Load(), lineno=16, col_offset=28, end_lineno=16, end_col_offset=40), lineno=16, col_offset=11, end_lineno=16, end_col_offset=40), lineno=16, col_offset=0, end_lineno=16, end_col_offset=40), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=19, col_offset=12, end_lineno=19, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_11', Store(), lineno=20, col_offset=4, end_lineno=20, end_col_offset=17)], BinOp(Call(Name('list', Load(), lineno=20, col_offset=21, end_lineno=20, end_col_offset=25), [Call(Name('range', Load(), lineno=20, col_offset=26, end_lineno=20, end_col_offset=31), [Constant(0, lineno=20, col_offset=32, end_lineno=20, end_col_offset=33), Call(Name('len', Load(), lineno=20, col_offset=35, end_lineno=20, end_col_offset=38), [Name('placeholder_10', Load(), lineno=20, col_offset=39, end_lineno=20, end_col_offset=49)], [], lineno=20, col_offset=35, end_lineno=20, end_col_offset=50), Name('placeholder_0', Load(), lineno=20, col_offset=52, end_lineno=20, end_col_offset=60)], [], lineno=20, col_offset=26, end_lineno=20, end_col_offset=61)], [], lineno=20, col_offset=21, end_lineno=20, end_col_offset=62), Add(), List([Call(Name('len', Load(), lineno=21, col_offset=22, end_lineno=21, end_col_offset=25), [Name('placeholder_10', Load(), lineno=21, col_offset=26, end_lineno=21, end_col_offset=36)], [], lineno=21, col_offset=22, end_lineno=21, end_col_offset=37)], Load(), lineno=21, col_offset=21, end_lineno=21, end_col_offset=38), lineno=20, col_offset=21, end_lineno=21, end_col_offset=38), lineno=20, col_offset=4, end_lineno=21, end_col_offset=39), Assign([Name('placeholder_12', Store(), lineno=23, col_offset=4, end_lineno=23, end_col_offset=9)], ListComp(Subscript(Name('placeholder_10', Load(), lineno=23, col_offset=13, end_lineno=23, end_col_offset=23), Slice(Name('placeholder_13', Load(), lineno=23, col_offset=24, end_lineno=23, end_col_offset=29), Name('placeholder_14', Load(), lineno=23, col_offset=30, end_lineno=23, end_col_offset=33), lineno=23, col_offset=24, end_lineno=23, end_col_offset=33), Load(), lineno=23, col_offset=13, end_lineno=23, end_col_offset=34), [comprehension(Tuple([Name('placeholder_13', Store(), lineno=24, col_offset=17, end_lineno=24, end_col_offset=22), Name('placeholder_14', Store(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=27)], Store(), lineno=24, col_offset=17, end_lineno=24, end_col_offset=27), Call(Name('zip', Load(), lineno=24, col_offset=31, end_lineno=24, end_col_offset=34), [Subscript(Name('placeholder_11', Load(), lineno=24, col_offset=35, end_lineno=24, end_col_offset=48), Slice(upper=UnaryOp(USub(), Constant(1, lineno=24, col_offset=51, end_lineno=24, end_col_offset=52), lineno=24, col_offset=50, end_lineno=24, end_col_offset=52), lineno=24, col_offset=49, end_lineno=24, end_col_offset=52), Load(), lineno=24, col_offset=35, end_lineno=24, end_col_offset=53), Subscript(Name('placeholder_11', Load(), lineno=24, col_offset=55, end_lineno=24, end_col_offset=68), Slice(Constant(1, lineno=24, col_offset=69, end_lineno=24, end_col_offset=70), lineno=24, col_offset=69, end_lineno=24, end_col_offset=71), Load(), lineno=24, col_offset=55, end_lineno=24, end_col_offset=72)], [], lineno=24, col_offset=31, end_lineno=24, end_col_offset=73), [], 0)], lineno=23, col_offset=12, end_lineno=24, end_col_offset=74), lineno=23, col_offset=4, end_lineno=24, end_col_offset=74), Return(Call(Attribute(Constant(',', lineno=26, col_offset=11, end_lineno=26, end_col_offset=14), 'join', Load(), lineno=26, col_offset=11, end_lineno=26, end_col_offset=19), [GeneratorExp(Call(Name('convert_one_line', Load(), lineno=26, col_offset=20, end_lineno=26, end_col_offset=36), [Name('placeholder_15', Load(), lineno=26, col_offset=37, end_lineno=26, end_col_offset=41)], [], lineno=26, col_offset=20, end_lineno=26, end_col_offset=42), [comprehension(Name('placeholder_15', Store(), lineno=26, col_offset=47, end_lineno=26, end_col_offset=51), Name('placeholder_12', Load(), lineno=26, col_offset=55, end_lineno=26, end_col_offset=60), [], 0)], lineno=26, col_offset=19, end_lineno=26, end_col_offset=61)], [], lineno=26, col_offset=11, end_lineno=26, end_col_offset=61), lineno=26, col_offset=4, end_lineno=26, end_col_offset=61)], [], lineno=19, col_offset=0, end_lineno=26, end_col_offset=61), FunctionDef('placeholder_16', arguments([], [arg('placeholder_10', lineno=29, col_offset=21, end_lineno=29, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=30, col_offset=7, end_lineno=30, end_col_offset=10), [Name('placeholder_10', Load(), lineno=30, col_offset=11, end_lineno=30, end_col_offset=21)], [], lineno=30, col_offset=7, end_lineno=30, end_col_offset=22), [NotEq()], [Name('placeholder_0', Load(), lineno=30, col_offset=26, end_lineno=30, end_col_offset=34)], lineno=30, col_offset=7, end_lineno=30, end_col_offset=34), [Raise(Call(Name('ValueError', Load(), lineno=31, col_offset=14, end_lineno=31, end_col_offset=24), [Constant('Number of input lines is not a multiple of four', lineno=31, col_offset=25, end_lineno=31, end_col_offset=74)], [], lineno=31, col_offset=14, end_lineno=31, end_col_offset=75), lineno=31, col_offset=8, end_lineno=31, end_col_offset=75)], [], lineno=30, col_offset=4, end_lineno=31, end_col_offset=75), If(BinOp(Call(Name('len', Load(), lineno=33, col_offset=7, end_lineno=33, end_col_offset=10), [Subscript(Name('placeholder_10', Load(), lineno=33, col_offset=11, end_lineno=33, end_col_offset=21), Constant(0, lineno=33, col_offset=22, end_lineno=33, end_col_offset=23), Load(), lineno=33, col_offset=11, end_lineno=33, end_col_offset=24)], [], lineno=33, col_offset=7, end_lineno=33, end_col_offset=25), Mod(), Name('placeholder_1', Load(), lineno=33, col_offset=28, end_lineno=33, end_col_offset=36), lineno=33, col_offset=7, end_lineno=33, end_col_offset=36), [Raise(Call(Name('ValueError', Load(), lineno=34, col_offset=14, end_lineno=34, end_col_offset=24), [Constant('Number of input columns is not a multiple of three', lineno=34, col_offset=25, end_lineno=34, end_col_offset=77)], [], lineno=34, col_offset=14, end_lineno=34, end_col_offset=78), lineno=34, col_offset=8, end_lineno=34, end_col_offset=78)], [], lineno=33, col_offset=4, end_lineno=34, end_col_offset=78), Assign([Name('placeholder_17', Store(), lineno=36, col_offset=4, end_lineno=36, end_col_offset=11)], Call(Name('placeholder_2', Load(), lineno=36, col_offset=14, end_lineno=36, end_col_offset=23), [Name('placeholder_10', Load(), lineno=36, col_offset=24, end_lineno=36, end_col_offset=34)], [], lineno=36, col_offset=14, end_lineno=36, end_col_offset=35), lineno=36, col_offset=4, end_lineno=36, end_col_offset=35), Assign([Name('placeholder_18', Store(), lineno=37, col_offset=4, end_lineno=37, end_col_offset=10)], Constant('', lineno=37, col_offset=13, end_lineno=37, end_col_offset=15), lineno=37, col_offset=4, end_lineno=37, end_col_offset=15), For(Name('placeholder_19', Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=11), Name('placeholder_17', Load(), lineno=38, col_offset=15, end_lineno=38, end_col_offset=22), [Try([AugAssign(Name('placeholder_18', Store(), lineno=40, col_offset=12, end_lineno=40, end_col_offset=18), Add(), Call(Name('str', Load(), lineno=40, col_offset=22, end_lineno=40, end_col_offset=25), [Call(Attribute(Name('placeholder_8', Load(), lineno=40, col_offset=26, end_lineno=40, end_col_offset=34), 'index', Load(), lineno=40, col_offset=26, end_lineno=40, end_col_offset=40), [Name('placeholder_19', Load(), lineno=40, col_offset=41, end_lineno=40, end_col_offset=44)], [], lineno=40, col_offset=26, end_lineno=40, end_col_offset=45)], [], lineno=40, col_offset=22, end_lineno=40, end_col_offset=46), lineno=40, col_offset=12, end_lineno=40, end_col_offset=46)], [ExceptHandler(Name('ValueError', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=25), body=[AugAssign(Name('placeholder_18', Store(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=18), Add(), Constant('?', lineno=42, col_offset=22, end_lineno=42, end_col_offset=25), lineno=42, col_offset=12, end_lineno=42, end_col_offset=25)], lineno=41, col_offset=8, end_lineno=42, end_col_offset=25)], [], [], lineno=39, col_offset=8, end_lineno=42, end_col_offset=25)], [], lineno=38, col_offset=4, end_lineno=42, end_col_offset=25), Return(Name('placeholder_18', Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=17), lineno=43, col_offset=4, end_lineno=43, end_col_offset=17)], [], lineno=29, col_offset=0, end_lineno=43, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-octal/.meta/config.json b/test/practice-octal/.meta/config.json new file mode 100644 index 0000000..4fe6c11 --- /dev/null +++ b/test/practice-octal/.meta/config.json @@ -0,0 +1,30 @@ +{ + "blurb": "Convert a octal number, represented as a string (e.g. '1735263'), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion).", + "authors": [ + "sjakobi" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "jesserizzo", + "kytrinyx", + "N-Parsons", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "octal.py" + ], + "test": [ + "octal_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "All of Computer Science", + "source_url": "https://www.wolframalpha.com/examples/mathematics/numbers/base-conversions" +} diff --git a/test/practice-octal/mapping.json b/test/practice-octal/mapping.json new file mode 100644 index 0000000..7dd881b --- /dev/null +++ b/test/practice-octal/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "parse_octal", + "placeholder_1": "digits", + "placeholder_2": "idx", + "placeholder_3": "digit", + "placeholder_4": "_validate_octal" +} \ No newline at end of file diff --git a/test/practice-octal/octal.py b/test/practice-octal/octal.py new file mode 100644 index 0000000..86000ee --- /dev/null +++ b/test/practice-octal/octal.py @@ -0,0 +1,11 @@ +def parse_octal(digits): + digits = _validate_octal(digits) + return sum(int(digit) * 8 ** idx + for (idx, digit) in enumerate(reversed(digits))) + + +def _validate_octal(digits): + for digit in digits: + if not '0' <= digit < '8': + raise ValueError("Invalid octal digit: " + digit) + return digits diff --git a/test/practice-octal/representation.json b/test/practice-octal/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-octal/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-octal/representation.out b/test/practice-octal/representation.out new file mode 100644 index 0000000..4e29710 --- /dev/null +++ b/test/practice-octal/representation.out @@ -0,0 +1,662 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_1 = _validate_octal(placeholder_1) + return sum( + ( + int(placeholder_3) * 8**placeholder_2 + for placeholder_2, placeholder_3 in enumerate(reversed(placeholder_1)) + ) + ) + + +def placeholder_4(placeholder_1): + for placeholder_3 in placeholder_1: + if not "0" <= placeholder_3 < "8": + raise ValueError("Invalid octal digit: " + placeholder_3) + return placeholder_1 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'parse_octal', + arguments( + [], + [ + arg( + 'digits', + lineno=1, + col_offset=16, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'digits', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=10)], + Call( + Name( + '_validate_octal', + Load(), + lineno=2, + col_offset=13, + end_lineno=2, + end_col_offset=28), + [ + Name( + 'digits', + Load(), + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=35)], + [], + lineno=2, + col_offset=13, + end_lineno=2, + end_col_offset=36), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=36), + Return( + Call( + Name( + 'sum', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=14), + [ + GeneratorExp( + BinOp( + Call( + Name( + 'int', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=18), + [ + Name( + 'digit', + Load(), + lineno=3, + col_offset=19, + end_lineno=3, + end_col_offset=24)], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=25), + Mult(), + BinOp( + Constant( + 8, + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=29), + Pow(), + Name( + 'idx', + Load(), + lineno=3, + col_offset=33, + end_lineno=3, + end_col_offset=36), + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=36), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=36), + [ + comprehension( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=23), + Name( + 'digit', + Store(), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=30)], + Store(), + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=31), + Call( + Name( + 'enumerate', + Load(), + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=44), + [ + Call( + Name( + 'reversed', + Load(), + lineno=4, + col_offset=45, + end_lineno=4, + end_col_offset=53), + [ + Name( + 'digits', + Load(), + lineno=4, + col_offset=54, + end_lineno=4, + end_col_offset=60)], + [], + lineno=4, + col_offset=45, + end_lineno=4, + end_col_offset=61)], + [], + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=62), + [], + 0)], + lineno=3, + col_offset=14, + end_lineno=4, + end_col_offset=63)], + [], + lineno=3, + col_offset=11, + end_lineno=4, + end_col_offset=63), + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=63)], + [], + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=63), + FunctionDef( + '_validate_octal', + arguments( + [], + [ + arg( + 'digits', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'digit', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=13), + Name( + 'digits', + Load(), + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=23), + [ + If( + UnaryOp( + Not(), + Compare( + Constant( + '0', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=18), + [ + LtE(), + Lt()], + [ + Name( + 'digit', + Load(), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=27), + Constant( + '8', + lineno=9, + col_offset=30, + end_lineno=9, + end_col_offset=33)], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=33), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=28), + [ + BinOp( + Constant( + 'Invalid octal digit: ', + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=52), + Add(), + Name( + 'digit', + Load(), + lineno=10, + col_offset=55, + end_lineno=10, + end_col_offset=60), + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=60)], + [], + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=61), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=61)], + [], + lineno=9, + col_offset=8, + end_lineno=10, + end_col_offset=61)], + [], + lineno=8, + col_offset=4, + end_lineno=10, + end_col_offset=61), + Return( + Name( + 'digits', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=17), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=17)], + [], + lineno=7, + col_offset=0, + end_lineno=11, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=16, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=10)], + Call( + Name( + '_validate_octal', + Load(), + lineno=2, + col_offset=13, + end_lineno=2, + end_col_offset=28), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=35)], + [], + lineno=2, + col_offset=13, + end_lineno=2, + end_col_offset=36), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=36), + Return( + Call( + Name( + 'sum', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=14), + [ + GeneratorExp( + BinOp( + Call( + Name( + 'int', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=18), + [ + Name( + 'placeholder_3', + Load(), + lineno=3, + col_offset=19, + end_lineno=3, + end_col_offset=24)], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=25), + Mult(), + BinOp( + Constant( + 8, + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=29), + Pow(), + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=33, + end_lineno=3, + end_col_offset=36), + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=36), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=36), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_2', + Store(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=23), + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=30)], + Store(), + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=31), + Call( + Name( + 'enumerate', + Load(), + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=44), + [ + Call( + Name( + 'reversed', + Load(), + lineno=4, + col_offset=45, + end_lineno=4, + end_col_offset=53), + [ + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=54, + end_lineno=4, + end_col_offset=60)], + [], + lineno=4, + col_offset=45, + end_lineno=4, + end_col_offset=61)], + [], + lineno=4, + col_offset=35, + end_lineno=4, + end_col_offset=62), + [], + 0)], + lineno=3, + col_offset=14, + end_lineno=4, + end_col_offset=63)], + [], + lineno=3, + col_offset=11, + end_lineno=4, + end_col_offset=63), + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=63)], + [], + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=63), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_3', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=13), + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=23), + [ + If( + UnaryOp( + Not(), + Compare( + Constant( + '0', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=18), + [ + LtE(), + Lt()], + [ + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=22, + end_lineno=9, + end_col_offset=27), + Constant( + '8', + lineno=9, + col_offset=30, + end_lineno=9, + end_col_offset=33)], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=33), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=28), + [ + BinOp( + Constant( + 'Invalid octal digit: ', + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=52), + Add(), + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=55, + end_lineno=10, + end_col_offset=60), + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=60)], + [], + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=61), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=61)], + [], + lineno=9, + col_offset=8, + end_lineno=10, + end_col_offset=61)], + [], + lineno=8, + col_offset=4, + end_lineno=10, + end_col_offset=61), + Return( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=17), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=17)], + [], + lineno=7, + col_offset=0, + end_lineno=11, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-octal/representation.txt b/test/practice-octal/representation.txt new file mode 100644 index 0000000..c667dfd --- /dev/null +++ b/test/practice-octal/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=16, end_lineno=1, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_1', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=10)], Call(Name('_validate_octal', Load(), lineno=2, col_offset=13, end_lineno=2, end_col_offset=28), [Name('placeholder_1', Load(), lineno=2, col_offset=29, end_lineno=2, end_col_offset=35)], [], lineno=2, col_offset=13, end_lineno=2, end_col_offset=36), lineno=2, col_offset=4, end_lineno=2, end_col_offset=36), Return(Call(Name('sum', Load(), lineno=3, col_offset=11, end_lineno=3, end_col_offset=14), [GeneratorExp(BinOp(Call(Name('int', Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=18), [Name('placeholder_3', Load(), lineno=3, col_offset=19, end_lineno=3, end_col_offset=24)], [], lineno=3, col_offset=15, end_lineno=3, end_col_offset=25), Mult(), BinOp(Constant(8, lineno=3, col_offset=28, end_lineno=3, end_col_offset=29), Pow(), Name('placeholder_2', Load(), lineno=3, col_offset=33, end_lineno=3, end_col_offset=36), lineno=3, col_offset=28, end_lineno=3, end_col_offset=36), lineno=3, col_offset=15, end_lineno=3, end_col_offset=36), [comprehension(Tuple([Name('placeholder_2', Store(), lineno=4, col_offset=20, end_lineno=4, end_col_offset=23), Name('placeholder_3', Store(), lineno=4, col_offset=25, end_lineno=4, end_col_offset=30)], Store(), lineno=4, col_offset=19, end_lineno=4, end_col_offset=31), Call(Name('enumerate', Load(), lineno=4, col_offset=35, end_lineno=4, end_col_offset=44), [Call(Name('reversed', Load(), lineno=4, col_offset=45, end_lineno=4, end_col_offset=53), [Name('placeholder_1', Load(), lineno=4, col_offset=54, end_lineno=4, end_col_offset=60)], [], lineno=4, col_offset=45, end_lineno=4, end_col_offset=61)], [], lineno=4, col_offset=35, end_lineno=4, end_col_offset=62), [], 0)], lineno=3, col_offset=14, end_lineno=4, end_col_offset=63)], [], lineno=3, col_offset=11, end_lineno=4, end_col_offset=63), lineno=3, col_offset=4, end_lineno=4, end_col_offset=63)], [], lineno=1, col_offset=0, end_lineno=4, end_col_offset=63), FunctionDef('placeholder_4', arguments([], [arg('placeholder_1', lineno=7, col_offset=20, end_lineno=7, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_3', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=13), Name('placeholder_1', Load(), lineno=8, col_offset=17, end_lineno=8, end_col_offset=23), [If(UnaryOp(Not(), Compare(Constant('0', lineno=9, col_offset=15, end_lineno=9, end_col_offset=18), [LtE(), Lt()], [Name('placeholder_3', Load(), lineno=9, col_offset=22, end_lineno=9, end_col_offset=27), Constant('8', lineno=9, col_offset=30, end_lineno=9, end_col_offset=33)], lineno=9, col_offset=15, end_lineno=9, end_col_offset=33), lineno=9, col_offset=11, end_lineno=9, end_col_offset=33), [Raise(Call(Name('ValueError', Load(), lineno=10, col_offset=18, end_lineno=10, end_col_offset=28), [BinOp(Constant('Invalid octal digit: ', lineno=10, col_offset=29, end_lineno=10, end_col_offset=52), Add(), Name('placeholder_3', Load(), lineno=10, col_offset=55, end_lineno=10, end_col_offset=60), lineno=10, col_offset=29, end_lineno=10, end_col_offset=60)], [], lineno=10, col_offset=18, end_lineno=10, end_col_offset=61), lineno=10, col_offset=12, end_lineno=10, end_col_offset=61)], [], lineno=9, col_offset=8, end_lineno=10, end_col_offset=61)], [], lineno=8, col_offset=4, end_lineno=10, end_col_offset=61), Return(Name('placeholder_1', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=17), lineno=11, col_offset=4, end_lineno=11, end_col_offset=17)], [], lineno=7, col_offset=0, end_lineno=11, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-paasio/.meta/config.json b/test/practice-paasio/.meta/config.json new file mode 100644 index 0000000..a9c0b9c --- /dev/null +++ b/test/practice-paasio/.meta/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "AnAccountForReportingBugs" + ], + "contributors": [ + "cmccandless" + ], + "files": { + "solution": [ + "paasio.py" + ], + "test": [ + "paasio_test.py", + "test_utils.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Report network IO statistics.", + "source": "Brian Matsuo", + "source_url": "https://github.com/bmatsuo" +} diff --git a/test/practice-paasio/mapping.json b/test/practice-paasio/mapping.json new file mode 100644 index 0000000..bf653a6 --- /dev/null +++ b/test/practice-paasio/mapping.json @@ -0,0 +1,42 @@ +{ + "placeholder_0": "MeteredFile", + "placeholder_1": "__init__", + "placeholder_2": "args", + "placeholder_3": "kwargs", + "placeholder_4": "_read_bytes", + "placeholder_5": "_read_ops", + "placeholder_6": "_write_bytes", + "placeholder_7": "_write_ops", + "placeholder_8": "__enter__", + "placeholder_9": "__exit__", + "placeholder_10": "exc_type", + "placeholder_11": "exc_val", + "placeholder_12": "exc_tb", + "placeholder_13": "__iter__", + "placeholder_14": "__next__", + "placeholder_15": "data", + "placeholder_16": "read", + "placeholder_17": "size", + "placeholder_18": "read_bytes", + "placeholder_19": "read_ops", + "placeholder_20": "write", + "placeholder_21": "b", + "placeholder_22": "length", + "placeholder_23": "write_bytes", + "placeholder_24": "write_ops", + "placeholder_25": "MeteredSocket", + "placeholder_26": "socket", + "placeholder_27": "_socket", + "placeholder_28": "_recv_bytes", + "placeholder_29": "_recv_ops", + "placeholder_30": "_send_bytes", + "placeholder_31": "_send_ops", + "placeholder_32": "recv", + "placeholder_33": "bufsize", + "placeholder_34": "flags", + "placeholder_35": "recv_bytes", + "placeholder_36": "recv_ops", + "placeholder_37": "send", + "placeholder_38": "send_bytes", + "placeholder_39": "send_ops" +} \ No newline at end of file diff --git a/test/practice-paasio/paasio.py b/test/practice-paasio/paasio.py new file mode 100644 index 0000000..54a404a --- /dev/null +++ b/test/practice-paasio/paasio.py @@ -0,0 +1,102 @@ +import io + + +class MeteredFile(io.BufferedRandom): + """Implement using a subclassing model.""" + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self._read_bytes = 0 + self._read_ops = 0 + self._write_bytes = 0 + self._write_ops = 0 + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + return super().__exit__(exc_type, exc_val, exc_tb) + + def __iter__(self): + return self + + def __next__(self): + self._read_ops += 1 + data = super().readline() + self._read_bytes += len(data) + if data: + return data + raise StopIteration + + def read(self, size=-1): + self._read_ops += 1 + data = super().read(size) + self._read_bytes += len(data) + return data + + @property + def read_bytes(self): + return self._read_bytes + + @property + def read_ops(self): + return self._read_ops + + def write(self, b): + self._write_ops += 1 + length = super().write(b) + self._write_bytes += length + return length + + @property + def write_bytes(self): + return self._write_bytes + + @property + def write_ops(self): + return self._write_ops + + +class MeteredSocket: + """Implement using a delegation model.""" + + def __init__(self, socket): + self._socket = socket + self._recv_bytes = 0 + self._recv_ops = 0 + self._send_bytes = 0 + self._send_ops = 0 + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + return self._socket.__exit__(exc_type, exc_val, exc_tb) + + def recv(self, bufsize, flags=0): + self._recv_ops += 1 + data = self._socket.recv(bufsize, flags) + self._recv_bytes += len(data) + return data + + @property + def recv_bytes(self): + return self._recv_bytes + + @property + def recv_ops(self): + return self._recv_ops + + def send(self, data, flags=0): + self._send_ops += 1 + length = self._socket.send(data, flags) + self._send_bytes += length + return length + + @property + def send_bytes(self): + return self._send_bytes + + @property + def send_ops(self): + return self._send_ops diff --git a/test/practice-paasio/representation.json b/test/practice-paasio/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-paasio/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-paasio/representation.out b/test/practice-paasio/representation.out new file mode 100644 index 0000000..d66d88f --- /dev/null +++ b/test/practice-paasio/representation.out @@ -0,0 +1,3831 @@ +## BEGIN NORMALIZED CODE ## +import io + + +class placeholder_0(io.BufferedRandom): + def placeholder_1(self, *placeholder_2, **placeholder_3): + super().placeholder_1(*placeholder_2, **placeholder_3) + self.placeholder_4 = 0 + self.placeholder_5 = 0 + self.placeholder_6 = 0 + self.placeholder_7 = 0 + + def placeholder_8(self): + return self + + def placeholder_9(self, placeholder_10, placeholder_11, placeholder_12): + return super().placeholder_9(placeholder_10, placeholder_11, placeholder_12) + + def placeholder_13(self): + return self + + def placeholder_14(self): + self.placeholder_5 += 1 + placeholder_15 = super().readline() + self.placeholder_4 += len(placeholder_15) + if placeholder_15: + return placeholder_15 + raise StopIteration + + def placeholder_16(self, placeholder_17=-1): + self.placeholder_5 += 1 + placeholder_15 = super().placeholder_16(placeholder_17) + self.placeholder_4 += len(placeholder_15) + return placeholder_15 + + @property + def placeholder_18(self): + return self.placeholder_4 + + @property + def placeholder_19(self): + return self.placeholder_5 + + def placeholder_20(self, placeholder_21): + self.placeholder_7 += 1 + placeholder_22 = super().placeholder_20(placeholder_21) + self.placeholder_6 += placeholder_22 + return placeholder_22 + + @property + def placeholder_23(self): + return self.placeholder_6 + + @property + def placeholder_24(self): + return self.placeholder_7 + + +class placeholder_25: + def placeholder_1(self, placeholder_26): + self.placeholder_27 = placeholder_26 + self.placeholder_28 = 0 + self.placeholder_29 = 0 + self.placeholder_30 = 0 + self.placeholder_31 = 0 + + def placeholder_8(self): + return self + + def placeholder_9(self, placeholder_10, placeholder_11, placeholder_12): + return self.placeholder_27.placeholder_9( + placeholder_10, placeholder_11, placeholder_12 + ) + + def placeholder_32(self, placeholder_33, placeholder_34=0): + self.placeholder_29 += 1 + placeholder_15 = self.placeholder_27.placeholder_32( + placeholder_33, placeholder_34 + ) + self.placeholder_28 += len(placeholder_15) + return placeholder_15 + + @property + def placeholder_35(self): + return self.placeholder_28 + + @property + def placeholder_36(self): + return self.placeholder_29 + + def placeholder_37(self, placeholder_15, placeholder_34=0): + self.placeholder_31 += 1 + placeholder_22 = self.placeholder_27.placeholder_37( + placeholder_15, placeholder_34 + ) + self.placeholder_30 += placeholder_22 + return placeholder_22 + + @property + def placeholder_38(self): + return self.placeholder_30 + + @property + def placeholder_39(self): + return self.placeholder_31 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'io', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + ClassDef( + 'MeteredFile', + [ + Attribute( + Name( + 'io', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=20), + 'BufferedRandom', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=35)], + [], + [ + Expr( + Constant( + 'Implement using a subclassing model.', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=46), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=46), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21)], + arg( + 'args', + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=28), + [], + [], + arg( + 'kwargs', + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=38), + []), + [ + Expr( + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=13), + [], + [], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=15), + '__init__', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=24), + [ + Starred( + Name( + 'args', + Load(), + lineno=8, + col_offset=26, + end_lineno=8, + end_col_offset=30), + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=30)], + [ + keyword( + value=Name( + 'kwargs', + Load(), + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=40), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=40)], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=41), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=41), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + '_read_bytes', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=24)], + Constant( + 0, + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=28), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + '_read_ops', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=22)], + Constant( + 0, + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=26), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + '_write_bytes', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=25)], + Constant( + 0, + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=29), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=29), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + '_write_ops', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=23)], + Constant( + 0, + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=27), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=27)], + [], + lineno=7, + col_offset=4, + end_lineno=12, + end_col_offset=27), + FunctionDef( + '__enter__', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'self', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=19)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=19), + FunctionDef( + '__exit__', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21), + arg( + 'exc_type', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=31), + arg( + 'exc_val', + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=40), + arg( + 'exc_tb', + lineno=17, + col_offset=42, + end_lineno=17, + end_col_offset=48)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=20), + [], + [], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=22), + '__exit__', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=31), + [ + Name( + 'exc_type', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=40), + Name( + 'exc_val', + Load(), + lineno=18, + col_offset=42, + end_lineno=18, + end_col_offset=49), + Name( + 'exc_tb', + Load(), + lineno=18, + col_offset=51, + end_lineno=18, + end_col_offset=57)], + [], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=58), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=58)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=58), + FunctionDef( + '__iter__', + arguments( + [], + [ + arg( + 'self', + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'self', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=19)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=19), + FunctionDef( + '__next__', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12), + '_read_ops', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=27), + Assign( + [ + Name( + 'data', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=12)], + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=20), + [], + [], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=22), + 'readline', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=31), + [], + [], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=33), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=33), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=12), + '_read_bytes', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=24), + Add(), + Call( + Name( + 'len', + Load(), + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=31), + [ + Name( + 'data', + Load(), + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=36)], + [], + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=37), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=37), + If( + Name( + 'data', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=15), + [ + Return( + Name( + 'data', + Load(), + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=23), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=23)], + [], + lineno=27, + col_offset=8, + end_lineno=28, + end_col_offset=23), + Raise( + Name( + 'StopIteration', + Load(), + lineno=29, + col_offset=14, + end_lineno=29, + end_col_offset=27), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=27)], + [], + lineno=23, + col_offset=4, + end_lineno=29, + end_col_offset=27), + FunctionDef( + 'read', + arguments( + [], + [ + arg( + 'self', + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=17), + arg( + 'size', + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + UnaryOp( + USub(), + Constant( + 1, + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=26), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=26)]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + '_read_ops', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=32, + col_offset=26, + end_lineno=32, + end_col_offset=27), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=27), + Assign( + [ + Name( + 'data', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=12)], + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=20), + [], + [], + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=22), + 'read', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=27), + [ + Name( + 'size', + Load(), + lineno=33, + col_offset=28, + end_lineno=33, + end_col_offset=32)], + [], + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=33), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=33), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + '_read_bytes', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=24), + Add(), + Call( + Name( + 'len', + Load(), + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=31), + [ + Name( + 'data', + Load(), + lineno=34, + col_offset=32, + end_lineno=34, + end_col_offset=36)], + [], + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=37), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=37), + Return( + Name( + 'data', + Load(), + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=19), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=19)], + [], + lineno=31, + col_offset=4, + end_lineno=35, + end_col_offset=19), + FunctionDef( + 'read_bytes', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=19, + end_lineno=38, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=19), + '_read_bytes', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=31), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=31)], + [ + Name( + 'property', + Load(), + lineno=37, + col_offset=5, + end_lineno=37, + end_col_offset=13)], + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=31), + FunctionDef( + 'read_ops', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=19), + '_read_ops', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=29), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=29)], + [ + Name( + 'property', + Load(), + lineno=41, + col_offset=5, + end_lineno=41, + end_col_offset=13)], + lineno=42, + col_offset=4, + end_lineno=43, + end_col_offset=29), + FunctionDef( + 'write', + arguments( + [], + [ + arg( + 'self', + lineno=45, + col_offset=14, + end_lineno=45, + end_col_offset=18), + arg( + 'b', + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=12), + '_write_ops', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=28), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=28), + Assign( + [ + Name( + 'length', + Store(), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=14)], + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=22), + [], + [], + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=24), + 'write', + Load(), + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=30), + [ + Name( + 'b', + Load(), + lineno=47, + col_offset=31, + end_lineno=47, + end_col_offset=32)], + [], + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=33), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=33), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=12), + '_write_bytes', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=25), + Add(), + Name( + 'length', + Load(), + lineno=48, + col_offset=29, + end_lineno=48, + end_col_offset=35), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=35), + Return( + Name( + 'length', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=21), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=21)], + [], + lineno=45, + col_offset=4, + end_lineno=49, + end_col_offset=21), + FunctionDef( + 'write_bytes', + arguments( + [], + [ + arg( + 'self', + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=19), + '_write_bytes', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=32), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=32)], + [ + Name( + 'property', + Load(), + lineno=51, + col_offset=5, + end_lineno=51, + end_col_offset=13)], + lineno=52, + col_offset=4, + end_lineno=53, + end_col_offset=32), + FunctionDef( + 'write_ops', + arguments( + [], + [ + arg( + 'self', + lineno=56, + col_offset=18, + end_lineno=56, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=19), + '_write_ops', + Load(), + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=30), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=30)], + [ + Name( + 'property', + Load(), + lineno=55, + col_offset=5, + end_lineno=55, + end_col_offset=13)], + lineno=56, + col_offset=4, + end_lineno=57, + end_col_offset=30)], + [], + lineno=4, + col_offset=0, + end_lineno=57, + end_col_offset=30), + ClassDef( + 'MeteredSocket', + [], + [], + [ + Expr( + Constant( + 'Implement using a delegation model.', + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=45), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=45), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=21), + arg( + 'socket', + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=12), + '_socket', + Store(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=20)], + Name( + 'socket', + Load(), + lineno=64, + col_offset=23, + end_lineno=64, + end_col_offset=29), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=29), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=12), + '_recv_bytes', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=24)], + Constant( + 0, + lineno=65, + col_offset=27, + end_lineno=65, + end_col_offset=28), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=12), + '_recv_ops', + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=22)], + Constant( + 0, + lineno=66, + col_offset=25, + end_lineno=66, + end_col_offset=26), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=12), + '_send_bytes', + Store(), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=24)], + Constant( + 0, + lineno=67, + col_offset=27, + end_lineno=67, + end_col_offset=28), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=12), + '_send_ops', + Store(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=22)], + Constant( + 0, + lineno=68, + col_offset=25, + end_lineno=68, + end_col_offset=26), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=26)], + [], + lineno=63, + col_offset=4, + end_lineno=68, + end_col_offset=26), + FunctionDef( + '__enter__', + arguments( + [], + [ + arg( + 'self', + lineno=70, + col_offset=18, + end_lineno=70, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'self', + Load(), + lineno=71, + col_offset=15, + end_lineno=71, + end_col_offset=19), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=19)], + [], + lineno=70, + col_offset=4, + end_lineno=71, + end_col_offset=19), + FunctionDef( + '__exit__', + arguments( + [], + [ + arg( + 'self', + lineno=73, + col_offset=17, + end_lineno=73, + end_col_offset=21), + arg( + 'exc_type', + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=31), + arg( + 'exc_val', + lineno=73, + col_offset=33, + end_lineno=73, + end_col_offset=40), + arg( + 'exc_tb', + lineno=73, + col_offset=42, + end_lineno=73, + end_col_offset=48)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=19), + '_socket', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=27), + '__exit__', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=36), + [ + Name( + 'exc_type', + Load(), + lineno=74, + col_offset=37, + end_lineno=74, + end_col_offset=45), + Name( + 'exc_val', + Load(), + lineno=74, + col_offset=47, + end_lineno=74, + end_col_offset=54), + Name( + 'exc_tb', + Load(), + lineno=74, + col_offset=56, + end_lineno=74, + end_col_offset=62)], + [], + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=63), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=63)], + [], + lineno=73, + col_offset=4, + end_lineno=74, + end_col_offset=63), + FunctionDef( + 'recv', + arguments( + [], + [ + arg( + 'self', + lineno=76, + col_offset=13, + end_lineno=76, + end_col_offset=17), + arg( + 'bufsize', + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=26), + arg( + 'flags', + lineno=76, + col_offset=28, + end_lineno=76, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 0, + lineno=76, + col_offset=34, + end_lineno=76, + end_col_offset=35)]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=12), + '_recv_ops', + Store(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=77, + col_offset=26, + end_lineno=77, + end_col_offset=27), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=27), + Assign( + [ + Name( + 'data', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=12)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=19), + '_socket', + Load(), + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=27), + 'recv', + Load(), + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=32), + [ + Name( + 'bufsize', + Load(), + lineno=78, + col_offset=33, + end_lineno=78, + end_col_offset=40), + Name( + 'flags', + Load(), + lineno=78, + col_offset=42, + end_lineno=78, + end_col_offset=47)], + [], + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=48), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=48), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=12), + '_recv_bytes', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=24), + Add(), + Call( + Name( + 'len', + Load(), + lineno=79, + col_offset=28, + end_lineno=79, + end_col_offset=31), + [ + Name( + 'data', + Load(), + lineno=79, + col_offset=32, + end_lineno=79, + end_col_offset=36)], + [], + lineno=79, + col_offset=28, + end_lineno=79, + end_col_offset=37), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=37), + Return( + Name( + 'data', + Load(), + lineno=80, + col_offset=15, + end_lineno=80, + end_col_offset=19), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=19)], + [], + lineno=76, + col_offset=4, + end_lineno=80, + end_col_offset=19), + FunctionDef( + 'recv_bytes', + arguments( + [], + [ + arg( + 'self', + lineno=83, + col_offset=19, + end_lineno=83, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=19), + '_recv_bytes', + Load(), + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=31), + lineno=84, + col_offset=8, + end_lineno=84, + end_col_offset=31)], + [ + Name( + 'property', + Load(), + lineno=82, + col_offset=5, + end_lineno=82, + end_col_offset=13)], + lineno=83, + col_offset=4, + end_lineno=84, + end_col_offset=31), + FunctionDef( + 'recv_ops', + arguments( + [], + [ + arg( + 'self', + lineno=87, + col_offset=17, + end_lineno=87, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=19), + '_recv_ops', + Load(), + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=29), + lineno=88, + col_offset=8, + end_lineno=88, + end_col_offset=29)], + [ + Name( + 'property', + Load(), + lineno=86, + col_offset=5, + end_lineno=86, + end_col_offset=13)], + lineno=87, + col_offset=4, + end_lineno=88, + end_col_offset=29), + FunctionDef( + 'send', + arguments( + [], + [ + arg( + 'self', + lineno=90, + col_offset=13, + end_lineno=90, + end_col_offset=17), + arg( + 'data', + lineno=90, + col_offset=19, + end_lineno=90, + end_col_offset=23), + arg( + 'flags', + lineno=90, + col_offset=25, + end_lineno=90, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 0, + lineno=90, + col_offset=31, + end_lineno=90, + end_col_offset=32)]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=12), + '_send_ops', + Store(), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=91, + col_offset=26, + end_lineno=91, + end_col_offset=27), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=27), + Assign( + [ + Name( + 'length', + Store(), + lineno=92, + col_offset=8, + end_lineno=92, + end_col_offset=14)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=21), + '_socket', + Load(), + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=29), + 'send', + Load(), + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=34), + [ + Name( + 'data', + Load(), + lineno=92, + col_offset=35, + end_lineno=92, + end_col_offset=39), + Name( + 'flags', + Load(), + lineno=92, + col_offset=41, + end_lineno=92, + end_col_offset=46)], + [], + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=47), + lineno=92, + col_offset=8, + end_lineno=92, + end_col_offset=47), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=93, + col_offset=8, + end_lineno=93, + end_col_offset=12), + '_send_bytes', + Store(), + lineno=93, + col_offset=8, + end_lineno=93, + end_col_offset=24), + Add(), + Name( + 'length', + Load(), + lineno=93, + col_offset=28, + end_lineno=93, + end_col_offset=34), + lineno=93, + col_offset=8, + end_lineno=93, + end_col_offset=34), + Return( + Name( + 'length', + Load(), + lineno=94, + col_offset=15, + end_lineno=94, + end_col_offset=21), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=21)], + [], + lineno=90, + col_offset=4, + end_lineno=94, + end_col_offset=21), + FunctionDef( + 'send_bytes', + arguments( + [], + [ + arg( + 'self', + lineno=97, + col_offset=19, + end_lineno=97, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=98, + col_offset=15, + end_lineno=98, + end_col_offset=19), + '_send_bytes', + Load(), + lineno=98, + col_offset=15, + end_lineno=98, + end_col_offset=31), + lineno=98, + col_offset=8, + end_lineno=98, + end_col_offset=31)], + [ + Name( + 'property', + Load(), + lineno=96, + col_offset=5, + end_lineno=96, + end_col_offset=13)], + lineno=97, + col_offset=4, + end_lineno=98, + end_col_offset=31), + FunctionDef( + 'send_ops', + arguments( + [], + [ + arg( + 'self', + lineno=101, + col_offset=17, + end_lineno=101, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=102, + col_offset=15, + end_lineno=102, + end_col_offset=19), + '_send_ops', + Load(), + lineno=102, + col_offset=15, + end_lineno=102, + end_col_offset=29), + lineno=102, + col_offset=8, + end_lineno=102, + end_col_offset=29)], + [ + Name( + 'property', + Load(), + lineno=100, + col_offset=5, + end_lineno=100, + end_col_offset=13)], + lineno=101, + col_offset=4, + end_lineno=102, + end_col_offset=29)], + [], + lineno=60, + col_offset=0, + end_lineno=102, + end_col_offset=29)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'io', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + ClassDef( + 'placeholder_0', + [ + Attribute( + Name( + 'io', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=20), + 'BufferedRandom', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=35)], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21)], + arg( + 'placeholder_2', + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=28), + [], + [], + arg( + 'placeholder_3', + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=38), + []), + [ + Expr( + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=13), + [], + [], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=15), + 'placeholder_1', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=24), + [ + Starred( + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=26, + end_lineno=8, + end_col_offset=30), + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=30)], + [ + keyword( + value=Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=40), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=40)], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=41), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=41), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=24)], + Constant( + 0, + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=28), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=22)], + Constant( + 0, + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=26), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=25)], + Constant( + 0, + lineno=11, + col_offset=28, + end_lineno=11, + end_col_offset=29), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=29), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=23)], + Constant( + 0, + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=27), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=27)], + [], + lineno=7, + col_offset=4, + end_lineno=12, + end_col_offset=27), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'self', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=19)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=19), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21), + arg( + 'placeholder_10', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=31), + arg( + 'placeholder_11', + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=40), + arg( + 'placeholder_12', + lineno=17, + col_offset=42, + end_lineno=17, + end_col_offset=48)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=20), + [], + [], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=22), + 'placeholder_9', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=31), + [ + Name( + 'placeholder_10', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=40), + Name( + 'placeholder_11', + Load(), + lineno=18, + col_offset=42, + end_lineno=18, + end_col_offset=49), + Name( + 'placeholder_12', + Load(), + lineno=18, + col_offset=51, + end_lineno=18, + end_col_offset=57)], + [], + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=58), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=58)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=58), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'self', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=19)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=19), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=12)], + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=20), + [], + [], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=22), + 'readline', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=31), + [], + [], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=33), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=33), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=24), + Add(), + Call( + Name( + 'len', + Load(), + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=31), + [ + Name( + 'placeholder_15', + Load(), + lineno=26, + col_offset=32, + end_lineno=26, + end_col_offset=36)], + [], + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=37), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=37), + If( + Name( + 'placeholder_15', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=15), + [ + Return( + Name( + 'placeholder_15', + Load(), + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=23), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=23)], + [], + lineno=27, + col_offset=8, + end_lineno=28, + end_col_offset=23), + Raise( + Name( + 'StopIteration', + Load(), + lineno=29, + col_offset=14, + end_lineno=29, + end_col_offset=27), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=27)], + [], + lineno=23, + col_offset=4, + end_lineno=29, + end_col_offset=27), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'self', + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=17), + arg( + 'placeholder_17', + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + UnaryOp( + USub(), + Constant( + 1, + lineno=31, + col_offset=25, + end_lineno=31, + end_col_offset=26), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=26)]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=32, + col_offset=26, + end_lineno=32, + end_col_offset=27), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=12)], + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=20), + [], + [], + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=22), + 'placeholder_16', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=27), + [ + Name( + 'placeholder_17', + Load(), + lineno=33, + col_offset=28, + end_lineno=33, + end_col_offset=32)], + [], + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=33), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=33), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=24), + Add(), + Call( + Name( + 'len', + Load(), + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=31), + [ + Name( + 'placeholder_15', + Load(), + lineno=34, + col_offset=32, + end_lineno=34, + end_col_offset=36)], + [], + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=37), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=37), + Return( + Name( + 'placeholder_15', + Load(), + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=19), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=19)], + [], + lineno=31, + col_offset=4, + end_lineno=35, + end_col_offset=19), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=19, + end_lineno=38, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=19), + 'placeholder_4', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=31), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=31)], + [ + Name( + 'property', + Load(), + lineno=37, + col_offset=5, + end_lineno=37, + end_col_offset=13)], + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=31), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=19), + 'placeholder_5', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=29), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=29)], + [ + Name( + 'property', + Load(), + lineno=41, + col_offset=5, + end_lineno=41, + end_col_offset=13)], + lineno=42, + col_offset=4, + end_lineno=43, + end_col_offset=29), + FunctionDef( + 'placeholder_20', + arguments( + [], + [ + arg( + 'self', + lineno=45, + col_offset=14, + end_lineno=45, + end_col_offset=18), + arg( + 'placeholder_21', + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=46, + col_offset=27, + end_lineno=46, + end_col_offset=28), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=14)], + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=22), + [], + [], + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=24), + 'placeholder_20', + Load(), + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=30), + [ + Name( + 'placeholder_21', + Load(), + lineno=47, + col_offset=31, + end_lineno=47, + end_col_offset=32)], + [], + lineno=47, + col_offset=17, + end_lineno=47, + end_col_offset=33), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=33), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=25), + Add(), + Name( + 'placeholder_22', + Load(), + lineno=48, + col_offset=29, + end_lineno=48, + end_col_offset=35), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=35), + Return( + Name( + 'placeholder_22', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=21), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=21)], + [], + lineno=45, + col_offset=4, + end_lineno=49, + end_col_offset=21), + FunctionDef( + 'placeholder_23', + arguments( + [], + [ + arg( + 'self', + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=19), + 'placeholder_6', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=32), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=32)], + [ + Name( + 'property', + Load(), + lineno=51, + col_offset=5, + end_lineno=51, + end_col_offset=13)], + lineno=52, + col_offset=4, + end_lineno=53, + end_col_offset=32), + FunctionDef( + 'placeholder_24', + arguments( + [], + [ + arg( + 'self', + lineno=56, + col_offset=18, + end_lineno=56, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=19), + 'placeholder_7', + Load(), + lineno=57, + col_offset=15, + end_lineno=57, + end_col_offset=30), + lineno=57, + col_offset=8, + end_lineno=57, + end_col_offset=30)], + [ + Name( + 'property', + Load(), + lineno=55, + col_offset=5, + end_lineno=55, + end_col_offset=13)], + lineno=56, + col_offset=4, + end_lineno=57, + end_col_offset=30)], + [], + lineno=4, + col_offset=0, + end_lineno=57, + end_col_offset=30), + ClassDef( + 'placeholder_25', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=21), + arg( + 'placeholder_26', + lineno=63, + col_offset=23, + end_lineno=63, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=12), + 'placeholder_27', + Store(), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=20)], + Name( + 'placeholder_26', + Load(), + lineno=64, + col_offset=23, + end_lineno=64, + end_col_offset=29), + lineno=64, + col_offset=8, + end_lineno=64, + end_col_offset=29), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=12), + 'placeholder_28', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=24)], + Constant( + 0, + lineno=65, + col_offset=27, + end_lineno=65, + end_col_offset=28), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=12), + 'placeholder_29', + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=22)], + Constant( + 0, + lineno=66, + col_offset=25, + end_lineno=66, + end_col_offset=26), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=12), + 'placeholder_30', + Store(), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=24)], + Constant( + 0, + lineno=67, + col_offset=27, + end_lineno=67, + end_col_offset=28), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=12), + 'placeholder_31', + Store(), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=22)], + Constant( + 0, + lineno=68, + col_offset=25, + end_lineno=68, + end_col_offset=26), + lineno=68, + col_offset=8, + end_lineno=68, + end_col_offset=26)], + [], + lineno=63, + col_offset=4, + end_lineno=68, + end_col_offset=26), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=70, + col_offset=18, + end_lineno=70, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'self', + Load(), + lineno=71, + col_offset=15, + end_lineno=71, + end_col_offset=19), + lineno=71, + col_offset=8, + end_lineno=71, + end_col_offset=19)], + [], + lineno=70, + col_offset=4, + end_lineno=71, + end_col_offset=19), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=73, + col_offset=17, + end_lineno=73, + end_col_offset=21), + arg( + 'placeholder_10', + lineno=73, + col_offset=23, + end_lineno=73, + end_col_offset=31), + arg( + 'placeholder_11', + lineno=73, + col_offset=33, + end_lineno=73, + end_col_offset=40), + arg( + 'placeholder_12', + lineno=73, + col_offset=42, + end_lineno=73, + end_col_offset=48)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=19), + 'placeholder_27', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=27), + 'placeholder_9', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=36), + [ + Name( + 'placeholder_10', + Load(), + lineno=74, + col_offset=37, + end_lineno=74, + end_col_offset=45), + Name( + 'placeholder_11', + Load(), + lineno=74, + col_offset=47, + end_lineno=74, + end_col_offset=54), + Name( + 'placeholder_12', + Load(), + lineno=74, + col_offset=56, + end_lineno=74, + end_col_offset=62)], + [], + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=63), + lineno=74, + col_offset=8, + end_lineno=74, + end_col_offset=63)], + [], + lineno=73, + col_offset=4, + end_lineno=74, + end_col_offset=63), + FunctionDef( + 'placeholder_32', + arguments( + [], + [ + arg( + 'self', + lineno=76, + col_offset=13, + end_lineno=76, + end_col_offset=17), + arg( + 'placeholder_33', + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=26), + arg( + 'placeholder_34', + lineno=76, + col_offset=28, + end_lineno=76, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 0, + lineno=76, + col_offset=34, + end_lineno=76, + end_col_offset=35)]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=12), + 'placeholder_29', + Store(), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=77, + col_offset=26, + end_lineno=77, + end_col_offset=27), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=12)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=19), + 'placeholder_27', + Load(), + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=27), + 'placeholder_32', + Load(), + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=32), + [ + Name( + 'placeholder_33', + Load(), + lineno=78, + col_offset=33, + end_lineno=78, + end_col_offset=40), + Name( + 'placeholder_34', + Load(), + lineno=78, + col_offset=42, + end_lineno=78, + end_col_offset=47)], + [], + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=48), + lineno=78, + col_offset=8, + end_lineno=78, + end_col_offset=48), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=12), + 'placeholder_28', + Store(), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=24), + Add(), + Call( + Name( + 'len', + Load(), + lineno=79, + col_offset=28, + end_lineno=79, + end_col_offset=31), + [ + Name( + 'placeholder_15', + Load(), + lineno=79, + col_offset=32, + end_lineno=79, + end_col_offset=36)], + [], + lineno=79, + col_offset=28, + end_lineno=79, + end_col_offset=37), + lineno=79, + col_offset=8, + end_lineno=79, + end_col_offset=37), + Return( + Name( + 'placeholder_15', + Load(), + lineno=80, + col_offset=15, + end_lineno=80, + end_col_offset=19), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=19)], + [], + lineno=76, + col_offset=4, + end_lineno=80, + end_col_offset=19), + FunctionDef( + 'placeholder_35', + arguments( + [], + [ + arg( + 'self', + lineno=83, + col_offset=19, + end_lineno=83, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=19), + 'placeholder_28', + Load(), + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=31), + lineno=84, + col_offset=8, + end_lineno=84, + end_col_offset=31)], + [ + Name( + 'property', + Load(), + lineno=82, + col_offset=5, + end_lineno=82, + end_col_offset=13)], + lineno=83, + col_offset=4, + end_lineno=84, + end_col_offset=31), + FunctionDef( + 'placeholder_36', + arguments( + [], + [ + arg( + 'self', + lineno=87, + col_offset=17, + end_lineno=87, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=19), + 'placeholder_29', + Load(), + lineno=88, + col_offset=15, + end_lineno=88, + end_col_offset=29), + lineno=88, + col_offset=8, + end_lineno=88, + end_col_offset=29)], + [ + Name( + 'property', + Load(), + lineno=86, + col_offset=5, + end_lineno=86, + end_col_offset=13)], + lineno=87, + col_offset=4, + end_lineno=88, + end_col_offset=29), + FunctionDef( + 'placeholder_37', + arguments( + [], + [ + arg( + 'self', + lineno=90, + col_offset=13, + end_lineno=90, + end_col_offset=17), + arg( + 'placeholder_15', + lineno=90, + col_offset=19, + end_lineno=90, + end_col_offset=23), + arg( + 'placeholder_34', + lineno=90, + col_offset=25, + end_lineno=90, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 0, + lineno=90, + col_offset=31, + end_lineno=90, + end_col_offset=32)]), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=12), + 'placeholder_31', + Store(), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=91, + col_offset=26, + end_lineno=91, + end_col_offset=27), + lineno=91, + col_offset=8, + end_lineno=91, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=92, + col_offset=8, + end_lineno=92, + end_col_offset=14)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=21), + 'placeholder_27', + Load(), + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=29), + 'placeholder_37', + Load(), + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=34), + [ + Name( + 'placeholder_15', + Load(), + lineno=92, + col_offset=35, + end_lineno=92, + end_col_offset=39), + Name( + 'placeholder_34', + Load(), + lineno=92, + col_offset=41, + end_lineno=92, + end_col_offset=46)], + [], + lineno=92, + col_offset=17, + end_lineno=92, + end_col_offset=47), + lineno=92, + col_offset=8, + end_lineno=92, + end_col_offset=47), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=93, + col_offset=8, + end_lineno=93, + end_col_offset=12), + 'placeholder_30', + Store(), + lineno=93, + col_offset=8, + end_lineno=93, + end_col_offset=24), + Add(), + Name( + 'placeholder_22', + Load(), + lineno=93, + col_offset=28, + end_lineno=93, + end_col_offset=34), + lineno=93, + col_offset=8, + end_lineno=93, + end_col_offset=34), + Return( + Name( + 'placeholder_22', + Load(), + lineno=94, + col_offset=15, + end_lineno=94, + end_col_offset=21), + lineno=94, + col_offset=8, + end_lineno=94, + end_col_offset=21)], + [], + lineno=90, + col_offset=4, + end_lineno=94, + end_col_offset=21), + FunctionDef( + 'placeholder_38', + arguments( + [], + [ + arg( + 'self', + lineno=97, + col_offset=19, + end_lineno=97, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=98, + col_offset=15, + end_lineno=98, + end_col_offset=19), + 'placeholder_30', + Load(), + lineno=98, + col_offset=15, + end_lineno=98, + end_col_offset=31), + lineno=98, + col_offset=8, + end_lineno=98, + end_col_offset=31)], + [ + Name( + 'property', + Load(), + lineno=96, + col_offset=5, + end_lineno=96, + end_col_offset=13)], + lineno=97, + col_offset=4, + end_lineno=98, + end_col_offset=31), + FunctionDef( + 'placeholder_39', + arguments( + [], + [ + arg( + 'self', + lineno=101, + col_offset=17, + end_lineno=101, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=102, + col_offset=15, + end_lineno=102, + end_col_offset=19), + 'placeholder_31', + Load(), + lineno=102, + col_offset=15, + end_lineno=102, + end_col_offset=29), + lineno=102, + col_offset=8, + end_lineno=102, + end_col_offset=29)], + [ + Name( + 'property', + Load(), + lineno=100, + col_offset=5, + end_lineno=100, + end_col_offset=13)], + lineno=101, + col_offset=4, + end_lineno=102, + end_col_offset=29)], + [], + lineno=60, + col_offset=0, + end_lineno=102, + end_col_offset=29)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-paasio/representation.txt b/test/practice-paasio/representation.txt new file mode 100644 index 0000000..6b9d36e --- /dev/null +++ b/test/practice-paasio/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('io', lineno=1, col_offset=7, end_lineno=1, end_col_offset=9)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=9), ClassDef('placeholder_0', [Attribute(Name('io', Load(), lineno=4, col_offset=18, end_lineno=4, end_col_offset=20), 'BufferedRandom', Load(), lineno=4, col_offset=18, end_lineno=4, end_col_offset=35)], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=7, col_offset=17, end_lineno=7, end_col_offset=21)], arg('placeholder_2', lineno=7, col_offset=24, end_lineno=7, end_col_offset=28), [], [], arg('placeholder_3', lineno=7, col_offset=32, end_lineno=7, end_col_offset=38), []), [Expr(Call(Attribute(Call(Name('super', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=13), [], [], lineno=8, col_offset=8, end_lineno=8, end_col_offset=15), 'placeholder_1', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=24), [Starred(Name('placeholder_2', Load(), lineno=8, col_offset=26, end_lineno=8, end_col_offset=30), Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=30)], [keyword(value=Name('placeholder_3', Load(), lineno=8, col_offset=34, end_lineno=8, end_col_offset=40), lineno=8, col_offset=32, end_lineno=8, end_col_offset=40)], lineno=8, col_offset=8, end_lineno=8, end_col_offset=41), lineno=8, col_offset=8, end_lineno=8, end_col_offset=41), Assign([Attribute(Name('self', Load(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), 'placeholder_4', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=24)], Constant(0, lineno=9, col_offset=27, end_lineno=9, end_col_offset=28), lineno=9, col_offset=8, end_lineno=9, end_col_offset=28), Assign([Attribute(Name('self', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=12), 'placeholder_5', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=22)], Constant(0, lineno=10, col_offset=25, end_lineno=10, end_col_offset=26), lineno=10, col_offset=8, end_lineno=10, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), 'placeholder_6', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=25)], Constant(0, lineno=11, col_offset=28, end_lineno=11, end_col_offset=29), lineno=11, col_offset=8, end_lineno=11, end_col_offset=29), Assign([Attribute(Name('self', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), 'placeholder_7', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=23)], Constant(0, lineno=12, col_offset=26, end_lineno=12, end_col_offset=27), lineno=12, col_offset=8, end_lineno=12, end_col_offset=27)], [], lineno=7, col_offset=4, end_lineno=12, end_col_offset=27), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=14, col_offset=18, end_lineno=14, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Name('self', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), lineno=15, col_offset=8, end_lineno=15, end_col_offset=19)], [], lineno=14, col_offset=4, end_lineno=15, end_col_offset=19), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=17, col_offset=17, end_lineno=17, end_col_offset=21), arg('placeholder_10', lineno=17, col_offset=23, end_lineno=17, end_col_offset=31), arg('placeholder_11', lineno=17, col_offset=33, end_lineno=17, end_col_offset=40), arg('placeholder_12', lineno=17, col_offset=42, end_lineno=17, end_col_offset=48)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Call(Name('super', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=20), [], [], lineno=18, col_offset=15, end_lineno=18, end_col_offset=22), 'placeholder_9', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=31), [Name('placeholder_10', Load(), lineno=18, col_offset=32, end_lineno=18, end_col_offset=40), Name('placeholder_11', Load(), lineno=18, col_offset=42, end_lineno=18, end_col_offset=49), Name('placeholder_12', Load(), lineno=18, col_offset=51, end_lineno=18, end_col_offset=57)], [], lineno=18, col_offset=15, end_lineno=18, end_col_offset=58), lineno=18, col_offset=8, end_lineno=18, end_col_offset=58)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=58), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=20, col_offset=17, end_lineno=20, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Name('self', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=19), lineno=21, col_offset=8, end_lineno=21, end_col_offset=19)], [], lineno=20, col_offset=4, end_lineno=21, end_col_offset=19), FunctionDef('placeholder_14', arguments([], [arg('self', lineno=23, col_offset=17, end_lineno=23, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [AugAssign(Attribute(Name('self', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=12), 'placeholder_5', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=22), Add(), Constant(1, lineno=24, col_offset=26, end_lineno=24, end_col_offset=27), lineno=24, col_offset=8, end_lineno=24, end_col_offset=27), Assign([Name('placeholder_15', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=12)], Call(Attribute(Call(Name('super', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=20), [], [], lineno=25, col_offset=15, end_lineno=25, end_col_offset=22), 'readline', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=31), [], [], lineno=25, col_offset=15, end_lineno=25, end_col_offset=33), lineno=25, col_offset=8, end_lineno=25, end_col_offset=33), AugAssign(Attribute(Name('self', Load(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=12), 'placeholder_4', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=24), Add(), Call(Name('len', Load(), lineno=26, col_offset=28, end_lineno=26, end_col_offset=31), [Name('placeholder_15', Load(), lineno=26, col_offset=32, end_lineno=26, end_col_offset=36)], [], lineno=26, col_offset=28, end_lineno=26, end_col_offset=37), lineno=26, col_offset=8, end_lineno=26, end_col_offset=37), If(Name('placeholder_15', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=15), [Return(Name('placeholder_15', Load(), lineno=28, col_offset=19, end_lineno=28, end_col_offset=23), lineno=28, col_offset=12, end_lineno=28, end_col_offset=23)], [], lineno=27, col_offset=8, end_lineno=28, end_col_offset=23), Raise(Name('StopIteration', Load(), lineno=29, col_offset=14, end_lineno=29, end_col_offset=27), lineno=29, col_offset=8, end_lineno=29, end_col_offset=27)], [], lineno=23, col_offset=4, end_lineno=29, end_col_offset=27), FunctionDef('placeholder_16', arguments([], [arg('self', lineno=31, col_offset=13, end_lineno=31, end_col_offset=17), arg('placeholder_17', lineno=31, col_offset=19, end_lineno=31, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[UnaryOp(USub(), Constant(1, lineno=31, col_offset=25, end_lineno=31, end_col_offset=26), lineno=31, col_offset=24, end_lineno=31, end_col_offset=26)]), [AugAssign(Attribute(Name('self', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=12), 'placeholder_5', Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=22), Add(), Constant(1, lineno=32, col_offset=26, end_lineno=32, end_col_offset=27), lineno=32, col_offset=8, end_lineno=32, end_col_offset=27), Assign([Name('placeholder_15', Store(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=12)], Call(Attribute(Call(Name('super', Load(), lineno=33, col_offset=15, end_lineno=33, end_col_offset=20), [], [], lineno=33, col_offset=15, end_lineno=33, end_col_offset=22), 'placeholder_16', Load(), lineno=33, col_offset=15, end_lineno=33, end_col_offset=27), [Name('placeholder_17', Load(), lineno=33, col_offset=28, end_lineno=33, end_col_offset=32)], [], lineno=33, col_offset=15, end_lineno=33, end_col_offset=33), lineno=33, col_offset=8, end_lineno=33, end_col_offset=33), AugAssign(Attribute(Name('self', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=12), 'placeholder_4', Store(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=24), Add(), Call(Name('len', Load(), lineno=34, col_offset=28, end_lineno=34, end_col_offset=31), [Name('placeholder_15', Load(), lineno=34, col_offset=32, end_lineno=34, end_col_offset=36)], [], lineno=34, col_offset=28, end_lineno=34, end_col_offset=37), lineno=34, col_offset=8, end_lineno=34, end_col_offset=37), Return(Name('placeholder_15', Load(), lineno=35, col_offset=15, end_lineno=35, end_col_offset=19), lineno=35, col_offset=8, end_lineno=35, end_col_offset=19)], [], lineno=31, col_offset=4, end_lineno=35, end_col_offset=19), FunctionDef('placeholder_18', arguments([], [arg('self', lineno=38, col_offset=19, end_lineno=38, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=19), 'placeholder_4', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=31), lineno=39, col_offset=8, end_lineno=39, end_col_offset=31)], [Name('property', Load(), lineno=37, col_offset=5, end_lineno=37, end_col_offset=13)], lineno=38, col_offset=4, end_lineno=39, end_col_offset=31), FunctionDef('placeholder_19', arguments([], [arg('self', lineno=42, col_offset=17, end_lineno=42, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=43, col_offset=15, end_lineno=43, end_col_offset=19), 'placeholder_5', Load(), lineno=43, col_offset=15, end_lineno=43, end_col_offset=29), lineno=43, col_offset=8, end_lineno=43, end_col_offset=29)], [Name('property', Load(), lineno=41, col_offset=5, end_lineno=41, end_col_offset=13)], lineno=42, col_offset=4, end_lineno=43, end_col_offset=29), FunctionDef('placeholder_20', arguments([], [arg('self', lineno=45, col_offset=14, end_lineno=45, end_col_offset=18), arg('placeholder_21', lineno=45, col_offset=20, end_lineno=45, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [AugAssign(Attribute(Name('self', Load(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=12), 'placeholder_7', Store(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=23), Add(), Constant(1, lineno=46, col_offset=27, end_lineno=46, end_col_offset=28), lineno=46, col_offset=8, end_lineno=46, end_col_offset=28), Assign([Name('placeholder_22', Store(), lineno=47, col_offset=8, end_lineno=47, end_col_offset=14)], Call(Attribute(Call(Name('super', Load(), lineno=47, col_offset=17, end_lineno=47, end_col_offset=22), [], [], lineno=47, col_offset=17, end_lineno=47, end_col_offset=24), 'placeholder_20', Load(), lineno=47, col_offset=17, end_lineno=47, end_col_offset=30), [Name('placeholder_21', Load(), lineno=47, col_offset=31, end_lineno=47, end_col_offset=32)], [], lineno=47, col_offset=17, end_lineno=47, end_col_offset=33), lineno=47, col_offset=8, end_lineno=47, end_col_offset=33), AugAssign(Attribute(Name('self', Load(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=12), 'placeholder_6', Store(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=25), Add(), Name('placeholder_22', Load(), lineno=48, col_offset=29, end_lineno=48, end_col_offset=35), lineno=48, col_offset=8, end_lineno=48, end_col_offset=35), Return(Name('placeholder_22', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=21), lineno=49, col_offset=8, end_lineno=49, end_col_offset=21)], [], lineno=45, col_offset=4, end_lineno=49, end_col_offset=21), FunctionDef('placeholder_23', arguments([], [arg('self', lineno=52, col_offset=20, end_lineno=52, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=53, col_offset=15, end_lineno=53, end_col_offset=19), 'placeholder_6', Load(), lineno=53, col_offset=15, end_lineno=53, end_col_offset=32), lineno=53, col_offset=8, end_lineno=53, end_col_offset=32)], [Name('property', Load(), lineno=51, col_offset=5, end_lineno=51, end_col_offset=13)], lineno=52, col_offset=4, end_lineno=53, end_col_offset=32), FunctionDef('placeholder_24', arguments([], [arg('self', lineno=56, col_offset=18, end_lineno=56, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=57, col_offset=15, end_lineno=57, end_col_offset=19), 'placeholder_7', Load(), lineno=57, col_offset=15, end_lineno=57, end_col_offset=30), lineno=57, col_offset=8, end_lineno=57, end_col_offset=30)], [Name('property', Load(), lineno=55, col_offset=5, end_lineno=55, end_col_offset=13)], lineno=56, col_offset=4, end_lineno=57, end_col_offset=30)], [], lineno=4, col_offset=0, end_lineno=57, end_col_offset=30), ClassDef('placeholder_25', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=63, col_offset=17, end_lineno=63, end_col_offset=21), arg('placeholder_26', lineno=63, col_offset=23, end_lineno=63, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=12), 'placeholder_27', Store(), lineno=64, col_offset=8, end_lineno=64, end_col_offset=20)], Name('placeholder_26', Load(), lineno=64, col_offset=23, end_lineno=64, end_col_offset=29), lineno=64, col_offset=8, end_lineno=64, end_col_offset=29), Assign([Attribute(Name('self', Load(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=12), 'placeholder_28', Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=24)], Constant(0, lineno=65, col_offset=27, end_lineno=65, end_col_offset=28), lineno=65, col_offset=8, end_lineno=65, end_col_offset=28), Assign([Attribute(Name('self', Load(), lineno=66, col_offset=8, end_lineno=66, end_col_offset=12), 'placeholder_29', Store(), lineno=66, col_offset=8, end_lineno=66, end_col_offset=22)], Constant(0, lineno=66, col_offset=25, end_lineno=66, end_col_offset=26), lineno=66, col_offset=8, end_lineno=66, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=67, col_offset=8, end_lineno=67, end_col_offset=12), 'placeholder_30', Store(), lineno=67, col_offset=8, end_lineno=67, end_col_offset=24)], Constant(0, lineno=67, col_offset=27, end_lineno=67, end_col_offset=28), lineno=67, col_offset=8, end_lineno=67, end_col_offset=28), Assign([Attribute(Name('self', Load(), lineno=68, col_offset=8, end_lineno=68, end_col_offset=12), 'placeholder_31', Store(), lineno=68, col_offset=8, end_lineno=68, end_col_offset=22)], Constant(0, lineno=68, col_offset=25, end_lineno=68, end_col_offset=26), lineno=68, col_offset=8, end_lineno=68, end_col_offset=26)], [], lineno=63, col_offset=4, end_lineno=68, end_col_offset=26), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=70, col_offset=18, end_lineno=70, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Name('self', Load(), lineno=71, col_offset=15, end_lineno=71, end_col_offset=19), lineno=71, col_offset=8, end_lineno=71, end_col_offset=19)], [], lineno=70, col_offset=4, end_lineno=71, end_col_offset=19), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=73, col_offset=17, end_lineno=73, end_col_offset=21), arg('placeholder_10', lineno=73, col_offset=23, end_lineno=73, end_col_offset=31), arg('placeholder_11', lineno=73, col_offset=33, end_lineno=73, end_col_offset=40), arg('placeholder_12', lineno=73, col_offset=42, end_lineno=73, end_col_offset=48)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Attribute(Name('self', Load(), lineno=74, col_offset=15, end_lineno=74, end_col_offset=19), 'placeholder_27', Load(), lineno=74, col_offset=15, end_lineno=74, end_col_offset=27), 'placeholder_9', Load(), lineno=74, col_offset=15, end_lineno=74, end_col_offset=36), [Name('placeholder_10', Load(), lineno=74, col_offset=37, end_lineno=74, end_col_offset=45), Name('placeholder_11', Load(), lineno=74, col_offset=47, end_lineno=74, end_col_offset=54), Name('placeholder_12', Load(), lineno=74, col_offset=56, end_lineno=74, end_col_offset=62)], [], lineno=74, col_offset=15, end_lineno=74, end_col_offset=63), lineno=74, col_offset=8, end_lineno=74, end_col_offset=63)], [], lineno=73, col_offset=4, end_lineno=74, end_col_offset=63), FunctionDef('placeholder_32', arguments([], [arg('self', lineno=76, col_offset=13, end_lineno=76, end_col_offset=17), arg('placeholder_33', lineno=76, col_offset=19, end_lineno=76, end_col_offset=26), arg('placeholder_34', lineno=76, col_offset=28, end_lineno=76, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(0, lineno=76, col_offset=34, end_lineno=76, end_col_offset=35)]), [AugAssign(Attribute(Name('self', Load(), lineno=77, col_offset=8, end_lineno=77, end_col_offset=12), 'placeholder_29', Store(), lineno=77, col_offset=8, end_lineno=77, end_col_offset=22), Add(), Constant(1, lineno=77, col_offset=26, end_lineno=77, end_col_offset=27), lineno=77, col_offset=8, end_lineno=77, end_col_offset=27), Assign([Name('placeholder_15', Store(), lineno=78, col_offset=8, end_lineno=78, end_col_offset=12)], Call(Attribute(Attribute(Name('self', Load(), lineno=78, col_offset=15, end_lineno=78, end_col_offset=19), 'placeholder_27', Load(), lineno=78, col_offset=15, end_lineno=78, end_col_offset=27), 'placeholder_32', Load(), lineno=78, col_offset=15, end_lineno=78, end_col_offset=32), [Name('placeholder_33', Load(), lineno=78, col_offset=33, end_lineno=78, end_col_offset=40), Name('placeholder_34', Load(), lineno=78, col_offset=42, end_lineno=78, end_col_offset=47)], [], lineno=78, col_offset=15, end_lineno=78, end_col_offset=48), lineno=78, col_offset=8, end_lineno=78, end_col_offset=48), AugAssign(Attribute(Name('self', Load(), lineno=79, col_offset=8, end_lineno=79, end_col_offset=12), 'placeholder_28', Store(), lineno=79, col_offset=8, end_lineno=79, end_col_offset=24), Add(), Call(Name('len', Load(), lineno=79, col_offset=28, end_lineno=79, end_col_offset=31), [Name('placeholder_15', Load(), lineno=79, col_offset=32, end_lineno=79, end_col_offset=36)], [], lineno=79, col_offset=28, end_lineno=79, end_col_offset=37), lineno=79, col_offset=8, end_lineno=79, end_col_offset=37), Return(Name('placeholder_15', Load(), lineno=80, col_offset=15, end_lineno=80, end_col_offset=19), lineno=80, col_offset=8, end_lineno=80, end_col_offset=19)], [], lineno=76, col_offset=4, end_lineno=80, end_col_offset=19), FunctionDef('placeholder_35', arguments([], [arg('self', lineno=83, col_offset=19, end_lineno=83, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=84, col_offset=15, end_lineno=84, end_col_offset=19), 'placeholder_28', Load(), lineno=84, col_offset=15, end_lineno=84, end_col_offset=31), lineno=84, col_offset=8, end_lineno=84, end_col_offset=31)], [Name('property', Load(), lineno=82, col_offset=5, end_lineno=82, end_col_offset=13)], lineno=83, col_offset=4, end_lineno=84, end_col_offset=31), FunctionDef('placeholder_36', arguments([], [arg('self', lineno=87, col_offset=17, end_lineno=87, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=88, col_offset=15, end_lineno=88, end_col_offset=19), 'placeholder_29', Load(), lineno=88, col_offset=15, end_lineno=88, end_col_offset=29), lineno=88, col_offset=8, end_lineno=88, end_col_offset=29)], [Name('property', Load(), lineno=86, col_offset=5, end_lineno=86, end_col_offset=13)], lineno=87, col_offset=4, end_lineno=88, end_col_offset=29), FunctionDef('placeholder_37', arguments([], [arg('self', lineno=90, col_offset=13, end_lineno=90, end_col_offset=17), arg('placeholder_15', lineno=90, col_offset=19, end_lineno=90, end_col_offset=23), arg('placeholder_34', lineno=90, col_offset=25, end_lineno=90, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(0, lineno=90, col_offset=31, end_lineno=90, end_col_offset=32)]), [AugAssign(Attribute(Name('self', Load(), lineno=91, col_offset=8, end_lineno=91, end_col_offset=12), 'placeholder_31', Store(), lineno=91, col_offset=8, end_lineno=91, end_col_offset=22), Add(), Constant(1, lineno=91, col_offset=26, end_lineno=91, end_col_offset=27), lineno=91, col_offset=8, end_lineno=91, end_col_offset=27), Assign([Name('placeholder_22', Store(), lineno=92, col_offset=8, end_lineno=92, end_col_offset=14)], Call(Attribute(Attribute(Name('self', Load(), lineno=92, col_offset=17, end_lineno=92, end_col_offset=21), 'placeholder_27', Load(), lineno=92, col_offset=17, end_lineno=92, end_col_offset=29), 'placeholder_37', Load(), lineno=92, col_offset=17, end_lineno=92, end_col_offset=34), [Name('placeholder_15', Load(), lineno=92, col_offset=35, end_lineno=92, end_col_offset=39), Name('placeholder_34', Load(), lineno=92, col_offset=41, end_lineno=92, end_col_offset=46)], [], lineno=92, col_offset=17, end_lineno=92, end_col_offset=47), lineno=92, col_offset=8, end_lineno=92, end_col_offset=47), AugAssign(Attribute(Name('self', Load(), lineno=93, col_offset=8, end_lineno=93, end_col_offset=12), 'placeholder_30', Store(), lineno=93, col_offset=8, end_lineno=93, end_col_offset=24), Add(), Name('placeholder_22', Load(), lineno=93, col_offset=28, end_lineno=93, end_col_offset=34), lineno=93, col_offset=8, end_lineno=93, end_col_offset=34), Return(Name('placeholder_22', Load(), lineno=94, col_offset=15, end_lineno=94, end_col_offset=21), lineno=94, col_offset=8, end_lineno=94, end_col_offset=21)], [], lineno=90, col_offset=4, end_lineno=94, end_col_offset=21), FunctionDef('placeholder_38', arguments([], [arg('self', lineno=97, col_offset=19, end_lineno=97, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=98, col_offset=15, end_lineno=98, end_col_offset=19), 'placeholder_30', Load(), lineno=98, col_offset=15, end_lineno=98, end_col_offset=31), lineno=98, col_offset=8, end_lineno=98, end_col_offset=31)], [Name('property', Load(), lineno=96, col_offset=5, end_lineno=96, end_col_offset=13)], lineno=97, col_offset=4, end_lineno=98, end_col_offset=31), FunctionDef('placeholder_39', arguments([], [arg('self', lineno=101, col_offset=17, end_lineno=101, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=102, col_offset=15, end_lineno=102, end_col_offset=19), 'placeholder_31', Load(), lineno=102, col_offset=15, end_lineno=102, end_col_offset=29), lineno=102, col_offset=8, end_lineno=102, end_col_offset=29)], [Name('property', Load(), lineno=100, col_offset=5, end_lineno=100, end_col_offset=13)], lineno=101, col_offset=4, end_lineno=102, end_col_offset=29)], [], lineno=60, col_offset=0, end_lineno=102, end_col_offset=29)], []) \ No newline at end of file diff --git a/test/practice-palindrome-products/.meta/config.json b/test/practice-palindrome-products/.meta/config.json new file mode 100644 index 0000000..fa833ed --- /dev/null +++ b/test/practice-palindrome-products/.meta/config.json @@ -0,0 +1,35 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "AnAccountForReportingBugs", + "behrtam", + "BethanyG", + "cmccandless", + "deep110", + "Dog", + "emerali", + "gabriel376", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "pheanex", + "pywkm", + "tqa236" + ], + "files": { + "solution": [ + "palindrome_products.py" + ], + "test": [ + "palindrome_products_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Detect palindrome products in a given range.", + "source": "Problem 4 at Project Euler", + "source_url": "https://projecteuler.net/problem=4" +} diff --git a/test/practice-palindrome-products/mapping.json b/test/practice-palindrome-products/mapping.json new file mode 100644 index 0000000..01a1102 --- /dev/null +++ b/test/practice-palindrome-products/mapping.json @@ -0,0 +1,33 @@ +{ + "placeholder_0": "largest", + "placeholder_1": "min_factor", + "placeholder_2": "max_factor", + "placeholder_3": "smallest", + "placeholder_4": "get_extreme_palindrome_with_factors", + "placeholder_5": "extreme", + "placeholder_6": "palindromes_found", + "placeholder_7": "reverse", + "placeholder_8": "factor_pairs", + "placeholder_9": "palindrome", + "placeholder_10": "factor", + "placeholder_11": "pair", + "placeholder_12": "reverse_num", + "placeholder_13": "number", + "placeholder_14": "reversed_nums", + "placeholder_15": "num_digits", + "placeholder_16": "palindromes", + "placeholder_17": "minimum", + "placeholder_18": "maximum", + "placeholder_19": "gen_palindromes_of_length", + "placeholder_20": "digit_count", + "placeholder_21": "even_nd", + "placeholder_22": "min_left_half", + "placeholder_23": "max_left_half", + "placeholder_24": "current_left_half", + "placeholder_25": "make_palindrome", + "placeholder_26": "left_half", + "placeholder_27": "right_half", + "placeholder_28": "min_nd", + "placeholder_29": "max_nd", + "placeholder_30": "lengths" +} \ No newline at end of file diff --git a/test/practice-palindrome-products/palindrome_products.py b/test/practice-palindrome-products/palindrome_products.py new file mode 100644 index 0000000..f656ff1 --- /dev/null +++ b/test/practice-palindrome-products/palindrome_products.py @@ -0,0 +1,108 @@ +from itertools import chain +from math import log10, floor, ceil + + +def largest(min_factor, max_factor): + return get_extreme_palindrome_with_factors(max_factor, min_factor, 'largest') + + +def smallest(max_factor, min_factor): + return get_extreme_palindrome_with_factors(max_factor, min_factor, 'smallest') + + +def get_extreme_palindrome_with_factors(max_factor, min_factor, extreme): + palindromes_found = palindromes(max_factor, min_factor, reverse=(extreme == 'largest')) + factor_pairs = None + for palindrome in palindromes_found: + factor_pairs = ((factor, palindrome // factor) + for factor in range(min_factor, max_factor + 1) + if palindrome % factor == 0) + factor_pairs = list(pair for pair in factor_pairs + if min_factor <= pair[1] <= max_factor) + if len(factor_pairs) > 0: + break + + if not factor_pairs: + return (None, []) + + return (palindrome, factor_pairs) + + +def reverse_num(number): + reversed_nums = 0 + while number > 0: + reversed_nums *= 10 + reversed_nums += (number % 10) + number //= 10 + return reversed_nums + + +def num_digits(number): + return int(floor(log10(number) + 1)) + + +def palindromes(max_factor, min_factor, reverse=False): + """Generates all palindromes between `min_factor`**2 and max_factor`**2 + If `reverse` is True, will produce the palindromes in decreasing order, + from `max_factor`**2 down to `min_factor`**2. This is needed for + `largest_palindrome`, since it won't have to iterate through a + most of the palindromes just to find the one it needs. + """ + if max_factor < min_factor: + raise ValueError('min must be <= max') + + minimum = min_factor ** 2 + maximum = max_factor ** 2 + + def gen_palindromes_of_length(digit_count, reverse=reverse): + """Generates all palindromes with `nd` number of digits that are + within the desired range. + Again, if `reverse` is True, the palindromes are generated in + reverse order. + """ + even_nd = (digit_count % 2 == 0) + + min_left_half = max(10 ** (int(ceil(digit_count / 2)) - 1), + minimum // (10 ** (digit_count // 2))) + max_left_half = min((10 ** int(ceil(digit_count / 2))) - 1, + maximum // (10 ** (digit_count // 2))) + + current_left_half = min_left_half if not reverse else max_left_half + + def make_palindrome(left_half, even_nd=False): + right_half = (reverse_num(left_half) + if even_nd + else reverse_num(left_half // 10)) + return (left_half * (10 ** (digit_count // 2))) + right_half + + if not reverse: + while current_left_half <= max_left_half: + palindrome = make_palindrome(current_left_half, even_nd) + if minimum <= palindrome <= maximum: + yield palindrome + elif palindrome > maximum: + # since palindromes are generated in increasing order, + # we break out of the loop once we've exceeded the + # maximum value + break + current_left_half += 1 + else: + while current_left_half >= min_left_half: + palindrome = make_palindrome(current_left_half, even_nd) + if minimum <= palindrome <= maximum: + yield palindrome + elif palindrome < minimum: + # since palindromes are generated in decreasing order, + # we break out of the loop once we've gone below the + # minimum value + break + current_left_half -= 1 + + min_nd = num_digits(minimum) + max_nd = num_digits(maximum) + + lengths = (range(min_nd, max_nd + 1) + if not reverse + else range(max_nd, min_nd - 1, -1)) + + return chain(*map(gen_palindromes_of_length, lengths)) diff --git a/test/practice-palindrome-products/representation.json b/test/practice-palindrome-products/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-palindrome-products/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-palindrome-products/representation.out b/test/practice-palindrome-products/representation.out new file mode 100644 index 0000000..2dc7886 --- /dev/null +++ b/test/practice-palindrome-products/representation.out @@ -0,0 +1,4646 @@ +## BEGIN NORMALIZED CODE ## +from itertools import chain +from math import log10, floor, ceil + + +def placeholder_0(placeholder_1, placeholder_2): + return get_extreme_palindrome_with_factors(placeholder_2, placeholder_1, "largest") + + +def placeholder_3(placeholder_2, placeholder_1): + return get_extreme_palindrome_with_factors(placeholder_2, placeholder_1, "smallest") + + +def placeholder_4(placeholder_2, placeholder_1, placeholder_5): + placeholder_6 = palindromes( + placeholder_2, placeholder_1, placeholder_7=placeholder_5 == "largest" + ) + placeholder_8 = None + for placeholder_9 in placeholder_6: + placeholder_8 = ( + (placeholder_10, placeholder_9 // placeholder_10) + for placeholder_10 in range(placeholder_1, placeholder_2 + 1) + if placeholder_9 % placeholder_10 == 0 + ) + placeholder_8 = list( + ( + placeholder_11 + for placeholder_11 in placeholder_8 + if placeholder_1 <= placeholder_11[1] <= placeholder_2 + ) + ) + if len(placeholder_8) > 0: + break + if not placeholder_8: + return (None, []) + return (placeholder_9, placeholder_8) + + +def placeholder_12(placeholder_13): + placeholder_14 = 0 + while placeholder_13 > 0: + placeholder_14 *= 10 + placeholder_14 += placeholder_13 % 10 + placeholder_13 //= 10 + return placeholder_14 + + +def placeholder_15(placeholder_13): + return int(floor(log10(placeholder_13) + 1)) + + +def placeholder_16(placeholder_2, placeholder_1, placeholder_7=False): + if placeholder_2 < placeholder_1: + raise ValueError("min must be <= max") + placeholder_17 = placeholder_1**2 + placeholder_18 = placeholder_2**2 + + def placeholder_19(placeholder_20, placeholder_7=placeholder_7): + placeholder_21 = placeholder_20 % 2 == 0 + placeholder_22 = max( + 10 ** (int(ceil(placeholder_20 / 2)) - 1), + placeholder_17 // 10 ** (placeholder_20 // 2), + ) + placeholder_23 = min( + 10 ** int(ceil(placeholder_20 / 2)) - 1, + placeholder_18 // 10 ** (placeholder_20 // 2), + ) + placeholder_24 = placeholder_22 if not placeholder_7 else placeholder_23 + + def placeholder_25(placeholder_26, placeholder_21=False): + placeholder_27 = ( + placeholder_12(placeholder_26) + if placeholder_21 + else placeholder_12(placeholder_26 // 10) + ) + return placeholder_26 * 10 ** (placeholder_20 // 2) + placeholder_27 + + if not placeholder_7: + while placeholder_24 <= placeholder_23: + placeholder_9 = placeholder_25(placeholder_24, placeholder_21) + if placeholder_17 <= placeholder_9 <= placeholder_18: + yield palindrome + elif placeholder_9 > placeholder_18: + break + placeholder_24 += 1 + else: + while placeholder_24 >= placeholder_22: + placeholder_9 = placeholder_25(placeholder_24, placeholder_21) + if placeholder_17 <= placeholder_9 <= placeholder_18: + yield palindrome + elif placeholder_9 < placeholder_17: + break + placeholder_24 -= 1 + + placeholder_28 = placeholder_15(placeholder_17) + placeholder_29 = placeholder_15(placeholder_18) + placeholder_30 = ( + range(placeholder_28, placeholder_29 + 1) + if not placeholder_7 + else range(placeholder_29, placeholder_28 - 1, -1) + ) + return chain(*map(placeholder_19, placeholder_30)) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'chain', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=27), + ImportFrom( + 'math', + [ + alias( + 'log10', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=22), + alias( + 'floor', + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=29), + alias( + 'ceil', + lineno=2, + col_offset=31, + end_lineno=2, + end_col_offset=35)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=35), + FunctionDef( + 'largest', + arguments( + [], + [ + arg( + 'min_factor', + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=22), + arg( + 'max_factor', + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'get_extreme_palindrome_with_factors', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=46), + [ + Name( + 'max_factor', + Load(), + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=57), + Name( + 'min_factor', + Load(), + lineno=6, + col_offset=59, + end_lineno=6, + end_col_offset=69), + Constant( + 'largest', + lineno=6, + col_offset=71, + end_lineno=6, + end_col_offset=80)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=81), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=81)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=81), + FunctionDef( + 'smallest', + arguments( + [], + [ + arg( + 'max_factor', + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=23), + arg( + 'min_factor', + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'get_extreme_palindrome_with_factors', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=46), + [ + Name( + 'max_factor', + Load(), + lineno=10, + col_offset=47, + end_lineno=10, + end_col_offset=57), + Name( + 'min_factor', + Load(), + lineno=10, + col_offset=59, + end_lineno=10, + end_col_offset=69), + Constant( + 'smallest', + lineno=10, + col_offset=71, + end_lineno=10, + end_col_offset=81)], + [], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=82), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=82)], + [], + lineno=9, + col_offset=0, + end_lineno=10, + end_col_offset=82), + FunctionDef( + 'get_extreme_palindrome_with_factors', + arguments( + [], + [ + arg( + 'max_factor', + lineno=13, + col_offset=40, + end_lineno=13, + end_col_offset=50), + arg( + 'min_factor', + lineno=13, + col_offset=52, + end_lineno=13, + end_col_offset=62), + arg( + 'extreme', + lineno=13, + col_offset=64, + end_lineno=13, + end_col_offset=71)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'palindromes_found', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=21)], + Call( + Name( + 'palindromes', + Load(), + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=35), + [ + Name( + 'max_factor', + Load(), + lineno=14, + col_offset=36, + end_lineno=14, + end_col_offset=46), + Name( + 'min_factor', + Load(), + lineno=14, + col_offset=48, + end_lineno=14, + end_col_offset=58)], + [ + keyword( + 'reverse', + Compare( + Name( + 'extreme', + Load(), + lineno=14, + col_offset=69, + end_lineno=14, + end_col_offset=76), + [ + Eq()], + [ + Constant( + 'largest', + lineno=14, + col_offset=80, + end_lineno=14, + end_col_offset=89)], + lineno=14, + col_offset=69, + end_lineno=14, + end_col_offset=89), + lineno=14, + col_offset=60, + end_lineno=14, + end_col_offset=90)], + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=91), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=91), + Assign( + [ + Name( + 'factor_pairs', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=16)], + Constant( + None, + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=23), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=23), + For( + Name( + 'palindrome', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18), + Name( + 'palindromes_found', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=39), + [ + Assign( + [ + Name( + 'factor_pairs', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=20)], + GeneratorExp( + Tuple( + [ + Name( + 'factor', + Load(), + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=31), + BinOp( + Name( + 'palindrome', + Load(), + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=43), + FloorDiv(), + Name( + 'factor', + Load(), + lineno=17, + col_offset=47, + end_lineno=17, + end_col_offset=53), + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=53)], + Load(), + lineno=17, + col_offset=24, + end_lineno=17, + end_col_offset=54), + [ + comprehension( + Name( + 'factor', + Store(), + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=34), + Call( + Name( + 'range', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=43), + [ + Name( + 'min_factor', + Load(), + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=54), + BinOp( + Name( + 'max_factor', + Load(), + lineno=18, + col_offset=56, + end_lineno=18, + end_col_offset=66), + Add(), + Constant( + 1, + lineno=18, + col_offset=69, + end_lineno=18, + end_col_offset=70), + lineno=18, + col_offset=56, + end_lineno=18, + end_col_offset=70)], + [], + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=71), + [ + Compare( + BinOp( + Name( + 'palindrome', + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=37), + Mod(), + Name( + 'factor', + Load(), + lineno=19, + col_offset=40, + end_lineno=19, + end_col_offset=46), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=46), + [ + Eq()], + [ + Constant( + 0, + lineno=19, + col_offset=50, + end_lineno=19, + end_col_offset=51)], + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=51)], + 0)], + lineno=17, + col_offset=23, + end_lineno=19, + end_col_offset=52), + lineno=17, + col_offset=8, + end_lineno=19, + end_col_offset=52), + Assign( + [ + Name( + 'factor_pairs', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=20)], + Call( + Name( + 'list', + Load(), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=27), + [ + GeneratorExp( + Name( + 'pair', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=32), + [ + comprehension( + Name( + 'pair', + Store(), + lineno=20, + col_offset=37, + end_lineno=20, + end_col_offset=41), + Name( + 'factor_pairs', + Load(), + lineno=20, + col_offset=45, + end_lineno=20, + end_col_offset=57), + [ + Compare( + Name( + 'min_factor', + Load(), + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=41), + [ + LtE(), + LtE()], + [ + Subscript( + Name( + 'pair', + Load(), + lineno=21, + col_offset=45, + end_lineno=21, + end_col_offset=49), + Constant( + 1, + lineno=21, + col_offset=50, + end_lineno=21, + end_col_offset=51), + Load(), + lineno=21, + col_offset=45, + end_lineno=21, + end_col_offset=52), + Name( + 'max_factor', + Load(), + lineno=21, + col_offset=56, + end_lineno=21, + end_col_offset=66)], + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=66)], + 0)], + lineno=20, + col_offset=27, + end_lineno=21, + end_col_offset=67)], + [], + lineno=20, + col_offset=23, + end_lineno=21, + end_col_offset=67), + lineno=20, + col_offset=8, + end_lineno=21, + end_col_offset=67), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=14), + [ + Name( + 'factor_pairs', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=27)], + [], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=28), + [ + Gt()], + [ + Constant( + 0, + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=32)], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=32), + [ + Break( + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17)], + [], + lineno=22, + col_offset=8, + end_lineno=23, + end_col_offset=17)], + [], + lineno=16, + col_offset=4, + end_lineno=23, + end_col_offset=17), + If( + UnaryOp( + Not(), + Name( + 'factor_pairs', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=23), + lineno=25, + col_offset=7, + end_lineno=25, + end_col_offset=23), + [ + Return( + Tuple( + [ + Constant( + None, + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=20), + List( + [], + Load(), + lineno=26, + col_offset=22, + end_lineno=26, + end_col_offset=24)], + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=25), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=25)], + [], + lineno=25, + col_offset=4, + end_lineno=26, + end_col_offset=25), + Return( + Tuple( + [ + Name( + 'palindrome', + Load(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=22), + Name( + 'factor_pairs', + Load(), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=36)], + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=37), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=37)], + [], + lineno=13, + col_offset=0, + end_lineno=28, + end_col_offset=37), + FunctionDef( + 'reverse_num', + arguments( + [], + [ + arg( + 'number', + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'reversed_nums', + Store(), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=17)], + Constant( + 0, + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=21), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=21), + While( + Compare( + Name( + 'number', + Load(), + lineno=33, + col_offset=10, + end_lineno=33, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 0, + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=20)], + lineno=33, + col_offset=10, + end_lineno=33, + end_col_offset=20), + [ + AugAssign( + Name( + 'reversed_nums', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=21), + Mult(), + Constant( + 10, + lineno=34, + col_offset=25, + end_lineno=34, + end_col_offset=27), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=27), + AugAssign( + Name( + 'reversed_nums', + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=21), + Add(), + BinOp( + Name( + 'number', + Load(), + lineno=35, + col_offset=26, + end_lineno=35, + end_col_offset=32), + Mod(), + Constant( + 10, + lineno=35, + col_offset=35, + end_lineno=35, + end_col_offset=37), + lineno=35, + col_offset=26, + end_lineno=35, + end_col_offset=37), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=38), + AugAssign( + Name( + 'number', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=14), + FloorDiv(), + Constant( + 10, + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=21), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=21)], + [], + lineno=33, + col_offset=4, + end_lineno=36, + end_col_offset=21), + Return( + Name( + 'reversed_nums', + Load(), + lineno=37, + col_offset=11, + end_lineno=37, + end_col_offset=24), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=24)], + [], + lineno=31, + col_offset=0, + end_lineno=37, + end_col_offset=24), + FunctionDef( + 'num_digits', + arguments( + [], + [ + arg( + 'number', + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'int', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=14), + [ + Call( + Name( + 'floor', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=20), + [ + BinOp( + Call( + Name( + 'log10', + Load(), + lineno=41, + col_offset=21, + end_lineno=41, + end_col_offset=26), + [ + Name( + 'number', + Load(), + lineno=41, + col_offset=27, + end_lineno=41, + end_col_offset=33)], + [], + lineno=41, + col_offset=21, + end_lineno=41, + end_col_offset=34), + Add(), + Constant( + 1, + lineno=41, + col_offset=37, + end_lineno=41, + end_col_offset=38), + lineno=41, + col_offset=21, + end_lineno=41, + end_col_offset=38)], + [], + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=39)], + [], + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=40), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=40)], + [], + lineno=40, + col_offset=0, + end_lineno=41, + end_col_offset=40), + FunctionDef( + 'palindromes', + arguments( + [], + [ + arg( + 'max_factor', + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=26), + arg( + 'min_factor', + lineno=44, + col_offset=28, + end_lineno=44, + end_col_offset=38), + arg( + 'reverse', + lineno=44, + col_offset=40, + end_lineno=44, + end_col_offset=47)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + False, + lineno=44, + col_offset=48, + end_lineno=44, + end_col_offset=53)]), + [ + Expr( + Constant( + "Generates all palindromes between `min_factor`**2 and max_factor`**2\n If `reverse` is True, will produce the palindromes in decreasing order,\n from `max_factor`**2 down to `min_factor`**2. This is needed for\n `largest_palindrome`, since it won't have to iterate through a\n most of the palindromes just to find the one it needs.\n ", + lineno=45, + col_offset=4, + end_lineno=50, + end_col_offset=7), + lineno=45, + col_offset=4, + end_lineno=50, + end_col_offset=7), + If( + Compare( + Name( + 'max_factor', + Load(), + lineno=51, + col_offset=7, + end_lineno=51, + end_col_offset=17), + [ + Lt()], + [ + Name( + 'min_factor', + Load(), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=30)], + lineno=51, + col_offset=7, + end_lineno=51, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=24), + [ + Constant( + 'min must be <= max', + lineno=52, + col_offset=25, + end_lineno=52, + end_col_offset=45)], + [], + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=46), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=46)], + [], + lineno=51, + col_offset=4, + end_lineno=52, + end_col_offset=46), + Assign( + [ + Name( + 'minimum', + Store(), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=11)], + BinOp( + Name( + 'min_factor', + Load(), + lineno=54, + col_offset=14, + end_lineno=54, + end_col_offset=24), + Pow(), + Constant( + 2, + lineno=54, + col_offset=28, + end_lineno=54, + end_col_offset=29), + lineno=54, + col_offset=14, + end_lineno=54, + end_col_offset=29), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=29), + Assign( + [ + Name( + 'maximum', + Store(), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=11)], + BinOp( + Name( + 'max_factor', + Load(), + lineno=55, + col_offset=14, + end_lineno=55, + end_col_offset=24), + Pow(), + Constant( + 2, + lineno=55, + col_offset=28, + end_lineno=55, + end_col_offset=29), + lineno=55, + col_offset=14, + end_lineno=55, + end_col_offset=29), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=29), + FunctionDef( + 'gen_palindromes_of_length', + arguments( + [], + [ + arg( + 'digit_count', + lineno=57, + col_offset=34, + end_lineno=57, + end_col_offset=45), + arg( + 'reverse', + lineno=57, + col_offset=47, + end_lineno=57, + end_col_offset=54)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Name( + 'reverse', + Load(), + lineno=57, + col_offset=55, + end_lineno=57, + end_col_offset=62)]), + [ + Expr( + Constant( + 'Generates all palindromes with `nd` number of digits that are\n within the desired range.\n Again, if `reverse` is True, the palindromes are generated in\n reverse order.\n ', + lineno=58, + col_offset=8, + end_lineno=62, + end_col_offset=11), + lineno=58, + col_offset=8, + end_lineno=62, + end_col_offset=11), + Assign( + [ + Name( + 'even_nd', + Store(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=15)], + Compare( + BinOp( + Name( + 'digit_count', + Load(), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=30), + Mod(), + Constant( + 2, + lineno=63, + col_offset=33, + end_lineno=63, + end_col_offset=34), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=34), + [ + Eq()], + [ + Constant( + 0, + lineno=63, + col_offset=38, + end_lineno=63, + end_col_offset=39)], + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=39), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=40), + Assign( + [ + Name( + 'min_left_half', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=21)], + Call( + Name( + 'max', + Load(), + lineno=65, + col_offset=24, + end_lineno=65, + end_col_offset=27), + [ + BinOp( + Constant( + 10, + lineno=65, + col_offset=28, + end_lineno=65, + end_col_offset=30), + Pow(), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=65, + col_offset=35, + end_lineno=65, + end_col_offset=38), + [ + Call( + Name( + 'ceil', + Load(), + lineno=65, + col_offset=39, + end_lineno=65, + end_col_offset=43), + [ + BinOp( + Name( + 'digit_count', + Load(), + lineno=65, + col_offset=44, + end_lineno=65, + end_col_offset=55), + Div(), + Constant( + 2, + lineno=65, + col_offset=58, + end_lineno=65, + end_col_offset=59), + lineno=65, + col_offset=44, + end_lineno=65, + end_col_offset=59)], + [], + lineno=65, + col_offset=39, + end_lineno=65, + end_col_offset=60)], + [], + lineno=65, + col_offset=35, + end_lineno=65, + end_col_offset=61), + Sub(), + Constant( + 1, + lineno=65, + col_offset=64, + end_lineno=65, + end_col_offset=65), + lineno=65, + col_offset=35, + end_lineno=65, + end_col_offset=65), + lineno=65, + col_offset=28, + end_lineno=65, + end_col_offset=66), + BinOp( + Name( + 'minimum', + Load(), + lineno=66, + col_offset=28, + end_lineno=66, + end_col_offset=35), + FloorDiv(), + BinOp( + Constant( + 10, + lineno=66, + col_offset=40, + end_lineno=66, + end_col_offset=42), + Pow(), + BinOp( + Name( + 'digit_count', + Load(), + lineno=66, + col_offset=47, + end_lineno=66, + end_col_offset=58), + FloorDiv(), + Constant( + 2, + lineno=66, + col_offset=62, + end_lineno=66, + end_col_offset=63), + lineno=66, + col_offset=47, + end_lineno=66, + end_col_offset=63), + lineno=66, + col_offset=40, + end_lineno=66, + end_col_offset=64), + lineno=66, + col_offset=28, + end_lineno=66, + end_col_offset=65)], + [], + lineno=65, + col_offset=24, + end_lineno=66, + end_col_offset=66), + lineno=65, + col_offset=8, + end_lineno=66, + end_col_offset=66), + Assign( + [ + Name( + 'max_left_half', + Store(), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=21)], + Call( + Name( + 'min', + Load(), + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=27), + [ + BinOp( + BinOp( + Constant( + 10, + lineno=67, + col_offset=29, + end_lineno=67, + end_col_offset=31), + Pow(), + Call( + Name( + 'int', + Load(), + lineno=67, + col_offset=35, + end_lineno=67, + end_col_offset=38), + [ + Call( + Name( + 'ceil', + Load(), + lineno=67, + col_offset=39, + end_lineno=67, + end_col_offset=43), + [ + BinOp( + Name( + 'digit_count', + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=55), + Div(), + Constant( + 2, + lineno=67, + col_offset=58, + end_lineno=67, + end_col_offset=59), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=59)], + [], + lineno=67, + col_offset=39, + end_lineno=67, + end_col_offset=60)], + [], + lineno=67, + col_offset=35, + end_lineno=67, + end_col_offset=61), + lineno=67, + col_offset=29, + end_lineno=67, + end_col_offset=61), + Sub(), + Constant( + 1, + lineno=67, + col_offset=65, + end_lineno=67, + end_col_offset=66), + lineno=67, + col_offset=28, + end_lineno=67, + end_col_offset=66), + BinOp( + Name( + 'maximum', + Load(), + lineno=68, + col_offset=28, + end_lineno=68, + end_col_offset=35), + FloorDiv(), + BinOp( + Constant( + 10, + lineno=68, + col_offset=40, + end_lineno=68, + end_col_offset=42), + Pow(), + BinOp( + Name( + 'digit_count', + Load(), + lineno=68, + col_offset=47, + end_lineno=68, + end_col_offset=58), + FloorDiv(), + Constant( + 2, + lineno=68, + col_offset=62, + end_lineno=68, + end_col_offset=63), + lineno=68, + col_offset=47, + end_lineno=68, + end_col_offset=63), + lineno=68, + col_offset=40, + end_lineno=68, + end_col_offset=64), + lineno=68, + col_offset=28, + end_lineno=68, + end_col_offset=65)], + [], + lineno=67, + col_offset=24, + end_lineno=68, + end_col_offset=66), + lineno=67, + col_offset=8, + end_lineno=68, + end_col_offset=66), + Assign( + [ + Name( + 'current_left_half', + Store(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=25)], + IfExp( + UnaryOp( + Not(), + Name( + 'reverse', + Load(), + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=56), + lineno=70, + col_offset=45, + end_lineno=70, + end_col_offset=56), + Name( + 'min_left_half', + Load(), + lineno=70, + col_offset=28, + end_lineno=70, + end_col_offset=41), + Name( + 'max_left_half', + Load(), + lineno=70, + col_offset=62, + end_lineno=70, + end_col_offset=75), + lineno=70, + col_offset=28, + end_lineno=70, + end_col_offset=75), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=75), + FunctionDef( + 'make_palindrome', + arguments( + [], + [ + arg( + 'left_half', + lineno=72, + col_offset=28, + end_lineno=72, + end_col_offset=37), + arg( + 'even_nd', + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + False, + lineno=72, + col_offset=47, + end_lineno=72, + end_col_offset=52)]), + [ + Assign( + [ + Name( + 'right_half', + Store(), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=22)], + IfExp( + Name( + 'even_nd', + Load(), + lineno=74, + col_offset=29, + end_lineno=74, + end_col_offset=36), + Call( + Name( + 'reverse_num', + Load(), + lineno=73, + col_offset=26, + end_lineno=73, + end_col_offset=37), + [ + Name( + 'left_half', + Load(), + lineno=73, + col_offset=38, + end_lineno=73, + end_col_offset=47)], + [], + lineno=73, + col_offset=26, + end_lineno=73, + end_col_offset=48), + Call( + Name( + 'reverse_num', + Load(), + lineno=75, + col_offset=31, + end_lineno=75, + end_col_offset=42), + [ + BinOp( + Name( + 'left_half', + Load(), + lineno=75, + col_offset=43, + end_lineno=75, + end_col_offset=52), + FloorDiv(), + Constant( + 10, + lineno=75, + col_offset=56, + end_lineno=75, + end_col_offset=58), + lineno=75, + col_offset=43, + end_lineno=75, + end_col_offset=58)], + [], + lineno=75, + col_offset=31, + end_lineno=75, + end_col_offset=59), + lineno=73, + col_offset=26, + end_lineno=75, + end_col_offset=59), + lineno=73, + col_offset=12, + end_lineno=75, + end_col_offset=60), + Return( + BinOp( + BinOp( + Name( + 'left_half', + Load(), + lineno=76, + col_offset=20, + end_lineno=76, + end_col_offset=29), + Mult(), + BinOp( + Constant( + 10, + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=35), + Pow(), + BinOp( + Name( + 'digit_count', + Load(), + lineno=76, + col_offset=40, + end_lineno=76, + end_col_offset=51), + FloorDiv(), + Constant( + 2, + lineno=76, + col_offset=55, + end_lineno=76, + end_col_offset=56), + lineno=76, + col_offset=40, + end_lineno=76, + end_col_offset=56), + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=57), + lineno=76, + col_offset=20, + end_lineno=76, + end_col_offset=58), + Add(), + Name( + 'right_half', + Load(), + lineno=76, + col_offset=62, + end_lineno=76, + end_col_offset=72), + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=72), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=72)], + [], + lineno=72, + col_offset=8, + end_lineno=76, + end_col_offset=72), + If( + UnaryOp( + Not(), + Name( + 'reverse', + Load(), + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=22), + lineno=78, + col_offset=11, + end_lineno=78, + end_col_offset=22), + [ + While( + Compare( + Name( + 'current_left_half', + Load(), + lineno=79, + col_offset=18, + end_lineno=79, + end_col_offset=35), + [ + LtE()], + [ + Name( + 'max_left_half', + Load(), + lineno=79, + col_offset=39, + end_lineno=79, + end_col_offset=52)], + lineno=79, + col_offset=18, + end_lineno=79, + end_col_offset=52), + [ + Assign( + [ + Name( + 'palindrome', + Store(), + lineno=80, + col_offset=16, + end_lineno=80, + end_col_offset=26)], + Call( + Name( + 'make_palindrome', + Load(), + lineno=80, + col_offset=29, + end_lineno=80, + end_col_offset=44), + [ + Name( + 'current_left_half', + Load(), + lineno=80, + col_offset=45, + end_lineno=80, + end_col_offset=62), + Name( + 'even_nd', + Load(), + lineno=80, + col_offset=64, + end_lineno=80, + end_col_offset=71)], + [], + lineno=80, + col_offset=29, + end_lineno=80, + end_col_offset=72), + lineno=80, + col_offset=16, + end_lineno=80, + end_col_offset=72), + If( + Compare( + Name( + 'minimum', + Load(), + lineno=81, + col_offset=19, + end_lineno=81, + end_col_offset=26), + [ + LtE(), + LtE()], + [ + Name( + 'palindrome', + Load(), + lineno=81, + col_offset=30, + end_lineno=81, + end_col_offset=40), + Name( + 'maximum', + Load(), + lineno=81, + col_offset=44, + end_lineno=81, + end_col_offset=51)], + lineno=81, + col_offset=19, + end_lineno=81, + end_col_offset=51), + [ + Expr( + Yield( + Name( + 'palindrome', + Load(), + lineno=82, + col_offset=26, + end_lineno=82, + end_col_offset=36), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=36), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=36)], + [ + If( + Compare( + Name( + 'palindrome', + Load(), + lineno=83, + col_offset=21, + end_lineno=83, + end_col_offset=31), + [ + Gt()], + [ + Name( + 'maximum', + Load(), + lineno=83, + col_offset=34, + end_lineno=83, + end_col_offset=41)], + lineno=83, + col_offset=21, + end_lineno=83, + end_col_offset=41), + [ + Break( + lineno=87, + col_offset=20, + end_lineno=87, + end_col_offset=25)], + [], + lineno=83, + col_offset=16, + end_lineno=87, + end_col_offset=25)], + lineno=81, + col_offset=16, + end_lineno=87, + end_col_offset=25), + AugAssign( + Name( + 'current_left_half', + Store(), + lineno=88, + col_offset=16, + end_lineno=88, + end_col_offset=33), + Add(), + Constant( + 1, + lineno=88, + col_offset=37, + end_lineno=88, + end_col_offset=38), + lineno=88, + col_offset=16, + end_lineno=88, + end_col_offset=38)], + [], + lineno=79, + col_offset=12, + end_lineno=88, + end_col_offset=38)], + [ + While( + Compare( + Name( + 'current_left_half', + Load(), + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=35), + [ + GtE()], + [ + Name( + 'min_left_half', + Load(), + lineno=90, + col_offset=39, + end_lineno=90, + end_col_offset=52)], + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=52), + [ + Assign( + [ + Name( + 'palindrome', + Store(), + lineno=91, + col_offset=16, + end_lineno=91, + end_col_offset=26)], + Call( + Name( + 'make_palindrome', + Load(), + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=44), + [ + Name( + 'current_left_half', + Load(), + lineno=91, + col_offset=45, + end_lineno=91, + end_col_offset=62), + Name( + 'even_nd', + Load(), + lineno=91, + col_offset=64, + end_lineno=91, + end_col_offset=71)], + [], + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=72), + lineno=91, + col_offset=16, + end_lineno=91, + end_col_offset=72), + If( + Compare( + Name( + 'minimum', + Load(), + lineno=92, + col_offset=19, + end_lineno=92, + end_col_offset=26), + [ + LtE(), + LtE()], + [ + Name( + 'palindrome', + Load(), + lineno=92, + col_offset=30, + end_lineno=92, + end_col_offset=40), + Name( + 'maximum', + Load(), + lineno=92, + col_offset=44, + end_lineno=92, + end_col_offset=51)], + lineno=92, + col_offset=19, + end_lineno=92, + end_col_offset=51), + [ + Expr( + Yield( + Name( + 'palindrome', + Load(), + lineno=93, + col_offset=26, + end_lineno=93, + end_col_offset=36), + lineno=93, + col_offset=20, + end_lineno=93, + end_col_offset=36), + lineno=93, + col_offset=20, + end_lineno=93, + end_col_offset=36)], + [ + If( + Compare( + Name( + 'palindrome', + Load(), + lineno=94, + col_offset=21, + end_lineno=94, + end_col_offset=31), + [ + Lt()], + [ + Name( + 'minimum', + Load(), + lineno=94, + col_offset=34, + end_lineno=94, + end_col_offset=41)], + lineno=94, + col_offset=21, + end_lineno=94, + end_col_offset=41), + [ + Break( + lineno=98, + col_offset=20, + end_lineno=98, + end_col_offset=25)], + [], + lineno=94, + col_offset=16, + end_lineno=98, + end_col_offset=25)], + lineno=92, + col_offset=16, + end_lineno=98, + end_col_offset=25), + AugAssign( + Name( + 'current_left_half', + Store(), + lineno=99, + col_offset=16, + end_lineno=99, + end_col_offset=33), + Sub(), + Constant( + 1, + lineno=99, + col_offset=37, + end_lineno=99, + end_col_offset=38), + lineno=99, + col_offset=16, + end_lineno=99, + end_col_offset=38)], + [], + lineno=90, + col_offset=12, + end_lineno=99, + end_col_offset=38)], + lineno=78, + col_offset=8, + end_lineno=99, + end_col_offset=38)], + [], + lineno=57, + col_offset=4, + end_lineno=99, + end_col_offset=38), + Assign( + [ + Name( + 'min_nd', + Store(), + lineno=101, + col_offset=4, + end_lineno=101, + end_col_offset=10)], + Call( + Name( + 'num_digits', + Load(), + lineno=101, + col_offset=13, + end_lineno=101, + end_col_offset=23), + [ + Name( + 'minimum', + Load(), + lineno=101, + col_offset=24, + end_lineno=101, + end_col_offset=31)], + [], + lineno=101, + col_offset=13, + end_lineno=101, + end_col_offset=32), + lineno=101, + col_offset=4, + end_lineno=101, + end_col_offset=32), + Assign( + [ + Name( + 'max_nd', + Store(), + lineno=102, + col_offset=4, + end_lineno=102, + end_col_offset=10)], + Call( + Name( + 'num_digits', + Load(), + lineno=102, + col_offset=13, + end_lineno=102, + end_col_offset=23), + [ + Name( + 'maximum', + Load(), + lineno=102, + col_offset=24, + end_lineno=102, + end_col_offset=31)], + [], + lineno=102, + col_offset=13, + end_lineno=102, + end_col_offset=32), + lineno=102, + col_offset=4, + end_lineno=102, + end_col_offset=32), + Assign( + [ + Name( + 'lengths', + Store(), + lineno=104, + col_offset=4, + end_lineno=104, + end_col_offset=11)], + IfExp( + UnaryOp( + Not(), + Name( + 'reverse', + Load(), + lineno=105, + col_offset=22, + end_lineno=105, + end_col_offset=29), + lineno=105, + col_offset=18, + end_lineno=105, + end_col_offset=29), + Call( + Name( + 'range', + Load(), + lineno=104, + col_offset=15, + end_lineno=104, + end_col_offset=20), + [ + Name( + 'min_nd', + Load(), + lineno=104, + col_offset=21, + end_lineno=104, + end_col_offset=27), + BinOp( + Name( + 'max_nd', + Load(), + lineno=104, + col_offset=29, + end_lineno=104, + end_col_offset=35), + Add(), + Constant( + 1, + lineno=104, + col_offset=38, + end_lineno=104, + end_col_offset=39), + lineno=104, + col_offset=29, + end_lineno=104, + end_col_offset=39)], + [], + lineno=104, + col_offset=15, + end_lineno=104, + end_col_offset=40), + Call( + Name( + 'range', + Load(), + lineno=106, + col_offset=20, + end_lineno=106, + end_col_offset=25), + [ + Name( + 'max_nd', + Load(), + lineno=106, + col_offset=26, + end_lineno=106, + end_col_offset=32), + BinOp( + Name( + 'min_nd', + Load(), + lineno=106, + col_offset=34, + end_lineno=106, + end_col_offset=40), + Sub(), + Constant( + 1, + lineno=106, + col_offset=43, + end_lineno=106, + end_col_offset=44), + lineno=106, + col_offset=34, + end_lineno=106, + end_col_offset=44), + UnaryOp( + USub(), + Constant( + 1, + lineno=106, + col_offset=47, + end_lineno=106, + end_col_offset=48), + lineno=106, + col_offset=46, + end_lineno=106, + end_col_offset=48)], + [], + lineno=106, + col_offset=20, + end_lineno=106, + end_col_offset=49), + lineno=104, + col_offset=15, + end_lineno=106, + end_col_offset=49), + lineno=104, + col_offset=4, + end_lineno=106, + end_col_offset=50), + Return( + Call( + Name( + 'chain', + Load(), + lineno=108, + col_offset=11, + end_lineno=108, + end_col_offset=16), + [ + Starred( + Call( + Name( + 'map', + Load(), + lineno=108, + col_offset=18, + end_lineno=108, + end_col_offset=21), + [ + Name( + 'gen_palindromes_of_length', + Load(), + lineno=108, + col_offset=22, + end_lineno=108, + end_col_offset=47), + Name( + 'lengths', + Load(), + lineno=108, + col_offset=49, + end_lineno=108, + end_col_offset=56)], + [], + lineno=108, + col_offset=18, + end_lineno=108, + end_col_offset=57), + Load(), + lineno=108, + col_offset=17, + end_lineno=108, + end_col_offset=57)], + [], + lineno=108, + col_offset=11, + end_lineno=108, + end_col_offset=58), + lineno=108, + col_offset=4, + end_lineno=108, + end_col_offset=58)], + [], + lineno=44, + col_offset=0, + end_lineno=108, + end_col_offset=58)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'chain', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=27), + ImportFrom( + 'math', + [ + alias( + 'log10', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=22), + alias( + 'floor', + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=29), + alias( + 'ceil', + lineno=2, + col_offset=31, + end_lineno=2, + end_col_offset=35)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=35), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=22), + arg( + 'placeholder_2', + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'get_extreme_palindrome_with_factors', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=46), + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=57), + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=59, + end_lineno=6, + end_col_offset=69), + Constant( + 'largest', + lineno=6, + col_offset=71, + end_lineno=6, + end_col_offset=80)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=81), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=81)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=81), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=23), + arg( + 'placeholder_1', + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'get_extreme_palindrome_with_factors', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=46), + [ + Name( + 'placeholder_2', + Load(), + lineno=10, + col_offset=47, + end_lineno=10, + end_col_offset=57), + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=59, + end_lineno=10, + end_col_offset=69), + Constant( + 'smallest', + lineno=10, + col_offset=71, + end_lineno=10, + end_col_offset=81)], + [], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=82), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=82)], + [], + lineno=9, + col_offset=0, + end_lineno=10, + end_col_offset=82), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=13, + col_offset=40, + end_lineno=13, + end_col_offset=50), + arg( + 'placeholder_1', + lineno=13, + col_offset=52, + end_lineno=13, + end_col_offset=62), + arg( + 'placeholder_5', + lineno=13, + col_offset=64, + end_lineno=13, + end_col_offset=71)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=21)], + Call( + Name( + 'palindromes', + Load(), + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=35), + [ + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=36, + end_lineno=14, + end_col_offset=46), + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=48, + end_lineno=14, + end_col_offset=58)], + [ + keyword( + 'placeholder_7', + Compare( + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=69, + end_lineno=14, + end_col_offset=76), + [ + Eq()], + [ + Constant( + 'largest', + lineno=14, + col_offset=80, + end_lineno=14, + end_col_offset=89)], + lineno=14, + col_offset=69, + end_lineno=14, + end_col_offset=89), + lineno=14, + col_offset=60, + end_lineno=14, + end_col_offset=90)], + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=91), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=91), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=16)], + Constant( + None, + lineno=15, + col_offset=19, + end_lineno=15, + end_col_offset=23), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=23), + For( + Name( + 'placeholder_9', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18), + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=39), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=20)], + GeneratorExp( + Tuple( + [ + Name( + 'placeholder_10', + Load(), + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=31), + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=43), + FloorDiv(), + Name( + 'placeholder_10', + Load(), + lineno=17, + col_offset=47, + end_lineno=17, + end_col_offset=53), + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=53)], + Load(), + lineno=17, + col_offset=24, + end_lineno=17, + end_col_offset=54), + [ + comprehension( + Name( + 'placeholder_10', + Store(), + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=34), + Call( + Name( + 'range', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=43), + [ + Name( + 'placeholder_1', + Load(), + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=54), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=18, + col_offset=56, + end_lineno=18, + end_col_offset=66), + Add(), + Constant( + 1, + lineno=18, + col_offset=69, + end_lineno=18, + end_col_offset=70), + lineno=18, + col_offset=56, + end_lineno=18, + end_col_offset=70)], + [], + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=71), + [ + Compare( + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=37), + Mod(), + Name( + 'placeholder_10', + Load(), + lineno=19, + col_offset=40, + end_lineno=19, + end_col_offset=46), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=46), + [ + Eq()], + [ + Constant( + 0, + lineno=19, + col_offset=50, + end_lineno=19, + end_col_offset=51)], + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=51)], + 0)], + lineno=17, + col_offset=23, + end_lineno=19, + end_col_offset=52), + lineno=17, + col_offset=8, + end_lineno=19, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=20)], + Call( + Name( + 'list', + Load(), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=27), + [ + GeneratorExp( + Name( + 'placeholder_11', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=32), + [ + comprehension( + Name( + 'placeholder_11', + Store(), + lineno=20, + col_offset=37, + end_lineno=20, + end_col_offset=41), + Name( + 'placeholder_8', + Load(), + lineno=20, + col_offset=45, + end_lineno=20, + end_col_offset=57), + [ + Compare( + Name( + 'placeholder_1', + Load(), + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=41), + [ + LtE(), + LtE()], + [ + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=21, + col_offset=45, + end_lineno=21, + end_col_offset=49), + Constant( + 1, + lineno=21, + col_offset=50, + end_lineno=21, + end_col_offset=51), + Load(), + lineno=21, + col_offset=45, + end_lineno=21, + end_col_offset=52), + Name( + 'placeholder_2', + Load(), + lineno=21, + col_offset=56, + end_lineno=21, + end_col_offset=66)], + lineno=21, + col_offset=31, + end_lineno=21, + end_col_offset=66)], + 0)], + lineno=20, + col_offset=27, + end_lineno=21, + end_col_offset=67)], + [], + lineno=20, + col_offset=23, + end_lineno=21, + end_col_offset=67), + lineno=20, + col_offset=8, + end_lineno=21, + end_col_offset=67), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=14), + [ + Name( + 'placeholder_8', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=27)], + [], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=28), + [ + Gt()], + [ + Constant( + 0, + lineno=22, + col_offset=31, + end_lineno=22, + end_col_offset=32)], + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=32), + [ + Break( + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17)], + [], + lineno=22, + col_offset=8, + end_lineno=23, + end_col_offset=17)], + [], + lineno=16, + col_offset=4, + end_lineno=23, + end_col_offset=17), + If( + UnaryOp( + Not(), + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=23), + lineno=25, + col_offset=7, + end_lineno=25, + end_col_offset=23), + [ + Return( + Tuple( + [ + Constant( + None, + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=20), + List( + [], + Load(), + lineno=26, + col_offset=22, + end_lineno=26, + end_col_offset=24)], + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=25), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=25)], + [], + lineno=25, + col_offset=4, + end_lineno=26, + end_col_offset=25), + Return( + Tuple( + [ + Name( + 'placeholder_9', + Load(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=22), + Name( + 'placeholder_8', + Load(), + lineno=28, + col_offset=24, + end_lineno=28, + end_col_offset=36)], + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=37), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=37)], + [], + lineno=13, + col_offset=0, + end_lineno=28, + end_col_offset=37), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=31, + col_offset=16, + end_lineno=31, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=17)], + Constant( + 0, + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=21), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=21), + While( + Compare( + Name( + 'placeholder_13', + Load(), + lineno=33, + col_offset=10, + end_lineno=33, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 0, + lineno=33, + col_offset=19, + end_lineno=33, + end_col_offset=20)], + lineno=33, + col_offset=10, + end_lineno=33, + end_col_offset=20), + [ + AugAssign( + Name( + 'placeholder_14', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=21), + Mult(), + Constant( + 10, + lineno=34, + col_offset=25, + end_lineno=34, + end_col_offset=27), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=27), + AugAssign( + Name( + 'placeholder_14', + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=21), + Add(), + BinOp( + Name( + 'placeholder_13', + Load(), + lineno=35, + col_offset=26, + end_lineno=35, + end_col_offset=32), + Mod(), + Constant( + 10, + lineno=35, + col_offset=35, + end_lineno=35, + end_col_offset=37), + lineno=35, + col_offset=26, + end_lineno=35, + end_col_offset=37), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=38), + AugAssign( + Name( + 'placeholder_13', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=14), + FloorDiv(), + Constant( + 10, + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=21), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=21)], + [], + lineno=33, + col_offset=4, + end_lineno=36, + end_col_offset=21), + Return( + Name( + 'placeholder_14', + Load(), + lineno=37, + col_offset=11, + end_lineno=37, + end_col_offset=24), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=24)], + [], + lineno=31, + col_offset=0, + end_lineno=37, + end_col_offset=24), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'int', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=14), + [ + Call( + Name( + 'floor', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=20), + [ + BinOp( + Call( + Name( + 'log10', + Load(), + lineno=41, + col_offset=21, + end_lineno=41, + end_col_offset=26), + [ + Name( + 'placeholder_13', + Load(), + lineno=41, + col_offset=27, + end_lineno=41, + end_col_offset=33)], + [], + lineno=41, + col_offset=21, + end_lineno=41, + end_col_offset=34), + Add(), + Constant( + 1, + lineno=41, + col_offset=37, + end_lineno=41, + end_col_offset=38), + lineno=41, + col_offset=21, + end_lineno=41, + end_col_offset=38)], + [], + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=39)], + [], + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=40), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=40)], + [], + lineno=40, + col_offset=0, + end_lineno=41, + end_col_offset=40), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=26), + arg( + 'placeholder_1', + lineno=44, + col_offset=28, + end_lineno=44, + end_col_offset=38), + arg( + 'placeholder_7', + lineno=44, + col_offset=40, + end_lineno=44, + end_col_offset=47)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + False, + lineno=44, + col_offset=48, + end_lineno=44, + end_col_offset=53)]), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=51, + col_offset=7, + end_lineno=51, + end_col_offset=17), + [ + Lt()], + [ + Name( + 'placeholder_1', + Load(), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=30)], + lineno=51, + col_offset=7, + end_lineno=51, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=24), + [ + Constant( + 'min must be <= max', + lineno=52, + col_offset=25, + end_lineno=52, + end_col_offset=45)], + [], + lineno=52, + col_offset=14, + end_lineno=52, + end_col_offset=46), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=46)], + [], + lineno=51, + col_offset=4, + end_lineno=52, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=11)], + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=54, + col_offset=14, + end_lineno=54, + end_col_offset=24), + Pow(), + Constant( + 2, + lineno=54, + col_offset=28, + end_lineno=54, + end_col_offset=29), + lineno=54, + col_offset=14, + end_lineno=54, + end_col_offset=29), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=29), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=11)], + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=55, + col_offset=14, + end_lineno=55, + end_col_offset=24), + Pow(), + Constant( + 2, + lineno=55, + col_offset=28, + end_lineno=55, + end_col_offset=29), + lineno=55, + col_offset=14, + end_lineno=55, + end_col_offset=29), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=29), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'placeholder_20', + lineno=57, + col_offset=34, + end_lineno=57, + end_col_offset=45), + arg( + 'placeholder_7', + lineno=57, + col_offset=47, + end_lineno=57, + end_col_offset=54)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Name( + 'placeholder_7', + Load(), + lineno=57, + col_offset=55, + end_lineno=57, + end_col_offset=62)]), + [ + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=15)], + Compare( + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=30), + Mod(), + Constant( + 2, + lineno=63, + col_offset=33, + end_lineno=63, + end_col_offset=34), + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=34), + [ + Eq()], + [ + Constant( + 0, + lineno=63, + col_offset=38, + end_lineno=63, + end_col_offset=39)], + lineno=63, + col_offset=19, + end_lineno=63, + end_col_offset=39), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=21)], + Call( + Name( + 'max', + Load(), + lineno=65, + col_offset=24, + end_lineno=65, + end_col_offset=27), + [ + BinOp( + Constant( + 10, + lineno=65, + col_offset=28, + end_lineno=65, + end_col_offset=30), + Pow(), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=65, + col_offset=35, + end_lineno=65, + end_col_offset=38), + [ + Call( + Name( + 'ceil', + Load(), + lineno=65, + col_offset=39, + end_lineno=65, + end_col_offset=43), + [ + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=65, + col_offset=44, + end_lineno=65, + end_col_offset=55), + Div(), + Constant( + 2, + lineno=65, + col_offset=58, + end_lineno=65, + end_col_offset=59), + lineno=65, + col_offset=44, + end_lineno=65, + end_col_offset=59)], + [], + lineno=65, + col_offset=39, + end_lineno=65, + end_col_offset=60)], + [], + lineno=65, + col_offset=35, + end_lineno=65, + end_col_offset=61), + Sub(), + Constant( + 1, + lineno=65, + col_offset=64, + end_lineno=65, + end_col_offset=65), + lineno=65, + col_offset=35, + end_lineno=65, + end_col_offset=65), + lineno=65, + col_offset=28, + end_lineno=65, + end_col_offset=66), + BinOp( + Name( + 'placeholder_17', + Load(), + lineno=66, + col_offset=28, + end_lineno=66, + end_col_offset=35), + FloorDiv(), + BinOp( + Constant( + 10, + lineno=66, + col_offset=40, + end_lineno=66, + end_col_offset=42), + Pow(), + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=66, + col_offset=47, + end_lineno=66, + end_col_offset=58), + FloorDiv(), + Constant( + 2, + lineno=66, + col_offset=62, + end_lineno=66, + end_col_offset=63), + lineno=66, + col_offset=47, + end_lineno=66, + end_col_offset=63), + lineno=66, + col_offset=40, + end_lineno=66, + end_col_offset=64), + lineno=66, + col_offset=28, + end_lineno=66, + end_col_offset=65)], + [], + lineno=65, + col_offset=24, + end_lineno=66, + end_col_offset=66), + lineno=65, + col_offset=8, + end_lineno=66, + end_col_offset=66), + Assign( + [ + Name( + 'placeholder_23', + Store(), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=21)], + Call( + Name( + 'min', + Load(), + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=27), + [ + BinOp( + BinOp( + Constant( + 10, + lineno=67, + col_offset=29, + end_lineno=67, + end_col_offset=31), + Pow(), + Call( + Name( + 'int', + Load(), + lineno=67, + col_offset=35, + end_lineno=67, + end_col_offset=38), + [ + Call( + Name( + 'ceil', + Load(), + lineno=67, + col_offset=39, + end_lineno=67, + end_col_offset=43), + [ + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=55), + Div(), + Constant( + 2, + lineno=67, + col_offset=58, + end_lineno=67, + end_col_offset=59), + lineno=67, + col_offset=44, + end_lineno=67, + end_col_offset=59)], + [], + lineno=67, + col_offset=39, + end_lineno=67, + end_col_offset=60)], + [], + lineno=67, + col_offset=35, + end_lineno=67, + end_col_offset=61), + lineno=67, + col_offset=29, + end_lineno=67, + end_col_offset=61), + Sub(), + Constant( + 1, + lineno=67, + col_offset=65, + end_lineno=67, + end_col_offset=66), + lineno=67, + col_offset=28, + end_lineno=67, + end_col_offset=66), + BinOp( + Name( + 'placeholder_18', + Load(), + lineno=68, + col_offset=28, + end_lineno=68, + end_col_offset=35), + FloorDiv(), + BinOp( + Constant( + 10, + lineno=68, + col_offset=40, + end_lineno=68, + end_col_offset=42), + Pow(), + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=68, + col_offset=47, + end_lineno=68, + end_col_offset=58), + FloorDiv(), + Constant( + 2, + lineno=68, + col_offset=62, + end_lineno=68, + end_col_offset=63), + lineno=68, + col_offset=47, + end_lineno=68, + end_col_offset=63), + lineno=68, + col_offset=40, + end_lineno=68, + end_col_offset=64), + lineno=68, + col_offset=28, + end_lineno=68, + end_col_offset=65)], + [], + lineno=67, + col_offset=24, + end_lineno=68, + end_col_offset=66), + lineno=67, + col_offset=8, + end_lineno=68, + end_col_offset=66), + Assign( + [ + Name( + 'placeholder_24', + Store(), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=25)], + IfExp( + UnaryOp( + Not(), + Name( + 'placeholder_7', + Load(), + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=56), + lineno=70, + col_offset=45, + end_lineno=70, + end_col_offset=56), + Name( + 'placeholder_22', + Load(), + lineno=70, + col_offset=28, + end_lineno=70, + end_col_offset=41), + Name( + 'placeholder_23', + Load(), + lineno=70, + col_offset=62, + end_lineno=70, + end_col_offset=75), + lineno=70, + col_offset=28, + end_lineno=70, + end_col_offset=75), + lineno=70, + col_offset=8, + end_lineno=70, + end_col_offset=75), + FunctionDef( + 'placeholder_25', + arguments( + [], + [ + arg( + 'placeholder_26', + lineno=72, + col_offset=28, + end_lineno=72, + end_col_offset=37), + arg( + 'placeholder_21', + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=46)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + False, + lineno=72, + col_offset=47, + end_lineno=72, + end_col_offset=52)]), + [ + Assign( + [ + Name( + 'placeholder_27', + Store(), + lineno=73, + col_offset=12, + end_lineno=73, + end_col_offset=22)], + IfExp( + Name( + 'placeholder_21', + Load(), + lineno=74, + col_offset=29, + end_lineno=74, + end_col_offset=36), + Call( + Name( + 'placeholder_12', + Load(), + lineno=73, + col_offset=26, + end_lineno=73, + end_col_offset=37), + [ + Name( + 'placeholder_26', + Load(), + lineno=73, + col_offset=38, + end_lineno=73, + end_col_offset=47)], + [], + lineno=73, + col_offset=26, + end_lineno=73, + end_col_offset=48), + Call( + Name( + 'placeholder_12', + Load(), + lineno=75, + col_offset=31, + end_lineno=75, + end_col_offset=42), + [ + BinOp( + Name( + 'placeholder_26', + Load(), + lineno=75, + col_offset=43, + end_lineno=75, + end_col_offset=52), + FloorDiv(), + Constant( + 10, + lineno=75, + col_offset=56, + end_lineno=75, + end_col_offset=58), + lineno=75, + col_offset=43, + end_lineno=75, + end_col_offset=58)], + [], + lineno=75, + col_offset=31, + end_lineno=75, + end_col_offset=59), + lineno=73, + col_offset=26, + end_lineno=75, + end_col_offset=59), + lineno=73, + col_offset=12, + end_lineno=75, + end_col_offset=60), + Return( + BinOp( + BinOp( + Name( + 'placeholder_26', + Load(), + lineno=76, + col_offset=20, + end_lineno=76, + end_col_offset=29), + Mult(), + BinOp( + Constant( + 10, + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=35), + Pow(), + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=76, + col_offset=40, + end_lineno=76, + end_col_offset=51), + FloorDiv(), + Constant( + 2, + lineno=76, + col_offset=55, + end_lineno=76, + end_col_offset=56), + lineno=76, + col_offset=40, + end_lineno=76, + end_col_offset=56), + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=57), + lineno=76, + col_offset=20, + end_lineno=76, + end_col_offset=58), + Add(), + Name( + 'placeholder_27', + Load(), + lineno=76, + col_offset=62, + end_lineno=76, + end_col_offset=72), + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=72), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=72)], + [], + lineno=72, + col_offset=8, + end_lineno=76, + end_col_offset=72), + If( + UnaryOp( + Not(), + Name( + 'placeholder_7', + Load(), + lineno=78, + col_offset=15, + end_lineno=78, + end_col_offset=22), + lineno=78, + col_offset=11, + end_lineno=78, + end_col_offset=22), + [ + While( + Compare( + Name( + 'placeholder_24', + Load(), + lineno=79, + col_offset=18, + end_lineno=79, + end_col_offset=35), + [ + LtE()], + [ + Name( + 'placeholder_23', + Load(), + lineno=79, + col_offset=39, + end_lineno=79, + end_col_offset=52)], + lineno=79, + col_offset=18, + end_lineno=79, + end_col_offset=52), + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=80, + col_offset=16, + end_lineno=80, + end_col_offset=26)], + Call( + Name( + 'placeholder_25', + Load(), + lineno=80, + col_offset=29, + end_lineno=80, + end_col_offset=44), + [ + Name( + 'placeholder_24', + Load(), + lineno=80, + col_offset=45, + end_lineno=80, + end_col_offset=62), + Name( + 'placeholder_21', + Load(), + lineno=80, + col_offset=64, + end_lineno=80, + end_col_offset=71)], + [], + lineno=80, + col_offset=29, + end_lineno=80, + end_col_offset=72), + lineno=80, + col_offset=16, + end_lineno=80, + end_col_offset=72), + If( + Compare( + Name( + 'placeholder_17', + Load(), + lineno=81, + col_offset=19, + end_lineno=81, + end_col_offset=26), + [ + LtE(), + LtE()], + [ + Name( + 'placeholder_9', + Load(), + lineno=81, + col_offset=30, + end_lineno=81, + end_col_offset=40), + Name( + 'placeholder_18', + Load(), + lineno=81, + col_offset=44, + end_lineno=81, + end_col_offset=51)], + lineno=81, + col_offset=19, + end_lineno=81, + end_col_offset=51), + [ + Expr( + Yield( + Name( + 'palindrome', + Load(), + lineno=82, + col_offset=26, + end_lineno=82, + end_col_offset=36), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=36), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=36)], + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=83, + col_offset=21, + end_lineno=83, + end_col_offset=31), + [ + Gt()], + [ + Name( + 'placeholder_18', + Load(), + lineno=83, + col_offset=34, + end_lineno=83, + end_col_offset=41)], + lineno=83, + col_offset=21, + end_lineno=83, + end_col_offset=41), + [ + Break( + lineno=87, + col_offset=20, + end_lineno=87, + end_col_offset=25)], + [], + lineno=83, + col_offset=16, + end_lineno=87, + end_col_offset=25)], + lineno=81, + col_offset=16, + end_lineno=87, + end_col_offset=25), + AugAssign( + Name( + 'placeholder_24', + Store(), + lineno=88, + col_offset=16, + end_lineno=88, + end_col_offset=33), + Add(), + Constant( + 1, + lineno=88, + col_offset=37, + end_lineno=88, + end_col_offset=38), + lineno=88, + col_offset=16, + end_lineno=88, + end_col_offset=38)], + [], + lineno=79, + col_offset=12, + end_lineno=88, + end_col_offset=38)], + [ + While( + Compare( + Name( + 'placeholder_24', + Load(), + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=35), + [ + GtE()], + [ + Name( + 'placeholder_22', + Load(), + lineno=90, + col_offset=39, + end_lineno=90, + end_col_offset=52)], + lineno=90, + col_offset=18, + end_lineno=90, + end_col_offset=52), + [ + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=91, + col_offset=16, + end_lineno=91, + end_col_offset=26)], + Call( + Name( + 'placeholder_25', + Load(), + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=44), + [ + Name( + 'placeholder_24', + Load(), + lineno=91, + col_offset=45, + end_lineno=91, + end_col_offset=62), + Name( + 'placeholder_21', + Load(), + lineno=91, + col_offset=64, + end_lineno=91, + end_col_offset=71)], + [], + lineno=91, + col_offset=29, + end_lineno=91, + end_col_offset=72), + lineno=91, + col_offset=16, + end_lineno=91, + end_col_offset=72), + If( + Compare( + Name( + 'placeholder_17', + Load(), + lineno=92, + col_offset=19, + end_lineno=92, + end_col_offset=26), + [ + LtE(), + LtE()], + [ + Name( + 'placeholder_9', + Load(), + lineno=92, + col_offset=30, + end_lineno=92, + end_col_offset=40), + Name( + 'placeholder_18', + Load(), + lineno=92, + col_offset=44, + end_lineno=92, + end_col_offset=51)], + lineno=92, + col_offset=19, + end_lineno=92, + end_col_offset=51), + [ + Expr( + Yield( + Name( + 'palindrome', + Load(), + lineno=93, + col_offset=26, + end_lineno=93, + end_col_offset=36), + lineno=93, + col_offset=20, + end_lineno=93, + end_col_offset=36), + lineno=93, + col_offset=20, + end_lineno=93, + end_col_offset=36)], + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=94, + col_offset=21, + end_lineno=94, + end_col_offset=31), + [ + Lt()], + [ + Name( + 'placeholder_17', + Load(), + lineno=94, + col_offset=34, + end_lineno=94, + end_col_offset=41)], + lineno=94, + col_offset=21, + end_lineno=94, + end_col_offset=41), + [ + Break( + lineno=98, + col_offset=20, + end_lineno=98, + end_col_offset=25)], + [], + lineno=94, + col_offset=16, + end_lineno=98, + end_col_offset=25)], + lineno=92, + col_offset=16, + end_lineno=98, + end_col_offset=25), + AugAssign( + Name( + 'placeholder_24', + Store(), + lineno=99, + col_offset=16, + end_lineno=99, + end_col_offset=33), + Sub(), + Constant( + 1, + lineno=99, + col_offset=37, + end_lineno=99, + end_col_offset=38), + lineno=99, + col_offset=16, + end_lineno=99, + end_col_offset=38)], + [], + lineno=90, + col_offset=12, + end_lineno=99, + end_col_offset=38)], + lineno=78, + col_offset=8, + end_lineno=99, + end_col_offset=38)], + [], + lineno=57, + col_offset=4, + end_lineno=99, + end_col_offset=38), + Assign( + [ + Name( + 'placeholder_28', + Store(), + lineno=101, + col_offset=4, + end_lineno=101, + end_col_offset=10)], + Call( + Name( + 'placeholder_15', + Load(), + lineno=101, + col_offset=13, + end_lineno=101, + end_col_offset=23), + [ + Name( + 'placeholder_17', + Load(), + lineno=101, + col_offset=24, + end_lineno=101, + end_col_offset=31)], + [], + lineno=101, + col_offset=13, + end_lineno=101, + end_col_offset=32), + lineno=101, + col_offset=4, + end_lineno=101, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_29', + Store(), + lineno=102, + col_offset=4, + end_lineno=102, + end_col_offset=10)], + Call( + Name( + 'placeholder_15', + Load(), + lineno=102, + col_offset=13, + end_lineno=102, + end_col_offset=23), + [ + Name( + 'placeholder_18', + Load(), + lineno=102, + col_offset=24, + end_lineno=102, + end_col_offset=31)], + [], + lineno=102, + col_offset=13, + end_lineno=102, + end_col_offset=32), + lineno=102, + col_offset=4, + end_lineno=102, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_30', + Store(), + lineno=104, + col_offset=4, + end_lineno=104, + end_col_offset=11)], + IfExp( + UnaryOp( + Not(), + Name( + 'placeholder_7', + Load(), + lineno=105, + col_offset=22, + end_lineno=105, + end_col_offset=29), + lineno=105, + col_offset=18, + end_lineno=105, + end_col_offset=29), + Call( + Name( + 'range', + Load(), + lineno=104, + col_offset=15, + end_lineno=104, + end_col_offset=20), + [ + Name( + 'placeholder_28', + Load(), + lineno=104, + col_offset=21, + end_lineno=104, + end_col_offset=27), + BinOp( + Name( + 'placeholder_29', + Load(), + lineno=104, + col_offset=29, + end_lineno=104, + end_col_offset=35), + Add(), + Constant( + 1, + lineno=104, + col_offset=38, + end_lineno=104, + end_col_offset=39), + lineno=104, + col_offset=29, + end_lineno=104, + end_col_offset=39)], + [], + lineno=104, + col_offset=15, + end_lineno=104, + end_col_offset=40), + Call( + Name( + 'range', + Load(), + lineno=106, + col_offset=20, + end_lineno=106, + end_col_offset=25), + [ + Name( + 'placeholder_29', + Load(), + lineno=106, + col_offset=26, + end_lineno=106, + end_col_offset=32), + BinOp( + Name( + 'placeholder_28', + Load(), + lineno=106, + col_offset=34, + end_lineno=106, + end_col_offset=40), + Sub(), + Constant( + 1, + lineno=106, + col_offset=43, + end_lineno=106, + end_col_offset=44), + lineno=106, + col_offset=34, + end_lineno=106, + end_col_offset=44), + UnaryOp( + USub(), + Constant( + 1, + lineno=106, + col_offset=47, + end_lineno=106, + end_col_offset=48), + lineno=106, + col_offset=46, + end_lineno=106, + end_col_offset=48)], + [], + lineno=106, + col_offset=20, + end_lineno=106, + end_col_offset=49), + lineno=104, + col_offset=15, + end_lineno=106, + end_col_offset=49), + lineno=104, + col_offset=4, + end_lineno=106, + end_col_offset=50), + Return( + Call( + Name( + 'chain', + Load(), + lineno=108, + col_offset=11, + end_lineno=108, + end_col_offset=16), + [ + Starred( + Call( + Name( + 'map', + Load(), + lineno=108, + col_offset=18, + end_lineno=108, + end_col_offset=21), + [ + Name( + 'placeholder_19', + Load(), + lineno=108, + col_offset=22, + end_lineno=108, + end_col_offset=47), + Name( + 'placeholder_30', + Load(), + lineno=108, + col_offset=49, + end_lineno=108, + end_col_offset=56)], + [], + lineno=108, + col_offset=18, + end_lineno=108, + end_col_offset=57), + Load(), + lineno=108, + col_offset=17, + end_lineno=108, + end_col_offset=57)], + [], + lineno=108, + col_offset=11, + end_lineno=108, + end_col_offset=58), + lineno=108, + col_offset=4, + end_lineno=108, + end_col_offset=58)], + [], + lineno=44, + col_offset=0, + end_lineno=108, + end_col_offset=58)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-palindrome-products/representation.txt b/test/practice-palindrome-products/representation.txt new file mode 100644 index 0000000..3dcc07e --- /dev/null +++ b/test/practice-palindrome-products/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('itertools', [alias('chain', lineno=1, col_offset=22, end_lineno=1, end_col_offset=27)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=27), ImportFrom('math', [alias('log10', lineno=2, col_offset=17, end_lineno=2, end_col_offset=22), alias('floor', lineno=2, col_offset=24, end_lineno=2, end_col_offset=29), alias('ceil', lineno=2, col_offset=31, end_lineno=2, end_col_offset=35)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=35), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=12, end_lineno=5, end_col_offset=22), arg('placeholder_2', lineno=5, col_offset=24, end_lineno=5, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('get_extreme_palindrome_with_factors', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=46), [Name('placeholder_2', Load(), lineno=6, col_offset=47, end_lineno=6, end_col_offset=57), Name('placeholder_1', Load(), lineno=6, col_offset=59, end_lineno=6, end_col_offset=69), Constant('largest', lineno=6, col_offset=71, end_lineno=6, end_col_offset=80)], [], lineno=6, col_offset=11, end_lineno=6, end_col_offset=81), lineno=6, col_offset=4, end_lineno=6, end_col_offset=81)], [], lineno=5, col_offset=0, end_lineno=6, end_col_offset=81), FunctionDef('placeholder_3', arguments([], [arg('placeholder_2', lineno=9, col_offset=13, end_lineno=9, end_col_offset=23), arg('placeholder_1', lineno=9, col_offset=25, end_lineno=9, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('get_extreme_palindrome_with_factors', Load(), lineno=10, col_offset=11, end_lineno=10, end_col_offset=46), [Name('placeholder_2', Load(), lineno=10, col_offset=47, end_lineno=10, end_col_offset=57), Name('placeholder_1', Load(), lineno=10, col_offset=59, end_lineno=10, end_col_offset=69), Constant('smallest', lineno=10, col_offset=71, end_lineno=10, end_col_offset=81)], [], lineno=10, col_offset=11, end_lineno=10, end_col_offset=82), lineno=10, col_offset=4, end_lineno=10, end_col_offset=82)], [], lineno=9, col_offset=0, end_lineno=10, end_col_offset=82), FunctionDef('placeholder_4', arguments([], [arg('placeholder_2', lineno=13, col_offset=40, end_lineno=13, end_col_offset=50), arg('placeholder_1', lineno=13, col_offset=52, end_lineno=13, end_col_offset=62), arg('placeholder_5', lineno=13, col_offset=64, end_lineno=13, end_col_offset=71)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=21)], Call(Name('palindromes', Load(), lineno=14, col_offset=24, end_lineno=14, end_col_offset=35), [Name('placeholder_2', Load(), lineno=14, col_offset=36, end_lineno=14, end_col_offset=46), Name('placeholder_1', Load(), lineno=14, col_offset=48, end_lineno=14, end_col_offset=58)], [keyword('placeholder_7', Compare(Name('placeholder_5', Load(), lineno=14, col_offset=69, end_lineno=14, end_col_offset=76), [Eq()], [Constant('largest', lineno=14, col_offset=80, end_lineno=14, end_col_offset=89)], lineno=14, col_offset=69, end_lineno=14, end_col_offset=89), lineno=14, col_offset=60, end_lineno=14, end_col_offset=90)], lineno=14, col_offset=24, end_lineno=14, end_col_offset=91), lineno=14, col_offset=4, end_lineno=14, end_col_offset=91), Assign([Name('placeholder_8', Store(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=16)], Constant(None, lineno=15, col_offset=19, end_lineno=15, end_col_offset=23), lineno=15, col_offset=4, end_lineno=15, end_col_offset=23), For(Name('placeholder_9', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=18), Name('placeholder_6', Load(), lineno=16, col_offset=22, end_lineno=16, end_col_offset=39), [Assign([Name('placeholder_8', Store(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=20)], GeneratorExp(Tuple([Name('placeholder_10', Load(), lineno=17, col_offset=25, end_lineno=17, end_col_offset=31), BinOp(Name('placeholder_9', Load(), lineno=17, col_offset=33, end_lineno=17, end_col_offset=43), FloorDiv(), Name('placeholder_10', Load(), lineno=17, col_offset=47, end_lineno=17, end_col_offset=53), lineno=17, col_offset=33, end_lineno=17, end_col_offset=53)], Load(), lineno=17, col_offset=24, end_lineno=17, end_col_offset=54), [comprehension(Name('placeholder_10', Store(), lineno=18, col_offset=28, end_lineno=18, end_col_offset=34), Call(Name('range', Load(), lineno=18, col_offset=38, end_lineno=18, end_col_offset=43), [Name('placeholder_1', Load(), lineno=18, col_offset=44, end_lineno=18, end_col_offset=54), BinOp(Name('placeholder_2', Load(), lineno=18, col_offset=56, end_lineno=18, end_col_offset=66), Add(), Constant(1, lineno=18, col_offset=69, end_lineno=18, end_col_offset=70), lineno=18, col_offset=56, end_lineno=18, end_col_offset=70)], [], lineno=18, col_offset=38, end_lineno=18, end_col_offset=71), [Compare(BinOp(Name('placeholder_9', Load(), lineno=19, col_offset=27, end_lineno=19, end_col_offset=37), Mod(), Name('placeholder_10', Load(), lineno=19, col_offset=40, end_lineno=19, end_col_offset=46), lineno=19, col_offset=27, end_lineno=19, end_col_offset=46), [Eq()], [Constant(0, lineno=19, col_offset=50, end_lineno=19, end_col_offset=51)], lineno=19, col_offset=27, end_lineno=19, end_col_offset=51)], 0)], lineno=17, col_offset=23, end_lineno=19, end_col_offset=52), lineno=17, col_offset=8, end_lineno=19, end_col_offset=52), Assign([Name('placeholder_8', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=20)], Call(Name('list', Load(), lineno=20, col_offset=23, end_lineno=20, end_col_offset=27), [GeneratorExp(Name('placeholder_11', Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=32), [comprehension(Name('placeholder_11', Store(), lineno=20, col_offset=37, end_lineno=20, end_col_offset=41), Name('placeholder_8', Load(), lineno=20, col_offset=45, end_lineno=20, end_col_offset=57), [Compare(Name('placeholder_1', Load(), lineno=21, col_offset=31, end_lineno=21, end_col_offset=41), [LtE(), LtE()], [Subscript(Name('placeholder_11', Load(), lineno=21, col_offset=45, end_lineno=21, end_col_offset=49), Constant(1, lineno=21, col_offset=50, end_lineno=21, end_col_offset=51), Load(), lineno=21, col_offset=45, end_lineno=21, end_col_offset=52), Name('placeholder_2', Load(), lineno=21, col_offset=56, end_lineno=21, end_col_offset=66)], lineno=21, col_offset=31, end_lineno=21, end_col_offset=66)], 0)], lineno=20, col_offset=27, end_lineno=21, end_col_offset=67)], [], lineno=20, col_offset=23, end_lineno=21, end_col_offset=67), lineno=20, col_offset=8, end_lineno=21, end_col_offset=67), If(Compare(Call(Name('len', Load(), lineno=22, col_offset=11, end_lineno=22, end_col_offset=14), [Name('placeholder_8', Load(), lineno=22, col_offset=15, end_lineno=22, end_col_offset=27)], [], lineno=22, col_offset=11, end_lineno=22, end_col_offset=28), [Gt()], [Constant(0, lineno=22, col_offset=31, end_lineno=22, end_col_offset=32)], lineno=22, col_offset=11, end_lineno=22, end_col_offset=32), [Break(lineno=23, col_offset=12, end_lineno=23, end_col_offset=17)], [], lineno=22, col_offset=8, end_lineno=23, end_col_offset=17)], [], lineno=16, col_offset=4, end_lineno=23, end_col_offset=17), If(UnaryOp(Not(), Name('placeholder_8', Load(), lineno=25, col_offset=11, end_lineno=25, end_col_offset=23), lineno=25, col_offset=7, end_lineno=25, end_col_offset=23), [Return(Tuple([Constant(None, lineno=26, col_offset=16, end_lineno=26, end_col_offset=20), List([], Load(), lineno=26, col_offset=22, end_lineno=26, end_col_offset=24)], Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=25), lineno=26, col_offset=8, end_lineno=26, end_col_offset=25)], [], lineno=25, col_offset=4, end_lineno=26, end_col_offset=25), Return(Tuple([Name('placeholder_9', Load(), lineno=28, col_offset=12, end_lineno=28, end_col_offset=22), Name('placeholder_8', Load(), lineno=28, col_offset=24, end_lineno=28, end_col_offset=36)], Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=37), lineno=28, col_offset=4, end_lineno=28, end_col_offset=37)], [], lineno=13, col_offset=0, end_lineno=28, end_col_offset=37), FunctionDef('placeholder_12', arguments([], [arg('placeholder_13', lineno=31, col_offset=16, end_lineno=31, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_14', Store(), lineno=32, col_offset=4, end_lineno=32, end_col_offset=17)], Constant(0, lineno=32, col_offset=20, end_lineno=32, end_col_offset=21), lineno=32, col_offset=4, end_lineno=32, end_col_offset=21), While(Compare(Name('placeholder_13', Load(), lineno=33, col_offset=10, end_lineno=33, end_col_offset=16), [Gt()], [Constant(0, lineno=33, col_offset=19, end_lineno=33, end_col_offset=20)], lineno=33, col_offset=10, end_lineno=33, end_col_offset=20), [AugAssign(Name('placeholder_14', Store(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=21), Mult(), Constant(10, lineno=34, col_offset=25, end_lineno=34, end_col_offset=27), lineno=34, col_offset=8, end_lineno=34, end_col_offset=27), AugAssign(Name('placeholder_14', Store(), lineno=35, col_offset=8, end_lineno=35, end_col_offset=21), Add(), BinOp(Name('placeholder_13', Load(), lineno=35, col_offset=26, end_lineno=35, end_col_offset=32), Mod(), Constant(10, lineno=35, col_offset=35, end_lineno=35, end_col_offset=37), lineno=35, col_offset=26, end_lineno=35, end_col_offset=37), lineno=35, col_offset=8, end_lineno=35, end_col_offset=38), AugAssign(Name('placeholder_13', Store(), lineno=36, col_offset=8, end_lineno=36, end_col_offset=14), FloorDiv(), Constant(10, lineno=36, col_offset=19, end_lineno=36, end_col_offset=21), lineno=36, col_offset=8, end_lineno=36, end_col_offset=21)], [], lineno=33, col_offset=4, end_lineno=36, end_col_offset=21), Return(Name('placeholder_14', Load(), lineno=37, col_offset=11, end_lineno=37, end_col_offset=24), lineno=37, col_offset=4, end_lineno=37, end_col_offset=24)], [], lineno=31, col_offset=0, end_lineno=37, end_col_offset=24), FunctionDef('placeholder_15', arguments([], [arg('placeholder_13', lineno=40, col_offset=15, end_lineno=40, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('int', Load(), lineno=41, col_offset=11, end_lineno=41, end_col_offset=14), [Call(Name('floor', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=20), [BinOp(Call(Name('log10', Load(), lineno=41, col_offset=21, end_lineno=41, end_col_offset=26), [Name('placeholder_13', Load(), lineno=41, col_offset=27, end_lineno=41, end_col_offset=33)], [], lineno=41, col_offset=21, end_lineno=41, end_col_offset=34), Add(), Constant(1, lineno=41, col_offset=37, end_lineno=41, end_col_offset=38), lineno=41, col_offset=21, end_lineno=41, end_col_offset=38)], [], lineno=41, col_offset=15, end_lineno=41, end_col_offset=39)], [], lineno=41, col_offset=11, end_lineno=41, end_col_offset=40), lineno=41, col_offset=4, end_lineno=41, end_col_offset=40)], [], lineno=40, col_offset=0, end_lineno=41, end_col_offset=40), FunctionDef('placeholder_16', arguments([], [arg('placeholder_2', lineno=44, col_offset=16, end_lineno=44, end_col_offset=26), arg('placeholder_1', lineno=44, col_offset=28, end_lineno=44, end_col_offset=38), arg('placeholder_7', lineno=44, col_offset=40, end_lineno=44, end_col_offset=47)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(False, lineno=44, col_offset=48, end_lineno=44, end_col_offset=53)]), [If(Compare(Name('placeholder_2', Load(), lineno=51, col_offset=7, end_lineno=51, end_col_offset=17), [Lt()], [Name('placeholder_1', Load(), lineno=51, col_offset=20, end_lineno=51, end_col_offset=30)], lineno=51, col_offset=7, end_lineno=51, end_col_offset=30), [Raise(Call(Name('ValueError', Load(), lineno=52, col_offset=14, end_lineno=52, end_col_offset=24), [Constant('min must be <= max', lineno=52, col_offset=25, end_lineno=52, end_col_offset=45)], [], lineno=52, col_offset=14, end_lineno=52, end_col_offset=46), lineno=52, col_offset=8, end_lineno=52, end_col_offset=46)], [], lineno=51, col_offset=4, end_lineno=52, end_col_offset=46), Assign([Name('placeholder_17', Store(), lineno=54, col_offset=4, end_lineno=54, end_col_offset=11)], BinOp(Name('placeholder_1', Load(), lineno=54, col_offset=14, end_lineno=54, end_col_offset=24), Pow(), Constant(2, lineno=54, col_offset=28, end_lineno=54, end_col_offset=29), lineno=54, col_offset=14, end_lineno=54, end_col_offset=29), lineno=54, col_offset=4, end_lineno=54, end_col_offset=29), Assign([Name('placeholder_18', Store(), lineno=55, col_offset=4, end_lineno=55, end_col_offset=11)], BinOp(Name('placeholder_2', Load(), lineno=55, col_offset=14, end_lineno=55, end_col_offset=24), Pow(), Constant(2, lineno=55, col_offset=28, end_lineno=55, end_col_offset=29), lineno=55, col_offset=14, end_lineno=55, end_col_offset=29), lineno=55, col_offset=4, end_lineno=55, end_col_offset=29), FunctionDef('placeholder_19', arguments([], [arg('placeholder_20', lineno=57, col_offset=34, end_lineno=57, end_col_offset=45), arg('placeholder_7', lineno=57, col_offset=47, end_lineno=57, end_col_offset=54)], kwonlyargs=[], kw_defaults=[], defaults=[Name('placeholder_7', Load(), lineno=57, col_offset=55, end_lineno=57, end_col_offset=62)]), [Assign([Name('placeholder_21', Store(), lineno=63, col_offset=8, end_lineno=63, end_col_offset=15)], Compare(BinOp(Name('placeholder_20', Load(), lineno=63, col_offset=19, end_lineno=63, end_col_offset=30), Mod(), Constant(2, lineno=63, col_offset=33, end_lineno=63, end_col_offset=34), lineno=63, col_offset=19, end_lineno=63, end_col_offset=34), [Eq()], [Constant(0, lineno=63, col_offset=38, end_lineno=63, end_col_offset=39)], lineno=63, col_offset=19, end_lineno=63, end_col_offset=39), lineno=63, col_offset=8, end_lineno=63, end_col_offset=40), Assign([Name('placeholder_22', Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=21)], Call(Name('max', Load(), lineno=65, col_offset=24, end_lineno=65, end_col_offset=27), [BinOp(Constant(10, lineno=65, col_offset=28, end_lineno=65, end_col_offset=30), Pow(), BinOp(Call(Name('int', Load(), lineno=65, col_offset=35, end_lineno=65, end_col_offset=38), [Call(Name('ceil', Load(), lineno=65, col_offset=39, end_lineno=65, end_col_offset=43), [BinOp(Name('placeholder_20', Load(), lineno=65, col_offset=44, end_lineno=65, end_col_offset=55), Div(), Constant(2, lineno=65, col_offset=58, end_lineno=65, end_col_offset=59), lineno=65, col_offset=44, end_lineno=65, end_col_offset=59)], [], lineno=65, col_offset=39, end_lineno=65, end_col_offset=60)], [], lineno=65, col_offset=35, end_lineno=65, end_col_offset=61), Sub(), Constant(1, lineno=65, col_offset=64, end_lineno=65, end_col_offset=65), lineno=65, col_offset=35, end_lineno=65, end_col_offset=65), lineno=65, col_offset=28, end_lineno=65, end_col_offset=66), BinOp(Name('placeholder_17', Load(), lineno=66, col_offset=28, end_lineno=66, end_col_offset=35), FloorDiv(), BinOp(Constant(10, lineno=66, col_offset=40, end_lineno=66, end_col_offset=42), Pow(), BinOp(Name('placeholder_20', Load(), lineno=66, col_offset=47, end_lineno=66, end_col_offset=58), FloorDiv(), Constant(2, lineno=66, col_offset=62, end_lineno=66, end_col_offset=63), lineno=66, col_offset=47, end_lineno=66, end_col_offset=63), lineno=66, col_offset=40, end_lineno=66, end_col_offset=64), lineno=66, col_offset=28, end_lineno=66, end_col_offset=65)], [], lineno=65, col_offset=24, end_lineno=66, end_col_offset=66), lineno=65, col_offset=8, end_lineno=66, end_col_offset=66), Assign([Name('placeholder_23', Store(), lineno=67, col_offset=8, end_lineno=67, end_col_offset=21)], Call(Name('min', Load(), lineno=67, col_offset=24, end_lineno=67, end_col_offset=27), [BinOp(BinOp(Constant(10, lineno=67, col_offset=29, end_lineno=67, end_col_offset=31), Pow(), Call(Name('int', Load(), lineno=67, col_offset=35, end_lineno=67, end_col_offset=38), [Call(Name('ceil', Load(), lineno=67, col_offset=39, end_lineno=67, end_col_offset=43), [BinOp(Name('placeholder_20', Load(), lineno=67, col_offset=44, end_lineno=67, end_col_offset=55), Div(), Constant(2, lineno=67, col_offset=58, end_lineno=67, end_col_offset=59), lineno=67, col_offset=44, end_lineno=67, end_col_offset=59)], [], lineno=67, col_offset=39, end_lineno=67, end_col_offset=60)], [], lineno=67, col_offset=35, end_lineno=67, end_col_offset=61), lineno=67, col_offset=29, end_lineno=67, end_col_offset=61), Sub(), Constant(1, lineno=67, col_offset=65, end_lineno=67, end_col_offset=66), lineno=67, col_offset=28, end_lineno=67, end_col_offset=66), BinOp(Name('placeholder_18', Load(), lineno=68, col_offset=28, end_lineno=68, end_col_offset=35), FloorDiv(), BinOp(Constant(10, lineno=68, col_offset=40, end_lineno=68, end_col_offset=42), Pow(), BinOp(Name('placeholder_20', Load(), lineno=68, col_offset=47, end_lineno=68, end_col_offset=58), FloorDiv(), Constant(2, lineno=68, col_offset=62, end_lineno=68, end_col_offset=63), lineno=68, col_offset=47, end_lineno=68, end_col_offset=63), lineno=68, col_offset=40, end_lineno=68, end_col_offset=64), lineno=68, col_offset=28, end_lineno=68, end_col_offset=65)], [], lineno=67, col_offset=24, end_lineno=68, end_col_offset=66), lineno=67, col_offset=8, end_lineno=68, end_col_offset=66), Assign([Name('placeholder_24', Store(), lineno=70, col_offset=8, end_lineno=70, end_col_offset=25)], IfExp(UnaryOp(Not(), Name('placeholder_7', Load(), lineno=70, col_offset=49, end_lineno=70, end_col_offset=56), lineno=70, col_offset=45, end_lineno=70, end_col_offset=56), Name('placeholder_22', Load(), lineno=70, col_offset=28, end_lineno=70, end_col_offset=41), Name('placeholder_23', Load(), lineno=70, col_offset=62, end_lineno=70, end_col_offset=75), lineno=70, col_offset=28, end_lineno=70, end_col_offset=75), lineno=70, col_offset=8, end_lineno=70, end_col_offset=75), FunctionDef('placeholder_25', arguments([], [arg('placeholder_26', lineno=72, col_offset=28, end_lineno=72, end_col_offset=37), arg('placeholder_21', lineno=72, col_offset=39, end_lineno=72, end_col_offset=46)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(False, lineno=72, col_offset=47, end_lineno=72, end_col_offset=52)]), [Assign([Name('placeholder_27', Store(), lineno=73, col_offset=12, end_lineno=73, end_col_offset=22)], IfExp(Name('placeholder_21', Load(), lineno=74, col_offset=29, end_lineno=74, end_col_offset=36), Call(Name('placeholder_12', Load(), lineno=73, col_offset=26, end_lineno=73, end_col_offset=37), [Name('placeholder_26', Load(), lineno=73, col_offset=38, end_lineno=73, end_col_offset=47)], [], lineno=73, col_offset=26, end_lineno=73, end_col_offset=48), Call(Name('placeholder_12', Load(), lineno=75, col_offset=31, end_lineno=75, end_col_offset=42), [BinOp(Name('placeholder_26', Load(), lineno=75, col_offset=43, end_lineno=75, end_col_offset=52), FloorDiv(), Constant(10, lineno=75, col_offset=56, end_lineno=75, end_col_offset=58), lineno=75, col_offset=43, end_lineno=75, end_col_offset=58)], [], lineno=75, col_offset=31, end_lineno=75, end_col_offset=59), lineno=73, col_offset=26, end_lineno=75, end_col_offset=59), lineno=73, col_offset=12, end_lineno=75, end_col_offset=60), Return(BinOp(BinOp(Name('placeholder_26', Load(), lineno=76, col_offset=20, end_lineno=76, end_col_offset=29), Mult(), BinOp(Constant(10, lineno=76, col_offset=33, end_lineno=76, end_col_offset=35), Pow(), BinOp(Name('placeholder_20', Load(), lineno=76, col_offset=40, end_lineno=76, end_col_offset=51), FloorDiv(), Constant(2, lineno=76, col_offset=55, end_lineno=76, end_col_offset=56), lineno=76, col_offset=40, end_lineno=76, end_col_offset=56), lineno=76, col_offset=33, end_lineno=76, end_col_offset=57), lineno=76, col_offset=20, end_lineno=76, end_col_offset=58), Add(), Name('placeholder_27', Load(), lineno=76, col_offset=62, end_lineno=76, end_col_offset=72), lineno=76, col_offset=19, end_lineno=76, end_col_offset=72), lineno=76, col_offset=12, end_lineno=76, end_col_offset=72)], [], lineno=72, col_offset=8, end_lineno=76, end_col_offset=72), If(UnaryOp(Not(), Name('placeholder_7', Load(), lineno=78, col_offset=15, end_lineno=78, end_col_offset=22), lineno=78, col_offset=11, end_lineno=78, end_col_offset=22), [While(Compare(Name('placeholder_24', Load(), lineno=79, col_offset=18, end_lineno=79, end_col_offset=35), [LtE()], [Name('placeholder_23', Load(), lineno=79, col_offset=39, end_lineno=79, end_col_offset=52)], lineno=79, col_offset=18, end_lineno=79, end_col_offset=52), [Assign([Name('placeholder_9', Store(), lineno=80, col_offset=16, end_lineno=80, end_col_offset=26)], Call(Name('placeholder_25', Load(), lineno=80, col_offset=29, end_lineno=80, end_col_offset=44), [Name('placeholder_24', Load(), lineno=80, col_offset=45, end_lineno=80, end_col_offset=62), Name('placeholder_21', Load(), lineno=80, col_offset=64, end_lineno=80, end_col_offset=71)], [], lineno=80, col_offset=29, end_lineno=80, end_col_offset=72), lineno=80, col_offset=16, end_lineno=80, end_col_offset=72), If(Compare(Name('placeholder_17', Load(), lineno=81, col_offset=19, end_lineno=81, end_col_offset=26), [LtE(), LtE()], [Name('placeholder_9', Load(), lineno=81, col_offset=30, end_lineno=81, end_col_offset=40), Name('placeholder_18', Load(), lineno=81, col_offset=44, end_lineno=81, end_col_offset=51)], lineno=81, col_offset=19, end_lineno=81, end_col_offset=51), [Expr(Yield(Name('palindrome', Load(), lineno=82, col_offset=26, end_lineno=82, end_col_offset=36), lineno=82, col_offset=20, end_lineno=82, end_col_offset=36), lineno=82, col_offset=20, end_lineno=82, end_col_offset=36)], [If(Compare(Name('placeholder_9', Load(), lineno=83, col_offset=21, end_lineno=83, end_col_offset=31), [Gt()], [Name('placeholder_18', Load(), lineno=83, col_offset=34, end_lineno=83, end_col_offset=41)], lineno=83, col_offset=21, end_lineno=83, end_col_offset=41), [Break(lineno=87, col_offset=20, end_lineno=87, end_col_offset=25)], [], lineno=83, col_offset=16, end_lineno=87, end_col_offset=25)], lineno=81, col_offset=16, end_lineno=87, end_col_offset=25), AugAssign(Name('placeholder_24', Store(), lineno=88, col_offset=16, end_lineno=88, end_col_offset=33), Add(), Constant(1, lineno=88, col_offset=37, end_lineno=88, end_col_offset=38), lineno=88, col_offset=16, end_lineno=88, end_col_offset=38)], [], lineno=79, col_offset=12, end_lineno=88, end_col_offset=38)], [While(Compare(Name('placeholder_24', Load(), lineno=90, col_offset=18, end_lineno=90, end_col_offset=35), [GtE()], [Name('placeholder_22', Load(), lineno=90, col_offset=39, end_lineno=90, end_col_offset=52)], lineno=90, col_offset=18, end_lineno=90, end_col_offset=52), [Assign([Name('placeholder_9', Store(), lineno=91, col_offset=16, end_lineno=91, end_col_offset=26)], Call(Name('placeholder_25', Load(), lineno=91, col_offset=29, end_lineno=91, end_col_offset=44), [Name('placeholder_24', Load(), lineno=91, col_offset=45, end_lineno=91, end_col_offset=62), Name('placeholder_21', Load(), lineno=91, col_offset=64, end_lineno=91, end_col_offset=71)], [], lineno=91, col_offset=29, end_lineno=91, end_col_offset=72), lineno=91, col_offset=16, end_lineno=91, end_col_offset=72), If(Compare(Name('placeholder_17', Load(), lineno=92, col_offset=19, end_lineno=92, end_col_offset=26), [LtE(), LtE()], [Name('placeholder_9', Load(), lineno=92, col_offset=30, end_lineno=92, end_col_offset=40), Name('placeholder_18', Load(), lineno=92, col_offset=44, end_lineno=92, end_col_offset=51)], lineno=92, col_offset=19, end_lineno=92, end_col_offset=51), [Expr(Yield(Name('palindrome', Load(), lineno=93, col_offset=26, end_lineno=93, end_col_offset=36), lineno=93, col_offset=20, end_lineno=93, end_col_offset=36), lineno=93, col_offset=20, end_lineno=93, end_col_offset=36)], [If(Compare(Name('placeholder_9', Load(), lineno=94, col_offset=21, end_lineno=94, end_col_offset=31), [Lt()], [Name('placeholder_17', Load(), lineno=94, col_offset=34, end_lineno=94, end_col_offset=41)], lineno=94, col_offset=21, end_lineno=94, end_col_offset=41), [Break(lineno=98, col_offset=20, end_lineno=98, end_col_offset=25)], [], lineno=94, col_offset=16, end_lineno=98, end_col_offset=25)], lineno=92, col_offset=16, end_lineno=98, end_col_offset=25), AugAssign(Name('placeholder_24', Store(), lineno=99, col_offset=16, end_lineno=99, end_col_offset=33), Sub(), Constant(1, lineno=99, col_offset=37, end_lineno=99, end_col_offset=38), lineno=99, col_offset=16, end_lineno=99, end_col_offset=38)], [], lineno=90, col_offset=12, end_lineno=99, end_col_offset=38)], lineno=78, col_offset=8, end_lineno=99, end_col_offset=38)], [], lineno=57, col_offset=4, end_lineno=99, end_col_offset=38), Assign([Name('placeholder_28', Store(), lineno=101, col_offset=4, end_lineno=101, end_col_offset=10)], Call(Name('placeholder_15', Load(), lineno=101, col_offset=13, end_lineno=101, end_col_offset=23), [Name('placeholder_17', Load(), lineno=101, col_offset=24, end_lineno=101, end_col_offset=31)], [], lineno=101, col_offset=13, end_lineno=101, end_col_offset=32), lineno=101, col_offset=4, end_lineno=101, end_col_offset=32), Assign([Name('placeholder_29', Store(), lineno=102, col_offset=4, end_lineno=102, end_col_offset=10)], Call(Name('placeholder_15', Load(), lineno=102, col_offset=13, end_lineno=102, end_col_offset=23), [Name('placeholder_18', Load(), lineno=102, col_offset=24, end_lineno=102, end_col_offset=31)], [], lineno=102, col_offset=13, end_lineno=102, end_col_offset=32), lineno=102, col_offset=4, end_lineno=102, end_col_offset=32), Assign([Name('placeholder_30', Store(), lineno=104, col_offset=4, end_lineno=104, end_col_offset=11)], IfExp(UnaryOp(Not(), Name('placeholder_7', Load(), lineno=105, col_offset=22, end_lineno=105, end_col_offset=29), lineno=105, col_offset=18, end_lineno=105, end_col_offset=29), Call(Name('range', Load(), lineno=104, col_offset=15, end_lineno=104, end_col_offset=20), [Name('placeholder_28', Load(), lineno=104, col_offset=21, end_lineno=104, end_col_offset=27), BinOp(Name('placeholder_29', Load(), lineno=104, col_offset=29, end_lineno=104, end_col_offset=35), Add(), Constant(1, lineno=104, col_offset=38, end_lineno=104, end_col_offset=39), lineno=104, col_offset=29, end_lineno=104, end_col_offset=39)], [], lineno=104, col_offset=15, end_lineno=104, end_col_offset=40), Call(Name('range', Load(), lineno=106, col_offset=20, end_lineno=106, end_col_offset=25), [Name('placeholder_29', Load(), lineno=106, col_offset=26, end_lineno=106, end_col_offset=32), BinOp(Name('placeholder_28', Load(), lineno=106, col_offset=34, end_lineno=106, end_col_offset=40), Sub(), Constant(1, lineno=106, col_offset=43, end_lineno=106, end_col_offset=44), lineno=106, col_offset=34, end_lineno=106, end_col_offset=44), UnaryOp(USub(), Constant(1, lineno=106, col_offset=47, end_lineno=106, end_col_offset=48), lineno=106, col_offset=46, end_lineno=106, end_col_offset=48)], [], lineno=106, col_offset=20, end_lineno=106, end_col_offset=49), lineno=104, col_offset=15, end_lineno=106, end_col_offset=49), lineno=104, col_offset=4, end_lineno=106, end_col_offset=50), Return(Call(Name('chain', Load(), lineno=108, col_offset=11, end_lineno=108, end_col_offset=16), [Starred(Call(Name('map', Load(), lineno=108, col_offset=18, end_lineno=108, end_col_offset=21), [Name('placeholder_19', Load(), lineno=108, col_offset=22, end_lineno=108, end_col_offset=47), Name('placeholder_30', Load(), lineno=108, col_offset=49, end_lineno=108, end_col_offset=56)], [], lineno=108, col_offset=18, end_lineno=108, end_col_offset=57), Load(), lineno=108, col_offset=17, end_lineno=108, end_col_offset=57)], [], lineno=108, col_offset=11, end_lineno=108, end_col_offset=58), lineno=108, col_offset=4, end_lineno=108, end_col_offset=58)], [], lineno=44, col_offset=0, end_lineno=108, end_col_offset=58)], []) \ No newline at end of file diff --git a/test/practice-pangram/.meta/additional_tests.json b/test/practice-pangram/.meta/additional_tests.json new file mode 100644 index 0000000..db7c781 --- /dev/null +++ b/test/practice-pangram/.meta/additional_tests.json @@ -0,0 +1,20 @@ +{ + "cases": [ + { + "description": "sentence without lower bound", + "property": "isPangram", + "input": { + "sentence": "bcdefghijklmnopqrstuvwxyz" + }, + "expected": false + }, + { + "description": "sentence without upper bound", + "property": "isPangram", + "input": { + "sentence": "abcdefghijklmnopqrstuvwxy" + }, + "expected": false + } + ] +} diff --git a/test/practice-pangram/.meta/config.json b/test/practice-pangram/.meta/config.json new file mode 100644 index 0000000..3d57bb9 --- /dev/null +++ b/test/practice-pangram/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "cmccandless", + "Dog", + "Grociu", + "helenst", + "ikhadykin", + "luoken", + "mtroiani", + "N-Parsons", + "olufotebig", + "patricksjackson", + "pheanex", + "thomasjpfan", + "tqa236" + ], + "files": { + "solution": [ + "pangram.py" + ], + "test": [ + "pangram_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Determine if a sentence is a pangram.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Pangram" +} diff --git a/test/practice-pangram/mapping.json b/test/practice-pangram/mapping.json new file mode 100644 index 0000000..2a43926 --- /dev/null +++ b/test/practice-pangram/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "is_pangram", + "placeholder_1": "sentence", + "placeholder_2": "char" +} \ No newline at end of file diff --git a/test/practice-pangram/pangram.py b/test/practice-pangram/pangram.py new file mode 100644 index 0000000..7cc810f --- /dev/null +++ b/test/practice-pangram/pangram.py @@ -0,0 +1,5 @@ +from string import ascii_lowercase + + +def is_pangram(sentence): + return all(char in sentence.lower() for char in ascii_lowercase) diff --git a/test/practice-pangram/representation.json b/test/practice-pangram/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-pangram/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-pangram/representation.out b/test/practice-pangram/representation.out new file mode 100644 index 0000000..e85c952 --- /dev/null +++ b/test/practice-pangram/representation.out @@ -0,0 +1,246 @@ +## BEGIN NORMALIZED CODE ## +from string import ascii_lowercase + + +def placeholder_0(placeholder_1): + return all( + (placeholder_2 in placeholder_1.lower() for placeholder_2 in ascii_lowercase) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'string', + [ + alias( + 'ascii_lowercase', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + FunctionDef( + 'is_pangram', + arguments( + [], + [ + arg( + 'sentence', + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'all', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + GeneratorExp( + Compare( + Name( + 'char', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=19), + [ + In()], + [ + Call( + Attribute( + Name( + 'sentence', + Load(), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=31), + 'lower', + Load(), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=37), + [], + [], + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=39)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=39), + [ + comprehension( + Name( + 'char', + Store(), + lineno=5, + col_offset=44, + end_lineno=5, + end_col_offset=48), + Name( + 'ascii_lowercase', + Load(), + lineno=5, + col_offset=52, + end_lineno=5, + end_col_offset=67), + [], + 0)], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=68)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=68), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=68)], + [], + lineno=4, + col_offset=0, + end_lineno=5, + end_col_offset=68)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'string', + [ + alias( + 'ascii_lowercase', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'all', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + GeneratorExp( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=19), + [ + In()], + [ + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=31), + 'lower', + Load(), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=37), + [], + [], + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=39)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=39), + [ + comprehension( + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=44, + end_lineno=5, + end_col_offset=48), + Name( + 'ascii_lowercase', + Load(), + lineno=5, + col_offset=52, + end_lineno=5, + end_col_offset=67), + [], + 0)], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=68)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=68), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=68)], + [], + lineno=4, + col_offset=0, + end_lineno=5, + end_col_offset=68)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-pangram/representation.txt b/test/practice-pangram/representation.txt new file mode 100644 index 0000000..4cc194b --- /dev/null +++ b/test/practice-pangram/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('string', [alias('ascii_lowercase', lineno=1, col_offset=19, end_lineno=1, end_col_offset=34)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=34), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=15, end_lineno=4, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('all', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=14), [GeneratorExp(Compare(Name('placeholder_2', Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=19), [In()], [Call(Attribute(Name('placeholder_1', Load(), lineno=5, col_offset=23, end_lineno=5, end_col_offset=31), 'lower', Load(), lineno=5, col_offset=23, end_lineno=5, end_col_offset=37), [], [], lineno=5, col_offset=23, end_lineno=5, end_col_offset=39)], lineno=5, col_offset=15, end_lineno=5, end_col_offset=39), [comprehension(Name('placeholder_2', Store(), lineno=5, col_offset=44, end_lineno=5, end_col_offset=48), Name('ascii_lowercase', Load(), lineno=5, col_offset=52, end_lineno=5, end_col_offset=67), [], 0)], lineno=5, col_offset=14, end_lineno=5, end_col_offset=68)], [], lineno=5, col_offset=11, end_lineno=5, end_col_offset=68), lineno=5, col_offset=4, end_lineno=5, end_col_offset=68)], [], lineno=4, col_offset=0, end_lineno=5, end_col_offset=68)], []) \ No newline at end of file diff --git a/test/practice-parallel-letter-frequency/.meta/config.json b/test/practice-parallel-letter-frequency/.meta/config.json new file mode 100644 index 0000000..3945e3f --- /dev/null +++ b/test/practice-parallel-letter-frequency/.meta/config.json @@ -0,0 +1,25 @@ +{ + "blurb": "Count the frequency of letters in texts using parallel computation.", + "authors": [ + "forgeRW" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "kytrinyx", + "N-Parsons", + "tqa236" + ], + "files": { + "solution": [ + "parallel_letter_frequency.py" + ], + "test": [ + "parallel_letter_frequency_test.py" + ], + "example": [ + ".meta/example.py" + ] + } +} diff --git a/test/practice-parallel-letter-frequency/mapping.json b/test/practice-parallel-letter-frequency/mapping.json new file mode 100644 index 0000000..8709a90 --- /dev/null +++ b/test/practice-parallel-letter-frequency/mapping.json @@ -0,0 +1,25 @@ +{ + "placeholder_0": "TOTAL_WORKERS", + "placeholder_1": "LetterCounter", + "placeholder_2": "__init__", + "placeholder_3": "lock", + "placeholder_4": "value", + "placeholder_5": "add_counter", + "placeholder_6": "counter_to_add", + "placeholder_7": "count_letters", + "placeholder_8": "queue_of_texts", + "placeholder_9": "letter_to_frequency", + "placeholder_10": "worker_id", + "placeholder_11": "line_input", + "placeholder_12": "letters_in_line", + "placeholder_13": "idx", + "placeholder_14": "calculate", + "placeholder_15": "list_of_texts", + "placeholder_16": "line", + "placeholder_17": "threads", + "placeholder_18": "worker", + "placeholder_19": "target", + "placeholder_20": "args", + "placeholder_21": "_", + "placeholder_22": "thread" +} \ No newline at end of file diff --git a/test/practice-parallel-letter-frequency/parallel_letter_frequency.py b/test/practice-parallel-letter-frequency/parallel_letter_frequency.py new file mode 100644 index 0000000..5a16fb3 --- /dev/null +++ b/test/practice-parallel-letter-frequency/parallel_letter_frequency.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +from collections import Counter +from threading import Lock, Thread +from time import sleep +from queue import Queue + + +TOTAL_WORKERS = 3 # Maximum number of threads chosen arbitrarily + +class LetterCounter: + + def __init__(self): + self.lock = Lock() + self.value = Counter() + + def add_counter(self, counter_to_add): + self.lock.acquire() + try: + self.value = self.value + counter_to_add + finally: + self.lock.release() + + +def count_letters(queue_of_texts, letter_to_frequency, worker_id): + while not queue_of_texts.empty(): + sleep(worker_id + 1) + line_input = queue_of_texts.get() + if line_input is not None: + letters_in_line = Counter(idx for idx in line_input.lower() if idx.isalpha()) + letter_to_frequency.add_counter(letters_in_line) + queue_of_texts.task_done() + if line_input is None: + break + + +def calculate(list_of_texts): + queue_of_texts = Queue() + for line in list_of_texts: + queue_of_texts.put(line) + letter_to_frequency = LetterCounter() + threads = [] + for idx in range(TOTAL_WORKERS): + worker = Thread(target=count_letters, args=(queue_of_texts, letter_to_frequency, idx)) + worker.start() + threads.append(worker) + queue_of_texts.join() + for _ in range(TOTAL_WORKERS): + queue_of_texts.put(None) + for thread in threads: + thread.join() + return letter_to_frequency.value diff --git a/test/practice-parallel-letter-frequency/representation.json b/test/practice-parallel-letter-frequency/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-parallel-letter-frequency/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-parallel-letter-frequency/representation.out b/test/practice-parallel-letter-frequency/representation.out new file mode 100644 index 0000000..2f6df45 --- /dev/null +++ b/test/practice-parallel-letter-frequency/representation.out @@ -0,0 +1,2377 @@ +## BEGIN NORMALIZED CODE ## +from collections import Counter +from threading import Lock, Thread +from time import sleep +from queue import Queue + +placeholder_0 = 3 + + +class placeholder_1: + def placeholder_2(self): + self.placeholder_3 = Lock() + self.placeholder_4 = Counter() + + def placeholder_5(self, placeholder_6): + self.placeholder_3.acquire() + try: + self.placeholder_4 = self.placeholder_4 + placeholder_6 + finally: + self.placeholder_3.release() + + +def placeholder_7(placeholder_8, placeholder_9, placeholder_10): + while not placeholder_8.empty(): + sleep(placeholder_10 + 1) + placeholder_11 = placeholder_8.get() + if placeholder_11 is not None: + placeholder_12 = Counter( + ( + placeholder_13 + for placeholder_13 in placeholder_11.lower() + if placeholder_13.isalpha() + ) + ) + placeholder_9.placeholder_5(placeholder_12) + placeholder_8.task_done() + if placeholder_11 is None: + break + + +def placeholder_14(placeholder_15): + placeholder_8 = Queue() + for placeholder_16 in placeholder_15: + placeholder_8.put(placeholder_16) + placeholder_9 = placeholder_1() + placeholder_17 = [] + for placeholder_13 in range(placeholder_0): + placeholder_18 = Thread( + placeholder_19=placeholder_7, + placeholder_20=(placeholder_8, placeholder_9, placeholder_13), + ) + placeholder_18.start() + placeholder_17.append(placeholder_18) + placeholder_8.join() + for placeholder_21 in range(placeholder_0): + placeholder_8.put(None) + for placeholder_22 in placeholder_17: + placeholder_22.join() + return placeholder_9.placeholder_4 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'Counter', + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=31)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=31), + ImportFrom( + 'threading', + [ + alias( + 'Lock', + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=26), + alias( + 'Thread', + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=34)], + 0, + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=34), + ImportFrom( + 'time', + [ + alias( + 'sleep', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=22)], + 0, + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=22), + ImportFrom( + 'queue', + [ + alias( + 'Queue', + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=23)], + 0, + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=23), + Assign( + [ + Name( + 'TOTAL_WORKERS', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=13)], + Constant( + 3, + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=17), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=17), + ClassDef( + 'LetterCounter', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'lock', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=17)], + Call( + Name( + 'Lock', + Load(), + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=24), + [], + [], + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=26), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=12), + 'value', + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=18)], + Call( + Name( + 'Counter', + Load(), + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=28), + [], + [], + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=30), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=30)], + [], + lineno=12, + col_offset=4, + end_lineno=14, + end_col_offset=30), + FunctionDef( + 'add_counter', + arguments( + [], + [ + arg( + 'self', + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=24), + arg( + 'counter_to_add', + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=12), + 'lock', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=17), + 'acquire', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=25), + [], + [], + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=27), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=27), + Try( + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=16), + 'value', + Store(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=29), + 'value', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=35), + Add(), + Name( + 'counter_to_add', + Load(), + lineno=19, + col_offset=38, + end_lineno=19, + end_col_offset=52), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=52), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=52)], + [], + [], + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=16), + 'lock', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=21), + 'release', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=29), + [], + [], + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=31), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=31)], + lineno=18, + col_offset=8, + end_lineno=21, + end_col_offset=31)], + [], + lineno=16, + col_offset=4, + end_lineno=21, + end_col_offset=31)], + [], + lineno=10, + col_offset=0, + end_lineno=21, + end_col_offset=31), + FunctionDef( + 'count_letters', + arguments( + [], + [ + arg( + 'queue_of_texts', + lineno=24, + col_offset=18, + end_lineno=24, + end_col_offset=32), + arg( + 'letter_to_frequency', + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=53), + arg( + 'worker_id', + lineno=24, + col_offset=55, + end_lineno=24, + end_col_offset=64)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + While( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'queue_of_texts', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=28), + 'empty', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=34), + [], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=36), + lineno=25, + col_offset=10, + end_lineno=25, + end_col_offset=36), + [ + Expr( + Call( + Name( + 'sleep', + Load(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=13), + [ + BinOp( + Name( + 'worker_id', + Load(), + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=27), + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=27)], + [], + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=28), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=28), + Assign( + [ + Name( + 'line_input', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=18)], + Call( + Attribute( + Name( + 'queue_of_texts', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=35), + 'get', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=39), + [], + [], + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=41), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=41), + If( + Compare( + Name( + 'line_input', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=21), + [ + IsNot()], + [ + Constant( + None, + lineno=28, + col_offset=29, + end_lineno=28, + end_col_offset=33)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=33), + [ + Assign( + [ + Name( + 'letters_in_line', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=27)], + Call( + Name( + 'Counter', + Load(), + lineno=29, + col_offset=30, + end_lineno=29, + end_col_offset=37), + [ + GeneratorExp( + Name( + 'idx', + Load(), + lineno=29, + col_offset=38, + end_lineno=29, + end_col_offset=41), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=29, + col_offset=46, + end_lineno=29, + end_col_offset=49), + Call( + Attribute( + Name( + 'line_input', + Load(), + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=63), + 'lower', + Load(), + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=69), + [], + [], + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=71), + [ + Call( + Attribute( + Name( + 'idx', + Load(), + lineno=29, + col_offset=75, + end_lineno=29, + end_col_offset=78), + 'isalpha', + Load(), + lineno=29, + col_offset=75, + end_lineno=29, + end_col_offset=86), + [], + [], + lineno=29, + col_offset=75, + end_lineno=29, + end_col_offset=88)], + 0)], + lineno=29, + col_offset=37, + end_lineno=29, + end_col_offset=89)], + [], + lineno=29, + col_offset=30, + end_lineno=29, + end_col_offset=89), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=89), + Expr( + Call( + Attribute( + Name( + 'letter_to_frequency', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=31), + 'add_counter', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=43), + [ + Name( + 'letters_in_line', + Load(), + lineno=30, + col_offset=44, + end_lineno=30, + end_col_offset=59)], + [], + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=60), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=60)], + [], + lineno=28, + col_offset=8, + end_lineno=30, + end_col_offset=60), + Expr( + Call( + Attribute( + Name( + 'queue_of_texts', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=22), + 'task_done', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=32), + [], + [], + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=34), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=34), + If( + Compare( + Name( + 'line_input', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=21), + [ + Is()], + [ + Constant( + None, + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=29)], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=29), + [ + Break( + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=17)], + [], + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=17)], + [], + lineno=25, + col_offset=4, + end_lineno=33, + end_col_offset=17)], + [], + lineno=24, + col_offset=0, + end_lineno=33, + end_col_offset=17), + FunctionDef( + 'calculate', + arguments( + [], + [ + arg( + 'list_of_texts', + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'queue_of_texts', + Store(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=18)], + Call( + Name( + 'Queue', + Load(), + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=26), + [], + [], + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=28), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=28), + For( + Name( + 'line', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=12), + Name( + 'list_of_texts', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'queue_of_texts', + Load(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=22), + 'put', + Load(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=26), + [ + Name( + 'line', + Load(), + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=31)], + [], + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=32), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=32)], + [], + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=32), + Assign( + [ + Name( + 'letter_to_frequency', + Store(), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=23)], + Call( + Name( + 'LetterCounter', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=39), + [], + [], + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=41), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=41), + Assign( + [ + Name( + 'threads', + Store(), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=11)], + List( + [], + Load(), + lineno=41, + col_offset=14, + end_lineno=41, + end_col_offset=16), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=16), + For( + Name( + 'idx', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=20), + [ + Name( + 'TOTAL_WORKERS', + Load(), + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=34)], + [], + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=35), + [ + Assign( + [ + Name( + 'worker', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=14)], + Call( + Name( + 'Thread', + Load(), + lineno=43, + col_offset=17, + end_lineno=43, + end_col_offset=23), + [], + [ + keyword( + 'target', + Name( + 'count_letters', + Load(), + lineno=43, + col_offset=31, + end_lineno=43, + end_col_offset=44), + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=44), + keyword( + 'args', + Tuple( + [ + Name( + 'queue_of_texts', + Load(), + lineno=43, + col_offset=52, + end_lineno=43, + end_col_offset=66), + Name( + 'letter_to_frequency', + Load(), + lineno=43, + col_offset=68, + end_lineno=43, + end_col_offset=87), + Name( + 'idx', + Load(), + lineno=43, + col_offset=89, + end_lineno=43, + end_col_offset=92)], + Load(), + lineno=43, + col_offset=51, + end_lineno=43, + end_col_offset=93), + lineno=43, + col_offset=46, + end_lineno=43, + end_col_offset=93)], + lineno=43, + col_offset=17, + end_lineno=43, + end_col_offset=94), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=94), + Expr( + Call( + Attribute( + Name( + 'worker', + Load(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=14), + 'start', + Load(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=20), + [], + [], + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=22), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=22), + Expr( + Call( + Attribute( + Name( + 'threads', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=15), + 'append', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=22), + [ + Name( + 'worker', + Load(), + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=29)], + [], + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=30), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=30)], + [], + lineno=42, + col_offset=4, + end_lineno=45, + end_col_offset=30), + Expr( + Call( + Attribute( + Name( + 'queue_of_texts', + Load(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=18), + 'join', + Load(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=23), + [], + [], + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=25), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=25), + For( + Name( + '_', + Store(), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=9), + Call( + Name( + 'range', + Load(), + lineno=47, + col_offset=13, + end_lineno=47, + end_col_offset=18), + [ + Name( + 'TOTAL_WORKERS', + Load(), + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=32)], + [], + lineno=47, + col_offset=13, + end_lineno=47, + end_col_offset=33), + [ + Expr( + Call( + Attribute( + Name( + 'queue_of_texts', + Load(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=22), + 'put', + Load(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=26), + [ + Constant( + None, + lineno=48, + col_offset=27, + end_lineno=48, + end_col_offset=31)], + [], + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=32), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=32)], + [], + lineno=47, + col_offset=4, + end_lineno=48, + end_col_offset=32), + For( + Name( + 'thread', + Store(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=14), + Name( + 'threads', + Load(), + lineno=49, + col_offset=18, + end_lineno=49, + end_col_offset=25), + [ + Expr( + Call( + Attribute( + Name( + 'thread', + Load(), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=14), + 'join', + Load(), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=19), + [], + [], + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=21), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=21)], + [], + lineno=49, + col_offset=4, + end_lineno=50, + end_col_offset=21), + Return( + Attribute( + Name( + 'letter_to_frequency', + Load(), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=30), + 'value', + Load(), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=36), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=36)], + [], + lineno=36, + col_offset=0, + end_lineno=51, + end_col_offset=36)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'Counter', + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=31)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=31), + ImportFrom( + 'threading', + [ + alias( + 'Lock', + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=26), + alias( + 'Thread', + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=34)], + 0, + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=34), + ImportFrom( + 'time', + [ + alias( + 'sleep', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=22)], + 0, + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=22), + ImportFrom( + 'queue', + [ + alias( + 'Queue', + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=23)], + 0, + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=23), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=13)], + Constant( + 3, + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=17), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=17), + ClassDef( + 'placeholder_1', + [], + [], + [ + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=17)], + Call( + Name( + 'Lock', + Load(), + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=24), + [], + [], + lineno=13, + col_offset=20, + end_lineno=13, + end_col_offset=26), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=18)], + Call( + Name( + 'Counter', + Load(), + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=28), + [], + [], + lineno=14, + col_offset=21, + end_lineno=14, + end_col_offset=30), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=30)], + [], + lineno=12, + col_offset=4, + end_lineno=14, + end_col_offset=30), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=24), + arg( + 'placeholder_6', + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=12), + 'placeholder_3', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=17), + 'acquire', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=25), + [], + [], + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=27), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=27), + Try( + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=16), + 'placeholder_4', + Store(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=22)], + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=29), + 'placeholder_4', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=35), + Add(), + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=38, + end_lineno=19, + end_col_offset=52), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=52), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=52)], + [], + [], + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=16), + 'placeholder_3', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=21), + 'release', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=29), + [], + [], + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=31), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=31)], + lineno=18, + col_offset=8, + end_lineno=21, + end_col_offset=31)], + [], + lineno=16, + col_offset=4, + end_lineno=21, + end_col_offset=31)], + [], + lineno=10, + col_offset=0, + end_lineno=21, + end_col_offset=31), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=24, + col_offset=18, + end_lineno=24, + end_col_offset=32), + arg( + 'placeholder_9', + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=53), + arg( + 'placeholder_10', + lineno=24, + col_offset=55, + end_lineno=24, + end_col_offset=64)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + While( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=28), + 'empty', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=34), + [], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=36), + lineno=25, + col_offset=10, + end_lineno=25, + end_col_offset=36), + [ + Expr( + Call( + Name( + 'sleep', + Load(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=13), + [ + BinOp( + Name( + 'placeholder_10', + Load(), + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=27), + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=27)], + [], + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=28), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=18)], + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=35), + 'get', + Load(), + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=39), + [], + [], + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=41), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=41), + If( + Compare( + Name( + 'placeholder_11', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=21), + [ + IsNot()], + [ + Constant( + None, + lineno=28, + col_offset=29, + end_lineno=28, + end_col_offset=33)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=33), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=27)], + Call( + Name( + 'Counter', + Load(), + lineno=29, + col_offset=30, + end_lineno=29, + end_col_offset=37), + [ + GeneratorExp( + Name( + 'placeholder_13', + Load(), + lineno=29, + col_offset=38, + end_lineno=29, + end_col_offset=41), + [ + comprehension( + Name( + 'placeholder_13', + Store(), + lineno=29, + col_offset=46, + end_lineno=29, + end_col_offset=49), + Call( + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=63), + 'lower', + Load(), + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=69), + [], + [], + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=71), + [ + Call( + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=29, + col_offset=75, + end_lineno=29, + end_col_offset=78), + 'isalpha', + Load(), + lineno=29, + col_offset=75, + end_lineno=29, + end_col_offset=86), + [], + [], + lineno=29, + col_offset=75, + end_lineno=29, + end_col_offset=88)], + 0)], + lineno=29, + col_offset=37, + end_lineno=29, + end_col_offset=89)], + [], + lineno=29, + col_offset=30, + end_lineno=29, + end_col_offset=89), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=89), + Expr( + Call( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=31), + 'placeholder_5', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=43), + [ + Name( + 'placeholder_12', + Load(), + lineno=30, + col_offset=44, + end_lineno=30, + end_col_offset=59)], + [], + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=60), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=60)], + [], + lineno=28, + col_offset=8, + end_lineno=30, + end_col_offset=60), + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=22), + 'task_done', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=32), + [], + [], + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=34), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=34), + If( + Compare( + Name( + 'placeholder_11', + Load(), + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=21), + [ + Is()], + [ + Constant( + None, + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=29)], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=29), + [ + Break( + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=17)], + [], + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=17)], + [], + lineno=25, + col_offset=4, + end_lineno=33, + end_col_offset=17)], + [], + lineno=24, + col_offset=0, + end_lineno=33, + end_col_offset=17), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'placeholder_15', + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=18)], + Call( + Name( + 'Queue', + Load(), + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=26), + [], + [], + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=28), + lineno=37, + col_offset=4, + end_lineno=37, + end_col_offset=28), + For( + Name( + 'placeholder_16', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=12), + Name( + 'placeholder_15', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=29), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=22), + 'put', + Load(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=26), + [ + Name( + 'placeholder_16', + Load(), + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=31)], + [], + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=32), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=32)], + [], + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=23)], + Call( + Name( + 'placeholder_1', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=39), + [], + [], + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=41), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=41), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=11)], + List( + [], + Load(), + lineno=41, + col_offset=14, + end_lineno=41, + end_col_offset=16), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=16), + For( + Name( + 'placeholder_13', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=20), + [ + Name( + 'placeholder_0', + Load(), + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=34)], + [], + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=35), + [ + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=14)], + Call( + Name( + 'Thread', + Load(), + lineno=43, + col_offset=17, + end_lineno=43, + end_col_offset=23), + [], + [ + keyword( + 'placeholder_19', + Name( + 'placeholder_7', + Load(), + lineno=43, + col_offset=31, + end_lineno=43, + end_col_offset=44), + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=44), + keyword( + 'placeholder_20', + Tuple( + [ + Name( + 'placeholder_8', + Load(), + lineno=43, + col_offset=52, + end_lineno=43, + end_col_offset=66), + Name( + 'placeholder_9', + Load(), + lineno=43, + col_offset=68, + end_lineno=43, + end_col_offset=87), + Name( + 'placeholder_13', + Load(), + lineno=43, + col_offset=89, + end_lineno=43, + end_col_offset=92)], + Load(), + lineno=43, + col_offset=51, + end_lineno=43, + end_col_offset=93), + lineno=43, + col_offset=46, + end_lineno=43, + end_col_offset=93)], + lineno=43, + col_offset=17, + end_lineno=43, + end_col_offset=94), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=94), + Expr( + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=14), + 'start', + Load(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=20), + [], + [], + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=22), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=22), + Expr( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=15), + 'append', + Load(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=22), + [ + Name( + 'placeholder_18', + Load(), + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=29)], + [], + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=30), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=30)], + [], + lineno=42, + col_offset=4, + end_lineno=45, + end_col_offset=30), + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=18), + 'join', + Load(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=23), + [], + [], + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=25), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=25), + For( + Name( + 'placeholder_21', + Store(), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=9), + Call( + Name( + 'range', + Load(), + lineno=47, + col_offset=13, + end_lineno=47, + end_col_offset=18), + [ + Name( + 'placeholder_0', + Load(), + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=32)], + [], + lineno=47, + col_offset=13, + end_lineno=47, + end_col_offset=33), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=22), + 'put', + Load(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=26), + [ + Constant( + None, + lineno=48, + col_offset=27, + end_lineno=48, + end_col_offset=31)], + [], + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=32), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=32)], + [], + lineno=47, + col_offset=4, + end_lineno=48, + end_col_offset=32), + For( + Name( + 'placeholder_22', + Store(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=14), + Name( + 'placeholder_17', + Load(), + lineno=49, + col_offset=18, + end_lineno=49, + end_col_offset=25), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=14), + 'join', + Load(), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=19), + [], + [], + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=21), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=21)], + [], + lineno=49, + col_offset=4, + end_lineno=50, + end_col_offset=21), + Return( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=30), + 'placeholder_4', + Load(), + lineno=51, + col_offset=11, + end_lineno=51, + end_col_offset=36), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=36)], + [], + lineno=36, + col_offset=0, + end_lineno=51, + end_col_offset=36)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-parallel-letter-frequency/representation.txt b/test/practice-parallel-letter-frequency/representation.txt new file mode 100644 index 0000000..cb0b7eb --- /dev/null +++ b/test/practice-parallel-letter-frequency/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('collections', [alias('Counter', lineno=2, col_offset=24, end_lineno=2, end_col_offset=31)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=31), ImportFrom('threading', [alias('Lock', lineno=3, col_offset=22, end_lineno=3, end_col_offset=26), alias('Thread', lineno=3, col_offset=28, end_lineno=3, end_col_offset=34)], 0, lineno=3, col_offset=0, end_lineno=3, end_col_offset=34), ImportFrom('time', [alias('sleep', lineno=4, col_offset=17, end_lineno=4, end_col_offset=22)], 0, lineno=4, col_offset=0, end_lineno=4, end_col_offset=22), ImportFrom('queue', [alias('Queue', lineno=5, col_offset=18, end_lineno=5, end_col_offset=23)], 0, lineno=5, col_offset=0, end_lineno=5, end_col_offset=23), Assign([Name('placeholder_0', Store(), lineno=8, col_offset=0, end_lineno=8, end_col_offset=13)], Constant(3, lineno=8, col_offset=16, end_lineno=8, end_col_offset=17), lineno=8, col_offset=0, end_lineno=8, end_col_offset=17), ClassDef('placeholder_1', [], [], [FunctionDef('placeholder_2', arguments([], [arg('self', lineno=12, col_offset=17, end_lineno=12, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=12), 'placeholder_3', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=17)], Call(Name('Lock', Load(), lineno=13, col_offset=20, end_lineno=13, end_col_offset=24), [], [], lineno=13, col_offset=20, end_lineno=13, end_col_offset=26), lineno=13, col_offset=8, end_lineno=13, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=12), 'placeholder_4', Store(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=18)], Call(Name('Counter', Load(), lineno=14, col_offset=21, end_lineno=14, end_col_offset=28), [], [], lineno=14, col_offset=21, end_lineno=14, end_col_offset=30), lineno=14, col_offset=8, end_lineno=14, end_col_offset=30)], [], lineno=12, col_offset=4, end_lineno=14, end_col_offset=30), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=16, col_offset=20, end_lineno=16, end_col_offset=24), arg('placeholder_6', lineno=16, col_offset=26, end_lineno=16, end_col_offset=40)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=12), 'placeholder_3', Load(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=17), 'acquire', Load(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=25), [], [], lineno=17, col_offset=8, end_lineno=17, end_col_offset=27), lineno=17, col_offset=8, end_lineno=17, end_col_offset=27), Try([Assign([Attribute(Name('self', Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=16), 'placeholder_4', Store(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=22)], BinOp(Attribute(Name('self', Load(), lineno=19, col_offset=25, end_lineno=19, end_col_offset=29), 'placeholder_4', Load(), lineno=19, col_offset=25, end_lineno=19, end_col_offset=35), Add(), Name('placeholder_6', Load(), lineno=19, col_offset=38, end_lineno=19, end_col_offset=52), lineno=19, col_offset=25, end_lineno=19, end_col_offset=52), lineno=19, col_offset=12, end_lineno=19, end_col_offset=52)], [], [], [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=16), 'placeholder_3', Load(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=21), 'release', Load(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=29), [], [], lineno=21, col_offset=12, end_lineno=21, end_col_offset=31), lineno=21, col_offset=12, end_lineno=21, end_col_offset=31)], lineno=18, col_offset=8, end_lineno=21, end_col_offset=31)], [], lineno=16, col_offset=4, end_lineno=21, end_col_offset=31)], [], lineno=10, col_offset=0, end_lineno=21, end_col_offset=31), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=24, col_offset=18, end_lineno=24, end_col_offset=32), arg('placeholder_9', lineno=24, col_offset=34, end_lineno=24, end_col_offset=53), arg('placeholder_10', lineno=24, col_offset=55, end_lineno=24, end_col_offset=64)], kwonlyargs=[], kw_defaults=[], defaults=[]), [While(UnaryOp(Not(), Call(Attribute(Name('placeholder_8', Load(), lineno=25, col_offset=14, end_lineno=25, end_col_offset=28), 'empty', Load(), lineno=25, col_offset=14, end_lineno=25, end_col_offset=34), [], [], lineno=25, col_offset=14, end_lineno=25, end_col_offset=36), lineno=25, col_offset=10, end_lineno=25, end_col_offset=36), [Expr(Call(Name('sleep', Load(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=13), [BinOp(Name('placeholder_10', Load(), lineno=26, col_offset=14, end_lineno=26, end_col_offset=23), Add(), Constant(1, lineno=26, col_offset=26, end_lineno=26, end_col_offset=27), lineno=26, col_offset=14, end_lineno=26, end_col_offset=27)], [], lineno=26, col_offset=8, end_lineno=26, end_col_offset=28), lineno=26, col_offset=8, end_lineno=26, end_col_offset=28), Assign([Name('placeholder_11', Store(), lineno=27, col_offset=8, end_lineno=27, end_col_offset=18)], Call(Attribute(Name('placeholder_8', Load(), lineno=27, col_offset=21, end_lineno=27, end_col_offset=35), 'get', Load(), lineno=27, col_offset=21, end_lineno=27, end_col_offset=39), [], [], lineno=27, col_offset=21, end_lineno=27, end_col_offset=41), lineno=27, col_offset=8, end_lineno=27, end_col_offset=41), If(Compare(Name('placeholder_11', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=21), [IsNot()], [Constant(None, lineno=28, col_offset=29, end_lineno=28, end_col_offset=33)], lineno=28, col_offset=11, end_lineno=28, end_col_offset=33), [Assign([Name('placeholder_12', Store(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=27)], Call(Name('Counter', Load(), lineno=29, col_offset=30, end_lineno=29, end_col_offset=37), [GeneratorExp(Name('placeholder_13', Load(), lineno=29, col_offset=38, end_lineno=29, end_col_offset=41), [comprehension(Name('placeholder_13', Store(), lineno=29, col_offset=46, end_lineno=29, end_col_offset=49), Call(Attribute(Name('placeholder_11', Load(), lineno=29, col_offset=53, end_lineno=29, end_col_offset=63), 'lower', Load(), lineno=29, col_offset=53, end_lineno=29, end_col_offset=69), [], [], lineno=29, col_offset=53, end_lineno=29, end_col_offset=71), [Call(Attribute(Name('placeholder_13', Load(), lineno=29, col_offset=75, end_lineno=29, end_col_offset=78), 'isalpha', Load(), lineno=29, col_offset=75, end_lineno=29, end_col_offset=86), [], [], lineno=29, col_offset=75, end_lineno=29, end_col_offset=88)], 0)], lineno=29, col_offset=37, end_lineno=29, end_col_offset=89)], [], lineno=29, col_offset=30, end_lineno=29, end_col_offset=89), lineno=29, col_offset=12, end_lineno=29, end_col_offset=89), Expr(Call(Attribute(Name('placeholder_9', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=31), 'placeholder_5', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=43), [Name('placeholder_12', Load(), lineno=30, col_offset=44, end_lineno=30, end_col_offset=59)], [], lineno=30, col_offset=12, end_lineno=30, end_col_offset=60), lineno=30, col_offset=12, end_lineno=30, end_col_offset=60)], [], lineno=28, col_offset=8, end_lineno=30, end_col_offset=60), Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=22), 'task_done', Load(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=32), [], [], lineno=31, col_offset=8, end_lineno=31, end_col_offset=34), lineno=31, col_offset=8, end_lineno=31, end_col_offset=34), If(Compare(Name('placeholder_11', Load(), lineno=32, col_offset=11, end_lineno=32, end_col_offset=21), [Is()], [Constant(None, lineno=32, col_offset=25, end_lineno=32, end_col_offset=29)], lineno=32, col_offset=11, end_lineno=32, end_col_offset=29), [Break(lineno=33, col_offset=12, end_lineno=33, end_col_offset=17)], [], lineno=32, col_offset=8, end_lineno=33, end_col_offset=17)], [], lineno=25, col_offset=4, end_lineno=33, end_col_offset=17)], [], lineno=24, col_offset=0, end_lineno=33, end_col_offset=17), FunctionDef('placeholder_14', arguments([], [arg('placeholder_15', lineno=36, col_offset=14, end_lineno=36, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=37, col_offset=4, end_lineno=37, end_col_offset=18)], Call(Name('Queue', Load(), lineno=37, col_offset=21, end_lineno=37, end_col_offset=26), [], [], lineno=37, col_offset=21, end_lineno=37, end_col_offset=28), lineno=37, col_offset=4, end_lineno=37, end_col_offset=28), For(Name('placeholder_16', Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=12), Name('placeholder_15', Load(), lineno=38, col_offset=16, end_lineno=38, end_col_offset=29), [Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=39, col_offset=8, end_lineno=39, end_col_offset=22), 'put', Load(), lineno=39, col_offset=8, end_lineno=39, end_col_offset=26), [Name('placeholder_16', Load(), lineno=39, col_offset=27, end_lineno=39, end_col_offset=31)], [], lineno=39, col_offset=8, end_lineno=39, end_col_offset=32), lineno=39, col_offset=8, end_lineno=39, end_col_offset=32)], [], lineno=38, col_offset=4, end_lineno=39, end_col_offset=32), Assign([Name('placeholder_9', Store(), lineno=40, col_offset=4, end_lineno=40, end_col_offset=23)], Call(Name('placeholder_1', Load(), lineno=40, col_offset=26, end_lineno=40, end_col_offset=39), [], [], lineno=40, col_offset=26, end_lineno=40, end_col_offset=41), lineno=40, col_offset=4, end_lineno=40, end_col_offset=41), Assign([Name('placeholder_17', Store(), lineno=41, col_offset=4, end_lineno=41, end_col_offset=11)], List([], Load(), lineno=41, col_offset=14, end_lineno=41, end_col_offset=16), lineno=41, col_offset=4, end_lineno=41, end_col_offset=16), For(Name('placeholder_13', Store(), lineno=42, col_offset=8, end_lineno=42, end_col_offset=11), Call(Name('range', Load(), lineno=42, col_offset=15, end_lineno=42, end_col_offset=20), [Name('placeholder_0', Load(), lineno=42, col_offset=21, end_lineno=42, end_col_offset=34)], [], lineno=42, col_offset=15, end_lineno=42, end_col_offset=35), [Assign([Name('placeholder_18', Store(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=14)], Call(Name('Thread', Load(), lineno=43, col_offset=17, end_lineno=43, end_col_offset=23), [], [keyword('placeholder_19', Name('placeholder_7', Load(), lineno=43, col_offset=31, end_lineno=43, end_col_offset=44), lineno=43, col_offset=24, end_lineno=43, end_col_offset=44), keyword('placeholder_20', Tuple([Name('placeholder_8', Load(), lineno=43, col_offset=52, end_lineno=43, end_col_offset=66), Name('placeholder_9', Load(), lineno=43, col_offset=68, end_lineno=43, end_col_offset=87), Name('placeholder_13', Load(), lineno=43, col_offset=89, end_lineno=43, end_col_offset=92)], Load(), lineno=43, col_offset=51, end_lineno=43, end_col_offset=93), lineno=43, col_offset=46, end_lineno=43, end_col_offset=93)], lineno=43, col_offset=17, end_lineno=43, end_col_offset=94), lineno=43, col_offset=8, end_lineno=43, end_col_offset=94), Expr(Call(Attribute(Name('placeholder_18', Load(), lineno=44, col_offset=8, end_lineno=44, end_col_offset=14), 'start', Load(), lineno=44, col_offset=8, end_lineno=44, end_col_offset=20), [], [], lineno=44, col_offset=8, end_lineno=44, end_col_offset=22), lineno=44, col_offset=8, end_lineno=44, end_col_offset=22), Expr(Call(Attribute(Name('placeholder_17', Load(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=15), 'append', Load(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=22), [Name('placeholder_18', Load(), lineno=45, col_offset=23, end_lineno=45, end_col_offset=29)], [], lineno=45, col_offset=8, end_lineno=45, end_col_offset=30), lineno=45, col_offset=8, end_lineno=45, end_col_offset=30)], [], lineno=42, col_offset=4, end_lineno=45, end_col_offset=30), Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=46, col_offset=4, end_lineno=46, end_col_offset=18), 'join', Load(), lineno=46, col_offset=4, end_lineno=46, end_col_offset=23), [], [], lineno=46, col_offset=4, end_lineno=46, end_col_offset=25), lineno=46, col_offset=4, end_lineno=46, end_col_offset=25), For(Name('placeholder_21', Store(), lineno=47, col_offset=8, end_lineno=47, end_col_offset=9), Call(Name('range', Load(), lineno=47, col_offset=13, end_lineno=47, end_col_offset=18), [Name('placeholder_0', Load(), lineno=47, col_offset=19, end_lineno=47, end_col_offset=32)], [], lineno=47, col_offset=13, end_lineno=47, end_col_offset=33), [Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=22), 'put', Load(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=26), [Constant(None, lineno=48, col_offset=27, end_lineno=48, end_col_offset=31)], [], lineno=48, col_offset=8, end_lineno=48, end_col_offset=32), lineno=48, col_offset=8, end_lineno=48, end_col_offset=32)], [], lineno=47, col_offset=4, end_lineno=48, end_col_offset=32), For(Name('placeholder_22', Store(), lineno=49, col_offset=8, end_lineno=49, end_col_offset=14), Name('placeholder_17', Load(), lineno=49, col_offset=18, end_lineno=49, end_col_offset=25), [Expr(Call(Attribute(Name('placeholder_22', Load(), lineno=50, col_offset=8, end_lineno=50, end_col_offset=14), 'join', Load(), lineno=50, col_offset=8, end_lineno=50, end_col_offset=19), [], [], lineno=50, col_offset=8, end_lineno=50, end_col_offset=21), lineno=50, col_offset=8, end_lineno=50, end_col_offset=21)], [], lineno=49, col_offset=4, end_lineno=50, end_col_offset=21), Return(Attribute(Name('placeholder_9', Load(), lineno=51, col_offset=11, end_lineno=51, end_col_offset=30), 'placeholder_4', Load(), lineno=51, col_offset=11, end_lineno=51, end_col_offset=36), lineno=51, col_offset=4, end_lineno=51, end_col_offset=36)], [], lineno=36, col_offset=0, end_lineno=51, end_col_offset=36)], []) \ No newline at end of file diff --git a/test/practice-pascals-triangle/.meta/additional_tests.json b/test/practice-pascals-triangle/.meta/additional_tests.json new file mode 100644 index 0000000..7c1375a --- /dev/null +++ b/test/practice-pascals-triangle/.meta/additional_tests.json @@ -0,0 +1,26 @@ +{ + "cases": [ + { + "description": "negative rows are invalid", + "property": "rows", + "input": { + "count": -1 + }, + "expected": { + "error": "number of rows is negative", + "type": "ValueError" + } + }, + { + "description": "solution is recursive", + "property": "rows", + "input": { + "count": "OVERFLOW" + }, + "expected": { + "error": "maximum recursion depth exceeded", + "type": "RecursionError" + } + } + ] +} diff --git a/test/practice-pascals-triangle/.meta/config.json b/test/practice-pascals-triangle/.meta/config.json new file mode 100644 index 0000000..5871348 --- /dev/null +++ b/test/practice-pascals-triangle/.meta/config.json @@ -0,0 +1,34 @@ +{ + "blurb": "Compute Pascal's triangle up to a given number of rows.", + "authors": [ + "betegelse", + "PaulT89" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "ikkebr", + "kytrinyx", + "N-Parsons", + "olufotebig", + "parinporecha", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "pascals_triangle.py" + ], + "test": [ + "pascals_triangle_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "Pascal's Triangle at Wolfram Math World", + "source_url": "https://www.wolframalpha.com/input/?i=Pascal%27s+triangle" +} diff --git a/test/practice-pascals-triangle/mapping.json b/test/practice-pascals-triangle/mapping.json new file mode 100644 index 0000000..7e4f704 --- /dev/null +++ b/test/practice-pascals-triangle/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "rows", + "placeholder_1": "row_count", + "placeholder_2": "previous_row", + "placeholder_3": "temp_row", + "placeholder_4": "new_row" +} \ No newline at end of file diff --git a/test/practice-pascals-triangle/pascals_triangle.py b/test/practice-pascals-triangle/pascals_triangle.py new file mode 100644 index 0000000..9181199 --- /dev/null +++ b/test/practice-pascals-triangle/pascals_triangle.py @@ -0,0 +1,8 @@ +def rows(row_count, previous_row=[1]): + if row_count < 0: + raise ValueError("number of rows is negative") + elif row_count == 0: + return [] + temp_row = previous_row + [0] + new_row = list(map(sum, zip(temp_row, temp_row[::-1]))) + return [previous_row] + rows(row_count - 1, new_row) diff --git a/test/practice-pascals-triangle/representation.json b/test/practice-pascals-triangle/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-pascals-triangle/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-pascals-triangle/representation.out b/test/practice-pascals-triangle/representation.out new file mode 100644 index 0000000..20f41ee --- /dev/null +++ b/test/practice-pascals-triangle/representation.out @@ -0,0 +1,693 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2=[1]): + if placeholder_1 < 0: + raise ValueError("number of rows is negative") + elif placeholder_1 == 0: + return [] + placeholder_3 = placeholder_2 + [0] + placeholder_4 = list(map(sum, zip(placeholder_3, placeholder_3[::-1]))) + return [placeholder_2] + placeholder_0(placeholder_1 - 1, placeholder_4) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'rows', + arguments( + [], + [ + arg( + 'row_count', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=18), + arg( + 'previous_row', + lineno=1, + col_offset=20, + end_lineno=1, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + List( + [ + Constant( + 1, + lineno=1, + col_offset=34, + end_lineno=1, + end_col_offset=35)], + Load(), + lineno=1, + col_offset=33, + end_lineno=1, + end_col_offset=36)]), + [ + If( + Compare( + Name( + 'row_count', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=16), + [ + Lt()], + [ + Constant( + 0, + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=20)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'number of rows is negative', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=53)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=54), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=54)], + [ + If( + Compare( + Name( + 'row_count', + Load(), + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=18), + [ + Eq()], + [ + Constant( + 0, + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=23)], + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=23), + [ + Return( + List( + [], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=17), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17)], + [], + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=17)], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=17), + Assign( + [ + Name( + 'temp_row', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=12)], + BinOp( + Name( + 'previous_row', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=27), + Add(), + List( + [ + Constant( + 0, + lineno=6, + col_offset=31, + end_lineno=6, + end_col_offset=32)], + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=33), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=33), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=33), + Assign( + [ + Name( + 'new_row', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11)], + Call( + Name( + 'list', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=18), + [ + Call( + Name( + 'map', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=22), + [ + Name( + 'sum', + Load(), + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=26), + Call( + Name( + 'zip', + Load(), + lineno=7, + col_offset=28, + end_lineno=7, + end_col_offset=31), + [ + Name( + 'temp_row', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=40), + Subscript( + Name( + 'temp_row', + Load(), + lineno=7, + col_offset=42, + end_lineno=7, + end_col_offset=50), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=7, + col_offset=54, + end_lineno=7, + end_col_offset=55), + lineno=7, + col_offset=53, + end_lineno=7, + end_col_offset=55), + lineno=7, + col_offset=51, + end_lineno=7, + end_col_offset=55), + Load(), + lineno=7, + col_offset=42, + end_lineno=7, + end_col_offset=56)], + [], + lineno=7, + col_offset=28, + end_lineno=7, + end_col_offset=57)], + [], + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=58)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=59), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=59), + Return( + BinOp( + List( + [ + Name( + 'previous_row', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=24)], + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=25), + Add(), + Call( + Name( + 'rows', + Load(), + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=32), + [ + BinOp( + Name( + 'row_count', + Load(), + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=42), + Sub(), + Constant( + 1, + lineno=8, + col_offset=45, + end_lineno=8, + end_col_offset=46), + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=46), + Name( + 'new_row', + Load(), + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=55)], + [], + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=56), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=56), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=56)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=56)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=18), + arg( + 'placeholder_2', + lineno=1, + col_offset=20, + end_lineno=1, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + List( + [ + Constant( + 1, + lineno=1, + col_offset=34, + end_lineno=1, + end_col_offset=35)], + Load(), + lineno=1, + col_offset=33, + end_lineno=1, + end_col_offset=36)]), + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=16), + [ + Lt()], + [ + Constant( + 0, + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=20)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'number of rows is negative', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=53)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=54), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=54)], + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=18), + [ + Eq()], + [ + Constant( + 0, + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=23)], + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=23), + [ + Return( + List( + [], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=17), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=17)], + [], + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=17)], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=12)], + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=27), + Add(), + List( + [ + Constant( + 0, + lineno=6, + col_offset=31, + end_lineno=6, + end_col_offset=32)], + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=33), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=33), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11)], + Call( + Name( + 'list', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=18), + [ + Call( + Name( + 'map', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=22), + [ + Name( + 'sum', + Load(), + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=26), + Call( + Name( + 'zip', + Load(), + lineno=7, + col_offset=28, + end_lineno=7, + end_col_offset=31), + [ + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=32, + end_lineno=7, + end_col_offset=40), + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=42, + end_lineno=7, + end_col_offset=50), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=7, + col_offset=54, + end_lineno=7, + end_col_offset=55), + lineno=7, + col_offset=53, + end_lineno=7, + end_col_offset=55), + lineno=7, + col_offset=51, + end_lineno=7, + end_col_offset=55), + Load(), + lineno=7, + col_offset=42, + end_lineno=7, + end_col_offset=56)], + [], + lineno=7, + col_offset=28, + end_lineno=7, + end_col_offset=57)], + [], + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=58)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=59), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=59), + Return( + BinOp( + List( + [ + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=24)], + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=25), + Add(), + Call( + Name( + 'placeholder_0', + Load(), + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=32), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=42), + Sub(), + Constant( + 1, + lineno=8, + col_offset=45, + end_lineno=8, + end_col_offset=46), + lineno=8, + col_offset=33, + end_lineno=8, + end_col_offset=46), + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=48, + end_lineno=8, + end_col_offset=55)], + [], + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=56), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=56), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=56)], + [], + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=56)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-pascals-triangle/representation.txt b/test/practice-pascals-triangle/representation.txt new file mode 100644 index 0000000..318b710 --- /dev/null +++ b/test/practice-pascals-triangle/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=9, end_lineno=1, end_col_offset=18), arg('placeholder_2', lineno=1, col_offset=20, end_lineno=1, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[List([Constant(1, lineno=1, col_offset=34, end_lineno=1, end_col_offset=35)], Load(), lineno=1, col_offset=33, end_lineno=1, end_col_offset=36)]), [If(Compare(Name('placeholder_1', Load(), lineno=2, col_offset=7, end_lineno=2, end_col_offset=16), [Lt()], [Constant(0, lineno=2, col_offset=19, end_lineno=2, end_col_offset=20)], lineno=2, col_offset=7, end_lineno=2, end_col_offset=20), [Raise(Call(Name('ValueError', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=24), [Constant('number of rows is negative', lineno=3, col_offset=25, end_lineno=3, end_col_offset=53)], [], lineno=3, col_offset=14, end_lineno=3, end_col_offset=54), lineno=3, col_offset=8, end_lineno=3, end_col_offset=54)], [If(Compare(Name('placeholder_1', Load(), lineno=4, col_offset=9, end_lineno=4, end_col_offset=18), [Eq()], [Constant(0, lineno=4, col_offset=22, end_lineno=4, end_col_offset=23)], lineno=4, col_offset=9, end_lineno=4, end_col_offset=23), [Return(List([], Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=17), lineno=5, col_offset=8, end_lineno=5, end_col_offset=17)], [], lineno=4, col_offset=4, end_lineno=5, end_col_offset=17)], lineno=2, col_offset=4, end_lineno=5, end_col_offset=17), Assign([Name('placeholder_3', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=12)], BinOp(Name('placeholder_2', Load(), lineno=6, col_offset=15, end_lineno=6, end_col_offset=27), Add(), List([Constant(0, lineno=6, col_offset=31, end_lineno=6, end_col_offset=32)], Load(), lineno=6, col_offset=30, end_lineno=6, end_col_offset=33), lineno=6, col_offset=15, end_lineno=6, end_col_offset=33), lineno=6, col_offset=4, end_lineno=6, end_col_offset=33), Assign([Name('placeholder_4', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=11)], Call(Name('list', Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=18), [Call(Name('map', Load(), lineno=7, col_offset=19, end_lineno=7, end_col_offset=22), [Name('sum', Load(), lineno=7, col_offset=23, end_lineno=7, end_col_offset=26), Call(Name('zip', Load(), lineno=7, col_offset=28, end_lineno=7, end_col_offset=31), [Name('placeholder_3', Load(), lineno=7, col_offset=32, end_lineno=7, end_col_offset=40), Subscript(Name('placeholder_3', Load(), lineno=7, col_offset=42, end_lineno=7, end_col_offset=50), Slice(step=UnaryOp(USub(), Constant(1, lineno=7, col_offset=54, end_lineno=7, end_col_offset=55), lineno=7, col_offset=53, end_lineno=7, end_col_offset=55), lineno=7, col_offset=51, end_lineno=7, end_col_offset=55), Load(), lineno=7, col_offset=42, end_lineno=7, end_col_offset=56)], [], lineno=7, col_offset=28, end_lineno=7, end_col_offset=57)], [], lineno=7, col_offset=19, end_lineno=7, end_col_offset=58)], [], lineno=7, col_offset=14, end_lineno=7, end_col_offset=59), lineno=7, col_offset=4, end_lineno=7, end_col_offset=59), Return(BinOp(List([Name('placeholder_2', Load(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=24)], Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=25), Add(), Call(Name('placeholder_0', Load(), lineno=8, col_offset=28, end_lineno=8, end_col_offset=32), [BinOp(Name('placeholder_1', Load(), lineno=8, col_offset=33, end_lineno=8, end_col_offset=42), Sub(), Constant(1, lineno=8, col_offset=45, end_lineno=8, end_col_offset=46), lineno=8, col_offset=33, end_lineno=8, end_col_offset=46), Name('placeholder_4', Load(), lineno=8, col_offset=48, end_lineno=8, end_col_offset=55)], [], lineno=8, col_offset=28, end_lineno=8, end_col_offset=56), lineno=8, col_offset=11, end_lineno=8, end_col_offset=56), lineno=8, col_offset=4, end_lineno=8, end_col_offset=56)], [], lineno=1, col_offset=0, end_lineno=8, end_col_offset=56)], []) \ No newline at end of file diff --git a/test/practice-perfect-numbers/.meta/config.json b/test/practice-perfect-numbers/.meta/config.json new file mode 100644 index 0000000..a77ccea --- /dev/null +++ b/test/practice-perfect-numbers/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "cmccandless", + "Dog", + "emerali", + "ikhadykin", + "N-Parsons", + "olufotebig", + "pheanex", + "saurabhchalke", + "smalley", + "tqa236" + ], + "files": { + "solution": [ + "perfect_numbers.py" + ], + "test": [ + "perfect_numbers_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for positive integers.", + "source": "Taken from Chapter 2 of Functional Thinking by Neal Ford.", + "source_url": "https://www.oreilly.com/library/view/functional-thinking/9781449365509/" +} diff --git a/test/practice-perfect-numbers/mapping.json b/test/practice-perfect-numbers/mapping.json new file mode 100644 index 0000000..61eebe0 --- /dev/null +++ b/test/practice-perfect-numbers/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "divisor_generator", + "placeholder_1": "number", + "placeholder_2": "index", + "placeholder_3": "classify", + "placeholder_4": "aliquot_sum" +} \ No newline at end of file diff --git a/test/practice-perfect-numbers/perfect_numbers.py b/test/practice-perfect-numbers/perfect_numbers.py new file mode 100644 index 0000000..3a34948 --- /dev/null +++ b/test/practice-perfect-numbers/perfect_numbers.py @@ -0,0 +1,34 @@ +import math + +def divisor_generator(number): + """Returns an unordered list of divisors for n (1 < number). + + :param number: int a positive integer + :return: list of int divisors + """ + + for index in range(2, int(math.sqrt(number)) + 1): + if number % index == 0: + yield index + if index * index != number: + yield number // index + + +def classify(number): + """ A perfect number equals the sum of its positive divisors. + + :param number: int a positive integer + :return: str the classification of the input integer + """ + + if number <= 0: + raise ValueError('Classification is only possible for positive integers.') + + aliquot_sum = sum(divisor_generator(number)) + (1 if number > 1 else 0) + + if aliquot_sum < number: + return 'deficient' + elif aliquot_sum == number: + return 'perfect' + else: + return 'abundant' diff --git a/test/practice-perfect-numbers/representation.json b/test/practice-perfect-numbers/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-perfect-numbers/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-perfect-numbers/representation.out b/test/practice-perfect-numbers/representation.out new file mode 100644 index 0000000..dbb4b88 --- /dev/null +++ b/test/practice-perfect-numbers/representation.out @@ -0,0 +1,1070 @@ +## BEGIN NORMALIZED CODE ## +import math + + +def placeholder_0(placeholder_1): + for placeholder_2 in range(2, int(math.sqrt(placeholder_1)) + 1): + if placeholder_1 % placeholder_2 == 0: + yield index + if placeholder_2 * placeholder_2 != placeholder_1: + yield (number // index) + + +def placeholder_3(placeholder_1): + if placeholder_1 <= 0: + raise ValueError("Classification is only possible for positive integers.") + placeholder_4 = sum(placeholder_0(placeholder_1)) + (1 if placeholder_1 > 1 else 0) + if placeholder_4 < placeholder_1: + return "deficient" + elif placeholder_4 == placeholder_1: + return "perfect" + else: + return "abundant" + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'math', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + FunctionDef( + 'divisor_generator', + arguments( + [], + [ + arg( + 'number', + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Returns an unordered list of divisors for n (1 < number).\n\n :param number: int a positive integer\n :return: list of int divisors\n ', + lineno=4, + col_offset=4, + end_lineno=8, + end_col_offset=7), + lineno=4, + col_offset=4, + end_lineno=8, + end_col_offset=7), + For( + Name( + 'index', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=22), + [ + Constant( + 2, + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=24), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=29), + [ + Call( + Attribute( + Name( + 'math', + Load(), + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=34), + 'sqrt', + Load(), + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=39), + [ + Name( + 'number', + Load(), + lineno=10, + col_offset=40, + end_lineno=10, + end_col_offset=46)], + [], + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=47)], + [], + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=48), + Add(), + Constant( + 1, + lineno=10, + col_offset=51, + end_lineno=10, + end_col_offset=52), + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=52)], + [], + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=53), + [ + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=17), + Mod(), + Name( + 'index', + Load(), + lineno=11, + col_offset=20, + end_lineno=11, + end_col_offset=25), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=25), + [ + Eq()], + [ + Constant( + 0, + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=30)], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=30), + [ + Expr( + Yield( + Name( + 'index', + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=23), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=23), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=23), + If( + Compare( + BinOp( + Name( + 'index', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=20), + Mult(), + Name( + 'index', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=28), + [ + NotEq()], + [ + Name( + 'number', + Load(), + lineno=13, + col_offset=32, + end_lineno=13, + end_col_offset=38)], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=38), + [ + Expr( + Yield( + BinOp( + Name( + 'number', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=28), + FloorDiv(), + Name( + 'index', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=37)], + [], + lineno=13, + col_offset=12, + end_lineno=14, + end_col_offset=37)], + [], + lineno=11, + col_offset=8, + end_lineno=14, + end_col_offset=37)], + [], + lineno=10, + col_offset=4, + end_lineno=14, + end_col_offset=37)], + [], + lineno=3, + col_offset=0, + end_lineno=14, + end_col_offset=37), + FunctionDef( + 'classify', + arguments( + [], + [ + arg( + 'number', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + ' A perfect number equals the sum of its positive divisors.\n\n :param number: int a positive integer\n :return: str the classification of the input integer\n ', + lineno=18, + col_offset=4, + end_lineno=22, + end_col_offset=7), + lineno=18, + col_offset=4, + end_lineno=22, + end_col_offset=7), + If( + Compare( + Name( + 'number', + Load(), + lineno=24, + col_offset=7, + end_lineno=24, + end_col_offset=13), + [ + LtE()], + [ + Constant( + 0, + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=18)], + lineno=24, + col_offset=7, + end_lineno=24, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=24), + [ + Constant( + 'Classification is only possible for positive integers.', + lineno=25, + col_offset=25, + end_lineno=25, + end_col_offset=81)], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=82), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=82)], + [], + lineno=24, + col_offset=4, + end_lineno=25, + end_col_offset=82), + Assign( + [ + Name( + 'aliquot_sum', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=15)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=21), + [ + Call( + Name( + 'divisor_generator', + Load(), + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=39), + [ + Name( + 'number', + Load(), + lineno=27, + col_offset=40, + end_lineno=27, + end_col_offset=46)], + [], + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=47)], + [], + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=48), + Add(), + IfExp( + Compare( + Name( + 'number', + Load(), + lineno=27, + col_offset=57, + end_lineno=27, + end_col_offset=63), + [ + Gt()], + [ + Constant( + 1, + lineno=27, + col_offset=66, + end_lineno=27, + end_col_offset=67)], + lineno=27, + col_offset=57, + end_lineno=27, + end_col_offset=67), + Constant( + 1, + lineno=27, + col_offset=52, + end_lineno=27, + end_col_offset=53), + Constant( + 0, + lineno=27, + col_offset=73, + end_lineno=27, + end_col_offset=74), + lineno=27, + col_offset=52, + end_lineno=27, + end_col_offset=74), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=75), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=75), + If( + Compare( + Name( + 'aliquot_sum', + Load(), + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=18), + [ + Lt()], + [ + Name( + 'number', + Load(), + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=27)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=27), + [ + Return( + Constant( + 'deficient', + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=26), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=26)], + [ + If( + Compare( + Name( + 'aliquot_sum', + Load(), + lineno=31, + col_offset=9, + end_lineno=31, + end_col_offset=20), + [ + Eq()], + [ + Name( + 'number', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=30)], + lineno=31, + col_offset=9, + end_lineno=31, + end_col_offset=30), + [ + Return( + Constant( + 'perfect', + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=24), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=24)], + [ + Return( + Constant( + 'abundant', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=25), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=25)], + lineno=31, + col_offset=4, + end_lineno=34, + end_col_offset=25)], + lineno=29, + col_offset=4, + end_lineno=34, + end_col_offset=25)], + [], + lineno=17, + col_offset=0, + end_lineno=34, + end_col_offset=25)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'math', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_2', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=22), + [ + Constant( + 2, + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=24), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=29), + [ + Call( + Attribute( + Name( + 'math', + Load(), + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=34), + 'sqrt', + Load(), + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=39), + [ + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=40, + end_lineno=10, + end_col_offset=46)], + [], + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=47)], + [], + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=48), + Add(), + Constant( + 1, + lineno=10, + col_offset=51, + end_lineno=10, + end_col_offset=52), + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=52)], + [], + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=53), + [ + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=17), + Mod(), + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=20, + end_lineno=11, + end_col_offset=25), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=25), + [ + Eq()], + [ + Constant( + 0, + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=30)], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=30), + [ + Expr( + Yield( + Name( + 'index', + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=23), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=23), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=23), + If( + Compare( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=20), + Mult(), + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=28), + [ + NotEq()], + [ + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=32, + end_lineno=13, + end_col_offset=38)], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=38), + [ + Expr( + Yield( + BinOp( + Name( + 'number', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=28), + FloorDiv(), + Name( + 'index', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=37)], + [], + lineno=13, + col_offset=12, + end_lineno=14, + end_col_offset=37)], + [], + lineno=11, + col_offset=8, + end_lineno=14, + end_col_offset=37)], + [], + lineno=10, + col_offset=4, + end_lineno=14, + end_col_offset=37)], + [], + lineno=3, + col_offset=0, + end_lineno=14, + end_col_offset=37), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=24, + col_offset=7, + end_lineno=24, + end_col_offset=13), + [ + LtE()], + [ + Constant( + 0, + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=18)], + lineno=24, + col_offset=7, + end_lineno=24, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=24), + [ + Constant( + 'Classification is only possible for positive integers.', + lineno=25, + col_offset=25, + end_lineno=25, + end_col_offset=81)], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=82), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=82)], + [], + lineno=24, + col_offset=4, + end_lineno=25, + end_col_offset=82), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=15)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=21), + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=39), + [ + Name( + 'placeholder_1', + Load(), + lineno=27, + col_offset=40, + end_lineno=27, + end_col_offset=46)], + [], + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=47)], + [], + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=48), + Add(), + IfExp( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=27, + col_offset=57, + end_lineno=27, + end_col_offset=63), + [ + Gt()], + [ + Constant( + 1, + lineno=27, + col_offset=66, + end_lineno=27, + end_col_offset=67)], + lineno=27, + col_offset=57, + end_lineno=27, + end_col_offset=67), + Constant( + 1, + lineno=27, + col_offset=52, + end_lineno=27, + end_col_offset=53), + Constant( + 0, + lineno=27, + col_offset=73, + end_lineno=27, + end_col_offset=74), + lineno=27, + col_offset=52, + end_lineno=27, + end_col_offset=74), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=75), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=75), + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=18), + [ + Lt()], + [ + Name( + 'placeholder_1', + Load(), + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=27)], + lineno=29, + col_offset=7, + end_lineno=29, + end_col_offset=27), + [ + Return( + Constant( + 'deficient', + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=26), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=26)], + [ + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=31, + col_offset=9, + end_lineno=31, + end_col_offset=20), + [ + Eq()], + [ + Name( + 'placeholder_1', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=30)], + lineno=31, + col_offset=9, + end_lineno=31, + end_col_offset=30), + [ + Return( + Constant( + 'perfect', + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=24), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=24)], + [ + Return( + Constant( + 'abundant', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=25), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=25)], + lineno=31, + col_offset=4, + end_lineno=34, + end_col_offset=25)], + lineno=29, + col_offset=4, + end_lineno=34, + end_col_offset=25)], + [], + lineno=17, + col_offset=0, + end_lineno=34, + end_col_offset=25)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-perfect-numbers/representation.txt b/test/practice-perfect-numbers/representation.txt new file mode 100644 index 0000000..f65daf1 --- /dev/null +++ b/test/practice-perfect-numbers/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('math', lineno=1, col_offset=7, end_lineno=1, end_col_offset=11)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=11), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=3, col_offset=22, end_lineno=3, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_2', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=13), Call(Name('range', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=22), [Constant(2, lineno=10, col_offset=23, end_lineno=10, end_col_offset=24), BinOp(Call(Name('int', Load(), lineno=10, col_offset=26, end_lineno=10, end_col_offset=29), [Call(Attribute(Name('math', Load(), lineno=10, col_offset=30, end_lineno=10, end_col_offset=34), 'sqrt', Load(), lineno=10, col_offset=30, end_lineno=10, end_col_offset=39), [Name('placeholder_1', Load(), lineno=10, col_offset=40, end_lineno=10, end_col_offset=46)], [], lineno=10, col_offset=30, end_lineno=10, end_col_offset=47)], [], lineno=10, col_offset=26, end_lineno=10, end_col_offset=48), Add(), Constant(1, lineno=10, col_offset=51, end_lineno=10, end_col_offset=52), lineno=10, col_offset=26, end_lineno=10, end_col_offset=52)], [], lineno=10, col_offset=17, end_lineno=10, end_col_offset=53), [If(Compare(BinOp(Name('placeholder_1', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=17), Mod(), Name('placeholder_2', Load(), lineno=11, col_offset=20, end_lineno=11, end_col_offset=25), lineno=11, col_offset=11, end_lineno=11, end_col_offset=25), [Eq()], [Constant(0, lineno=11, col_offset=29, end_lineno=11, end_col_offset=30)], lineno=11, col_offset=11, end_lineno=11, end_col_offset=30), [Expr(Yield(Name('index', Load(), lineno=12, col_offset=18, end_lineno=12, end_col_offset=23), lineno=12, col_offset=12, end_lineno=12, end_col_offset=23), lineno=12, col_offset=12, end_lineno=12, end_col_offset=23), If(Compare(BinOp(Name('placeholder_2', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=20), Mult(), Name('placeholder_2', Load(), lineno=13, col_offset=23, end_lineno=13, end_col_offset=28), lineno=13, col_offset=15, end_lineno=13, end_col_offset=28), [NotEq()], [Name('placeholder_1', Load(), lineno=13, col_offset=32, end_lineno=13, end_col_offset=38)], lineno=13, col_offset=15, end_lineno=13, end_col_offset=38), [Expr(Yield(BinOp(Name('number', Load(), lineno=14, col_offset=22, end_lineno=14, end_col_offset=28), FloorDiv(), Name('index', Load(), lineno=14, col_offset=32, end_lineno=14, end_col_offset=37), lineno=14, col_offset=22, end_lineno=14, end_col_offset=37), lineno=14, col_offset=16, end_lineno=14, end_col_offset=37), lineno=14, col_offset=16, end_lineno=14, end_col_offset=37)], [], lineno=13, col_offset=12, end_lineno=14, end_col_offset=37)], [], lineno=11, col_offset=8, end_lineno=14, end_col_offset=37)], [], lineno=10, col_offset=4, end_lineno=14, end_col_offset=37)], [], lineno=3, col_offset=0, end_lineno=14, end_col_offset=37), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=17, col_offset=13, end_lineno=17, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_1', Load(), lineno=24, col_offset=7, end_lineno=24, end_col_offset=13), [LtE()], [Constant(0, lineno=24, col_offset=17, end_lineno=24, end_col_offset=18)], lineno=24, col_offset=7, end_lineno=24, end_col_offset=18), [Raise(Call(Name('ValueError', Load(), lineno=25, col_offset=14, end_lineno=25, end_col_offset=24), [Constant('Classification is only possible for positive integers.', lineno=25, col_offset=25, end_lineno=25, end_col_offset=81)], [], lineno=25, col_offset=14, end_lineno=25, end_col_offset=82), lineno=25, col_offset=8, end_lineno=25, end_col_offset=82)], [], lineno=24, col_offset=4, end_lineno=25, end_col_offset=82), Assign([Name('placeholder_4', Store(), lineno=27, col_offset=4, end_lineno=27, end_col_offset=15)], BinOp(Call(Name('sum', Load(), lineno=27, col_offset=18, end_lineno=27, end_col_offset=21), [Call(Name('placeholder_0', Load(), lineno=27, col_offset=22, end_lineno=27, end_col_offset=39), [Name('placeholder_1', Load(), lineno=27, col_offset=40, end_lineno=27, end_col_offset=46)], [], lineno=27, col_offset=22, end_lineno=27, end_col_offset=47)], [], lineno=27, col_offset=18, end_lineno=27, end_col_offset=48), Add(), IfExp(Compare(Name('placeholder_1', Load(), lineno=27, col_offset=57, end_lineno=27, end_col_offset=63), [Gt()], [Constant(1, lineno=27, col_offset=66, end_lineno=27, end_col_offset=67)], lineno=27, col_offset=57, end_lineno=27, end_col_offset=67), Constant(1, lineno=27, col_offset=52, end_lineno=27, end_col_offset=53), Constant(0, lineno=27, col_offset=73, end_lineno=27, end_col_offset=74), lineno=27, col_offset=52, end_lineno=27, end_col_offset=74), lineno=27, col_offset=18, end_lineno=27, end_col_offset=75), lineno=27, col_offset=4, end_lineno=27, end_col_offset=75), If(Compare(Name('placeholder_4', Load(), lineno=29, col_offset=7, end_lineno=29, end_col_offset=18), [Lt()], [Name('placeholder_1', Load(), lineno=29, col_offset=21, end_lineno=29, end_col_offset=27)], lineno=29, col_offset=7, end_lineno=29, end_col_offset=27), [Return(Constant('deficient', lineno=30, col_offset=15, end_lineno=30, end_col_offset=26), lineno=30, col_offset=8, end_lineno=30, end_col_offset=26)], [If(Compare(Name('placeholder_4', Load(), lineno=31, col_offset=9, end_lineno=31, end_col_offset=20), [Eq()], [Name('placeholder_1', Load(), lineno=31, col_offset=24, end_lineno=31, end_col_offset=30)], lineno=31, col_offset=9, end_lineno=31, end_col_offset=30), [Return(Constant('perfect', lineno=32, col_offset=15, end_lineno=32, end_col_offset=24), lineno=32, col_offset=8, end_lineno=32, end_col_offset=24)], [Return(Constant('abundant', lineno=34, col_offset=15, end_lineno=34, end_col_offset=25), lineno=34, col_offset=8, end_lineno=34, end_col_offset=25)], lineno=31, col_offset=4, end_lineno=34, end_col_offset=25)], lineno=29, col_offset=4, end_lineno=34, end_col_offset=25)], [], lineno=17, col_offset=0, end_lineno=34, end_col_offset=25)], []) \ No newline at end of file diff --git a/test/practice-phone-number/.meta/additional_tests.json b/test/practice-phone-number/.meta/additional_tests.json new file mode 100644 index 0000000..73fc9ab --- /dev/null +++ b/test/practice-phone-number/.meta/additional_tests.json @@ -0,0 +1,29 @@ +{ + "exercise": "phone-number", + "version": "1.7.0", + "cases": [{ + "description": "area code", + "property": "area_code", + "input": { + "phrase": "2234567890" + }, + "expected": "223" + }, + { + "description": "pretty print", + "property": "pretty", + "input": { + "phrase": "2234567890" + }, + "expected": "(223)-456-7890" + }, + { + "description": "pretty print with full US phone number", + "property": "pretty", + "input": { + "phrase": "12234567890" + }, + "expected": "(223)-456-7890" + } + ] +} diff --git a/test/practice-phone-number/.meta/config.json b/test/practice-phone-number/.meta/config.json new file mode 100644 index 0000000..f2fe78b --- /dev/null +++ b/test/practice-phone-number/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [], + "contributors": [ + "AnAccountForReportingBugs", + "behrtam", + "cmccandless", + "Dog", + "GascaK", + "ikhadykin", + "jeremystucki", + "kytrinyx", + "lowks", + "N-Parsons", + "pheanex", + "sjakobi", + "Sukhj1nder", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "phone_number.py" + ], + "test": [ + "phone_number_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Clean up user-entered phone numbers so that they can be sent SMS messages.", + "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", + "source_url": "https://turing.edu" +} diff --git a/test/practice-phone-number/mapping.json b/test/practice-phone-number/mapping.json new file mode 100644 index 0000000..db5b079 --- /dev/null +++ b/test/practice-phone-number/mapping.json @@ -0,0 +1,14 @@ +{ + "placeholder_0": "PhoneNumber", + "placeholder_1": "__init__", + "placeholder_2": "number", + "placeholder_3": "area_code", + "placeholder_4": "exchange_code", + "placeholder_5": "subscriber_number", + "placeholder_6": "pretty", + "placeholder_7": "_clean", + "placeholder_8": "preprocess", + "placeholder_9": "item", + "placeholder_10": "_normalize", + "placeholder_11": "valid" +} \ No newline at end of file diff --git a/test/practice-phone-number/phone_number.py b/test/practice-phone-number/phone_number.py new file mode 100644 index 0000000..d23102a --- /dev/null +++ b/test/practice-phone-number/phone_number.py @@ -0,0 +1,53 @@ +import re +from string import punctuation + + +class PhoneNumber: + def __init__(self, number): + self.number = self._clean(number) + self.area_code = self.number[:3] + self.exchange_code = self.number[3:6] + self.subscriber_number = self.number[-4:] + + def pretty(self): + return f'({self.area_code})-{self.exchange_code}-{self.subscriber_number}' + + def _clean(self, number): + preprocess = re.sub(r'[() +-.]', '', number) + + if any(item for item in preprocess if item.isalpha()): + raise ValueError('letters not permitted') + + if any(item for item in preprocess if item in punctuation): + raise ValueError('punctuations not permitted') + + return self._normalize(preprocess) + + def _normalize(self, number): + if len(number) < 10: + raise ValueError('must not be fewer than 10 digits') + + if len(number) > 11: + raise ValueError('must not be greater than 11 digits') + + if len(number) == 10 or len(number) == 11 and number.startswith('1'): + if number[-10] == '0': + raise ValueError('area code cannot start with zero') + elif number[-10] == '1': + raise ValueError('area code cannot start with one') + elif number[-7] == '0': + raise ValueError('exchange code cannot start with zero') + elif number[-7] == '1': + raise ValueError('exchange code cannot start with one') + else: + valid = number[-10] in '23456789' and number[-7] in '23456789' + + else: + valid = False + if number[0] in '023456789': + raise ValueError('11 digits must start with 1') + + if valid: + return number[-10:] + + return None # [Pylint]: R1710; diff --git a/test/practice-phone-number/representation.json b/test/practice-phone-number/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-phone-number/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-phone-number/representation.out b/test/practice-phone-number/representation.out new file mode 100644 index 0000000..b4668db --- /dev/null +++ b/test/practice-phone-number/representation.out @@ -0,0 +1,3066 @@ +## BEGIN NORMALIZED CODE ## +import re +from string import punctuation + + +class placeholder_0: + def placeholder_1(self, placeholder_2): + self.placeholder_2 = self._clean(placeholder_2) + self.placeholder_3 = self.placeholder_2[:3] + self.placeholder_4 = self.placeholder_2[3:6] + self.placeholder_5 = self.placeholder_2[-4:] + + def placeholder_6(self): + return f"({self.placeholder_3})-{self.placeholder_4}-{self.placeholder_5}" + + def placeholder_7(self, placeholder_2): + placeholder_8 = re.sub("[() +-.]", "", placeholder_2) + if any( + ( + placeholder_9 + for placeholder_9 in placeholder_8 + if placeholder_9.isalpha() + ) + ): + raise ValueError("letters not permitted") + if any( + ( + placeholder_9 + for placeholder_9 in placeholder_8 + if placeholder_9 in punctuation + ) + ): + raise ValueError("punctuations not permitted") + return self._normalize(placeholder_8) + + def placeholder_10(self, placeholder_2): + if len(placeholder_2) < 10: + raise ValueError("must not be fewer than 10 digits") + if len(placeholder_2) > 11: + raise ValueError("must not be greater than 11 digits") + if len(placeholder_2) == 10 or ( + len(placeholder_2) == 11 and placeholder_2.startswith("1") + ): + if placeholder_2[-10] == "0": + raise ValueError("area code cannot start with zero") + elif placeholder_2[-10] == "1": + raise ValueError("area code cannot start with one") + elif placeholder_2[-7] == "0": + raise ValueError("exchange code cannot start with zero") + elif placeholder_2[-7] == "1": + raise ValueError("exchange code cannot start with one") + else: + placeholder_11 = ( + placeholder_2[-10] in "23456789" and placeholder_2[-7] in "23456789" + ) + else: + placeholder_11 = False + if placeholder_2[0] in "023456789": + raise ValueError("11 digits must start with 1") + if placeholder_11: + return placeholder_2[-10:] + return None + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + ImportFrom( + 'string', + [ + alias( + 'punctuation', + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=30)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=30), + ClassDef( + 'PhoneNumber', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=21), + arg( + 'number', + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'number', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=19)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=26), + '_clean', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=33), + [ + Name( + 'number', + Load(), + lineno=7, + col_offset=34, + end_lineno=7, + end_col_offset=40)], + [], + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=41), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=41), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'area_code', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=29), + 'number', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=36), + Slice( + upper=Constant( + 3, + lineno=8, + col_offset=38, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=37, + end_lineno=8, + end_col_offset=39), + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=40), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'exchange_code', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=26)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=29, + end_lineno=9, + end_col_offset=33), + 'number', + Load(), + lineno=9, + col_offset=29, + end_lineno=9, + end_col_offset=40), + Slice( + Constant( + 3, + lineno=9, + col_offset=41, + end_lineno=9, + end_col_offset=42), + Constant( + 6, + lineno=9, + col_offset=43, + end_lineno=9, + end_col_offset=44), + lineno=9, + col_offset=41, + end_lineno=9, + end_col_offset=44), + Load(), + lineno=9, + col_offset=29, + end_lineno=9, + end_col_offset=45), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=45), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'subscriber_number', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=30)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=37), + 'number', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=44), + Slice( + UnaryOp( + USub(), + Constant( + 4, + lineno=10, + col_offset=46, + end_lineno=10, + end_col_offset=47), + lineno=10, + col_offset=45, + end_lineno=10, + end_col_offset=47), + lineno=10, + col_offset=45, + end_lineno=10, + end_col_offset=48), + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=49), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=49)], + [], + lineno=6, + col_offset=4, + end_lineno=10, + end_col_offset=49), + FunctionDef( + 'pretty', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + Constant( + '(', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=23), + 'area_code', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=33), + -1, + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + Constant( + ')-', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=37, + end_lineno=13, + end_col_offset=41), + 'exchange_code', + Load(), + lineno=13, + col_offset=37, + end_lineno=13, + end_col_offset=55), + -1, + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + Constant( + '-', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=62), + 'subscriber_number', + Load(), + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=80), + -1, + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82)], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=82)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=82), + FunctionDef( + '_clean', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + arg( + 'number', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'preprocess', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=23), + 'sub', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=27), + [ + Constant( + '[() +-.]', + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=39), + Constant( + '', + lineno=16, + col_offset=41, + end_lineno=16, + end_col_offset=43), + Name( + 'number', + Load(), + lineno=16, + col_offset=45, + end_lineno=16, + end_col_offset=51)], + [], + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=52), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=52), + If( + Call( + Name( + 'any', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=14), + [ + GeneratorExp( + Name( + 'item', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + [ + comprehension( + Name( + 'item', + Store(), + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=28), + Name( + 'preprocess', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=42), + [ + Call( + Attribute( + Name( + 'item', + Load(), + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=50), + 'isalpha', + Load(), + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=58), + [], + [], + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=60)], + 0)], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=61)], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=61), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=28), + [ + Constant( + 'letters not permitted', + lineno=19, + col_offset=29, + end_lineno=19, + end_col_offset=52)], + [], + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=53), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=53)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=53), + If( + Call( + Name( + 'any', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=14), + [ + GeneratorExp( + Name( + 'item', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + [ + comprehension( + Name( + 'item', + Store(), + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=28), + Name( + 'preprocess', + Load(), + lineno=21, + col_offset=32, + end_lineno=21, + end_col_offset=42), + [ + Compare( + Name( + 'item', + Load(), + lineno=21, + col_offset=46, + end_lineno=21, + end_col_offset=50), + [ + In()], + [ + Name( + 'punctuation', + Load(), + lineno=21, + col_offset=54, + end_lineno=21, + end_col_offset=65)], + lineno=21, + col_offset=46, + end_lineno=21, + end_col_offset=65)], + 0)], + lineno=21, + col_offset=14, + end_lineno=21, + end_col_offset=66)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=66), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=28), + [ + Constant( + 'punctuations not permitted', + lineno=22, + col_offset=29, + end_lineno=22, + end_col_offset=57)], + [], + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=58), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=58)], + [], + lineno=21, + col_offset=8, + end_lineno=22, + end_col_offset=58), + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=19), + '_normalize', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=30), + [ + Name( + 'preprocess', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=41)], + [], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=42), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=42)], + [], + lineno=15, + col_offset=4, + end_lineno=24, + end_col_offset=42), + FunctionDef( + '_normalize', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=23), + arg( + 'number', + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=14), + [ + Name( + 'number', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=21)], + [], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=22), + [ + Lt()], + [ + Constant( + 10, + lineno=27, + col_offset=25, + end_lineno=27, + end_col_offset=27)], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=28), + [ + Constant( + 'must not be fewer than 10 digits', + lineno=28, + col_offset=29, + end_lineno=28, + end_col_offset=63)], + [], + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=64), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=64)], + [], + lineno=27, + col_offset=8, + end_lineno=28, + end_col_offset=64), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=14), + [ + Name( + 'number', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=21)], + [], + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=22), + [ + Gt()], + [ + Constant( + 11, + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=27)], + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=28), + [ + Constant( + 'must not be greater than 11 digits', + lineno=31, + col_offset=29, + end_lineno=31, + end_col_offset=65)], + [], + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=66), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=66)], + [], + lineno=30, + col_offset=8, + end_lineno=31, + end_col_offset=66), + If( + BoolOp( + Or(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=14), + [ + Name( + 'number', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=21)], + [], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 10, + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=28)], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=28), + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=35), + [ + Name( + 'number', + Load(), + lineno=33, + col_offset=36, + end_lineno=33, + end_col_offset=42)], + [], + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=43), + [ + Eq()], + [ + Constant( + 11, + lineno=33, + col_offset=47, + end_lineno=33, + end_col_offset=49)], + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=49), + Call( + Attribute( + Name( + 'number', + Load(), + lineno=33, + col_offset=54, + end_lineno=33, + end_col_offset=60), + 'startswith', + Load(), + lineno=33, + col_offset=54, + end_lineno=33, + end_col_offset=71), + [ + Constant( + '1', + lineno=33, + col_offset=72, + end_lineno=33, + end_col_offset=75)], + [], + lineno=33, + col_offset=54, + end_lineno=33, + end_col_offset=76)], + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=76)], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=76), + [ + If( + Compare( + Subscript( + Name( + 'number', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=21), + UnaryOp( + USub(), + Constant( + 10, + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=25), + lineno=34, + col_offset=22, + end_lineno=34, + end_col_offset=25), + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=26), + [ + Eq()], + [ + Constant( + '0', + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=33)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=32), + [ + Constant( + 'area code cannot start with zero', + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=67)], + [], + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=68), + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=68)], + [ + If( + Compare( + Subscript( + Name( + 'number', + Load(), + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=23), + UnaryOp( + USub(), + Constant( + 10, + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=27), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=27), + Load(), + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=28), + [ + Eq()], + [ + Constant( + '1', + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=35)], + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=35), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=32), + [ + Constant( + 'area code cannot start with one', + lineno=37, + col_offset=33, + end_lineno=37, + end_col_offset=66)], + [], + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=67), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=67)], + [ + If( + Compare( + Subscript( + Name( + 'number', + Load(), + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=23), + UnaryOp( + USub(), + Constant( + 7, + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=26), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=26), + Load(), + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=27), + [ + Eq()], + [ + Constant( + '0', + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=34)], + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=34), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=39, + col_offset=22, + end_lineno=39, + end_col_offset=32), + [ + Constant( + 'exchange code cannot start with zero', + lineno=39, + col_offset=33, + end_lineno=39, + end_col_offset=71)], + [], + lineno=39, + col_offset=22, + end_lineno=39, + end_col_offset=72), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=72)], + [ + If( + Compare( + Subscript( + Name( + 'number', + Load(), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=23), + UnaryOp( + USub(), + Constant( + 7, + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=26), + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=26), + Load(), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=27), + [ + Eq()], + [ + Constant( + '1', + lineno=40, + col_offset=31, + end_lineno=40, + end_col_offset=34)], + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=34), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=32), + [ + Constant( + 'exchange code cannot start with one', + lineno=41, + col_offset=33, + end_lineno=41, + end_col_offset=70)], + [], + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=71), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=71)], + [ + Assign( + [ + Name( + 'valid', + Store(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=21)], + BoolOp( + And(), + [ + Compare( + Subscript( + Name( + 'number', + Load(), + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=30), + UnaryOp( + USub(), + Constant( + 10, + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=34), + lineno=43, + col_offset=31, + end_lineno=43, + end_col_offset=34), + Load(), + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=35), + [ + In()], + [ + Constant( + '23456789', + lineno=43, + col_offset=39, + end_lineno=43, + end_col_offset=49)], + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=49), + Compare( + Subscript( + Name( + 'number', + Load(), + lineno=43, + col_offset=54, + end_lineno=43, + end_col_offset=60), + UnaryOp( + USub(), + Constant( + 7, + lineno=43, + col_offset=62, + end_lineno=43, + end_col_offset=63), + lineno=43, + col_offset=61, + end_lineno=43, + end_col_offset=63), + Load(), + lineno=43, + col_offset=54, + end_lineno=43, + end_col_offset=64), + [ + In()], + [ + Constant( + '23456789', + lineno=43, + col_offset=68, + end_lineno=43, + end_col_offset=78)], + lineno=43, + col_offset=54, + end_lineno=43, + end_col_offset=78)], + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=78), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=78)], + lineno=40, + col_offset=12, + end_lineno=43, + end_col_offset=78)], + lineno=38, + col_offset=12, + end_lineno=43, + end_col_offset=78)], + lineno=36, + col_offset=12, + end_lineno=43, + end_col_offset=78)], + lineno=34, + col_offset=12, + end_lineno=43, + end_col_offset=78)], + [ + Assign( + [ + Name( + 'valid', + Store(), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=17)], + Constant( + False, + lineno=46, + col_offset=20, + end_lineno=46, + end_col_offset=25), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=25), + If( + Compare( + Subscript( + Name( + 'number', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=21), + Constant( + 0, + lineno=47, + col_offset=22, + end_lineno=47, + end_col_offset=23), + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=24), + [ + In()], + [ + Constant( + '023456789', + lineno=47, + col_offset=28, + end_lineno=47, + end_col_offset=39)], + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=39), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=32), + [ + Constant( + '11 digits must start with 1', + lineno=48, + col_offset=33, + end_lineno=48, + end_col_offset=62)], + [], + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=63), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=63)], + [], + lineno=47, + col_offset=12, + end_lineno=48, + end_col_offset=63)], + lineno=33, + col_offset=8, + end_lineno=48, + end_col_offset=63), + If( + Name( + 'valid', + Load(), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=16), + [ + Return( + Subscript( + Name( + 'number', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=25), + Slice( + UnaryOp( + USub(), + Constant( + 10, + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=29), + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=29), + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=30), + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=31), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=31)], + [], + lineno=50, + col_offset=8, + end_lineno=51, + end_col_offset=31), + Return( + Constant( + None, + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=19), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=19)], + [], + lineno=26, + col_offset=4, + end_lineno=53, + end_col_offset=19)], + [], + lineno=5, + col_offset=0, + end_lineno=53, + end_col_offset=19)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + ImportFrom( + 'string', + [ + alias( + 'punctuation', + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=30)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=30), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=19)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=26), + '_clean', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=33), + [ + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=34, + end_lineno=7, + end_col_offset=40)], + [], + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=41), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=41), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=29), + 'placeholder_2', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=36), + Slice( + upper=Constant( + 3, + lineno=8, + col_offset=38, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=37, + end_lineno=8, + end_col_offset=39), + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=40), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=26)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=29, + end_lineno=9, + end_col_offset=33), + 'placeholder_2', + Load(), + lineno=9, + col_offset=29, + end_lineno=9, + end_col_offset=40), + Slice( + Constant( + 3, + lineno=9, + col_offset=41, + end_lineno=9, + end_col_offset=42), + Constant( + 6, + lineno=9, + col_offset=43, + end_lineno=9, + end_col_offset=44), + lineno=9, + col_offset=41, + end_lineno=9, + end_col_offset=44), + Load(), + lineno=9, + col_offset=29, + end_lineno=9, + end_col_offset=45), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=45), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=30)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=37), + 'placeholder_2', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=44), + Slice( + UnaryOp( + USub(), + Constant( + 4, + lineno=10, + col_offset=46, + end_lineno=10, + end_col_offset=47), + lineno=10, + col_offset=45, + end_lineno=10, + end_col_offset=47), + lineno=10, + col_offset=45, + end_lineno=10, + end_col_offset=48), + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=49), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=49)], + [], + lineno=6, + col_offset=4, + end_lineno=10, + end_col_offset=49), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + Constant( + '(', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=23), + 'placeholder_3', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=33), + -1, + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + Constant( + ')-', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=37, + end_lineno=13, + end_col_offset=41), + 'placeholder_4', + Load(), + lineno=13, + col_offset=37, + end_lineno=13, + end_col_offset=55), + -1, + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + Constant( + '-', + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=62), + 'placeholder_5', + Load(), + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=80), + -1, + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82)], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=82), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=82)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=82), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + arg( + 'placeholder_2', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=23), + 'sub', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=27), + [ + Constant( + '[() +-.]', + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=39), + Constant( + '', + lineno=16, + col_offset=41, + end_lineno=16, + end_col_offset=43), + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=45, + end_lineno=16, + end_col_offset=51)], + [], + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=52), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=52), + If( + Call( + Name( + 'any', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=14), + [ + GeneratorExp( + Name( + 'placeholder_9', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + [ + comprehension( + Name( + 'placeholder_9', + Store(), + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=28), + Name( + 'placeholder_8', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=42), + [ + Call( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=50), + 'isalpha', + Load(), + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=58), + [], + [], + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=60)], + 0)], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=61)], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=61), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=28), + [ + Constant( + 'letters not permitted', + lineno=19, + col_offset=29, + end_lineno=19, + end_col_offset=52)], + [], + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=53), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=53)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=53), + If( + Call( + Name( + 'any', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=14), + [ + GeneratorExp( + Name( + 'placeholder_9', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + [ + comprehension( + Name( + 'placeholder_9', + Store(), + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=28), + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=32, + end_lineno=21, + end_col_offset=42), + [ + Compare( + Name( + 'placeholder_9', + Load(), + lineno=21, + col_offset=46, + end_lineno=21, + end_col_offset=50), + [ + In()], + [ + Name( + 'punctuation', + Load(), + lineno=21, + col_offset=54, + end_lineno=21, + end_col_offset=65)], + lineno=21, + col_offset=46, + end_lineno=21, + end_col_offset=65)], + 0)], + lineno=21, + col_offset=14, + end_lineno=21, + end_col_offset=66)], + [], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=66), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=28), + [ + Constant( + 'punctuations not permitted', + lineno=22, + col_offset=29, + end_lineno=22, + end_col_offset=57)], + [], + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=58), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=58)], + [], + lineno=21, + col_offset=8, + end_lineno=22, + end_col_offset=58), + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=19), + '_normalize', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=30), + [ + Name( + 'placeholder_8', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=41)], + [], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=42), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=42)], + [], + lineno=15, + col_offset=4, + end_lineno=24, + end_col_offset=42), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=23), + arg( + 'placeholder_2', + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=14), + [ + Name( + 'placeholder_2', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=21)], + [], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=22), + [ + Lt()], + [ + Constant( + 10, + lineno=27, + col_offset=25, + end_lineno=27, + end_col_offset=27)], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=28), + [ + Constant( + 'must not be fewer than 10 digits', + lineno=28, + col_offset=29, + end_lineno=28, + end_col_offset=63)], + [], + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=64), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=64)], + [], + lineno=27, + col_offset=8, + end_lineno=28, + end_col_offset=64), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=14), + [ + Name( + 'placeholder_2', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=21)], + [], + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=22), + [ + Gt()], + [ + Constant( + 11, + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=27)], + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=27), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=28), + [ + Constant( + 'must not be greater than 11 digits', + lineno=31, + col_offset=29, + end_lineno=31, + end_col_offset=65)], + [], + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=66), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=66)], + [], + lineno=30, + col_offset=8, + end_lineno=31, + end_col_offset=66), + If( + BoolOp( + Or(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=14), + [ + Name( + 'placeholder_2', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=21)], + [], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 10, + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=28)], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=28), + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=35), + [ + Name( + 'placeholder_2', + Load(), + lineno=33, + col_offset=36, + end_lineno=33, + end_col_offset=42)], + [], + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=43), + [ + Eq()], + [ + Constant( + 11, + lineno=33, + col_offset=47, + end_lineno=33, + end_col_offset=49)], + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=49), + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=33, + col_offset=54, + end_lineno=33, + end_col_offset=60), + 'startswith', + Load(), + lineno=33, + col_offset=54, + end_lineno=33, + end_col_offset=71), + [ + Constant( + '1', + lineno=33, + col_offset=72, + end_lineno=33, + end_col_offset=75)], + [], + lineno=33, + col_offset=54, + end_lineno=33, + end_col_offset=76)], + lineno=33, + col_offset=32, + end_lineno=33, + end_col_offset=76)], + lineno=33, + col_offset=11, + end_lineno=33, + end_col_offset=76), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=21), + UnaryOp( + USub(), + Constant( + 10, + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=25), + lineno=34, + col_offset=22, + end_lineno=34, + end_col_offset=25), + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=26), + [ + Eq()], + [ + Constant( + '0', + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=33)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=33), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=32), + [ + Constant( + 'area code cannot start with zero', + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=67)], + [], + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=68), + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=68)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=23), + UnaryOp( + USub(), + Constant( + 10, + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=27), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=27), + Load(), + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=28), + [ + Eq()], + [ + Constant( + '1', + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=35)], + lineno=36, + col_offset=17, + end_lineno=36, + end_col_offset=35), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=32), + [ + Constant( + 'area code cannot start with one', + lineno=37, + col_offset=33, + end_lineno=37, + end_col_offset=66)], + [], + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=67), + lineno=37, + col_offset=16, + end_lineno=37, + end_col_offset=67)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=23), + UnaryOp( + USub(), + Constant( + 7, + lineno=38, + col_offset=25, + end_lineno=38, + end_col_offset=26), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=26), + Load(), + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=27), + [ + Eq()], + [ + Constant( + '0', + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=34)], + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=34), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=39, + col_offset=22, + end_lineno=39, + end_col_offset=32), + [ + Constant( + 'exchange code cannot start with zero', + lineno=39, + col_offset=33, + end_lineno=39, + end_col_offset=71)], + [], + lineno=39, + col_offset=22, + end_lineno=39, + end_col_offset=72), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=72)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=23), + UnaryOp( + USub(), + Constant( + 7, + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=26), + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=26), + Load(), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=27), + [ + Eq()], + [ + Constant( + '1', + lineno=40, + col_offset=31, + end_lineno=40, + end_col_offset=34)], + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=34), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=32), + [ + Constant( + 'exchange code cannot start with one', + lineno=41, + col_offset=33, + end_lineno=41, + end_col_offset=70)], + [], + lineno=41, + col_offset=22, + end_lineno=41, + end_col_offset=71), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=71)], + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=21)], + BoolOp( + And(), + [ + Compare( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=30), + UnaryOp( + USub(), + Constant( + 10, + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=34), + lineno=43, + col_offset=31, + end_lineno=43, + end_col_offset=34), + Load(), + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=35), + [ + In()], + [ + Constant( + '23456789', + lineno=43, + col_offset=39, + end_lineno=43, + end_col_offset=49)], + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=49), + Compare( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=43, + col_offset=54, + end_lineno=43, + end_col_offset=60), + UnaryOp( + USub(), + Constant( + 7, + lineno=43, + col_offset=62, + end_lineno=43, + end_col_offset=63), + lineno=43, + col_offset=61, + end_lineno=43, + end_col_offset=63), + Load(), + lineno=43, + col_offset=54, + end_lineno=43, + end_col_offset=64), + [ + In()], + [ + Constant( + '23456789', + lineno=43, + col_offset=68, + end_lineno=43, + end_col_offset=78)], + lineno=43, + col_offset=54, + end_lineno=43, + end_col_offset=78)], + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=78), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=78)], + lineno=40, + col_offset=12, + end_lineno=43, + end_col_offset=78)], + lineno=38, + col_offset=12, + end_lineno=43, + end_col_offset=78)], + lineno=36, + col_offset=12, + end_lineno=43, + end_col_offset=78)], + lineno=34, + col_offset=12, + end_lineno=43, + end_col_offset=78)], + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=17)], + Constant( + False, + lineno=46, + col_offset=20, + end_lineno=46, + end_col_offset=25), + lineno=46, + col_offset=12, + end_lineno=46, + end_col_offset=25), + If( + Compare( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=21), + Constant( + 0, + lineno=47, + col_offset=22, + end_lineno=47, + end_col_offset=23), + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=24), + [ + In()], + [ + Constant( + '023456789', + lineno=47, + col_offset=28, + end_lineno=47, + end_col_offset=39)], + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=39), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=32), + [ + Constant( + '11 digits must start with 1', + lineno=48, + col_offset=33, + end_lineno=48, + end_col_offset=62)], + [], + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=63), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=63)], + [], + lineno=47, + col_offset=12, + end_lineno=48, + end_col_offset=63)], + lineno=33, + col_offset=8, + end_lineno=48, + end_col_offset=63), + If( + Name( + 'placeholder_11', + Load(), + lineno=50, + col_offset=11, + end_lineno=50, + end_col_offset=16), + [ + Return( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=25), + Slice( + UnaryOp( + USub(), + Constant( + 10, + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=29), + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=29), + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=30), + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=31), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=31)], + [], + lineno=50, + col_offset=8, + end_lineno=51, + end_col_offset=31), + Return( + Constant( + None, + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=19), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=19)], + [], + lineno=26, + col_offset=4, + end_lineno=53, + end_col_offset=19)], + [], + lineno=5, + col_offset=0, + end_lineno=53, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-phone-number/representation.txt b/test/practice-phone-number/representation.txt new file mode 100644 index 0000000..779dba5 --- /dev/null +++ b/test/practice-phone-number/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('re', lineno=1, col_offset=7, end_lineno=1, end_col_offset=9)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=9), ImportFrom('string', [alias('punctuation', lineno=2, col_offset=19, end_lineno=2, end_col_offset=30)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=30), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=6, col_offset=17, end_lineno=6, end_col_offset=21), arg('placeholder_2', lineno=6, col_offset=23, end_lineno=6, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_2', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=19)], Call(Attribute(Name('self', Load(), lineno=7, col_offset=22, end_lineno=7, end_col_offset=26), '_clean', Load(), lineno=7, col_offset=22, end_lineno=7, end_col_offset=33), [Name('placeholder_2', Load(), lineno=7, col_offset=34, end_lineno=7, end_col_offset=40)], [], lineno=7, col_offset=22, end_lineno=7, end_col_offset=41), lineno=7, col_offset=8, end_lineno=7, end_col_offset=41), Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_3', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=22)], Subscript(Attribute(Name('self', Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=29), 'placeholder_2', Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=36), Slice(upper=Constant(3, lineno=8, col_offset=38, end_lineno=8, end_col_offset=39), lineno=8, col_offset=37, end_lineno=8, end_col_offset=39), Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=40), lineno=8, col_offset=8, end_lineno=8, end_col_offset=40), Assign([Attribute(Name('self', Load(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), 'placeholder_4', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=26)], Subscript(Attribute(Name('self', Load(), lineno=9, col_offset=29, end_lineno=9, end_col_offset=33), 'placeholder_2', Load(), lineno=9, col_offset=29, end_lineno=9, end_col_offset=40), Slice(Constant(3, lineno=9, col_offset=41, end_lineno=9, end_col_offset=42), Constant(6, lineno=9, col_offset=43, end_lineno=9, end_col_offset=44), lineno=9, col_offset=41, end_lineno=9, end_col_offset=44), Load(), lineno=9, col_offset=29, end_lineno=9, end_col_offset=45), lineno=9, col_offset=8, end_lineno=9, end_col_offset=45), Assign([Attribute(Name('self', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=12), 'placeholder_5', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=30)], Subscript(Attribute(Name('self', Load(), lineno=10, col_offset=33, end_lineno=10, end_col_offset=37), 'placeholder_2', Load(), lineno=10, col_offset=33, end_lineno=10, end_col_offset=44), Slice(UnaryOp(USub(), Constant(4, lineno=10, col_offset=46, end_lineno=10, end_col_offset=47), lineno=10, col_offset=45, end_lineno=10, end_col_offset=47), lineno=10, col_offset=45, end_lineno=10, end_col_offset=48), Load(), lineno=10, col_offset=33, end_lineno=10, end_col_offset=49), lineno=10, col_offset=8, end_lineno=10, end_col_offset=49)], [], lineno=6, col_offset=4, end_lineno=10, end_col_offset=49), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=12, col_offset=15, end_lineno=12, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(JoinedStr([Constant('(', lineno=13, col_offset=15, end_lineno=13, end_col_offset=82), FormattedValue(Attribute(Name('self', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=23), 'placeholder_3', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=33), -1, lineno=13, col_offset=15, end_lineno=13, end_col_offset=82), Constant(')-', lineno=13, col_offset=15, end_lineno=13, end_col_offset=82), FormattedValue(Attribute(Name('self', Load(), lineno=13, col_offset=37, end_lineno=13, end_col_offset=41), 'placeholder_4', Load(), lineno=13, col_offset=37, end_lineno=13, end_col_offset=55), -1, lineno=13, col_offset=15, end_lineno=13, end_col_offset=82), Constant('-', lineno=13, col_offset=15, end_lineno=13, end_col_offset=82), FormattedValue(Attribute(Name('self', Load(), lineno=13, col_offset=58, end_lineno=13, end_col_offset=62), 'placeholder_5', Load(), lineno=13, col_offset=58, end_lineno=13, end_col_offset=80), -1, lineno=13, col_offset=15, end_lineno=13, end_col_offset=82)], lineno=13, col_offset=15, end_lineno=13, end_col_offset=82), lineno=13, col_offset=8, end_lineno=13, end_col_offset=82)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=82), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), arg('placeholder_2', lineno=15, col_offset=21, end_lineno=15, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=18)], Call(Attribute(Name('re', Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=23), 'sub', Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=27), [Constant('[() +-.]', lineno=16, col_offset=28, end_lineno=16, end_col_offset=39), Constant('', lineno=16, col_offset=41, end_lineno=16, end_col_offset=43), Name('placeholder_2', Load(), lineno=16, col_offset=45, end_lineno=16, end_col_offset=51)], [], lineno=16, col_offset=21, end_lineno=16, end_col_offset=52), lineno=16, col_offset=8, end_lineno=16, end_col_offset=52), If(Call(Name('any', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=14), [GeneratorExp(Name('placeholder_9', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=19), [comprehension(Name('placeholder_9', Store(), lineno=18, col_offset=24, end_lineno=18, end_col_offset=28), Name('placeholder_8', Load(), lineno=18, col_offset=32, end_lineno=18, end_col_offset=42), [Call(Attribute(Name('placeholder_9', Load(), lineno=18, col_offset=46, end_lineno=18, end_col_offset=50), 'isalpha', Load(), lineno=18, col_offset=46, end_lineno=18, end_col_offset=58), [], [], lineno=18, col_offset=46, end_lineno=18, end_col_offset=60)], 0)], lineno=18, col_offset=14, end_lineno=18, end_col_offset=61)], [], lineno=18, col_offset=11, end_lineno=18, end_col_offset=61), [Raise(Call(Name('ValueError', Load(), lineno=19, col_offset=18, end_lineno=19, end_col_offset=28), [Constant('letters not permitted', lineno=19, col_offset=29, end_lineno=19, end_col_offset=52)], [], lineno=19, col_offset=18, end_lineno=19, end_col_offset=53), lineno=19, col_offset=12, end_lineno=19, end_col_offset=53)], [], lineno=18, col_offset=8, end_lineno=19, end_col_offset=53), If(Call(Name('any', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=14), [GeneratorExp(Name('placeholder_9', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=19), [comprehension(Name('placeholder_9', Store(), lineno=21, col_offset=24, end_lineno=21, end_col_offset=28), Name('placeholder_8', Load(), lineno=21, col_offset=32, end_lineno=21, end_col_offset=42), [Compare(Name('placeholder_9', Load(), lineno=21, col_offset=46, end_lineno=21, end_col_offset=50), [In()], [Name('punctuation', Load(), lineno=21, col_offset=54, end_lineno=21, end_col_offset=65)], lineno=21, col_offset=46, end_lineno=21, end_col_offset=65)], 0)], lineno=21, col_offset=14, end_lineno=21, end_col_offset=66)], [], lineno=21, col_offset=11, end_lineno=21, end_col_offset=66), [Raise(Call(Name('ValueError', Load(), lineno=22, col_offset=18, end_lineno=22, end_col_offset=28), [Constant('punctuations not permitted', lineno=22, col_offset=29, end_lineno=22, end_col_offset=57)], [], lineno=22, col_offset=18, end_lineno=22, end_col_offset=58), lineno=22, col_offset=12, end_lineno=22, end_col_offset=58)], [], lineno=21, col_offset=8, end_lineno=22, end_col_offset=58), Return(Call(Attribute(Name('self', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=19), '_normalize', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=30), [Name('placeholder_8', Load(), lineno=24, col_offset=31, end_lineno=24, end_col_offset=41)], [], lineno=24, col_offset=15, end_lineno=24, end_col_offset=42), lineno=24, col_offset=8, end_lineno=24, end_col_offset=42)], [], lineno=15, col_offset=4, end_lineno=24, end_col_offset=42), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=26, col_offset=19, end_lineno=26, end_col_offset=23), arg('placeholder_2', lineno=26, col_offset=25, end_lineno=26, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=14), [Name('placeholder_2', Load(), lineno=27, col_offset=15, end_lineno=27, end_col_offset=21)], [], lineno=27, col_offset=11, end_lineno=27, end_col_offset=22), [Lt()], [Constant(10, lineno=27, col_offset=25, end_lineno=27, end_col_offset=27)], lineno=27, col_offset=11, end_lineno=27, end_col_offset=27), [Raise(Call(Name('ValueError', Load(), lineno=28, col_offset=18, end_lineno=28, end_col_offset=28), [Constant('must not be fewer than 10 digits', lineno=28, col_offset=29, end_lineno=28, end_col_offset=63)], [], lineno=28, col_offset=18, end_lineno=28, end_col_offset=64), lineno=28, col_offset=12, end_lineno=28, end_col_offset=64)], [], lineno=27, col_offset=8, end_lineno=28, end_col_offset=64), If(Compare(Call(Name('len', Load(), lineno=30, col_offset=11, end_lineno=30, end_col_offset=14), [Name('placeholder_2', Load(), lineno=30, col_offset=15, end_lineno=30, end_col_offset=21)], [], lineno=30, col_offset=11, end_lineno=30, end_col_offset=22), [Gt()], [Constant(11, lineno=30, col_offset=25, end_lineno=30, end_col_offset=27)], lineno=30, col_offset=11, end_lineno=30, end_col_offset=27), [Raise(Call(Name('ValueError', Load(), lineno=31, col_offset=18, end_lineno=31, end_col_offset=28), [Constant('must not be greater than 11 digits', lineno=31, col_offset=29, end_lineno=31, end_col_offset=65)], [], lineno=31, col_offset=18, end_lineno=31, end_col_offset=66), lineno=31, col_offset=12, end_lineno=31, end_col_offset=66)], [], lineno=30, col_offset=8, end_lineno=31, end_col_offset=66), If(BoolOp(Or(), [Compare(Call(Name('len', Load(), lineno=33, col_offset=11, end_lineno=33, end_col_offset=14), [Name('placeholder_2', Load(), lineno=33, col_offset=15, end_lineno=33, end_col_offset=21)], [], lineno=33, col_offset=11, end_lineno=33, end_col_offset=22), [Eq()], [Constant(10, lineno=33, col_offset=26, end_lineno=33, end_col_offset=28)], lineno=33, col_offset=11, end_lineno=33, end_col_offset=28), BoolOp(And(), [Compare(Call(Name('len', Load(), lineno=33, col_offset=32, end_lineno=33, end_col_offset=35), [Name('placeholder_2', Load(), lineno=33, col_offset=36, end_lineno=33, end_col_offset=42)], [], lineno=33, col_offset=32, end_lineno=33, end_col_offset=43), [Eq()], [Constant(11, lineno=33, col_offset=47, end_lineno=33, end_col_offset=49)], lineno=33, col_offset=32, end_lineno=33, end_col_offset=49), Call(Attribute(Name('placeholder_2', Load(), lineno=33, col_offset=54, end_lineno=33, end_col_offset=60), 'startswith', Load(), lineno=33, col_offset=54, end_lineno=33, end_col_offset=71), [Constant('1', lineno=33, col_offset=72, end_lineno=33, end_col_offset=75)], [], lineno=33, col_offset=54, end_lineno=33, end_col_offset=76)], lineno=33, col_offset=32, end_lineno=33, end_col_offset=76)], lineno=33, col_offset=11, end_lineno=33, end_col_offset=76), [If(Compare(Subscript(Name('placeholder_2', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=21), UnaryOp(USub(), Constant(10, lineno=34, col_offset=23, end_lineno=34, end_col_offset=25), lineno=34, col_offset=22, end_lineno=34, end_col_offset=25), Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=26), [Eq()], [Constant('0', lineno=34, col_offset=30, end_lineno=34, end_col_offset=33)], lineno=34, col_offset=15, end_lineno=34, end_col_offset=33), [Raise(Call(Name('ValueError', Load(), lineno=35, col_offset=22, end_lineno=35, end_col_offset=32), [Constant('area code cannot start with zero', lineno=35, col_offset=33, end_lineno=35, end_col_offset=67)], [], lineno=35, col_offset=22, end_lineno=35, end_col_offset=68), lineno=35, col_offset=16, end_lineno=35, end_col_offset=68)], [If(Compare(Subscript(Name('placeholder_2', Load(), lineno=36, col_offset=17, end_lineno=36, end_col_offset=23), UnaryOp(USub(), Constant(10, lineno=36, col_offset=25, end_lineno=36, end_col_offset=27), lineno=36, col_offset=24, end_lineno=36, end_col_offset=27), Load(), lineno=36, col_offset=17, end_lineno=36, end_col_offset=28), [Eq()], [Constant('1', lineno=36, col_offset=32, end_lineno=36, end_col_offset=35)], lineno=36, col_offset=17, end_lineno=36, end_col_offset=35), [Raise(Call(Name('ValueError', Load(), lineno=37, col_offset=22, end_lineno=37, end_col_offset=32), [Constant('area code cannot start with one', lineno=37, col_offset=33, end_lineno=37, end_col_offset=66)], [], lineno=37, col_offset=22, end_lineno=37, end_col_offset=67), lineno=37, col_offset=16, end_lineno=37, end_col_offset=67)], [If(Compare(Subscript(Name('placeholder_2', Load(), lineno=38, col_offset=17, end_lineno=38, end_col_offset=23), UnaryOp(USub(), Constant(7, lineno=38, col_offset=25, end_lineno=38, end_col_offset=26), lineno=38, col_offset=24, end_lineno=38, end_col_offset=26), Load(), lineno=38, col_offset=17, end_lineno=38, end_col_offset=27), [Eq()], [Constant('0', lineno=38, col_offset=31, end_lineno=38, end_col_offset=34)], lineno=38, col_offset=17, end_lineno=38, end_col_offset=34), [Raise(Call(Name('ValueError', Load(), lineno=39, col_offset=22, end_lineno=39, end_col_offset=32), [Constant('exchange code cannot start with zero', lineno=39, col_offset=33, end_lineno=39, end_col_offset=71)], [], lineno=39, col_offset=22, end_lineno=39, end_col_offset=72), lineno=39, col_offset=16, end_lineno=39, end_col_offset=72)], [If(Compare(Subscript(Name('placeholder_2', Load(), lineno=40, col_offset=17, end_lineno=40, end_col_offset=23), UnaryOp(USub(), Constant(7, lineno=40, col_offset=25, end_lineno=40, end_col_offset=26), lineno=40, col_offset=24, end_lineno=40, end_col_offset=26), Load(), lineno=40, col_offset=17, end_lineno=40, end_col_offset=27), [Eq()], [Constant('1', lineno=40, col_offset=31, end_lineno=40, end_col_offset=34)], lineno=40, col_offset=17, end_lineno=40, end_col_offset=34), [Raise(Call(Name('ValueError', Load(), lineno=41, col_offset=22, end_lineno=41, end_col_offset=32), [Constant('exchange code cannot start with one', lineno=41, col_offset=33, end_lineno=41, end_col_offset=70)], [], lineno=41, col_offset=22, end_lineno=41, end_col_offset=71), lineno=41, col_offset=16, end_lineno=41, end_col_offset=71)], [Assign([Name('placeholder_11', Store(), lineno=43, col_offset=16, end_lineno=43, end_col_offset=21)], BoolOp(And(), [Compare(Subscript(Name('placeholder_2', Load(), lineno=43, col_offset=24, end_lineno=43, end_col_offset=30), UnaryOp(USub(), Constant(10, lineno=43, col_offset=32, end_lineno=43, end_col_offset=34), lineno=43, col_offset=31, end_lineno=43, end_col_offset=34), Load(), lineno=43, col_offset=24, end_lineno=43, end_col_offset=35), [In()], [Constant('23456789', lineno=43, col_offset=39, end_lineno=43, end_col_offset=49)], lineno=43, col_offset=24, end_lineno=43, end_col_offset=49), Compare(Subscript(Name('placeholder_2', Load(), lineno=43, col_offset=54, end_lineno=43, end_col_offset=60), UnaryOp(USub(), Constant(7, lineno=43, col_offset=62, end_lineno=43, end_col_offset=63), lineno=43, col_offset=61, end_lineno=43, end_col_offset=63), Load(), lineno=43, col_offset=54, end_lineno=43, end_col_offset=64), [In()], [Constant('23456789', lineno=43, col_offset=68, end_lineno=43, end_col_offset=78)], lineno=43, col_offset=54, end_lineno=43, end_col_offset=78)], lineno=43, col_offset=24, end_lineno=43, end_col_offset=78), lineno=43, col_offset=16, end_lineno=43, end_col_offset=78)], lineno=40, col_offset=12, end_lineno=43, end_col_offset=78)], lineno=38, col_offset=12, end_lineno=43, end_col_offset=78)], lineno=36, col_offset=12, end_lineno=43, end_col_offset=78)], lineno=34, col_offset=12, end_lineno=43, end_col_offset=78)], [Assign([Name('placeholder_11', Store(), lineno=46, col_offset=12, end_lineno=46, end_col_offset=17)], Constant(False, lineno=46, col_offset=20, end_lineno=46, end_col_offset=25), lineno=46, col_offset=12, end_lineno=46, end_col_offset=25), If(Compare(Subscript(Name('placeholder_2', Load(), lineno=47, col_offset=15, end_lineno=47, end_col_offset=21), Constant(0, lineno=47, col_offset=22, end_lineno=47, end_col_offset=23), Load(), lineno=47, col_offset=15, end_lineno=47, end_col_offset=24), [In()], [Constant('023456789', lineno=47, col_offset=28, end_lineno=47, end_col_offset=39)], lineno=47, col_offset=15, end_lineno=47, end_col_offset=39), [Raise(Call(Name('ValueError', Load(), lineno=48, col_offset=22, end_lineno=48, end_col_offset=32), [Constant('11 digits must start with 1', lineno=48, col_offset=33, end_lineno=48, end_col_offset=62)], [], lineno=48, col_offset=22, end_lineno=48, end_col_offset=63), lineno=48, col_offset=16, end_lineno=48, end_col_offset=63)], [], lineno=47, col_offset=12, end_lineno=48, end_col_offset=63)], lineno=33, col_offset=8, end_lineno=48, end_col_offset=63), If(Name('placeholder_11', Load(), lineno=50, col_offset=11, end_lineno=50, end_col_offset=16), [Return(Subscript(Name('placeholder_2', Load(), lineno=51, col_offset=19, end_lineno=51, end_col_offset=25), Slice(UnaryOp(USub(), Constant(10, lineno=51, col_offset=27, end_lineno=51, end_col_offset=29), lineno=51, col_offset=26, end_lineno=51, end_col_offset=29), lineno=51, col_offset=26, end_lineno=51, end_col_offset=30), Load(), lineno=51, col_offset=19, end_lineno=51, end_col_offset=31), lineno=51, col_offset=12, end_lineno=51, end_col_offset=31)], [], lineno=50, col_offset=8, end_lineno=51, end_col_offset=31), Return(Constant(None, lineno=53, col_offset=15, end_lineno=53, end_col_offset=19), lineno=53, col_offset=8, end_lineno=53, end_col_offset=19)], [], lineno=26, col_offset=4, end_lineno=53, end_col_offset=19)], [], lineno=5, col_offset=0, end_lineno=53, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/practice-pig-latin/.meta/config.json b/test/practice-pig-latin/.meta/config.json new file mode 100644 index 0000000..6dd8c46 --- /dev/null +++ b/test/practice-pig-latin/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "akashsara", + "cmccandless", + "Dog", + "ikhadykin", + "N-Parsons", + "pheanex", + "Sukhj1nder", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "pig_latin.py" + ], + "test": [ + "pig_latin_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement a program that translates from English to Pig Latin.", + "source": "The Pig Latin exercise at Test First Teaching by Ultrasaurus", + "source_url": "https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/" +} diff --git a/test/practice-pig-latin/mapping.json b/test/practice-pig-latin/mapping.json new file mode 100644 index 0000000..3f43fb0 --- /dev/null +++ b/test/practice-pig-latin/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "re_cons", + "placeholder_1": "re_vowel", + "placeholder_2": "split_initial_consonant_sound", + "placeholder_3": "word", + "placeholder_4": "starts_with_vowel_sound", + "placeholder_5": "translate", + "placeholder_6": "text", + "placeholder_7": "words", + "placeholder_8": "head", + "placeholder_9": "tail" +} \ No newline at end of file diff --git a/test/practice-pig-latin/pig_latin.py b/test/practice-pig-latin/pig_latin.py new file mode 100644 index 0000000..f4b5ca5 --- /dev/null +++ b/test/practice-pig-latin/pig_latin.py @@ -0,0 +1,24 @@ +import re + + +re_cons = re.compile('^([^aeiou]?qu|[^aeiouy]+|y(?=[aeiou]))([a-z]*)') +re_vowel = re.compile('^([aeiou]|y[^aeiou]|xr)[a-z]*') + + +def split_initial_consonant_sound(word): + return re_cons.match(word).groups() + + +def starts_with_vowel_sound(word): + return re_vowel.match(word) is not None + + +def translate(text): + words = [] + for word in text.split(): + if starts_with_vowel_sound(word): + words.append(word + 'ay') + else: + head, tail = split_initial_consonant_sound(word) + words.append(tail + head + 'ay') + return ' '.join(words) diff --git a/test/practice-pig-latin/representation.json b/test/practice-pig-latin/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-pig-latin/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-pig-latin/representation.out b/test/practice-pig-latin/representation.out new file mode 100644 index 0000000..29fad05 --- /dev/null +++ b/test/practice-pig-latin/representation.out @@ -0,0 +1,1062 @@ +## BEGIN NORMALIZED CODE ## +import re + +placeholder_0 = re.compile("^([^aeiou]?qu|[^aeiouy]+|y(?=[aeiou]))([a-z]*)") +placeholder_1 = re.compile("^([aeiou]|y[^aeiou]|xr)[a-z]*") + + +def placeholder_2(placeholder_3): + return placeholder_0.match(placeholder_3).groups() + + +def placeholder_4(placeholder_3): + return placeholder_1.match(placeholder_3) is not None + + +def placeholder_5(placeholder_6): + placeholder_7 = [] + for placeholder_3 in placeholder_6.split(): + if placeholder_4(placeholder_3): + placeholder_7.append(placeholder_3 + "ay") + else: + placeholder_8, placeholder_9 = placeholder_2(placeholder_3) + placeholder_7.append(placeholder_9 + placeholder_8 + "ay") + return " ".join(placeholder_7) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + Assign( + [ + Name( + 're_cons', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=7)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=12), + 'compile', + Load(), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=20), + [ + Constant( + '^([^aeiou]?qu|[^aeiouy]+|y(?=[aeiou]))([a-z]*)', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=69)], + [], + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=70), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=70), + Assign( + [ + Name( + 're_vowel', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=8)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=13), + 'compile', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=21), + [ + Constant( + '^([aeiou]|y[^aeiou]|xr)[a-z]*', + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=53)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=54), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=54), + FunctionDef( + 'split_initial_consonant_sound', + arguments( + [], + [ + arg( + 'word', + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Attribute( + Name( + 're_cons', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + 'match', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=24), + [ + Name( + 'word', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=29)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=30), + 'groups', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=37), + [], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=39), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=39)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=39), + FunctionDef( + 'starts_with_vowel_sound', + arguments( + [], + [ + arg( + 'word', + lineno=12, + col_offset=28, + end_lineno=12, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Attribute( + Name( + 're_vowel', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=19), + 'match', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=25), + [ + Name( + 'word', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=30)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=31), + [ + IsNot()], + [ + Constant( + None, + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=43)], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=43), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=43)], + [], + lineno=12, + col_offset=0, + end_lineno=13, + end_col_offset=43), + FunctionDef( + 'translate', + arguments( + [], + [ + arg( + 'text', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'words', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=9)], + List( + [], + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=14), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=14), + For( + Name( + 'word', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=12), + Call( + Attribute( + Name( + 'text', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=20), + 'split', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=26), + [], + [], + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=28), + [ + If( + Call( + Name( + 'starts_with_vowel_sound', + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=34), + [ + Name( + 'word', + Load(), + lineno=19, + col_offset=35, + end_lineno=19, + end_col_offset=39)], + [], + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=40), + [ + Expr( + Call( + Attribute( + Name( + 'words', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=17), + 'append', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=24), + [ + BinOp( + Name( + 'word', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=29), + Add(), + Constant( + 'ay', + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=36), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=36)], + [], + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=37), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=37)], + [ + Assign( + [ + Tuple( + [ + Name( + 'head', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=16), + Name( + 'tail', + Store(), + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=22)], + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=22)], + Call( + Name( + 'split_initial_consonant_sound', + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=54), + [ + Name( + 'word', + Load(), + lineno=22, + col_offset=55, + end_lineno=22, + end_col_offset=59)], + [], + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=60), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=60), + Expr( + Call( + Attribute( + Name( + 'words', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + 'append', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=24), + [ + BinOp( + BinOp( + Name( + 'tail', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=29), + Add(), + Name( + 'head', + Load(), + lineno=23, + col_offset=32, + end_lineno=23, + end_col_offset=36), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=36), + Add(), + Constant( + 'ay', + lineno=23, + col_offset=39, + end_lineno=23, + end_col_offset=43), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=43)], + [], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=44), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=44)], + lineno=19, + col_offset=8, + end_lineno=23, + end_col_offset=44)], + [], + lineno=18, + col_offset=4, + end_lineno=23, + end_col_offset=44), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=14), + 'join', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=19), + [ + Name( + 'words', + Load(), + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=25)], + [], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=26), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=26)], + [], + lineno=16, + col_offset=0, + end_lineno=24, + end_col_offset=26)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=7)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=12), + 'compile', + Load(), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=20), + [ + Constant( + '^([^aeiou]?qu|[^aeiouy]+|y(?=[aeiou]))([a-z]*)', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=69)], + [], + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=70), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=70), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=8)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=13), + 'compile', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=21), + [ + Constant( + '^([aeiou]|y[^aeiou]|xr)[a-z]*', + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=53)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=54), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=54), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=8, + col_offset=34, + end_lineno=8, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + 'match', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=24), + [ + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=29)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=30), + 'groups', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=37), + [], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=39), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=39)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=39), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=12, + col_offset=28, + end_lineno=12, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=19), + 'match', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=25), + [ + Name( + 'placeholder_3', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=30)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=31), + [ + IsNot()], + [ + Constant( + None, + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=43)], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=43), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=43)], + [], + lineno=12, + col_offset=0, + end_lineno=13, + end_col_offset=43), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=9)], + List( + [], + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=14), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=14), + For( + Name( + 'placeholder_3', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=12), + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=20), + 'split', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=26), + [], + [], + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=28), + [ + If( + Call( + Name( + 'placeholder_4', + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=34), + [ + Name( + 'placeholder_3', + Load(), + lineno=19, + col_offset=35, + end_lineno=19, + end_col_offset=39)], + [], + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=40), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=17), + 'append', + Load(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=24), + [ + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=29), + Add(), + Constant( + 'ay', + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=36), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=36)], + [], + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=37), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=37)], + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_8', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=16), + Name( + 'placeholder_9', + Store(), + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=22)], + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=22)], + Call( + Name( + 'placeholder_2', + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=54), + [ + Name( + 'placeholder_3', + Load(), + lineno=22, + col_offset=55, + end_lineno=22, + end_col_offset=59)], + [], + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=60), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=60), + Expr( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + 'append', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=24), + [ + BinOp( + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=29), + Add(), + Name( + 'placeholder_8', + Load(), + lineno=23, + col_offset=32, + end_lineno=23, + end_col_offset=36), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=36), + Add(), + Constant( + 'ay', + lineno=23, + col_offset=39, + end_lineno=23, + end_col_offset=43), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=43)], + [], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=44), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=44)], + lineno=19, + col_offset=8, + end_lineno=23, + end_col_offset=44)], + [], + lineno=18, + col_offset=4, + end_lineno=23, + end_col_offset=44), + Return( + Call( + Attribute( + Constant( + ' ', + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=14), + 'join', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=19), + [ + Name( + 'placeholder_7', + Load(), + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=25)], + [], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=26), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=26)], + [], + lineno=16, + col_offset=0, + end_lineno=24, + end_col_offset=26)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-pig-latin/representation.txt b/test/practice-pig-latin/representation.txt new file mode 100644 index 0000000..b1d394f --- /dev/null +++ b/test/practice-pig-latin/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('re', lineno=1, col_offset=7, end_lineno=1, end_col_offset=9)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=9), Assign([Name('placeholder_0', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=7)], Call(Attribute(Name('re', Load(), lineno=4, col_offset=10, end_lineno=4, end_col_offset=12), 'compile', Load(), lineno=4, col_offset=10, end_lineno=4, end_col_offset=20), [Constant('^([^aeiou]?qu|[^aeiouy]+|y(?=[aeiou]))([a-z]*)', lineno=4, col_offset=21, end_lineno=4, end_col_offset=69)], [], lineno=4, col_offset=10, end_lineno=4, end_col_offset=70), lineno=4, col_offset=0, end_lineno=4, end_col_offset=70), Assign([Name('placeholder_1', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=8)], Call(Attribute(Name('re', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=13), 'compile', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=21), [Constant('^([aeiou]|y[^aeiou]|xr)[a-z]*', lineno=5, col_offset=22, end_lineno=5, end_col_offset=53)], [], lineno=5, col_offset=11, end_lineno=5, end_col_offset=54), lineno=5, col_offset=0, end_lineno=5, end_col_offset=54), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=8, col_offset=34, end_lineno=8, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Call(Attribute(Name('placeholder_0', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=18), 'match', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=24), [Name('placeholder_3', Load(), lineno=9, col_offset=25, end_lineno=9, end_col_offset=29)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=30), 'groups', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=37), [], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=39), lineno=9, col_offset=4, end_lineno=9, end_col_offset=39)], [], lineno=8, col_offset=0, end_lineno=9, end_col_offset=39), FunctionDef('placeholder_4', arguments([], [arg('placeholder_3', lineno=12, col_offset=28, end_lineno=12, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Call(Attribute(Name('placeholder_1', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=19), 'match', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=25), [Name('placeholder_3', Load(), lineno=13, col_offset=26, end_lineno=13, end_col_offset=30)], [], lineno=13, col_offset=11, end_lineno=13, end_col_offset=31), [IsNot()], [Constant(None, lineno=13, col_offset=39, end_lineno=13, end_col_offset=43)], lineno=13, col_offset=11, end_lineno=13, end_col_offset=43), lineno=13, col_offset=4, end_lineno=13, end_col_offset=43)], [], lineno=12, col_offset=0, end_lineno=13, end_col_offset=43), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=16, col_offset=14, end_lineno=16, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=9)], List([], Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=14), lineno=17, col_offset=4, end_lineno=17, end_col_offset=14), For(Name('placeholder_3', Store(), lineno=18, col_offset=8, end_lineno=18, end_col_offset=12), Call(Attribute(Name('placeholder_6', Load(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=20), 'split', Load(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=26), [], [], lineno=18, col_offset=16, end_lineno=18, end_col_offset=28), [If(Call(Name('placeholder_4', Load(), lineno=19, col_offset=11, end_lineno=19, end_col_offset=34), [Name('placeholder_3', Load(), lineno=19, col_offset=35, end_lineno=19, end_col_offset=39)], [], lineno=19, col_offset=11, end_lineno=19, end_col_offset=40), [Expr(Call(Attribute(Name('placeholder_7', Load(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=17), 'append', Load(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=24), [BinOp(Name('placeholder_3', Load(), lineno=20, col_offset=25, end_lineno=20, end_col_offset=29), Add(), Constant('ay', lineno=20, col_offset=32, end_lineno=20, end_col_offset=36), lineno=20, col_offset=25, end_lineno=20, end_col_offset=36)], [], lineno=20, col_offset=12, end_lineno=20, end_col_offset=37), lineno=20, col_offset=12, end_lineno=20, end_col_offset=37)], [Assign([Tuple([Name('placeholder_8', Store(), lineno=22, col_offset=12, end_lineno=22, end_col_offset=16), Name('placeholder_9', Store(), lineno=22, col_offset=18, end_lineno=22, end_col_offset=22)], Store(), lineno=22, col_offset=12, end_lineno=22, end_col_offset=22)], Call(Name('placeholder_2', Load(), lineno=22, col_offset=25, end_lineno=22, end_col_offset=54), [Name('placeholder_3', Load(), lineno=22, col_offset=55, end_lineno=22, end_col_offset=59)], [], lineno=22, col_offset=25, end_lineno=22, end_col_offset=60), lineno=22, col_offset=12, end_lineno=22, end_col_offset=60), Expr(Call(Attribute(Name('placeholder_7', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=17), 'append', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=24), [BinOp(BinOp(Name('placeholder_9', Load(), lineno=23, col_offset=25, end_lineno=23, end_col_offset=29), Add(), Name('placeholder_8', Load(), lineno=23, col_offset=32, end_lineno=23, end_col_offset=36), lineno=23, col_offset=25, end_lineno=23, end_col_offset=36), Add(), Constant('ay', lineno=23, col_offset=39, end_lineno=23, end_col_offset=43), lineno=23, col_offset=25, end_lineno=23, end_col_offset=43)], [], lineno=23, col_offset=12, end_lineno=23, end_col_offset=44), lineno=23, col_offset=12, end_lineno=23, end_col_offset=44)], lineno=19, col_offset=8, end_lineno=23, end_col_offset=44)], [], lineno=18, col_offset=4, end_lineno=23, end_col_offset=44), Return(Call(Attribute(Constant(' ', lineno=24, col_offset=11, end_lineno=24, end_col_offset=14), 'join', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=19), [Name('placeholder_7', Load(), lineno=24, col_offset=20, end_lineno=24, end_col_offset=25)], [], lineno=24, col_offset=11, end_lineno=24, end_col_offset=26), lineno=24, col_offset=4, end_lineno=24, end_col_offset=26)], [], lineno=16, col_offset=0, end_lineno=24, end_col_offset=26)], []) \ No newline at end of file diff --git a/test/practice-point-mutations/.meta/config.json b/test/practice-point-mutations/.meta/config.json new file mode 100644 index 0000000..b02f370 --- /dev/null +++ b/test/practice-point-mutations/.meta/config.json @@ -0,0 +1,30 @@ +{ + "blurb": "Calculate the Hamming difference between two DNA strands.", + "authors": [], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "lowks", + "N-Parsons", + "pheanex", + "sjakobi", + "susg", + "tqa236" + ], + "files": { + "solution": [ + "point_mutations.py" + ], + "test": [ + "point_mutations_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "The Calculating Point Mutations problem at Rosalind", + "source_url": "https://rosalind.info/problems/hamm/" +} diff --git a/test/practice-point-mutations/mapping.json b/test/practice-point-mutations/mapping.json new file mode 100644 index 0000000..d098592 --- /dev/null +++ b/test/practice-point-mutations/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "hamming_distance", + "placeholder_1": "strand1", + "placeholder_2": "strand2", + "placeholder_3": "idx", + "placeholder_4": "edx" +} \ No newline at end of file diff --git a/test/practice-point-mutations/point_mutations.py b/test/practice-point-mutations/point_mutations.py new file mode 100644 index 0000000..b55235a --- /dev/null +++ b/test/practice-point-mutations/point_mutations.py @@ -0,0 +1,2 @@ +def hamming_distance(strand1, strand2): + return sum(idx != edx for (idx, edx) in zip(strand1, strand2)) diff --git a/test/practice-point-mutations/representation.json b/test/practice-point-mutations/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-point-mutations/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-point-mutations/representation.out b/test/practice-point-mutations/representation.out new file mode 100644 index 0000000..808da05 --- /dev/null +++ b/test/practice-point-mutations/representation.out @@ -0,0 +1,272 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return sum( + ( + placeholder_3 != placeholder_4 + for placeholder_3, placeholder_4 in zip(placeholder_1, placeholder_2) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'hamming_distance', + arguments( + [], + [ + arg( + 'strand1', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=28), + arg( + 'strand2', + lineno=1, + col_offset=30, + end_lineno=1, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + GeneratorExp( + Compare( + Name( + 'idx', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=18), + [ + NotEq()], + [ + Name( + 'edx', + Load(), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=25)], + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=25), + [ + comprehension( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=2, + col_offset=31, + end_lineno=2, + end_col_offset=34), + Name( + 'edx', + Store(), + lineno=2, + col_offset=36, + end_lineno=2, + end_col_offset=39)], + Store(), + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=40), + Call( + Name( + 'zip', + Load(), + lineno=2, + col_offset=44, + end_lineno=2, + end_col_offset=47), + [ + Name( + 'strand1', + Load(), + lineno=2, + col_offset=48, + end_lineno=2, + end_col_offset=55), + Name( + 'strand2', + Load(), + lineno=2, + col_offset=57, + end_lineno=2, + end_col_offset=64)], + [], + lineno=2, + col_offset=44, + end_lineno=2, + end_col_offset=65), + [], + 0)], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=66)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=66), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=66)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=66)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=28), + arg( + 'placeholder_2', + lineno=1, + col_offset=30, + end_lineno=1, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + GeneratorExp( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=18), + [ + NotEq()], + [ + Name( + 'placeholder_4', + Load(), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=25)], + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=25), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=31, + end_lineno=2, + end_col_offset=34), + Name( + 'placeholder_4', + Store(), + lineno=2, + col_offset=36, + end_lineno=2, + end_col_offset=39)], + Store(), + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=40), + Call( + Name( + 'zip', + Load(), + lineno=2, + col_offset=44, + end_lineno=2, + end_col_offset=47), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=48, + end_lineno=2, + end_col_offset=55), + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=57, + end_lineno=2, + end_col_offset=64)], + [], + lineno=2, + col_offset=44, + end_lineno=2, + end_col_offset=65), + [], + 0)], + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=66)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=66), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=66)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=66)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-point-mutations/representation.txt b/test/practice-point-mutations/representation.txt new file mode 100644 index 0000000..0281bcf --- /dev/null +++ b/test/practice-point-mutations/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=21, end_lineno=1, end_col_offset=28), arg('placeholder_2', lineno=1, col_offset=30, end_lineno=1, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sum', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=14), [GeneratorExp(Compare(Name('placeholder_3', Load(), lineno=2, col_offset=15, end_lineno=2, end_col_offset=18), [NotEq()], [Name('placeholder_4', Load(), lineno=2, col_offset=22, end_lineno=2, end_col_offset=25)], lineno=2, col_offset=15, end_lineno=2, end_col_offset=25), [comprehension(Tuple([Name('placeholder_3', Store(), lineno=2, col_offset=31, end_lineno=2, end_col_offset=34), Name('placeholder_4', Store(), lineno=2, col_offset=36, end_lineno=2, end_col_offset=39)], Store(), lineno=2, col_offset=30, end_lineno=2, end_col_offset=40), Call(Name('zip', Load(), lineno=2, col_offset=44, end_lineno=2, end_col_offset=47), [Name('placeholder_1', Load(), lineno=2, col_offset=48, end_lineno=2, end_col_offset=55), Name('placeholder_2', Load(), lineno=2, col_offset=57, end_lineno=2, end_col_offset=64)], [], lineno=2, col_offset=44, end_lineno=2, end_col_offset=65), [], 0)], lineno=2, col_offset=14, end_lineno=2, end_col_offset=66)], [], lineno=2, col_offset=11, end_lineno=2, end_col_offset=66), lineno=2, col_offset=4, end_lineno=2, end_col_offset=66)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=66)], []) \ No newline at end of file diff --git a/test/practice-poker/.meta/config.json b/test/practice-poker/.meta/config.json new file mode 100644 index 0000000..fcb4079 --- /dev/null +++ b/test/practice-poker/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [ + "MartinDelille" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "dvermd", + "ikhadykin", + "jnaulty", + "kytrinyx", + "N-Parsons", + "njgingrich", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "poker.py" + ], + "test": [ + "poker_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Pick the best hand(s) from a list of poker hands.", + "source": "Inspired by the training course from Udacity.", + "source_url": "https://www.udacity.com/course/design-of-computer-programs--cs212" +} diff --git a/test/practice-poker/mapping.json b/test/practice-poker/mapping.json new file mode 100644 index 0000000..881309e --- /dev/null +++ b/test/practice-poker/mapping.json @@ -0,0 +1,21 @@ +{ + "placeholder_0": "best_hands", + "placeholder_1": "hands", + "placeholder_2": "key", + "placeholder_3": "allmax", + "placeholder_4": "iterable", + "placeholder_5": "result", + "placeholder_6": "maxval", + "placeholder_7": "idx", + "placeholder_8": "xval", + "placeholder_9": "hand_rank", + "placeholder_10": "hand", + "placeholder_11": "card_ranks", + "placeholder_12": "_", + "placeholder_13": "groups", + "placeholder_14": "reverse", + "placeholder_15": "counts", + "placeholder_16": "ranks", + "placeholder_17": "straight", + "placeholder_18": "flush" +} \ No newline at end of file diff --git a/test/practice-poker/poker.py b/test/practice-poker/poker.py new file mode 100644 index 0000000..e650f14 --- /dev/null +++ b/test/practice-poker/poker.py @@ -0,0 +1,36 @@ +def best_hands(hands): + return allmax(hands, key=hand_rank) + + +def allmax(iterable, key=None): + result, maxval = [], None + key = key or (lambda idx: idx) + for idx in iterable: + xval = key(idx) + if not result or xval > maxval: + result, maxval = [idx], xval + elif xval == maxval: + result.append(idx) + return result + + +def hand_rank(hand): + hand = hand.replace('10', 'T').split() + card_ranks = ['..23456789TJQKA'.index(idx) for idx, _ in hand] + groups = [(card_ranks.count(idx), idx) for idx in set(card_ranks)] + groups.sort(reverse=True) + counts, ranks = zip(*groups) + if ranks == (14, 5, 4, 3, 2): + ranks = (5, 4, 3, 2, 1) + straight = (len(counts) == 5) and (max(ranks) - min(ranks) == 4) + flush = len({idx for _, idx in hand}) == 1 + return (9 if counts == (5,) else + 8 if straight and flush else + 7 if counts == (4, 1) else + 6 if counts == (3, 2) else + 5 if flush else + 4 if straight else + 3 if counts == (3, 1, 1) else + 2 if counts == (2, 2, 1) else + 1 if counts == (2, 1, 1, 1) else + 0, ranks) diff --git a/test/practice-poker/representation.json b/test/practice-poker/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-poker/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-poker/representation.out b/test/practice-poker/representation.out new file mode 100644 index 0000000..183743c --- /dev/null +++ b/test/practice-poker/representation.out @@ -0,0 +1,2983 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return allmax(placeholder_1, placeholder_2=hand_rank) + + +def placeholder_3(placeholder_4, placeholder_2=None): + placeholder_5, placeholder_6 = ([], None) + placeholder_2 = placeholder_2 or (lambda placeholder_7: placeholder_7) + for placeholder_7 in placeholder_4: + placeholder_8 = placeholder_2(placeholder_7) + if not placeholder_5 or placeholder_8 > placeholder_6: + placeholder_5, placeholder_6 = ([placeholder_7], placeholder_8) + elif placeholder_8 == placeholder_6: + placeholder_5.append(placeholder_7) + return placeholder_5 + + +def placeholder_9(placeholder_10): + placeholder_10 = placeholder_10.replace("10", "T").split() + placeholder_11 = [ + "..23456789TJQKA".index(placeholder_7) + for placeholder_7, placeholder_12 in placeholder_10 + ] + placeholder_13 = [ + (placeholder_11.count(placeholder_7), placeholder_7) + for placeholder_7 in set(placeholder_11) + ] + placeholder_13.sort(placeholder_14=True) + placeholder_15, placeholder_16 = zip(*placeholder_13) + if placeholder_16 == (14, 5, 4, 3, 2): + placeholder_16 = (5, 4, 3, 2, 1) + placeholder_17 = ( + len(placeholder_15) == 5 and max(placeholder_16) - min(placeholder_16) == 4 + ) + placeholder_18 = ( + len({placeholder_7 for placeholder_12, placeholder_7 in placeholder_10}) == 1 + ) + return ( + 9 + if placeholder_15 == (5,) + else 8 + if placeholder_17 and placeholder_18 + else 7 + if placeholder_15 == (4, 1) + else 6 + if placeholder_15 == (3, 2) + else 5 + if placeholder_18 + else 4 + if placeholder_17 + else 3 + if placeholder_15 == (3, 1, 1) + else 2 + if placeholder_15 == (2, 2, 1) + else 1 + if placeholder_15 == (2, 1, 1, 1) + else 0, + placeholder_16, + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'best_hands', + arguments( + [], + [ + arg( + 'hands', + lineno=1, + col_offset=15, + end_lineno=1, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'allmax', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + [ + Name( + 'hands', + Load(), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=23)], + [ + keyword( + 'key', + Name( + 'hand_rank', + Load(), + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=38), + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=38)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=39), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=39)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=39), + FunctionDef( + 'allmax', + arguments( + [], + [ + arg( + 'iterable', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=19), + arg( + 'key', + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=29)]), + [ + Assign( + [ + Tuple( + [ + Name( + 'result', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=10), + Name( + 'maxval', + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=18)], + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=18)], + Tuple( + [ + List( + [], + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=23), + Constant( + None, + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=29)], + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=29), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=29), + Assign( + [ + Name( + 'key', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=7)], + BoolOp( + Or(), + [ + Name( + 'key', + Load(), + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=13), + Lambda( + arguments( + [], + [ + arg( + 'idx', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Name( + 'idx', + Load(), + lineno=7, + col_offset=30, + end_lineno=7, + end_col_offset=33), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=33)], + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=34), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=34), + For( + Name( + 'idx', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=11), + Name( + 'iterable', + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=23), + [ + Assign( + [ + Name( + 'xval', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12)], + Call( + Name( + 'key', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=18), + [ + Name( + 'idx', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=22)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=23), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=23), + If( + BoolOp( + Or(), + [ + UnaryOp( + Not(), + Name( + 'result', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=21), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=21), + Compare( + Name( + 'xval', + Load(), + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=29), + [ + Gt()], + [ + Name( + 'maxval', + Load(), + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=38)], + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=38)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=38), + [ + Assign( + [ + Tuple( + [ + Name( + 'result', + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18), + Name( + 'maxval', + Store(), + lineno=11, + col_offset=20, + end_lineno=11, + end_col_offset=26)], + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=26)], + Tuple( + [ + List( + [ + Name( + 'idx', + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=33)], + Load(), + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=34), + Name( + 'xval', + Load(), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=40)], + Load(), + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=40), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=40)], + [ + If( + Compare( + Name( + 'xval', + Load(), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=17), + [ + Eq()], + [ + Name( + 'maxval', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=27)], + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=27), + [ + Expr( + Call( + Attribute( + Name( + 'result', + Load(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=18), + 'append', + Load(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=25), + [ + Name( + 'idx', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=29)], + [], + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=30), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=30)], + [], + lineno=12, + col_offset=8, + end_lineno=13, + end_col_offset=30)], + lineno=10, + col_offset=8, + end_lineno=13, + end_col_offset=30)], + [], + lineno=8, + col_offset=4, + end_lineno=13, + end_col_offset=30), + Return( + Name( + 'result', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=17), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=17)], + [], + lineno=5, + col_offset=0, + end_lineno=14, + end_col_offset=17), + FunctionDef( + 'hand_rank', + arguments( + [], + [ + arg( + 'hand', + lineno=17, + col_offset=14, + end_lineno=17, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'hand', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=8)], + Call( + Attribute( + Call( + Attribute( + Name( + 'hand', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=15), + 'replace', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=23), + [ + Constant( + '10', + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=28), + Constant( + 'T', + lineno=18, + col_offset=30, + end_lineno=18, + end_col_offset=33)], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=34), + 'split', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=40), + [], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=42), + Assign( + [ + Name( + 'card_ranks', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=14)], + ListComp( + Call( + Attribute( + Constant( + '..23456789TJQKA', + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=35), + 'index', + Load(), + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=41), + [ + Name( + 'idx', + Load(), + lineno=19, + col_offset=42, + end_lineno=19, + end_col_offset=45)], + [], + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=46), + [ + comprehension( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=19, + col_offset=51, + end_lineno=19, + end_col_offset=54), + Name( + '_', + Store(), + lineno=19, + col_offset=56, + end_lineno=19, + end_col_offset=57)], + Store(), + lineno=19, + col_offset=51, + end_lineno=19, + end_col_offset=57), + Name( + 'hand', + Load(), + lineno=19, + col_offset=61, + end_lineno=19, + end_col_offset=65), + [], + 0)], + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=66), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=66), + Assign( + [ + Name( + 'groups', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=10)], + ListComp( + Tuple( + [ + Call( + Attribute( + Name( + 'card_ranks', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=25), + 'count', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=31), + [ + Name( + 'idx', + Load(), + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=35)], + [], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=36), + Name( + 'idx', + Load(), + lineno=20, + col_offset=38, + end_lineno=20, + end_col_offset=41)], + Load(), + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=42), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=20, + col_offset=47, + end_lineno=20, + end_col_offset=50), + Call( + Name( + 'set', + Load(), + lineno=20, + col_offset=54, + end_lineno=20, + end_col_offset=57), + [ + Name( + 'card_ranks', + Load(), + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=68)], + [], + lineno=20, + col_offset=54, + end_lineno=20, + end_col_offset=69), + [], + 0)], + lineno=20, + col_offset=13, + end_lineno=20, + end_col_offset=70), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=70), + Expr( + Call( + Attribute( + Name( + 'groups', + Load(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=10), + 'sort', + Load(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=15), + [], + [ + keyword( + 'reverse', + Constant( + True, + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=28), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=28)], + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=29), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=29), + Assign( + [ + Tuple( + [ + Name( + 'counts', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=10), + Name( + 'ranks', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=17)], + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=17)], + Call( + Name( + 'zip', + Load(), + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=23), + [ + Starred( + Name( + 'groups', + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=31), + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=31)], + [], + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=32), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=32), + If( + Compare( + Name( + 'ranks', + Load(), + lineno=23, + col_offset=7, + end_lineno=23, + end_col_offset=12), + [ + Eq()], + [ + Tuple( + [ + Constant( + 14, + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=19), + Constant( + 5, + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=22), + Constant( + 4, + lineno=23, + col_offset=24, + end_lineno=23, + end_col_offset=25), + Constant( + 3, + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=28), + Constant( + 2, + lineno=23, + col_offset=30, + end_lineno=23, + end_col_offset=31)], + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=32)], + lineno=23, + col_offset=7, + end_lineno=23, + end_col_offset=32), + [ + Assign( + [ + Name( + 'ranks', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=13)], + Tuple( + [ + Constant( + 5, + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=18), + Constant( + 4, + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=21), + Constant( + 3, + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=24), + Constant( + 2, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27), + Constant( + 1, + lineno=24, + col_offset=29, + end_lineno=24, + end_col_offset=30)], + Load(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=31), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=31)], + [], + lineno=23, + col_offset=4, + end_lineno=24, + end_col_offset=31), + Assign( + [ + Name( + 'straight', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=12)], + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=19), + [ + Name( + 'counts', + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=26)], + [], + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=27), + [ + Eq()], + [ + Constant( + 5, + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=32)], + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=32), + Compare( + BinOp( + Call( + Name( + 'max', + Load(), + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=42), + [ + Name( + 'ranks', + Load(), + lineno=25, + col_offset=43, + end_lineno=25, + end_col_offset=48)], + [], + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=49), + Sub(), + Call( + Name( + 'min', + Load(), + lineno=25, + col_offset=52, + end_lineno=25, + end_col_offset=55), + [ + Name( + 'ranks', + Load(), + lineno=25, + col_offset=56, + end_lineno=25, + end_col_offset=61)], + [], + lineno=25, + col_offset=52, + end_lineno=25, + end_col_offset=62), + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=62), + [ + Eq()], + [ + Constant( + 4, + lineno=25, + col_offset=66, + end_lineno=25, + end_col_offset=67)], + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=67)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=68), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=68), + Assign( + [ + Name( + 'flush', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=9)], + Compare( + Call( + Name( + 'len', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=15), + [ + SetComp( + Name( + 'idx', + Load(), + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=20), + [ + comprehension( + Tuple( + [ + Name( + '_', + Store(), + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=26), + Name( + 'idx', + Store(), + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=31)], + Store(), + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=31), + Name( + 'hand', + Load(), + lineno=26, + col_offset=35, + end_lineno=26, + end_col_offset=39), + [], + 0)], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=40)], + [], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=41), + [ + Eq()], + [ + Constant( + 1, + lineno=26, + col_offset=45, + end_lineno=26, + end_col_offset=46)], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=46), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=46), + Return( + Tuple( + [ + IfExp( + Compare( + Name( + 'counts', + Load(), + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 5, + lineno=27, + col_offset=28, + end_lineno=27, + end_col_offset=29)], + Load(), + lineno=27, + col_offset=27, + end_lineno=27, + end_col_offset=31)], + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=31), + Constant( + 9, + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=13), + IfExp( + BoolOp( + And(), + [ + Name( + 'straight', + Load(), + lineno=28, + col_offset=17, + end_lineno=28, + end_col_offset=25), + Name( + 'flush', + Load(), + lineno=28, + col_offset=30, + end_lineno=28, + end_col_offset=35)], + lineno=28, + col_offset=17, + end_lineno=28, + end_col_offset=35), + Constant( + 8, + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=13), + IfExp( + Compare( + Name( + 'counts', + Load(), + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 4, + lineno=29, + col_offset=28, + end_lineno=29, + end_col_offset=29), + Constant( + 1, + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=32)], + Load(), + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=33)], + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=33), + Constant( + 7, + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=13), + IfExp( + Compare( + Name( + 'counts', + Load(), + lineno=30, + col_offset=17, + end_lineno=30, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 3, + lineno=30, + col_offset=28, + end_lineno=30, + end_col_offset=29), + Constant( + 2, + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=32)], + Load(), + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=33)], + lineno=30, + col_offset=17, + end_lineno=30, + end_col_offset=33), + Constant( + 6, + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=13), + IfExp( + Name( + 'flush', + Load(), + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=22), + Constant( + 5, + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=13), + IfExp( + Name( + 'straight', + Load(), + lineno=32, + col_offset=17, + end_lineno=32, + end_col_offset=25), + Constant( + 4, + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=13), + IfExp( + Compare( + Name( + 'counts', + Load(), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 3, + lineno=33, + col_offset=28, + end_lineno=33, + end_col_offset=29), + Constant( + 1, + lineno=33, + col_offset=31, + end_lineno=33, + end_col_offset=32), + Constant( + 1, + lineno=33, + col_offset=34, + end_lineno=33, + end_col_offset=35)], + Load(), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=36)], + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=36), + Constant( + 3, + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=13), + IfExp( + Compare( + Name( + 'counts', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 2, + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=29), + Constant( + 2, + lineno=34, + col_offset=31, + end_lineno=34, + end_col_offset=32), + Constant( + 1, + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=35)], + Load(), + lineno=34, + col_offset=27, + end_lineno=34, + end_col_offset=36)], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=36), + Constant( + 2, + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=13), + IfExp( + Compare( + Name( + 'counts', + Load(), + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 2, + lineno=35, + col_offset=28, + end_lineno=35, + end_col_offset=29), + Constant( + 1, + lineno=35, + col_offset=31, + end_lineno=35, + end_col_offset=32), + Constant( + 1, + lineno=35, + col_offset=34, + end_lineno=35, + end_col_offset=35), + Constant( + 1, + lineno=35, + col_offset=37, + end_lineno=35, + end_col_offset=38)], + Load(), + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=39)], + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=39), + Constant( + 1, + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=13), + Constant( + 0, + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=35, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=34, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=33, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=32, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=31, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=30, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=29, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=28, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=27, + col_offset=12, + end_lineno=36, + end_col_offset=13), + Name( + 'ranks', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=20)], + Load(), + lineno=27, + col_offset=11, + end_lineno=36, + end_col_offset=21), + lineno=27, + col_offset=4, + end_lineno=36, + end_col_offset=21)], + [], + lineno=17, + col_offset=0, + end_lineno=36, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=15, + end_lineno=1, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'allmax', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=23)], + [ + keyword( + 'placeholder_2', + Name( + 'hand_rank', + Load(), + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=38), + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=38)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=39), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=39)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=39), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=19), + arg( + 'placeholder_2', + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=29)]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_5', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=10), + Name( + 'placeholder_6', + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=18)], + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=18)], + Tuple( + [ + List( + [], + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=23), + Constant( + None, + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=29)], + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=29), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=29), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=7)], + BoolOp( + Or(), + [ + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=13), + Lambda( + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Name( + 'placeholder_7', + Load(), + lineno=7, + col_offset=30, + end_lineno=7, + end_col_offset=33), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=33)], + lineno=7, + col_offset=10, + end_lineno=7, + end_col_offset=34), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=34), + For( + Name( + 'placeholder_7', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=11), + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=23), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12)], + Call( + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=18), + [ + Name( + 'placeholder_7', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=22)], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=23), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=23), + If( + BoolOp( + Or(), + [ + UnaryOp( + Not(), + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=21), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=21), + Compare( + Name( + 'placeholder_8', + Load(), + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=29), + [ + Gt()], + [ + Name( + 'placeholder_6', + Load(), + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=38)], + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=38)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=38), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_5', + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18), + Name( + 'placeholder_6', + Store(), + lineno=11, + col_offset=20, + end_lineno=11, + end_col_offset=26)], + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=26)], + Tuple( + [ + List( + [ + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=33)], + Load(), + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=34), + Name( + 'placeholder_8', + Load(), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=40)], + Load(), + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=40), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=40)], + [ + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=17), + [ + Eq()], + [ + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=27)], + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=27), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=18), + 'append', + Load(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=25), + [ + Name( + 'placeholder_7', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=29)], + [], + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=30), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=30)], + [], + lineno=12, + col_offset=8, + end_lineno=13, + end_col_offset=30)], + lineno=10, + col_offset=8, + end_lineno=13, + end_col_offset=30)], + [], + lineno=8, + col_offset=4, + end_lineno=13, + end_col_offset=30), + Return( + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=17), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=17)], + [], + lineno=5, + col_offset=0, + end_lineno=14, + end_col_offset=17), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=17, + col_offset=14, + end_lineno=17, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=8)], + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_10', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=15), + 'replace', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=23), + [ + Constant( + '10', + lineno=18, + col_offset=24, + end_lineno=18, + end_col_offset=28), + Constant( + 'T', + lineno=18, + col_offset=30, + end_lineno=18, + end_col_offset=33)], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=34), + 'split', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=40), + [], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=42), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=14)], + ListComp( + Call( + Attribute( + Constant( + '..23456789TJQKA', + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=35), + 'index', + Load(), + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=41), + [ + Name( + 'placeholder_7', + Load(), + lineno=19, + col_offset=42, + end_lineno=19, + end_col_offset=45)], + [], + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=46), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=19, + col_offset=51, + end_lineno=19, + end_col_offset=54), + Name( + 'placeholder_12', + Store(), + lineno=19, + col_offset=56, + end_lineno=19, + end_col_offset=57)], + Store(), + lineno=19, + col_offset=51, + end_lineno=19, + end_col_offset=57), + Name( + 'placeholder_10', + Load(), + lineno=19, + col_offset=61, + end_lineno=19, + end_col_offset=65), + [], + 0)], + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=66), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=66), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=10)], + ListComp( + Tuple( + [ + Call( + Attribute( + Name( + 'placeholder_11', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=25), + 'count', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=31), + [ + Name( + 'placeholder_7', + Load(), + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=35)], + [], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=36), + Name( + 'placeholder_7', + Load(), + lineno=20, + col_offset=38, + end_lineno=20, + end_col_offset=41)], + Load(), + lineno=20, + col_offset=14, + end_lineno=20, + end_col_offset=42), + [ + comprehension( + Name( + 'placeholder_7', + Store(), + lineno=20, + col_offset=47, + end_lineno=20, + end_col_offset=50), + Call( + Name( + 'set', + Load(), + lineno=20, + col_offset=54, + end_lineno=20, + end_col_offset=57), + [ + Name( + 'placeholder_11', + Load(), + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=68)], + [], + lineno=20, + col_offset=54, + end_lineno=20, + end_col_offset=69), + [], + 0)], + lineno=20, + col_offset=13, + end_lineno=20, + end_col_offset=70), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=70), + Expr( + Call( + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=10), + 'sort', + Load(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=15), + [], + [ + keyword( + 'placeholder_14', + Constant( + True, + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=28), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=28)], + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=29), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=29), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_15', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=10), + Name( + 'placeholder_16', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=17)], + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=17)], + Call( + Name( + 'zip', + Load(), + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=23), + [ + Starred( + Name( + 'placeholder_13', + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=31), + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=31)], + [], + lineno=22, + col_offset=20, + end_lineno=22, + end_col_offset=32), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=32), + If( + Compare( + Name( + 'placeholder_16', + Load(), + lineno=23, + col_offset=7, + end_lineno=23, + end_col_offset=12), + [ + Eq()], + [ + Tuple( + [ + Constant( + 14, + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=19), + Constant( + 5, + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=22), + Constant( + 4, + lineno=23, + col_offset=24, + end_lineno=23, + end_col_offset=25), + Constant( + 3, + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=28), + Constant( + 2, + lineno=23, + col_offset=30, + end_lineno=23, + end_col_offset=31)], + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=32)], + lineno=23, + col_offset=7, + end_lineno=23, + end_col_offset=32), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=13)], + Tuple( + [ + Constant( + 5, + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=18), + Constant( + 4, + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=21), + Constant( + 3, + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=24), + Constant( + 2, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27), + Constant( + 1, + lineno=24, + col_offset=29, + end_lineno=24, + end_col_offset=30)], + Load(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=31), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=31)], + [], + lineno=23, + col_offset=4, + end_lineno=24, + end_col_offset=31), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=12)], + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=19), + [ + Name( + 'placeholder_15', + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=26)], + [], + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=27), + [ + Eq()], + [ + Constant( + 5, + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=32)], + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=32), + Compare( + BinOp( + Call( + Name( + 'max', + Load(), + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=42), + [ + Name( + 'placeholder_16', + Load(), + lineno=25, + col_offset=43, + end_lineno=25, + end_col_offset=48)], + [], + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=49), + Sub(), + Call( + Name( + 'min', + Load(), + lineno=25, + col_offset=52, + end_lineno=25, + end_col_offset=55), + [ + Name( + 'placeholder_16', + Load(), + lineno=25, + col_offset=56, + end_lineno=25, + end_col_offset=61)], + [], + lineno=25, + col_offset=52, + end_lineno=25, + end_col_offset=62), + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=62), + [ + Eq()], + [ + Constant( + 4, + lineno=25, + col_offset=66, + end_lineno=25, + end_col_offset=67)], + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=67)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=68), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=68), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=9)], + Compare( + Call( + Name( + 'len', + Load(), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=15), + [ + SetComp( + Name( + 'placeholder_7', + Load(), + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=20), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_12', + Store(), + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=26), + Name( + 'placeholder_7', + Store(), + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=31)], + Store(), + lineno=26, + col_offset=25, + end_lineno=26, + end_col_offset=31), + Name( + 'placeholder_10', + Load(), + lineno=26, + col_offset=35, + end_lineno=26, + end_col_offset=39), + [], + 0)], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=40)], + [], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=41), + [ + Eq()], + [ + Constant( + 1, + lineno=26, + col_offset=45, + end_lineno=26, + end_col_offset=46)], + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=46), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=46), + Return( + Tuple( + [ + IfExp( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 5, + lineno=27, + col_offset=28, + end_lineno=27, + end_col_offset=29)], + Load(), + lineno=27, + col_offset=27, + end_lineno=27, + end_col_offset=31)], + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=31), + Constant( + 9, + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=13), + IfExp( + BoolOp( + And(), + [ + Name( + 'placeholder_17', + Load(), + lineno=28, + col_offset=17, + end_lineno=28, + end_col_offset=25), + Name( + 'placeholder_18', + Load(), + lineno=28, + col_offset=30, + end_lineno=28, + end_col_offset=35)], + lineno=28, + col_offset=17, + end_lineno=28, + end_col_offset=35), + Constant( + 8, + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=13), + IfExp( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 4, + lineno=29, + col_offset=28, + end_lineno=29, + end_col_offset=29), + Constant( + 1, + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=32)], + Load(), + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=33)], + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=33), + Constant( + 7, + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=13), + IfExp( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=30, + col_offset=17, + end_lineno=30, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 3, + lineno=30, + col_offset=28, + end_lineno=30, + end_col_offset=29), + Constant( + 2, + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=32)], + Load(), + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=33)], + lineno=30, + col_offset=17, + end_lineno=30, + end_col_offset=33), + Constant( + 6, + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=13), + IfExp( + Name( + 'placeholder_18', + Load(), + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=22), + Constant( + 5, + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=13), + IfExp( + Name( + 'placeholder_17', + Load(), + lineno=32, + col_offset=17, + end_lineno=32, + end_col_offset=25), + Constant( + 4, + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=13), + IfExp( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 3, + lineno=33, + col_offset=28, + end_lineno=33, + end_col_offset=29), + Constant( + 1, + lineno=33, + col_offset=31, + end_lineno=33, + end_col_offset=32), + Constant( + 1, + lineno=33, + col_offset=34, + end_lineno=33, + end_col_offset=35)], + Load(), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=36)], + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=36), + Constant( + 3, + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=13), + IfExp( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 2, + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=29), + Constant( + 2, + lineno=34, + col_offset=31, + end_lineno=34, + end_col_offset=32), + Constant( + 1, + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=35)], + Load(), + lineno=34, + col_offset=27, + end_lineno=34, + end_col_offset=36)], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=36), + Constant( + 2, + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=13), + IfExp( + Compare( + Name( + 'placeholder_15', + Load(), + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=23), + [ + Eq()], + [ + Tuple( + [ + Constant( + 2, + lineno=35, + col_offset=28, + end_lineno=35, + end_col_offset=29), + Constant( + 1, + lineno=35, + col_offset=31, + end_lineno=35, + end_col_offset=32), + Constant( + 1, + lineno=35, + col_offset=34, + end_lineno=35, + end_col_offset=35), + Constant( + 1, + lineno=35, + col_offset=37, + end_lineno=35, + end_col_offset=38)], + Load(), + lineno=35, + col_offset=27, + end_lineno=35, + end_col_offset=39)], + lineno=35, + col_offset=17, + end_lineno=35, + end_col_offset=39), + Constant( + 1, + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=13), + Constant( + 0, + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=35, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=34, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=33, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=32, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=31, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=30, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=29, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=28, + col_offset=12, + end_lineno=36, + end_col_offset=13), + lineno=27, + col_offset=12, + end_lineno=36, + end_col_offset=13), + Name( + 'placeholder_16', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=20)], + Load(), + lineno=27, + col_offset=11, + end_lineno=36, + end_col_offset=21), + lineno=27, + col_offset=4, + end_lineno=36, + end_col_offset=21)], + [], + lineno=17, + col_offset=0, + end_lineno=36, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-poker/representation.txt b/test/practice-poker/representation.txt new file mode 100644 index 0000000..40c249f --- /dev/null +++ b/test/practice-poker/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=15, end_lineno=1, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('allmax', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=17), [Name('placeholder_1', Load(), lineno=2, col_offset=18, end_lineno=2, end_col_offset=23)], [keyword('placeholder_2', Name('hand_rank', Load(), lineno=2, col_offset=29, end_lineno=2, end_col_offset=38), lineno=2, col_offset=25, end_lineno=2, end_col_offset=38)], lineno=2, col_offset=11, end_lineno=2, end_col_offset=39), lineno=2, col_offset=4, end_lineno=2, end_col_offset=39)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=39), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=5, col_offset=11, end_lineno=5, end_col_offset=19), arg('placeholder_2', lineno=5, col_offset=21, end_lineno=5, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=5, col_offset=25, end_lineno=5, end_col_offset=29)]), [Assign([Tuple([Name('placeholder_5', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=10), Name('placeholder_6', Store(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=18)], Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=18)], Tuple([List([], Load(), lineno=6, col_offset=21, end_lineno=6, end_col_offset=23), Constant(None, lineno=6, col_offset=25, end_lineno=6, end_col_offset=29)], Load(), lineno=6, col_offset=21, end_lineno=6, end_col_offset=29), lineno=6, col_offset=4, end_lineno=6, end_col_offset=29), Assign([Name('placeholder_2', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=7)], BoolOp(Or(), [Name('placeholder_2', Load(), lineno=7, col_offset=10, end_lineno=7, end_col_offset=13), Lambda(arguments([], [arg('placeholder_7', lineno=7, col_offset=25, end_lineno=7, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), Name('placeholder_7', Load(), lineno=7, col_offset=30, end_lineno=7, end_col_offset=33), lineno=7, col_offset=18, end_lineno=7, end_col_offset=33)], lineno=7, col_offset=10, end_lineno=7, end_col_offset=34), lineno=7, col_offset=4, end_lineno=7, end_col_offset=34), For(Name('placeholder_7', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=11), Name('placeholder_4', Load(), lineno=8, col_offset=15, end_lineno=8, end_col_offset=23), [Assign([Name('placeholder_8', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12)], Call(Name('placeholder_2', Load(), lineno=9, col_offset=15, end_lineno=9, end_col_offset=18), [Name('placeholder_7', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=22)], [], lineno=9, col_offset=15, end_lineno=9, end_col_offset=23), lineno=9, col_offset=8, end_lineno=9, end_col_offset=23), If(BoolOp(Or(), [UnaryOp(Not(), Name('placeholder_5', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=21), lineno=10, col_offset=11, end_lineno=10, end_col_offset=21), Compare(Name('placeholder_8', Load(), lineno=10, col_offset=25, end_lineno=10, end_col_offset=29), [Gt()], [Name('placeholder_6', Load(), lineno=10, col_offset=32, end_lineno=10, end_col_offset=38)], lineno=10, col_offset=25, end_lineno=10, end_col_offset=38)], lineno=10, col_offset=11, end_lineno=10, end_col_offset=38), [Assign([Tuple([Name('placeholder_5', Store(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=18), Name('placeholder_6', Store(), lineno=11, col_offset=20, end_lineno=11, end_col_offset=26)], Store(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=26)], Tuple([List([Name('placeholder_7', Load(), lineno=11, col_offset=30, end_lineno=11, end_col_offset=33)], Load(), lineno=11, col_offset=29, end_lineno=11, end_col_offset=34), Name('placeholder_8', Load(), lineno=11, col_offset=36, end_lineno=11, end_col_offset=40)], Load(), lineno=11, col_offset=29, end_lineno=11, end_col_offset=40), lineno=11, col_offset=12, end_lineno=11, end_col_offset=40)], [If(Compare(Name('placeholder_8', Load(), lineno=12, col_offset=13, end_lineno=12, end_col_offset=17), [Eq()], [Name('placeholder_6', Load(), lineno=12, col_offset=21, end_lineno=12, end_col_offset=27)], lineno=12, col_offset=13, end_lineno=12, end_col_offset=27), [Expr(Call(Attribute(Name('placeholder_5', Load(), lineno=13, col_offset=12, end_lineno=13, end_col_offset=18), 'append', Load(), lineno=13, col_offset=12, end_lineno=13, end_col_offset=25), [Name('placeholder_7', Load(), lineno=13, col_offset=26, end_lineno=13, end_col_offset=29)], [], lineno=13, col_offset=12, end_lineno=13, end_col_offset=30), lineno=13, col_offset=12, end_lineno=13, end_col_offset=30)], [], lineno=12, col_offset=8, end_lineno=13, end_col_offset=30)], lineno=10, col_offset=8, end_lineno=13, end_col_offset=30)], [], lineno=8, col_offset=4, end_lineno=13, end_col_offset=30), Return(Name('placeholder_5', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=17), lineno=14, col_offset=4, end_lineno=14, end_col_offset=17)], [], lineno=5, col_offset=0, end_lineno=14, end_col_offset=17), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=17, col_offset=14, end_lineno=17, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_10', Store(), lineno=18, col_offset=4, end_lineno=18, end_col_offset=8)], Call(Attribute(Call(Attribute(Name('placeholder_10', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=15), 'replace', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=23), [Constant('10', lineno=18, col_offset=24, end_lineno=18, end_col_offset=28), Constant('T', lineno=18, col_offset=30, end_lineno=18, end_col_offset=33)], [], lineno=18, col_offset=11, end_lineno=18, end_col_offset=34), 'split', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=40), [], [], lineno=18, col_offset=11, end_lineno=18, end_col_offset=42), lineno=18, col_offset=4, end_lineno=18, end_col_offset=42), Assign([Name('placeholder_11', Store(), lineno=19, col_offset=4, end_lineno=19, end_col_offset=14)], ListComp(Call(Attribute(Constant('..23456789TJQKA', lineno=19, col_offset=18, end_lineno=19, end_col_offset=35), 'index', Load(), lineno=19, col_offset=18, end_lineno=19, end_col_offset=41), [Name('placeholder_7', Load(), lineno=19, col_offset=42, end_lineno=19, end_col_offset=45)], [], lineno=19, col_offset=18, end_lineno=19, end_col_offset=46), [comprehension(Tuple([Name('placeholder_7', Store(), lineno=19, col_offset=51, end_lineno=19, end_col_offset=54), Name('placeholder_12', Store(), lineno=19, col_offset=56, end_lineno=19, end_col_offset=57)], Store(), lineno=19, col_offset=51, end_lineno=19, end_col_offset=57), Name('placeholder_10', Load(), lineno=19, col_offset=61, end_lineno=19, end_col_offset=65), [], 0)], lineno=19, col_offset=17, end_lineno=19, end_col_offset=66), lineno=19, col_offset=4, end_lineno=19, end_col_offset=66), Assign([Name('placeholder_13', Store(), lineno=20, col_offset=4, end_lineno=20, end_col_offset=10)], ListComp(Tuple([Call(Attribute(Name('placeholder_11', Load(), lineno=20, col_offset=15, end_lineno=20, end_col_offset=25), 'count', Load(), lineno=20, col_offset=15, end_lineno=20, end_col_offset=31), [Name('placeholder_7', Load(), lineno=20, col_offset=32, end_lineno=20, end_col_offset=35)], [], lineno=20, col_offset=15, end_lineno=20, end_col_offset=36), Name('placeholder_7', Load(), lineno=20, col_offset=38, end_lineno=20, end_col_offset=41)], Load(), lineno=20, col_offset=14, end_lineno=20, end_col_offset=42), [comprehension(Name('placeholder_7', Store(), lineno=20, col_offset=47, end_lineno=20, end_col_offset=50), Call(Name('set', Load(), lineno=20, col_offset=54, end_lineno=20, end_col_offset=57), [Name('placeholder_11', Load(), lineno=20, col_offset=58, end_lineno=20, end_col_offset=68)], [], lineno=20, col_offset=54, end_lineno=20, end_col_offset=69), [], 0)], lineno=20, col_offset=13, end_lineno=20, end_col_offset=70), lineno=20, col_offset=4, end_lineno=20, end_col_offset=70), Expr(Call(Attribute(Name('placeholder_13', Load(), lineno=21, col_offset=4, end_lineno=21, end_col_offset=10), 'sort', Load(), lineno=21, col_offset=4, end_lineno=21, end_col_offset=15), [], [keyword('placeholder_14', Constant(True, lineno=21, col_offset=24, end_lineno=21, end_col_offset=28), lineno=21, col_offset=16, end_lineno=21, end_col_offset=28)], lineno=21, col_offset=4, end_lineno=21, end_col_offset=29), lineno=21, col_offset=4, end_lineno=21, end_col_offset=29), Assign([Tuple([Name('placeholder_15', Store(), lineno=22, col_offset=4, end_lineno=22, end_col_offset=10), Name('placeholder_16', Store(), lineno=22, col_offset=12, end_lineno=22, end_col_offset=17)], Store(), lineno=22, col_offset=4, end_lineno=22, end_col_offset=17)], Call(Name('zip', Load(), lineno=22, col_offset=20, end_lineno=22, end_col_offset=23), [Starred(Name('placeholder_13', Load(), lineno=22, col_offset=25, end_lineno=22, end_col_offset=31), Load(), lineno=22, col_offset=24, end_lineno=22, end_col_offset=31)], [], lineno=22, col_offset=20, end_lineno=22, end_col_offset=32), lineno=22, col_offset=4, end_lineno=22, end_col_offset=32), If(Compare(Name('placeholder_16', Load(), lineno=23, col_offset=7, end_lineno=23, end_col_offset=12), [Eq()], [Tuple([Constant(14, lineno=23, col_offset=17, end_lineno=23, end_col_offset=19), Constant(5, lineno=23, col_offset=21, end_lineno=23, end_col_offset=22), Constant(4, lineno=23, col_offset=24, end_lineno=23, end_col_offset=25), Constant(3, lineno=23, col_offset=27, end_lineno=23, end_col_offset=28), Constant(2, lineno=23, col_offset=30, end_lineno=23, end_col_offset=31)], Load(), lineno=23, col_offset=16, end_lineno=23, end_col_offset=32)], lineno=23, col_offset=7, end_lineno=23, end_col_offset=32), [Assign([Name('placeholder_16', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=13)], Tuple([Constant(5, lineno=24, col_offset=17, end_lineno=24, end_col_offset=18), Constant(4, lineno=24, col_offset=20, end_lineno=24, end_col_offset=21), Constant(3, lineno=24, col_offset=23, end_lineno=24, end_col_offset=24), Constant(2, lineno=24, col_offset=26, end_lineno=24, end_col_offset=27), Constant(1, lineno=24, col_offset=29, end_lineno=24, end_col_offset=30)], Load(), lineno=24, col_offset=16, end_lineno=24, end_col_offset=31), lineno=24, col_offset=8, end_lineno=24, end_col_offset=31)], [], lineno=23, col_offset=4, end_lineno=24, end_col_offset=31), Assign([Name('placeholder_17', Store(), lineno=25, col_offset=4, end_lineno=25, end_col_offset=12)], BoolOp(And(), [Compare(Call(Name('len', Load(), lineno=25, col_offset=16, end_lineno=25, end_col_offset=19), [Name('placeholder_15', Load(), lineno=25, col_offset=20, end_lineno=25, end_col_offset=26)], [], lineno=25, col_offset=16, end_lineno=25, end_col_offset=27), [Eq()], [Constant(5, lineno=25, col_offset=31, end_lineno=25, end_col_offset=32)], lineno=25, col_offset=16, end_lineno=25, end_col_offset=32), Compare(BinOp(Call(Name('max', Load(), lineno=25, col_offset=39, end_lineno=25, end_col_offset=42), [Name('placeholder_16', Load(), lineno=25, col_offset=43, end_lineno=25, end_col_offset=48)], [], lineno=25, col_offset=39, end_lineno=25, end_col_offset=49), Sub(), Call(Name('min', Load(), lineno=25, col_offset=52, end_lineno=25, end_col_offset=55), [Name('placeholder_16', Load(), lineno=25, col_offset=56, end_lineno=25, end_col_offset=61)], [], lineno=25, col_offset=52, end_lineno=25, end_col_offset=62), lineno=25, col_offset=39, end_lineno=25, end_col_offset=62), [Eq()], [Constant(4, lineno=25, col_offset=66, end_lineno=25, end_col_offset=67)], lineno=25, col_offset=39, end_lineno=25, end_col_offset=67)], lineno=25, col_offset=15, end_lineno=25, end_col_offset=68), lineno=25, col_offset=4, end_lineno=25, end_col_offset=68), Assign([Name('placeholder_18', Store(), lineno=26, col_offset=4, end_lineno=26, end_col_offset=9)], Compare(Call(Name('len', Load(), lineno=26, col_offset=12, end_lineno=26, end_col_offset=15), [SetComp(Name('placeholder_7', Load(), lineno=26, col_offset=17, end_lineno=26, end_col_offset=20), [comprehension(Tuple([Name('placeholder_12', Store(), lineno=26, col_offset=25, end_lineno=26, end_col_offset=26), Name('placeholder_7', Store(), lineno=26, col_offset=28, end_lineno=26, end_col_offset=31)], Store(), lineno=26, col_offset=25, end_lineno=26, end_col_offset=31), Name('placeholder_10', Load(), lineno=26, col_offset=35, end_lineno=26, end_col_offset=39), [], 0)], lineno=26, col_offset=16, end_lineno=26, end_col_offset=40)], [], lineno=26, col_offset=12, end_lineno=26, end_col_offset=41), [Eq()], [Constant(1, lineno=26, col_offset=45, end_lineno=26, end_col_offset=46)], lineno=26, col_offset=12, end_lineno=26, end_col_offset=46), lineno=26, col_offset=4, end_lineno=26, end_col_offset=46), Return(Tuple([IfExp(Compare(Name('placeholder_15', Load(), lineno=27, col_offset=17, end_lineno=27, end_col_offset=23), [Eq()], [Tuple([Constant(5, lineno=27, col_offset=28, end_lineno=27, end_col_offset=29)], Load(), lineno=27, col_offset=27, end_lineno=27, end_col_offset=31)], lineno=27, col_offset=17, end_lineno=27, end_col_offset=31), Constant(9, lineno=27, col_offset=12, end_lineno=27, end_col_offset=13), IfExp(BoolOp(And(), [Name('placeholder_17', Load(), lineno=28, col_offset=17, end_lineno=28, end_col_offset=25), Name('placeholder_18', Load(), lineno=28, col_offset=30, end_lineno=28, end_col_offset=35)], lineno=28, col_offset=17, end_lineno=28, end_col_offset=35), Constant(8, lineno=28, col_offset=12, end_lineno=28, end_col_offset=13), IfExp(Compare(Name('placeholder_15', Load(), lineno=29, col_offset=17, end_lineno=29, end_col_offset=23), [Eq()], [Tuple([Constant(4, lineno=29, col_offset=28, end_lineno=29, end_col_offset=29), Constant(1, lineno=29, col_offset=31, end_lineno=29, end_col_offset=32)], Load(), lineno=29, col_offset=27, end_lineno=29, end_col_offset=33)], lineno=29, col_offset=17, end_lineno=29, end_col_offset=33), Constant(7, lineno=29, col_offset=12, end_lineno=29, end_col_offset=13), IfExp(Compare(Name('placeholder_15', Load(), lineno=30, col_offset=17, end_lineno=30, end_col_offset=23), [Eq()], [Tuple([Constant(3, lineno=30, col_offset=28, end_lineno=30, end_col_offset=29), Constant(2, lineno=30, col_offset=31, end_lineno=30, end_col_offset=32)], Load(), lineno=30, col_offset=27, end_lineno=30, end_col_offset=33)], lineno=30, col_offset=17, end_lineno=30, end_col_offset=33), Constant(6, lineno=30, col_offset=12, end_lineno=30, end_col_offset=13), IfExp(Name('placeholder_18', Load(), lineno=31, col_offset=17, end_lineno=31, end_col_offset=22), Constant(5, lineno=31, col_offset=12, end_lineno=31, end_col_offset=13), IfExp(Name('placeholder_17', Load(), lineno=32, col_offset=17, end_lineno=32, end_col_offset=25), Constant(4, lineno=32, col_offset=12, end_lineno=32, end_col_offset=13), IfExp(Compare(Name('placeholder_15', Load(), lineno=33, col_offset=17, end_lineno=33, end_col_offset=23), [Eq()], [Tuple([Constant(3, lineno=33, col_offset=28, end_lineno=33, end_col_offset=29), Constant(1, lineno=33, col_offset=31, end_lineno=33, end_col_offset=32), Constant(1, lineno=33, col_offset=34, end_lineno=33, end_col_offset=35)], Load(), lineno=33, col_offset=27, end_lineno=33, end_col_offset=36)], lineno=33, col_offset=17, end_lineno=33, end_col_offset=36), Constant(3, lineno=33, col_offset=12, end_lineno=33, end_col_offset=13), IfExp(Compare(Name('placeholder_15', Load(), lineno=34, col_offset=17, end_lineno=34, end_col_offset=23), [Eq()], [Tuple([Constant(2, lineno=34, col_offset=28, end_lineno=34, end_col_offset=29), Constant(2, lineno=34, col_offset=31, end_lineno=34, end_col_offset=32), Constant(1, lineno=34, col_offset=34, end_lineno=34, end_col_offset=35)], Load(), lineno=34, col_offset=27, end_lineno=34, end_col_offset=36)], lineno=34, col_offset=17, end_lineno=34, end_col_offset=36), Constant(2, lineno=34, col_offset=12, end_lineno=34, end_col_offset=13), IfExp(Compare(Name('placeholder_15', Load(), lineno=35, col_offset=17, end_lineno=35, end_col_offset=23), [Eq()], [Tuple([Constant(2, lineno=35, col_offset=28, end_lineno=35, end_col_offset=29), Constant(1, lineno=35, col_offset=31, end_lineno=35, end_col_offset=32), Constant(1, lineno=35, col_offset=34, end_lineno=35, end_col_offset=35), Constant(1, lineno=35, col_offset=37, end_lineno=35, end_col_offset=38)], Load(), lineno=35, col_offset=27, end_lineno=35, end_col_offset=39)], lineno=35, col_offset=17, end_lineno=35, end_col_offset=39), Constant(1, lineno=35, col_offset=12, end_lineno=35, end_col_offset=13), Constant(0, lineno=36, col_offset=12, end_lineno=36, end_col_offset=13), lineno=35, col_offset=12, end_lineno=36, end_col_offset=13), lineno=34, col_offset=12, end_lineno=36, end_col_offset=13), lineno=33, col_offset=12, end_lineno=36, end_col_offset=13), lineno=32, col_offset=12, end_lineno=36, end_col_offset=13), lineno=31, col_offset=12, end_lineno=36, end_col_offset=13), lineno=30, col_offset=12, end_lineno=36, end_col_offset=13), lineno=29, col_offset=12, end_lineno=36, end_col_offset=13), lineno=28, col_offset=12, end_lineno=36, end_col_offset=13), lineno=27, col_offset=12, end_lineno=36, end_col_offset=13), Name('placeholder_16', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=20)], Load(), lineno=27, col_offset=11, end_lineno=36, end_col_offset=21), lineno=27, col_offset=4, end_lineno=36, end_col_offset=21)], [], lineno=17, col_offset=0, end_lineno=36, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-pop-count/.meta/config.json b/test/practice-pop-count/.meta/config.json new file mode 100644 index 0000000..36b1259 --- /dev/null +++ b/test/practice-pop-count/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "vaeng" + ], + "files": { + "solution": [ + "pop_count.py" + ], + "test": [ + "pop_count_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Help Eluid count the number of eggs in her chicken coop by counting the number of 1 bits in a binary representation.", + "source": "Christian Willner, Eric Willigers", + "source_url": "https://forum.exercism.org/t/new-exercise-suggestion-pop-count/7632/5" +} diff --git a/test/practice-pop-count/mapping.json b/test/practice-pop-count/mapping.json new file mode 100644 index 0000000..1518dcf --- /dev/null +++ b/test/practice-pop-count/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "egg_count", + "placeholder_1": "display_value", + "placeholder_2": "eggs" +} \ No newline at end of file diff --git a/test/practice-pop-count/pop_count.py b/test/practice-pop-count/pop_count.py new file mode 100644 index 0000000..4e3320a --- /dev/null +++ b/test/practice-pop-count/pop_count.py @@ -0,0 +1,6 @@ +def egg_count(display_value): + eggs = 0 + while display_value: + eggs += display_value % 2 + display_value //= 2 + return eggs diff --git a/test/practice-pop-count/representation.json b/test/practice-pop-count/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-pop-count/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-pop-count/representation.out b/test/practice-pop-count/representation.out new file mode 100644 index 0000000..8035c1e --- /dev/null +++ b/test/practice-pop-count/representation.out @@ -0,0 +1,253 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = 0 + while placeholder_1: + placeholder_2 += placeholder_1 % 2 + placeholder_1 //= 2 + return placeholder_2 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'egg_count', + arguments( + [], + [ + arg( + 'display_value', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'eggs', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=8)], + Constant( + 0, + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=12), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=12), + While( + Name( + 'display_value', + Load(), + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=23), + [ + AugAssign( + Name( + 'eggs', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + Add(), + BinOp( + Name( + 'display_value', + Load(), + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=29), + Mod(), + Constant( + 2, + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=33), + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=33), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=33), + AugAssign( + Name( + 'display_value', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=21), + FloorDiv(), + Constant( + 2, + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=27), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=27)], + [], + lineno=3, + col_offset=4, + end_lineno=5, + end_col_offset=27), + Return( + Name( + 'eggs', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=15), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15)], + [], + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=15)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=8)], + Constant( + 0, + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=12), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=12), + While( + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=23), + [ + AugAssign( + Name( + 'placeholder_2', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + Add(), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=29), + Mod(), + Constant( + 2, + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=33), + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=33), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=33), + AugAssign( + Name( + 'placeholder_1', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=21), + FloorDiv(), + Constant( + 2, + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=27), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=27)], + [], + lineno=3, + col_offset=4, + end_lineno=5, + end_col_offset=27), + Return( + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=15), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15)], + [], + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=15)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-pop-count/representation.txt b/test/practice-pop-count/representation.txt new file mode 100644 index 0000000..5873882 --- /dev/null +++ b/test/practice-pop-count/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=14, end_lineno=1, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=8)], Constant(0, lineno=2, col_offset=11, end_lineno=2, end_col_offset=12), lineno=2, col_offset=4, end_lineno=2, end_col_offset=12), While(Name('placeholder_1', Load(), lineno=3, col_offset=10, end_lineno=3, end_col_offset=23), [AugAssign(Name('placeholder_2', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=12), Add(), BinOp(Name('placeholder_1', Load(), lineno=4, col_offset=16, end_lineno=4, end_col_offset=29), Mod(), Constant(2, lineno=4, col_offset=32, end_lineno=4, end_col_offset=33), lineno=4, col_offset=16, end_lineno=4, end_col_offset=33), lineno=4, col_offset=8, end_lineno=4, end_col_offset=33), AugAssign(Name('placeholder_1', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=21), FloorDiv(), Constant(2, lineno=5, col_offset=26, end_lineno=5, end_col_offset=27), lineno=5, col_offset=8, end_lineno=5, end_col_offset=27)], [], lineno=3, col_offset=4, end_lineno=5, end_col_offset=27), Return(Name('placeholder_2', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=15), lineno=6, col_offset=4, end_lineno=6, end_col_offset=15)], [], lineno=1, col_offset=0, end_lineno=6, end_col_offset=15)], []) \ No newline at end of file diff --git a/test/practice-pov/.meta/config.json b/test/practice-pov/.meta/config.json new file mode 100644 index 0000000..cdc96ff --- /dev/null +++ b/test/practice-pov/.meta/config.json @@ -0,0 +1,26 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "crsmi", + "Dog", + "N-Parsons", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "pov.py" + ], + "test": [ + "pov_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Reparent a graph on a selected node.", + "source": "Adaptation of exercise from 4clojure", + "source_url": "https://www.4clojure.com/" +} diff --git a/test/practice-pov/mapping.json b/test/practice-pov/mapping.json new file mode 100644 index 0000000..98cfc21 --- /dev/null +++ b/test/practice-pov/mapping.json @@ -0,0 +1,30 @@ +{ + "placeholder_0": "Tree", + "placeholder_1": "__init__", + "placeholder_2": "label", + "placeholder_3": "children", + "placeholder_4": "__dict__", + "placeholder_5": "member", + "placeholder_6": "__str__", + "placeholder_7": "indent", + "placeholder_8": "__lt__", + "placeholder_9": "other", + "placeholder_10": "__eq__", + "placeholder_11": "__iter__", + "placeholder_12": "child", + "placeholder_13": "grandchild", + "placeholder_14": "dup", + "placeholder_15": "add", + "placeholder_16": "tree", + "placeholder_17": "remove", + "placeholder_18": "node", + "placeholder_19": "from_pov", + "placeholder_20": "from_node", + "placeholder_21": "stack", + "placeholder_22": "visited", + "placeholder_23": "path_to", + "placeholder_24": "to_node", + "placeholder_25": "reordered", + "placeholder_26": "path", + "placeholder_27": "error" +} \ No newline at end of file diff --git a/test/practice-pov/pov.py b/test/practice-pov/pov.py new file mode 100644 index 0000000..9747d98 --- /dev/null +++ b/test/practice-pov/pov.py @@ -0,0 +1,77 @@ +from json import dumps + + +class Tree: + def __init__(self, label, children=None): + self.label = label + self.children = children if children is not None else [] + + def __dict__(self): + return {self.label: [member.__dict__() for member in sorted(self.children)]} + + def __str__(self, indent=None): + return dumps(self.__dict__(), indent=indent) + + def __lt__(self, other): + return self.label < other.label + + def __eq__(self, other): + return self.__dict__() == other.__dict__() + + def __iter__(self): + yield self.label + for child in self.children: + for grandchild in child: + yield grandchild + + def dup(self): + return Tree(self.label, [member.dup() for member in self.children]) + + def add(self, other): + tree = self.dup() + tree.children.append(other) + return tree + + def remove(self, node): + tree = self.dup() + for child in list(tree.children): + tree.children.remove(child) + if child.label == node: + break + tree.children.append(child.remove(node)) + return tree + + def from_pov(self, from_node): + stack = [self] + visited = set() + + while stack: + tree = stack.pop(0) + if tree.label in visited: + continue + + visited.add(tree.label) + if from_node == tree.label: + return tree + + for child in tree.children: + stack.append(child.add(tree.remove(child.label))) + + raise ValueError('Tree could not be reoriented') + + + + def path_to(self, from_node, to_node): + reordered = self.from_pov(from_node) + stack = reordered.children + path = [from_node] + + while path[-1] != to_node: + try: + tree = stack.pop() + except IndexError as error: + raise ValueError('No path found') from error + if to_node in tree: + path.append(tree.label) + stack = tree.children + return path diff --git a/test/practice-pov/representation.json b/test/practice-pov/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-pov/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-pov/representation.out b/test/practice-pov/representation.out new file mode 100644 index 0000000..67e4060 --- /dev/null +++ b/test/practice-pov/representation.out @@ -0,0 +1,3787 @@ +## BEGIN NORMALIZED CODE ## +from json import dumps + + +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3=None): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 if placeholder_3 is not None else [] + + def placeholder_4(self): + return { + self.placeholder_2: [ + placeholder_5.placeholder_4() + for placeholder_5 in sorted(self.placeholder_3) + ] + } + + def placeholder_6(self, placeholder_7=None): + return dumps(self.placeholder_4(), placeholder_7=placeholder_7) + + def placeholder_8(self, placeholder_9): + return self.placeholder_2 < placeholder_9.placeholder_2 + + def placeholder_10(self, placeholder_9): + return self.placeholder_4() == placeholder_9.placeholder_4() + + def placeholder_11(self): + yield self.label + for placeholder_12 in self.placeholder_3: + for placeholder_13 in placeholder_12: + yield grandchild + + def placeholder_14(self): + return placeholder_0( + self.placeholder_2, + [placeholder_5.placeholder_14() for placeholder_5 in self.placeholder_3], + ) + + def placeholder_15(self, placeholder_9): + placeholder_16 = self.placeholder_14() + placeholder_16.placeholder_3.append(placeholder_9) + return placeholder_16 + + def placeholder_17(self, placeholder_18): + placeholder_16 = self.placeholder_14() + for placeholder_12 in list(placeholder_16.placeholder_3): + placeholder_16.placeholder_3.placeholder_17(placeholder_12) + if placeholder_12.placeholder_2 == placeholder_18: + break + placeholder_16.placeholder_3.append( + placeholder_12.placeholder_17(placeholder_18) + ) + return placeholder_16 + + def placeholder_19(self, placeholder_20): + placeholder_21 = [self] + placeholder_22 = set() + while placeholder_21: + placeholder_16 = placeholder_21.pop(0) + if placeholder_16.placeholder_2 in placeholder_22: + continue + placeholder_22.placeholder_15(placeholder_16.placeholder_2) + if placeholder_20 == placeholder_16.placeholder_2: + return placeholder_16 + for placeholder_12 in placeholder_16.placeholder_3: + placeholder_21.append( + placeholder_12.placeholder_15( + placeholder_16.placeholder_17(placeholder_12.placeholder_2) + ) + ) + raise ValueError("Tree could not be reoriented") + + def placeholder_23(self, placeholder_20, placeholder_24): + placeholder_25 = self.placeholder_19(placeholder_20) + placeholder_21 = placeholder_25.placeholder_3 + placeholder_26 = [placeholder_20] + while placeholder_26[-1] != placeholder_24: + try: + placeholder_16 = placeholder_21.pop() + except IndexError as placeholder_27: + raise ValueError("No path found") from placeholder_27 + if placeholder_24 in placeholder_16: + placeholder_26.append(placeholder_16.placeholder_2) + placeholder_21 = placeholder_16.placeholder_3 + return placeholder_26 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'json', + [ + alias( + 'dumps', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=22)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=22), + ClassDef( + 'Tree', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'label', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=28), + arg( + 'children', + lineno=5, + col_offset=30, + end_lineno=5, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=43)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'label', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=18)], + Name( + 'label', + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=26), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'children', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=21)], + IfExp( + Compare( + Name( + 'children', + Load(), + lineno=7, + col_offset=36, + end_lineno=7, + end_col_offset=44), + [ + IsNot()], + [ + Constant( + None, + lineno=7, + col_offset=52, + end_lineno=7, + end_col_offset=56)], + lineno=7, + col_offset=36, + end_lineno=7, + end_col_offset=56), + Name( + 'children', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=32), + List( + [], + Load(), + lineno=7, + col_offset=62, + end_lineno=7, + end_col_offset=64), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=64), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=64)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=64), + FunctionDef( + '__dict__', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Dict( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=20), + 'label', + Load(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=26)], + [ + ListComp( + Call( + Attribute( + Name( + 'member', + Load(), + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=35), + '__dict__', + Load(), + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=44), + [], + [], + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=46), + [ + comprehension( + Name( + 'member', + Store(), + lineno=10, + col_offset=51, + end_lineno=10, + end_col_offset=57), + Call( + Name( + 'sorted', + Load(), + lineno=10, + col_offset=61, + end_lineno=10, + end_col_offset=67), + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=68, + end_lineno=10, + end_col_offset=72), + 'children', + Load(), + lineno=10, + col_offset=68, + end_lineno=10, + end_col_offset=81)], + [], + lineno=10, + col_offset=61, + end_lineno=10, + end_col_offset=82), + [], + 0)], + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=83)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=84), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=84)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=84), + FunctionDef( + '__str__', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=20), + arg( + 'indent', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=12, + col_offset=29, + end_lineno=12, + end_col_offset=33)]), + [ + Return( + Call( + Name( + 'dumps', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=20), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=25), + '__dict__', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=34), + [], + [], + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=36)], + [ + keyword( + 'indent', + Name( + 'indent', + Load(), + lineno=13, + col_offset=45, + end_lineno=13, + end_col_offset=51), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=51)], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=52), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=52)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=52), + FunctionDef( + '__lt__', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + arg( + 'other', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + 'label', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=25), + [ + Lt()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=33), + 'label', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=39)], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=39), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=39)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=39), + FunctionDef( + '__eq__', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + arg( + 'other', + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + '__dict__', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=28), + [], + [], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=30), + [ + Eq()], + [ + Call( + Attribute( + Name( + 'other', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=39), + '__dict__', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=48), + [], + [], + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=50)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=50), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=50)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=50), + FunctionDef( + '__iter__', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Yield( + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=18), + 'label', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=24), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=24), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=24), + For( + Name( + 'child', + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=25), + 'children', + Load(), + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=34), + [ + For( + Name( + 'grandchild', + Store(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=26), + Name( + 'child', + Load(), + lineno=24, + col_offset=30, + end_lineno=24, + end_col_offset=35), + [ + Expr( + Yield( + Name( + 'grandchild', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=32), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=32), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=32)], + [], + lineno=24, + col_offset=12, + end_lineno=25, + end_col_offset=32)], + [], + lineno=23, + col_offset=8, + end_lineno=25, + end_col_offset=32)], + [], + lineno=21, + col_offset=4, + end_lineno=25, + end_col_offset=32), + FunctionDef( + 'dup', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Tree', + Load(), + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=19), + [ + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=24), + 'label', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=30), + ListComp( + Call( + Attribute( + Name( + 'member', + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=39), + 'dup', + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=43), + [], + [], + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=45), + [ + comprehension( + Name( + 'member', + Store(), + lineno=28, + col_offset=50, + end_lineno=28, + end_col_offset=56), + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=60, + end_lineno=28, + end_col_offset=64), + 'children', + Load(), + lineno=28, + col_offset=60, + end_lineno=28, + end_col_offset=73), + [], + 0)], + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=74)], + [], + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=75), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=75)], + [], + lineno=27, + col_offset=4, + end_lineno=28, + end_col_offset=75), + FunctionDef( + 'add', + arguments( + [], + [ + arg( + 'self', + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=16), + arg( + 'other', + lineno=30, + col_offset=18, + end_lineno=30, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'tree', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=12)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=19), + 'dup', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=23), + [], + [], + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=25), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=25), + Expr( + Call( + Attribute( + Attribute( + Name( + 'tree', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'children', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=21), + 'append', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=28), + [ + Name( + 'other', + Load(), + lineno=32, + col_offset=29, + end_lineno=32, + end_col_offset=34)], + [], + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=35), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=35), + Return( + Name( + 'tree', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=19), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=19)], + [], + lineno=30, + col_offset=4, + end_lineno=33, + end_col_offset=19), + FunctionDef( + 'remove', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=19), + arg( + 'node', + lineno=35, + col_offset=21, + end_lineno=35, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'tree', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=12)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=19), + 'dup', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=23), + [], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=25), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=25), + For( + Name( + 'child', + Store(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=17), + Call( + Name( + 'list', + Load(), + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=25), + [ + Attribute( + Name( + 'tree', + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=30), + 'children', + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=39)], + [], + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=40), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'tree', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=16), + 'children', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=25), + 'remove', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=32), + [ + Name( + 'child', + Load(), + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=38)], + [], + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=39), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=39), + If( + Compare( + Attribute( + Name( + 'child', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=20), + 'label', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=26), + [ + Eq()], + [ + Name( + 'node', + Load(), + lineno=39, + col_offset=30, + end_lineno=39, + end_col_offset=34)], + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=34), + [ + Break( + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=21)], + [], + lineno=39, + col_offset=12, + end_lineno=40, + end_col_offset=21), + Expr( + Call( + Attribute( + Attribute( + Name( + 'tree', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=16), + 'children', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=25), + 'append', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=32), + [ + Call( + Attribute( + Name( + 'child', + Load(), + lineno=41, + col_offset=33, + end_lineno=41, + end_col_offset=38), + 'remove', + Load(), + lineno=41, + col_offset=33, + end_lineno=41, + end_col_offset=45), + [ + Name( + 'node', + Load(), + lineno=41, + col_offset=46, + end_lineno=41, + end_col_offset=50)], + [], + lineno=41, + col_offset=33, + end_lineno=41, + end_col_offset=51)], + [], + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=52), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=52)], + [], + lineno=37, + col_offset=8, + end_lineno=41, + end_col_offset=52), + Return( + Name( + 'tree', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=19), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=19)], + [], + lineno=35, + col_offset=4, + end_lineno=42, + end_col_offset=19), + FunctionDef( + 'from_pov', + arguments( + [], + [ + arg( + 'self', + lineno=44, + col_offset=17, + end_lineno=44, + end_col_offset=21), + arg( + 'from_node', + lineno=44, + col_offset=23, + end_lineno=44, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'stack', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=13)], + List( + [ + Name( + 'self', + Load(), + lineno=45, + col_offset=17, + end_lineno=45, + end_col_offset=21)], + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=22), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=22), + Assign( + [ + Name( + 'visited', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=15)], + Call( + Name( + 'set', + Load(), + lineno=46, + col_offset=18, + end_lineno=46, + end_col_offset=21), + [], + [], + lineno=46, + col_offset=18, + end_lineno=46, + end_col_offset=23), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=23), + While( + Name( + 'stack', + Load(), + lineno=48, + col_offset=14, + end_lineno=48, + end_col_offset=19), + [ + Assign( + [ + Name( + 'tree', + Store(), + lineno=49, + col_offset=12, + end_lineno=49, + end_col_offset=16)], + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=24), + 'pop', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=28), + [ + Constant( + 0, + lineno=49, + col_offset=29, + end_lineno=49, + end_col_offset=30)], + [], + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=31), + lineno=49, + col_offset=12, + end_lineno=49, + end_col_offset=31), + If( + Compare( + Attribute( + Name( + 'tree', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=19), + 'label', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=25), + [ + In()], + [ + Name( + 'visited', + Load(), + lineno=50, + col_offset=29, + end_lineno=50, + end_col_offset=36)], + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=36), + [ + Continue( + lineno=51, + col_offset=16, + end_lineno=51, + end_col_offset=24)], + [], + lineno=50, + col_offset=12, + end_lineno=51, + end_col_offset=24), + Expr( + Call( + Attribute( + Name( + 'visited', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=19), + 'add', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=23), + [ + Attribute( + Name( + 'tree', + Load(), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=28), + 'label', + Load(), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=34)], + [], + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=35), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=35), + If( + Compare( + Name( + 'from_node', + Load(), + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'tree', + Load(), + lineno=54, + col_offset=28, + end_lineno=54, + end_col_offset=32), + 'label', + Load(), + lineno=54, + col_offset=28, + end_lineno=54, + end_col_offset=38)], + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=38), + [ + Return( + Name( + 'tree', + Load(), + lineno=55, + col_offset=23, + end_lineno=55, + end_col_offset=27), + lineno=55, + col_offset=16, + end_lineno=55, + end_col_offset=27)], + [], + lineno=54, + col_offset=12, + end_lineno=55, + end_col_offset=27), + For( + Name( + 'child', + Store(), + lineno=57, + col_offset=16, + end_lineno=57, + end_col_offset=21), + Attribute( + Name( + 'tree', + Load(), + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=29), + 'children', + Load(), + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=38), + [ + Expr( + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=21), + 'append', + Load(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=28), + [ + Call( + Attribute( + Name( + 'child', + Load(), + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=34), + 'add', + Load(), + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=38), + [ + Call( + Attribute( + Name( + 'tree', + Load(), + lineno=58, + col_offset=39, + end_lineno=58, + end_col_offset=43), + 'remove', + Load(), + lineno=58, + col_offset=39, + end_lineno=58, + end_col_offset=50), + [ + Attribute( + Name( + 'child', + Load(), + lineno=58, + col_offset=51, + end_lineno=58, + end_col_offset=56), + 'label', + Load(), + lineno=58, + col_offset=51, + end_lineno=58, + end_col_offset=62)], + [], + lineno=58, + col_offset=39, + end_lineno=58, + end_col_offset=63)], + [], + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=64)], + [], + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=65), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=65)], + [], + lineno=57, + col_offset=12, + end_lineno=58, + end_col_offset=65)], + [], + lineno=48, + col_offset=8, + end_lineno=58, + end_col_offset=65), + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=24), + [ + Constant( + 'Tree could not be reoriented', + lineno=60, + col_offset=25, + end_lineno=60, + end_col_offset=55)], + [], + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=56), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=56)], + [], + lineno=44, + col_offset=4, + end_lineno=60, + end_col_offset=56), + FunctionDef( + 'path_to', + arguments( + [], + [ + arg( + 'self', + lineno=64, + col_offset=16, + end_lineno=64, + end_col_offset=20), + arg( + 'from_node', + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=31), + arg( + 'to_node', + lineno=64, + col_offset=33, + end_lineno=64, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'reordered', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=17)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=65, + col_offset=20, + end_lineno=65, + end_col_offset=24), + 'from_pov', + Load(), + lineno=65, + col_offset=20, + end_lineno=65, + end_col_offset=33), + [ + Name( + 'from_node', + Load(), + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=43)], + [], + lineno=65, + col_offset=20, + end_lineno=65, + end_col_offset=44), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=44), + Assign( + [ + Name( + 'stack', + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=13)], + Attribute( + Name( + 'reordered', + Load(), + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=25), + 'children', + Load(), + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=34), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=34), + Assign( + [ + Name( + 'path', + Store(), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=12)], + List( + [ + Name( + 'from_node', + Load(), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=25)], + Load(), + lineno=67, + col_offset=15, + end_lineno=67, + end_col_offset=26), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=26), + While( + Compare( + Subscript( + Name( + 'path', + Load(), + lineno=69, + col_offset=14, + end_lineno=69, + end_col_offset=18), + UnaryOp( + USub(), + Constant( + 1, + lineno=69, + col_offset=20, + end_lineno=69, + end_col_offset=21), + lineno=69, + col_offset=19, + end_lineno=69, + end_col_offset=21), + Load(), + lineno=69, + col_offset=14, + end_lineno=69, + end_col_offset=22), + [ + NotEq()], + [ + Name( + 'to_node', + Load(), + lineno=69, + col_offset=26, + end_lineno=69, + end_col_offset=33)], + lineno=69, + col_offset=14, + end_lineno=69, + end_col_offset=33), + [ + Try( + [ + Assign( + [ + Name( + 'tree', + Store(), + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=20)], + Call( + Attribute( + Name( + 'stack', + Load(), + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=28), + 'pop', + Load(), + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=32), + [], + [], + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=34), + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=34)], + [ + ExceptHandler( + Name( + 'IndexError', + Load(), + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=29), + 'error', + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=73, + col_offset=22, + end_lineno=73, + end_col_offset=32), + [ + Constant( + 'No path found', + lineno=73, + col_offset=33, + end_lineno=73, + end_col_offset=48)], + [], + lineno=73, + col_offset=22, + end_lineno=73, + end_col_offset=49), + Name( + 'error', + Load(), + lineno=73, + col_offset=55, + end_lineno=73, + end_col_offset=60), + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=60)], + lineno=72, + col_offset=12, + end_lineno=73, + end_col_offset=60)], + [], + [], + lineno=70, + col_offset=12, + end_lineno=73, + end_col_offset=60), + If( + Compare( + Name( + 'to_node', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=22), + [ + In()], + [ + Name( + 'tree', + Load(), + lineno=74, + col_offset=26, + end_lineno=74, + end_col_offset=30)], + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=30), + [ + Expr( + Call( + Attribute( + Name( + 'path', + Load(), + lineno=75, + col_offset=16, + end_lineno=75, + end_col_offset=20), + 'append', + Load(), + lineno=75, + col_offset=16, + end_lineno=75, + end_col_offset=27), + [ + Attribute( + Name( + 'tree', + Load(), + lineno=75, + col_offset=28, + end_lineno=75, + end_col_offset=32), + 'label', + Load(), + lineno=75, + col_offset=28, + end_lineno=75, + end_col_offset=38)], + [], + lineno=75, + col_offset=16, + end_lineno=75, + end_col_offset=39), + lineno=75, + col_offset=16, + end_lineno=75, + end_col_offset=39), + Assign( + [ + Name( + 'stack', + Store(), + lineno=76, + col_offset=16, + end_lineno=76, + end_col_offset=21)], + Attribute( + Name( + 'tree', + Load(), + lineno=76, + col_offset=24, + end_lineno=76, + end_col_offset=28), + 'children', + Load(), + lineno=76, + col_offset=24, + end_lineno=76, + end_col_offset=37), + lineno=76, + col_offset=16, + end_lineno=76, + end_col_offset=37)], + [], + lineno=74, + col_offset=12, + end_lineno=76, + end_col_offset=37)], + [], + lineno=69, + col_offset=8, + end_lineno=76, + end_col_offset=37), + Return( + Name( + 'path', + Load(), + lineno=77, + col_offset=15, + end_lineno=77, + end_col_offset=19), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=19)], + [], + lineno=64, + col_offset=4, + end_lineno=77, + end_col_offset=19)], + [], + lineno=4, + col_offset=0, + end_lineno=77, + end_col_offset=19)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'json', + [ + alias( + 'dumps', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=22)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=22), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=28), + arg( + 'placeholder_3', + lineno=5, + col_offset=30, + end_lineno=5, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=5, + col_offset=39, + end_lineno=5, + end_col_offset=43)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=18)], + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=26), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=21)], + IfExp( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=36, + end_lineno=7, + end_col_offset=44), + [ + IsNot()], + [ + Constant( + None, + lineno=7, + col_offset=52, + end_lineno=7, + end_col_offset=56)], + lineno=7, + col_offset=36, + end_lineno=7, + end_col_offset=56), + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=32), + List( + [], + Load(), + lineno=7, + col_offset=62, + end_lineno=7, + end_col_offset=64), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=64), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=64)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=64), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Dict( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=20), + 'placeholder_2', + Load(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=26)], + [ + ListComp( + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=35), + 'placeholder_4', + Load(), + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=44), + [], + [], + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=46), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=10, + col_offset=51, + end_lineno=10, + end_col_offset=57), + Call( + Name( + 'sorted', + Load(), + lineno=10, + col_offset=61, + end_lineno=10, + end_col_offset=67), + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=68, + end_lineno=10, + end_col_offset=72), + 'placeholder_3', + Load(), + lineno=10, + col_offset=68, + end_lineno=10, + end_col_offset=81)], + [], + lineno=10, + col_offset=61, + end_lineno=10, + end_col_offset=82), + [], + 0)], + lineno=10, + col_offset=28, + end_lineno=10, + end_col_offset=83)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=84), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=84)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=84), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=20), + arg( + 'placeholder_7', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=12, + col_offset=29, + end_lineno=12, + end_col_offset=33)]), + [ + Return( + Call( + Name( + 'dumps', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=20), + [ + Call( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=25), + 'placeholder_4', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=34), + [], + [], + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=36)], + [ + keyword( + 'placeholder_7', + Name( + 'placeholder_7', + Load(), + lineno=13, + col_offset=45, + end_lineno=13, + end_col_offset=51), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=51)], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=52), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=52)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=52), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + arg( + 'placeholder_9', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=25), + [ + Lt()], + [ + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=33), + 'placeholder_2', + Load(), + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=39)], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=39), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=39)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=39), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + arg( + 'placeholder_9', + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + 'placeholder_4', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=28), + [], + [], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=30), + [ + Eq()], + [ + Call( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=39), + 'placeholder_4', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=48), + [], + [], + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=50)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=50), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=50)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=50), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Yield( + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=18), + 'label', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=24), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=24), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=24), + For( + Name( + 'placeholder_12', + Store(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=17), + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=25), + 'placeholder_3', + Load(), + lineno=23, + col_offset=21, + end_lineno=23, + end_col_offset=34), + [ + For( + Name( + 'placeholder_13', + Store(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=26), + Name( + 'placeholder_12', + Load(), + lineno=24, + col_offset=30, + end_lineno=24, + end_col_offset=35), + [ + Expr( + Yield( + Name( + 'grandchild', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=32), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=32), + lineno=25, + col_offset=16, + end_lineno=25, + end_col_offset=32)], + [], + lineno=24, + col_offset=12, + end_lineno=25, + end_col_offset=32)], + [], + lineno=23, + col_offset=8, + end_lineno=25, + end_col_offset=32)], + [], + lineno=21, + col_offset=4, + end_lineno=25, + end_col_offset=32), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=19), + [ + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=30), + ListComp( + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=39), + 'placeholder_14', + Load(), + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=43), + [], + [], + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=45), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=28, + col_offset=50, + end_lineno=28, + end_col_offset=56), + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=60, + end_lineno=28, + end_col_offset=64), + 'placeholder_3', + Load(), + lineno=28, + col_offset=60, + end_lineno=28, + end_col_offset=73), + [], + 0)], + lineno=28, + col_offset=32, + end_lineno=28, + end_col_offset=74)], + [], + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=75), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=75)], + [], + lineno=27, + col_offset=4, + end_lineno=28, + end_col_offset=75), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=16), + arg( + 'placeholder_9', + lineno=30, + col_offset=18, + end_lineno=30, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=12)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=19), + 'placeholder_14', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=23), + [], + [], + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=25), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=25), + Expr( + Call( + Attribute( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'placeholder_3', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=21), + 'append', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=28), + [ + Name( + 'placeholder_9', + Load(), + lineno=32, + col_offset=29, + end_lineno=32, + end_col_offset=34)], + [], + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=35), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=35), + Return( + Name( + 'placeholder_16', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=19), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=19)], + [], + lineno=30, + col_offset=4, + end_lineno=33, + end_col_offset=19), + FunctionDef( + 'placeholder_17', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=15, + end_lineno=35, + end_col_offset=19), + arg( + 'placeholder_18', + lineno=35, + col_offset=21, + end_lineno=35, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=12)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=19), + 'placeholder_14', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=23), + [], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=25), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=25), + For( + Name( + 'placeholder_12', + Store(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=17), + Call( + Name( + 'list', + Load(), + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=25), + [ + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=30), + 'placeholder_3', + Load(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=39)], + [], + lineno=37, + col_offset=21, + end_lineno=37, + end_col_offset=40), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=16), + 'placeholder_3', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=25), + 'placeholder_17', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=32), + [ + Name( + 'placeholder_12', + Load(), + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=38)], + [], + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=39), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=39), + If( + Compare( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=20), + 'placeholder_2', + Load(), + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=26), + [ + Eq()], + [ + Name( + 'placeholder_18', + Load(), + lineno=39, + col_offset=30, + end_lineno=39, + end_col_offset=34)], + lineno=39, + col_offset=15, + end_lineno=39, + end_col_offset=34), + [ + Break( + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=21)], + [], + lineno=39, + col_offset=12, + end_lineno=40, + end_col_offset=21), + Expr( + Call( + Attribute( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=16), + 'placeholder_3', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=25), + 'append', + Load(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=32), + [ + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=41, + col_offset=33, + end_lineno=41, + end_col_offset=38), + 'placeholder_17', + Load(), + lineno=41, + col_offset=33, + end_lineno=41, + end_col_offset=45), + [ + Name( + 'placeholder_18', + Load(), + lineno=41, + col_offset=46, + end_lineno=41, + end_col_offset=50)], + [], + lineno=41, + col_offset=33, + end_lineno=41, + end_col_offset=51)], + [], + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=52), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=52)], + [], + lineno=37, + col_offset=8, + end_lineno=41, + end_col_offset=52), + Return( + Name( + 'placeholder_16', + Load(), + lineno=42, + col_offset=15, + end_lineno=42, + end_col_offset=19), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=19)], + [], + lineno=35, + col_offset=4, + end_lineno=42, + end_col_offset=19), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'self', + lineno=44, + col_offset=17, + end_lineno=44, + end_col_offset=21), + arg( + 'placeholder_20', + lineno=44, + col_offset=23, + end_lineno=44, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=13)], + List( + [ + Name( + 'self', + Load(), + lineno=45, + col_offset=17, + end_lineno=45, + end_col_offset=21)], + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=22), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=22), + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=15)], + Call( + Name( + 'set', + Load(), + lineno=46, + col_offset=18, + end_lineno=46, + end_col_offset=21), + [], + [], + lineno=46, + col_offset=18, + end_lineno=46, + end_col_offset=23), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=23), + While( + Name( + 'placeholder_21', + Load(), + lineno=48, + col_offset=14, + end_lineno=48, + end_col_offset=19), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=49, + col_offset=12, + end_lineno=49, + end_col_offset=16)], + Call( + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=24), + 'pop', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=28), + [ + Constant( + 0, + lineno=49, + col_offset=29, + end_lineno=49, + end_col_offset=30)], + [], + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=31), + lineno=49, + col_offset=12, + end_lineno=49, + end_col_offset=31), + If( + Compare( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=25), + [ + In()], + [ + Name( + 'placeholder_22', + Load(), + lineno=50, + col_offset=29, + end_lineno=50, + end_col_offset=36)], + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=36), + [ + Continue( + lineno=51, + col_offset=16, + end_lineno=51, + end_col_offset=24)], + [], + lineno=50, + col_offset=12, + end_lineno=51, + end_col_offset=24), + Expr( + Call( + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=19), + 'placeholder_15', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=23), + [ + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=34)], + [], + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=35), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=35), + If( + Compare( + Name( + 'placeholder_20', + Load(), + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=24), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=54, + col_offset=28, + end_lineno=54, + end_col_offset=32), + 'placeholder_2', + Load(), + lineno=54, + col_offset=28, + end_lineno=54, + end_col_offset=38)], + lineno=54, + col_offset=15, + end_lineno=54, + end_col_offset=38), + [ + Return( + Name( + 'placeholder_16', + Load(), + lineno=55, + col_offset=23, + end_lineno=55, + end_col_offset=27), + lineno=55, + col_offset=16, + end_lineno=55, + end_col_offset=27)], + [], + lineno=54, + col_offset=12, + end_lineno=55, + end_col_offset=27), + For( + Name( + 'placeholder_12', + Store(), + lineno=57, + col_offset=16, + end_lineno=57, + end_col_offset=21), + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=29), + 'placeholder_3', + Load(), + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=38), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=21), + 'append', + Load(), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=28), + [ + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=34), + 'placeholder_15', + Load(), + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=38), + [ + Call( + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=58, + col_offset=39, + end_lineno=58, + end_col_offset=43), + 'placeholder_17', + Load(), + lineno=58, + col_offset=39, + end_lineno=58, + end_col_offset=50), + [ + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=58, + col_offset=51, + end_lineno=58, + end_col_offset=56), + 'placeholder_2', + Load(), + lineno=58, + col_offset=51, + end_lineno=58, + end_col_offset=62)], + [], + lineno=58, + col_offset=39, + end_lineno=58, + end_col_offset=63)], + [], + lineno=58, + col_offset=29, + end_lineno=58, + end_col_offset=64)], + [], + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=65), + lineno=58, + col_offset=16, + end_lineno=58, + end_col_offset=65)], + [], + lineno=57, + col_offset=12, + end_lineno=58, + end_col_offset=65)], + [], + lineno=48, + col_offset=8, + end_lineno=58, + end_col_offset=65), + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=24), + [ + Constant( + 'Tree could not be reoriented', + lineno=60, + col_offset=25, + end_lineno=60, + end_col_offset=55)], + [], + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=56), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=56)], + [], + lineno=44, + col_offset=4, + end_lineno=60, + end_col_offset=56), + FunctionDef( + 'placeholder_23', + arguments( + [], + [ + arg( + 'self', + lineno=64, + col_offset=16, + end_lineno=64, + end_col_offset=20), + arg( + 'placeholder_20', + lineno=64, + col_offset=22, + end_lineno=64, + end_col_offset=31), + arg( + 'placeholder_24', + lineno=64, + col_offset=33, + end_lineno=64, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_25', + Store(), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=17)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=65, + col_offset=20, + end_lineno=65, + end_col_offset=24), + 'placeholder_19', + Load(), + lineno=65, + col_offset=20, + end_lineno=65, + end_col_offset=33), + [ + Name( + 'placeholder_20', + Load(), + lineno=65, + col_offset=34, + end_lineno=65, + end_col_offset=43)], + [], + lineno=65, + col_offset=20, + end_lineno=65, + end_col_offset=44), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=13)], + Attribute( + Name( + 'placeholder_25', + Load(), + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=25), + 'placeholder_3', + Load(), + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=34), + lineno=66, + col_offset=8, + end_lineno=66, + end_col_offset=34), + Assign( + [ + Name( + 'placeholder_26', + Store(), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=12)], + List( + [ + Name( + 'placeholder_20', + Load(), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=25)], + Load(), + lineno=67, + col_offset=15, + end_lineno=67, + end_col_offset=26), + lineno=67, + col_offset=8, + end_lineno=67, + end_col_offset=26), + While( + Compare( + Subscript( + Name( + 'placeholder_26', + Load(), + lineno=69, + col_offset=14, + end_lineno=69, + end_col_offset=18), + UnaryOp( + USub(), + Constant( + 1, + lineno=69, + col_offset=20, + end_lineno=69, + end_col_offset=21), + lineno=69, + col_offset=19, + end_lineno=69, + end_col_offset=21), + Load(), + lineno=69, + col_offset=14, + end_lineno=69, + end_col_offset=22), + [ + NotEq()], + [ + Name( + 'placeholder_24', + Load(), + lineno=69, + col_offset=26, + end_lineno=69, + end_col_offset=33)], + lineno=69, + col_offset=14, + end_lineno=69, + end_col_offset=33), + [ + Try( + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=20)], + Call( + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=28), + 'pop', + Load(), + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=32), + [], + [], + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=34), + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=34)], + [ + ExceptHandler( + Name( + 'IndexError', + Load(), + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=29), + 'placeholder_27', + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=73, + col_offset=22, + end_lineno=73, + end_col_offset=32), + [ + Constant( + 'No path found', + lineno=73, + col_offset=33, + end_lineno=73, + end_col_offset=48)], + [], + lineno=73, + col_offset=22, + end_lineno=73, + end_col_offset=49), + Name( + 'placeholder_27', + Load(), + lineno=73, + col_offset=55, + end_lineno=73, + end_col_offset=60), + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=60)], + lineno=72, + col_offset=12, + end_lineno=73, + end_col_offset=60)], + [], + [], + lineno=70, + col_offset=12, + end_lineno=73, + end_col_offset=60), + If( + Compare( + Name( + 'placeholder_24', + Load(), + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=22), + [ + In()], + [ + Name( + 'placeholder_16', + Load(), + lineno=74, + col_offset=26, + end_lineno=74, + end_col_offset=30)], + lineno=74, + col_offset=15, + end_lineno=74, + end_col_offset=30), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_26', + Load(), + lineno=75, + col_offset=16, + end_lineno=75, + end_col_offset=20), + 'append', + Load(), + lineno=75, + col_offset=16, + end_lineno=75, + end_col_offset=27), + [ + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=75, + col_offset=28, + end_lineno=75, + end_col_offset=32), + 'placeholder_2', + Load(), + lineno=75, + col_offset=28, + end_lineno=75, + end_col_offset=38)], + [], + lineno=75, + col_offset=16, + end_lineno=75, + end_col_offset=39), + lineno=75, + col_offset=16, + end_lineno=75, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=76, + col_offset=16, + end_lineno=76, + end_col_offset=21)], + Attribute( + Name( + 'placeholder_16', + Load(), + lineno=76, + col_offset=24, + end_lineno=76, + end_col_offset=28), + 'placeholder_3', + Load(), + lineno=76, + col_offset=24, + end_lineno=76, + end_col_offset=37), + lineno=76, + col_offset=16, + end_lineno=76, + end_col_offset=37)], + [], + lineno=74, + col_offset=12, + end_lineno=76, + end_col_offset=37)], + [], + lineno=69, + col_offset=8, + end_lineno=76, + end_col_offset=37), + Return( + Name( + 'placeholder_26', + Load(), + lineno=77, + col_offset=15, + end_lineno=77, + end_col_offset=19), + lineno=77, + col_offset=8, + end_lineno=77, + end_col_offset=19)], + [], + lineno=64, + col_offset=4, + end_lineno=77, + end_col_offset=19)], + [], + lineno=4, + col_offset=0, + end_lineno=77, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-pov/representation.txt b/test/practice-pov/representation.txt new file mode 100644 index 0000000..075a2e2 --- /dev/null +++ b/test/practice-pov/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('json', [alias('dumps', lineno=1, col_offset=17, end_lineno=1, end_col_offset=22)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=22), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21), arg('placeholder_2', lineno=5, col_offset=23, end_lineno=5, end_col_offset=28), arg('placeholder_3', lineno=5, col_offset=30, end_lineno=5, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=5, col_offset=39, end_lineno=5, end_col_offset=43)]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_2', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=18)], Name('placeholder_2', Load(), lineno=6, col_offset=21, end_lineno=6, end_col_offset=26), lineno=6, col_offset=8, end_lineno=6, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_3', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=21)], IfExp(Compare(Name('placeholder_3', Load(), lineno=7, col_offset=36, end_lineno=7, end_col_offset=44), [IsNot()], [Constant(None, lineno=7, col_offset=52, end_lineno=7, end_col_offset=56)], lineno=7, col_offset=36, end_lineno=7, end_col_offset=56), Name('placeholder_3', Load(), lineno=7, col_offset=24, end_lineno=7, end_col_offset=32), List([], Load(), lineno=7, col_offset=62, end_lineno=7, end_col_offset=64), lineno=7, col_offset=24, end_lineno=7, end_col_offset=64), lineno=7, col_offset=8, end_lineno=7, end_col_offset=64)], [], lineno=5, col_offset=4, end_lineno=7, end_col_offset=64), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=9, col_offset=17, end_lineno=9, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Dict([Attribute(Name('self', Load(), lineno=10, col_offset=16, end_lineno=10, end_col_offset=20), 'placeholder_2', Load(), lineno=10, col_offset=16, end_lineno=10, end_col_offset=26)], [ListComp(Call(Attribute(Name('placeholder_5', Load(), lineno=10, col_offset=29, end_lineno=10, end_col_offset=35), 'placeholder_4', Load(), lineno=10, col_offset=29, end_lineno=10, end_col_offset=44), [], [], lineno=10, col_offset=29, end_lineno=10, end_col_offset=46), [comprehension(Name('placeholder_5', Store(), lineno=10, col_offset=51, end_lineno=10, end_col_offset=57), Call(Name('sorted', Load(), lineno=10, col_offset=61, end_lineno=10, end_col_offset=67), [Attribute(Name('self', Load(), lineno=10, col_offset=68, end_lineno=10, end_col_offset=72), 'placeholder_3', Load(), lineno=10, col_offset=68, end_lineno=10, end_col_offset=81)], [], lineno=10, col_offset=61, end_lineno=10, end_col_offset=82), [], 0)], lineno=10, col_offset=28, end_lineno=10, end_col_offset=83)], lineno=10, col_offset=15, end_lineno=10, end_col_offset=84), lineno=10, col_offset=8, end_lineno=10, end_col_offset=84)], [], lineno=9, col_offset=4, end_lineno=10, end_col_offset=84), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=12, col_offset=16, end_lineno=12, end_col_offset=20), arg('placeholder_7', lineno=12, col_offset=22, end_lineno=12, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=12, col_offset=29, end_lineno=12, end_col_offset=33)]), [Return(Call(Name('dumps', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=20), [Call(Attribute(Name('self', Load(), lineno=13, col_offset=21, end_lineno=13, end_col_offset=25), 'placeholder_4', Load(), lineno=13, col_offset=21, end_lineno=13, end_col_offset=34), [], [], lineno=13, col_offset=21, end_lineno=13, end_col_offset=36)], [keyword('placeholder_7', Name('placeholder_7', Load(), lineno=13, col_offset=45, end_lineno=13, end_col_offset=51), lineno=13, col_offset=38, end_lineno=13, end_col_offset=51)], lineno=13, col_offset=15, end_lineno=13, end_col_offset=52), lineno=13, col_offset=8, end_lineno=13, end_col_offset=52)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=52), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), arg('placeholder_9', lineno=15, col_offset=21, end_lineno=15, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Attribute(Name('self', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=19), 'placeholder_2', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=25), [Lt()], [Attribute(Name('placeholder_9', Load(), lineno=16, col_offset=28, end_lineno=16, end_col_offset=33), 'placeholder_2', Load(), lineno=16, col_offset=28, end_lineno=16, end_col_offset=39)], lineno=16, col_offset=15, end_lineno=16, end_col_offset=39), lineno=16, col_offset=8, end_lineno=16, end_col_offset=39)], [], lineno=15, col_offset=4, end_lineno=16, end_col_offset=39), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=18, col_offset=15, end_lineno=18, end_col_offset=19), arg('placeholder_9', lineno=18, col_offset=21, end_lineno=18, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Call(Attribute(Name('self', Load(), lineno=19, col_offset=15, end_lineno=19, end_col_offset=19), 'placeholder_4', Load(), lineno=19, col_offset=15, end_lineno=19, end_col_offset=28), [], [], lineno=19, col_offset=15, end_lineno=19, end_col_offset=30), [Eq()], [Call(Attribute(Name('placeholder_9', Load(), lineno=19, col_offset=34, end_lineno=19, end_col_offset=39), 'placeholder_4', Load(), lineno=19, col_offset=34, end_lineno=19, end_col_offset=48), [], [], lineno=19, col_offset=34, end_lineno=19, end_col_offset=50)], lineno=19, col_offset=15, end_lineno=19, end_col_offset=50), lineno=19, col_offset=8, end_lineno=19, end_col_offset=50)], [], lineno=18, col_offset=4, end_lineno=19, end_col_offset=50), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=21, col_offset=17, end_lineno=21, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Yield(Attribute(Name('self', Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=18), 'label', Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=24), lineno=22, col_offset=8, end_lineno=22, end_col_offset=24), lineno=22, col_offset=8, end_lineno=22, end_col_offset=24), For(Name('placeholder_12', Store(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=17), Attribute(Name('self', Load(), lineno=23, col_offset=21, end_lineno=23, end_col_offset=25), 'placeholder_3', Load(), lineno=23, col_offset=21, end_lineno=23, end_col_offset=34), [For(Name('placeholder_13', Store(), lineno=24, col_offset=16, end_lineno=24, end_col_offset=26), Name('placeholder_12', Load(), lineno=24, col_offset=30, end_lineno=24, end_col_offset=35), [Expr(Yield(Name('grandchild', Load(), lineno=25, col_offset=22, end_lineno=25, end_col_offset=32), lineno=25, col_offset=16, end_lineno=25, end_col_offset=32), lineno=25, col_offset=16, end_lineno=25, end_col_offset=32)], [], lineno=24, col_offset=12, end_lineno=25, end_col_offset=32)], [], lineno=23, col_offset=8, end_lineno=25, end_col_offset=32)], [], lineno=21, col_offset=4, end_lineno=25, end_col_offset=32), FunctionDef('placeholder_14', arguments([], [arg('self', lineno=27, col_offset=12, end_lineno=27, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=28, col_offset=15, end_lineno=28, end_col_offset=19), [Attribute(Name('self', Load(), lineno=28, col_offset=20, end_lineno=28, end_col_offset=24), 'placeholder_2', Load(), lineno=28, col_offset=20, end_lineno=28, end_col_offset=30), ListComp(Call(Attribute(Name('placeholder_5', Load(), lineno=28, col_offset=33, end_lineno=28, end_col_offset=39), 'placeholder_14', Load(), lineno=28, col_offset=33, end_lineno=28, end_col_offset=43), [], [], lineno=28, col_offset=33, end_lineno=28, end_col_offset=45), [comprehension(Name('placeholder_5', Store(), lineno=28, col_offset=50, end_lineno=28, end_col_offset=56), Attribute(Name('self', Load(), lineno=28, col_offset=60, end_lineno=28, end_col_offset=64), 'placeholder_3', Load(), lineno=28, col_offset=60, end_lineno=28, end_col_offset=73), [], 0)], lineno=28, col_offset=32, end_lineno=28, end_col_offset=74)], [], lineno=28, col_offset=15, end_lineno=28, end_col_offset=75), lineno=28, col_offset=8, end_lineno=28, end_col_offset=75)], [], lineno=27, col_offset=4, end_lineno=28, end_col_offset=75), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=30, col_offset=12, end_lineno=30, end_col_offset=16), arg('placeholder_9', lineno=30, col_offset=18, end_lineno=30, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_16', Store(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=12)], Call(Attribute(Name('self', Load(), lineno=31, col_offset=15, end_lineno=31, end_col_offset=19), 'placeholder_14', Load(), lineno=31, col_offset=15, end_lineno=31, end_col_offset=23), [], [], lineno=31, col_offset=15, end_lineno=31, end_col_offset=25), lineno=31, col_offset=8, end_lineno=31, end_col_offset=25), Expr(Call(Attribute(Attribute(Name('placeholder_16', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=12), 'placeholder_3', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=21), 'append', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=28), [Name('placeholder_9', Load(), lineno=32, col_offset=29, end_lineno=32, end_col_offset=34)], [], lineno=32, col_offset=8, end_lineno=32, end_col_offset=35), lineno=32, col_offset=8, end_lineno=32, end_col_offset=35), Return(Name('placeholder_16', Load(), lineno=33, col_offset=15, end_lineno=33, end_col_offset=19), lineno=33, col_offset=8, end_lineno=33, end_col_offset=19)], [], lineno=30, col_offset=4, end_lineno=33, end_col_offset=19), FunctionDef('placeholder_17', arguments([], [arg('self', lineno=35, col_offset=15, end_lineno=35, end_col_offset=19), arg('placeholder_18', lineno=35, col_offset=21, end_lineno=35, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_16', Store(), lineno=36, col_offset=8, end_lineno=36, end_col_offset=12)], Call(Attribute(Name('self', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=19), 'placeholder_14', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=23), [], [], lineno=36, col_offset=15, end_lineno=36, end_col_offset=25), lineno=36, col_offset=8, end_lineno=36, end_col_offset=25), For(Name('placeholder_12', Store(), lineno=37, col_offset=12, end_lineno=37, end_col_offset=17), Call(Name('list', Load(), lineno=37, col_offset=21, end_lineno=37, end_col_offset=25), [Attribute(Name('placeholder_16', Load(), lineno=37, col_offset=26, end_lineno=37, end_col_offset=30), 'placeholder_3', Load(), lineno=37, col_offset=26, end_lineno=37, end_col_offset=39)], [], lineno=37, col_offset=21, end_lineno=37, end_col_offset=40), [Expr(Call(Attribute(Attribute(Name('placeholder_16', Load(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=16), 'placeholder_3', Load(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=25), 'placeholder_17', Load(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=32), [Name('placeholder_12', Load(), lineno=38, col_offset=33, end_lineno=38, end_col_offset=38)], [], lineno=38, col_offset=12, end_lineno=38, end_col_offset=39), lineno=38, col_offset=12, end_lineno=38, end_col_offset=39), If(Compare(Attribute(Name('placeholder_12', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=20), 'placeholder_2', Load(), lineno=39, col_offset=15, end_lineno=39, end_col_offset=26), [Eq()], [Name('placeholder_18', Load(), lineno=39, col_offset=30, end_lineno=39, end_col_offset=34)], lineno=39, col_offset=15, end_lineno=39, end_col_offset=34), [Break(lineno=40, col_offset=16, end_lineno=40, end_col_offset=21)], [], lineno=39, col_offset=12, end_lineno=40, end_col_offset=21), Expr(Call(Attribute(Attribute(Name('placeholder_16', Load(), lineno=41, col_offset=12, end_lineno=41, end_col_offset=16), 'placeholder_3', Load(), lineno=41, col_offset=12, end_lineno=41, end_col_offset=25), 'append', Load(), lineno=41, col_offset=12, end_lineno=41, end_col_offset=32), [Call(Attribute(Name('placeholder_12', Load(), lineno=41, col_offset=33, end_lineno=41, end_col_offset=38), 'placeholder_17', Load(), lineno=41, col_offset=33, end_lineno=41, end_col_offset=45), [Name('placeholder_18', Load(), lineno=41, col_offset=46, end_lineno=41, end_col_offset=50)], [], lineno=41, col_offset=33, end_lineno=41, end_col_offset=51)], [], lineno=41, col_offset=12, end_lineno=41, end_col_offset=52), lineno=41, col_offset=12, end_lineno=41, end_col_offset=52)], [], lineno=37, col_offset=8, end_lineno=41, end_col_offset=52), Return(Name('placeholder_16', Load(), lineno=42, col_offset=15, end_lineno=42, end_col_offset=19), lineno=42, col_offset=8, end_lineno=42, end_col_offset=19)], [], lineno=35, col_offset=4, end_lineno=42, end_col_offset=19), FunctionDef('placeholder_19', arguments([], [arg('self', lineno=44, col_offset=17, end_lineno=44, end_col_offset=21), arg('placeholder_20', lineno=44, col_offset=23, end_lineno=44, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_21', Store(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=13)], List([Name('self', Load(), lineno=45, col_offset=17, end_lineno=45, end_col_offset=21)], Load(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=22), lineno=45, col_offset=8, end_lineno=45, end_col_offset=22), Assign([Name('placeholder_22', Store(), lineno=46, col_offset=8, end_lineno=46, end_col_offset=15)], Call(Name('set', Load(), lineno=46, col_offset=18, end_lineno=46, end_col_offset=21), [], [], lineno=46, col_offset=18, end_lineno=46, end_col_offset=23), lineno=46, col_offset=8, end_lineno=46, end_col_offset=23), While(Name('placeholder_21', Load(), lineno=48, col_offset=14, end_lineno=48, end_col_offset=19), [Assign([Name('placeholder_16', Store(), lineno=49, col_offset=12, end_lineno=49, end_col_offset=16)], Call(Attribute(Name('placeholder_21', Load(), lineno=49, col_offset=19, end_lineno=49, end_col_offset=24), 'pop', Load(), lineno=49, col_offset=19, end_lineno=49, end_col_offset=28), [Constant(0, lineno=49, col_offset=29, end_lineno=49, end_col_offset=30)], [], lineno=49, col_offset=19, end_lineno=49, end_col_offset=31), lineno=49, col_offset=12, end_lineno=49, end_col_offset=31), If(Compare(Attribute(Name('placeholder_16', Load(), lineno=50, col_offset=15, end_lineno=50, end_col_offset=19), 'placeholder_2', Load(), lineno=50, col_offset=15, end_lineno=50, end_col_offset=25), [In()], [Name('placeholder_22', Load(), lineno=50, col_offset=29, end_lineno=50, end_col_offset=36)], lineno=50, col_offset=15, end_lineno=50, end_col_offset=36), [Continue(lineno=51, col_offset=16, end_lineno=51, end_col_offset=24)], [], lineno=50, col_offset=12, end_lineno=51, end_col_offset=24), Expr(Call(Attribute(Name('placeholder_22', Load(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=19), 'placeholder_15', Load(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=23), [Attribute(Name('placeholder_16', Load(), lineno=53, col_offset=24, end_lineno=53, end_col_offset=28), 'placeholder_2', Load(), lineno=53, col_offset=24, end_lineno=53, end_col_offset=34)], [], lineno=53, col_offset=12, end_lineno=53, end_col_offset=35), lineno=53, col_offset=12, end_lineno=53, end_col_offset=35), If(Compare(Name('placeholder_20', Load(), lineno=54, col_offset=15, end_lineno=54, end_col_offset=24), [Eq()], [Attribute(Name('placeholder_16', Load(), lineno=54, col_offset=28, end_lineno=54, end_col_offset=32), 'placeholder_2', Load(), lineno=54, col_offset=28, end_lineno=54, end_col_offset=38)], lineno=54, col_offset=15, end_lineno=54, end_col_offset=38), [Return(Name('placeholder_16', Load(), lineno=55, col_offset=23, end_lineno=55, end_col_offset=27), lineno=55, col_offset=16, end_lineno=55, end_col_offset=27)], [], lineno=54, col_offset=12, end_lineno=55, end_col_offset=27), For(Name('placeholder_12', Store(), lineno=57, col_offset=16, end_lineno=57, end_col_offset=21), Attribute(Name('placeholder_16', Load(), lineno=57, col_offset=25, end_lineno=57, end_col_offset=29), 'placeholder_3', Load(), lineno=57, col_offset=25, end_lineno=57, end_col_offset=38), [Expr(Call(Attribute(Name('placeholder_21', Load(), lineno=58, col_offset=16, end_lineno=58, end_col_offset=21), 'append', Load(), lineno=58, col_offset=16, end_lineno=58, end_col_offset=28), [Call(Attribute(Name('placeholder_12', Load(), lineno=58, col_offset=29, end_lineno=58, end_col_offset=34), 'placeholder_15', Load(), lineno=58, col_offset=29, end_lineno=58, end_col_offset=38), [Call(Attribute(Name('placeholder_16', Load(), lineno=58, col_offset=39, end_lineno=58, end_col_offset=43), 'placeholder_17', Load(), lineno=58, col_offset=39, end_lineno=58, end_col_offset=50), [Attribute(Name('placeholder_12', Load(), lineno=58, col_offset=51, end_lineno=58, end_col_offset=56), 'placeholder_2', Load(), lineno=58, col_offset=51, end_lineno=58, end_col_offset=62)], [], lineno=58, col_offset=39, end_lineno=58, end_col_offset=63)], [], lineno=58, col_offset=29, end_lineno=58, end_col_offset=64)], [], lineno=58, col_offset=16, end_lineno=58, end_col_offset=65), lineno=58, col_offset=16, end_lineno=58, end_col_offset=65)], [], lineno=57, col_offset=12, end_lineno=58, end_col_offset=65)], [], lineno=48, col_offset=8, end_lineno=58, end_col_offset=65), Raise(Call(Name('ValueError', Load(), lineno=60, col_offset=14, end_lineno=60, end_col_offset=24), [Constant('Tree could not be reoriented', lineno=60, col_offset=25, end_lineno=60, end_col_offset=55)], [], lineno=60, col_offset=14, end_lineno=60, end_col_offset=56), lineno=60, col_offset=8, end_lineno=60, end_col_offset=56)], [], lineno=44, col_offset=4, end_lineno=60, end_col_offset=56), FunctionDef('placeholder_23', arguments([], [arg('self', lineno=64, col_offset=16, end_lineno=64, end_col_offset=20), arg('placeholder_20', lineno=64, col_offset=22, end_lineno=64, end_col_offset=31), arg('placeholder_24', lineno=64, col_offset=33, end_lineno=64, end_col_offset=40)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_25', Store(), lineno=65, col_offset=8, end_lineno=65, end_col_offset=17)], Call(Attribute(Name('self', Load(), lineno=65, col_offset=20, end_lineno=65, end_col_offset=24), 'placeholder_19', Load(), lineno=65, col_offset=20, end_lineno=65, end_col_offset=33), [Name('placeholder_20', Load(), lineno=65, col_offset=34, end_lineno=65, end_col_offset=43)], [], lineno=65, col_offset=20, end_lineno=65, end_col_offset=44), lineno=65, col_offset=8, end_lineno=65, end_col_offset=44), Assign([Name('placeholder_21', Store(), lineno=66, col_offset=8, end_lineno=66, end_col_offset=13)], Attribute(Name('placeholder_25', Load(), lineno=66, col_offset=16, end_lineno=66, end_col_offset=25), 'placeholder_3', Load(), lineno=66, col_offset=16, end_lineno=66, end_col_offset=34), lineno=66, col_offset=8, end_lineno=66, end_col_offset=34), Assign([Name('placeholder_26', Store(), lineno=67, col_offset=8, end_lineno=67, end_col_offset=12)], List([Name('placeholder_20', Load(), lineno=67, col_offset=16, end_lineno=67, end_col_offset=25)], Load(), lineno=67, col_offset=15, end_lineno=67, end_col_offset=26), lineno=67, col_offset=8, end_lineno=67, end_col_offset=26), While(Compare(Subscript(Name('placeholder_26', Load(), lineno=69, col_offset=14, end_lineno=69, end_col_offset=18), UnaryOp(USub(), Constant(1, lineno=69, col_offset=20, end_lineno=69, end_col_offset=21), lineno=69, col_offset=19, end_lineno=69, end_col_offset=21), Load(), lineno=69, col_offset=14, end_lineno=69, end_col_offset=22), [NotEq()], [Name('placeholder_24', Load(), lineno=69, col_offset=26, end_lineno=69, end_col_offset=33)], lineno=69, col_offset=14, end_lineno=69, end_col_offset=33), [Try([Assign([Name('placeholder_16', Store(), lineno=71, col_offset=16, end_lineno=71, end_col_offset=20)], Call(Attribute(Name('placeholder_21', Load(), lineno=71, col_offset=23, end_lineno=71, end_col_offset=28), 'pop', Load(), lineno=71, col_offset=23, end_lineno=71, end_col_offset=32), [], [], lineno=71, col_offset=23, end_lineno=71, end_col_offset=34), lineno=71, col_offset=16, end_lineno=71, end_col_offset=34)], [ExceptHandler(Name('IndexError', Load(), lineno=72, col_offset=19, end_lineno=72, end_col_offset=29), 'placeholder_27', [Raise(Call(Name('ValueError', Load(), lineno=73, col_offset=22, end_lineno=73, end_col_offset=32), [Constant('No path found', lineno=73, col_offset=33, end_lineno=73, end_col_offset=48)], [], lineno=73, col_offset=22, end_lineno=73, end_col_offset=49), Name('placeholder_27', Load(), lineno=73, col_offset=55, end_lineno=73, end_col_offset=60), lineno=73, col_offset=16, end_lineno=73, end_col_offset=60)], lineno=72, col_offset=12, end_lineno=73, end_col_offset=60)], [], [], lineno=70, col_offset=12, end_lineno=73, end_col_offset=60), If(Compare(Name('placeholder_24', Load(), lineno=74, col_offset=15, end_lineno=74, end_col_offset=22), [In()], [Name('placeholder_16', Load(), lineno=74, col_offset=26, end_lineno=74, end_col_offset=30)], lineno=74, col_offset=15, end_lineno=74, end_col_offset=30), [Expr(Call(Attribute(Name('placeholder_26', Load(), lineno=75, col_offset=16, end_lineno=75, end_col_offset=20), 'append', Load(), lineno=75, col_offset=16, end_lineno=75, end_col_offset=27), [Attribute(Name('placeholder_16', Load(), lineno=75, col_offset=28, end_lineno=75, end_col_offset=32), 'placeholder_2', Load(), lineno=75, col_offset=28, end_lineno=75, end_col_offset=38)], [], lineno=75, col_offset=16, end_lineno=75, end_col_offset=39), lineno=75, col_offset=16, end_lineno=75, end_col_offset=39), Assign([Name('placeholder_21', Store(), lineno=76, col_offset=16, end_lineno=76, end_col_offset=21)], Attribute(Name('placeholder_16', Load(), lineno=76, col_offset=24, end_lineno=76, end_col_offset=28), 'placeholder_3', Load(), lineno=76, col_offset=24, end_lineno=76, end_col_offset=37), lineno=76, col_offset=16, end_lineno=76, end_col_offset=37)], [], lineno=74, col_offset=12, end_lineno=76, end_col_offset=37)], [], lineno=69, col_offset=8, end_lineno=76, end_col_offset=37), Return(Name('placeholder_26', Load(), lineno=77, col_offset=15, end_lineno=77, end_col_offset=19), lineno=77, col_offset=8, end_lineno=77, end_col_offset=19)], [], lineno=64, col_offset=4, end_lineno=77, end_col_offset=19)], [], lineno=4, col_offset=0, end_lineno=77, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/practice-prime-factors/.meta/config.json b/test/practice-prime-factors/.meta/config.json new file mode 100644 index 0000000..f50d3fc --- /dev/null +++ b/test/practice-prime-factors/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "crsmi", + "Dog", + "ikhadykin", + "kytrinyx", + "lowks", + "N-Parsons", + "pheanex", + "sjakobi", + "subkrish", + "tqa236" + ], + "files": { + "solution": [ + "prime_factors.py" + ], + "test": [ + "prime_factors_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Compute the prime factors of a given natural number.", + "source": "The Prime Factors Kata by Uncle Bob", + "source_url": "https://web.archive.org/web/20221026171801/http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" +} diff --git a/test/practice-prime-factors/mapping.json b/test/practice-prime-factors/mapping.json new file mode 100644 index 0000000..4141790 --- /dev/null +++ b/test/practice-prime-factors/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "factors", + "placeholder_1": "value", + "placeholder_2": "factor_list", + "placeholder_3": "divisor" +} \ No newline at end of file diff --git a/test/practice-prime-factors/prime_factors.py b/test/practice-prime-factors/prime_factors.py new file mode 100644 index 0000000..4224b7e --- /dev/null +++ b/test/practice-prime-factors/prime_factors.py @@ -0,0 +1,11 @@ +def factors(value): + factor_list = [] + divisor = 2 + while value > 1: + while value % divisor == 0: + factor_list.append(divisor) + value /= divisor + + divisor += 1 + + return factor_list diff --git a/test/practice-prime-factors/representation.json b/test/practice-prime-factors/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-prime-factors/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-prime-factors/representation.out b/test/practice-prime-factors/representation.out new file mode 100644 index 0000000..01144fa --- /dev/null +++ b/test/practice-prime-factors/representation.out @@ -0,0 +1,448 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = [] + placeholder_3 = 2 + while placeholder_1 > 1: + while placeholder_1 % placeholder_3 == 0: + placeholder_2.append(placeholder_3) + placeholder_1 /= placeholder_3 + placeholder_3 += 1 + return placeholder_2 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'factors', + arguments( + [], + [ + arg( + 'value', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'factor_list', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=15)], + List( + [], + Load(), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=20), + Assign( + [ + Name( + 'divisor', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11)], + Constant( + 2, + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=15), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=15), + While( + Compare( + Name( + 'value', + Load(), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=15), + [ + Gt()], + [ + Constant( + 1, + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=19)], + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=19), + [ + While( + Compare( + BinOp( + Name( + 'value', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=19), + Mod(), + Name( + 'divisor', + Load(), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=29), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=29), + [ + Eq()], + [ + Constant( + 0, + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=34)], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=34), + [ + Expr( + Call( + Attribute( + Name( + 'factor_list', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=23), + 'append', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=30), + [ + Name( + 'divisor', + Load(), + lineno=6, + col_offset=31, + end_lineno=6, + end_col_offset=38)], + [], + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=39), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=39), + AugAssign( + Name( + 'value', + Store(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=17), + Div(), + Name( + 'divisor', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=28), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=28)], + [], + lineno=5, + col_offset=8, + end_lineno=7, + end_col_offset=28), + AugAssign( + Name( + 'divisor', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=15), + Add(), + Constant( + 1, + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=20), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=20)], + [], + lineno=4, + col_offset=4, + end_lineno=9, + end_col_offset=20), + Return( + Name( + 'factor_list', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=22)], + [], + lineno=1, + col_offset=0, + end_lineno=11, + end_col_offset=22)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=15)], + List( + [], + Load(), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=20), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11)], + Constant( + 2, + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=15), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=15), + While( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=15), + [ + Gt()], + [ + Constant( + 1, + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=19)], + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=19), + [ + While( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=19), + Mod(), + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=29), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=29), + [ + Eq()], + [ + Constant( + 0, + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=34)], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=34), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=23), + 'append', + Load(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=30), + [ + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=31, + end_lineno=6, + end_col_offset=38)], + [], + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=39), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=39), + AugAssign( + Name( + 'placeholder_1', + Store(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=17), + Div(), + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=28), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=28)], + [], + lineno=5, + col_offset=8, + end_lineno=7, + end_col_offset=28), + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=15), + Add(), + Constant( + 1, + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=20), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=20)], + [], + lineno=4, + col_offset=4, + end_lineno=9, + end_col_offset=20), + Return( + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=22)], + [], + lineno=1, + col_offset=0, + end_lineno=11, + end_col_offset=22)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-prime-factors/representation.txt b/test/practice-prime-factors/representation.txt new file mode 100644 index 0000000..b2d2be6 --- /dev/null +++ b/test/practice-prime-factors/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=12, end_lineno=1, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=15)], List([], Load(), lineno=2, col_offset=18, end_lineno=2, end_col_offset=20), lineno=2, col_offset=4, end_lineno=2, end_col_offset=20), Assign([Name('placeholder_3', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=11)], Constant(2, lineno=3, col_offset=14, end_lineno=3, end_col_offset=15), lineno=3, col_offset=4, end_lineno=3, end_col_offset=15), While(Compare(Name('placeholder_1', Load(), lineno=4, col_offset=10, end_lineno=4, end_col_offset=15), [Gt()], [Constant(1, lineno=4, col_offset=18, end_lineno=4, end_col_offset=19)], lineno=4, col_offset=10, end_lineno=4, end_col_offset=19), [While(Compare(BinOp(Name('placeholder_1', Load(), lineno=5, col_offset=14, end_lineno=5, end_col_offset=19), Mod(), Name('placeholder_3', Load(), lineno=5, col_offset=22, end_lineno=5, end_col_offset=29), lineno=5, col_offset=14, end_lineno=5, end_col_offset=29), [Eq()], [Constant(0, lineno=5, col_offset=33, end_lineno=5, end_col_offset=34)], lineno=5, col_offset=14, end_lineno=5, end_col_offset=34), [Expr(Call(Attribute(Name('placeholder_2', Load(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=23), 'append', Load(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=30), [Name('placeholder_3', Load(), lineno=6, col_offset=31, end_lineno=6, end_col_offset=38)], [], lineno=6, col_offset=12, end_lineno=6, end_col_offset=39), lineno=6, col_offset=12, end_lineno=6, end_col_offset=39), AugAssign(Name('placeholder_1', Store(), lineno=7, col_offset=12, end_lineno=7, end_col_offset=17), Div(), Name('placeholder_3', Load(), lineno=7, col_offset=21, end_lineno=7, end_col_offset=28), lineno=7, col_offset=12, end_lineno=7, end_col_offset=28)], [], lineno=5, col_offset=8, end_lineno=7, end_col_offset=28), AugAssign(Name('placeholder_3', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=15), Add(), Constant(1, lineno=9, col_offset=19, end_lineno=9, end_col_offset=20), lineno=9, col_offset=8, end_lineno=9, end_col_offset=20)], [], lineno=4, col_offset=4, end_lineno=9, end_col_offset=20), Return(Name('placeholder_2', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=22), lineno=11, col_offset=4, end_lineno=11, end_col_offset=22)], [], lineno=1, col_offset=0, end_lineno=11, end_col_offset=22)], []) \ No newline at end of file diff --git a/test/practice-protein-translation/.meta/config.json b/test/practice-protein-translation/.meta/config.json new file mode 100644 index 0000000..3a2569b --- /dev/null +++ b/test/practice-protein-translation/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "cptjackson" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "N-Parsons", + "nmbrgts", + "sjwarner-bp", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "protein_translation.py" + ], + "test": [ + "protein_translation_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Translate RNA sequences into proteins.", + "source": "Tyler Long" +} diff --git a/test/practice-protein-translation/mapping.json b/test/practice-protein-translation/mapping.json new file mode 100644 index 0000000..0cf1ea0 --- /dev/null +++ b/test/practice-protein-translation/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "CODONS", + "placeholder_1": "of_codon", + "placeholder_2": "codon", + "placeholder_3": "proteins", + "placeholder_4": "strand", + "placeholder_5": "protein_list", + "placeholder_6": "_chunkstring", + "placeholder_7": "string", + "placeholder_8": "number", + "placeholder_9": "idx" +} \ No newline at end of file diff --git a/test/practice-protein-translation/protein_translation.py b/test/practice-protein-translation/protein_translation.py new file mode 100644 index 0000000..e8c2ac2 --- /dev/null +++ b/test/practice-protein-translation/protein_translation.py @@ -0,0 +1,25 @@ +CODONS = {'AUG': 'Methionine', 'UUU': 'Phenylalanine', + 'UUC': 'Phenylalanine', 'UUA': 'Leucine', 'UUG': 'Leucine', + 'UCU': 'Serine', 'UCC': 'Serine', 'UCA': 'Serine', + 'UCG': 'Serine', 'UAU': 'Tyrosine', 'UAC': 'Tyrosine', + 'UGU': 'Cysteine', 'UGC': 'Cysteine', 'UGG': 'Tryptophan', + 'UAA': 'STOP', 'UAG': 'STOP', 'UGA': 'STOP'} + + +def of_codon(codon): + if codon not in CODONS: + raise ValueError(f'Invalid codon: {codon}') + return CODONS[codon] + + +def proteins(strand): + protein_list = [] + for codon in map(of_codon, _chunkstring(strand, 3)): + if codon == 'STOP': + break + protein_list.append(codon) + return protein_list + + +def _chunkstring(string, number): + return (string[idx:number + idx] for idx in range(0, len(string), number)) diff --git a/test/practice-protein-translation/representation.json b/test/practice-protein-translation/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-protein-translation/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-protein-translation/representation.out b/test/practice-protein-translation/representation.out new file mode 100644 index 0000000..7b96129 --- /dev/null +++ b/test/practice-protein-translation/representation.out @@ -0,0 +1,1380 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = { + "AUG": "Methionine", + "UUU": "Phenylalanine", + "UUC": "Phenylalanine", + "UUA": "Leucine", + "UUG": "Leucine", + "UCU": "Serine", + "UCC": "Serine", + "UCA": "Serine", + "UCG": "Serine", + "UAU": "Tyrosine", + "UAC": "Tyrosine", + "UGU": "Cysteine", + "UGC": "Cysteine", + "UGG": "Tryptophan", + "UAA": "STOP", + "UAG": "STOP", + "UGA": "STOP", +} + + +def placeholder_1(placeholder_2): + if placeholder_2 not in placeholder_0: + raise ValueError(f"Invalid codon: {placeholder_2}") + return placeholder_0[placeholder_2] + + +def placeholder_3(placeholder_4): + placeholder_5 = [] + for placeholder_2 in map(placeholder_1, _chunkstring(placeholder_4, 3)): + if placeholder_2 == "STOP": + break + placeholder_5.append(placeholder_2) + return placeholder_5 + + +def placeholder_6(placeholder_7, placeholder_8): + return ( + placeholder_7[placeholder_9 : placeholder_8 + placeholder_9] + for placeholder_9 in range(0, len(placeholder_7), placeholder_8) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'CODONS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + Dict( + [ + Constant( + 'AUG', + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=15), + Constant( + 'UUU', + lineno=1, + col_offset=31, + end_lineno=1, + end_col_offset=36), + Constant( + 'UUC', + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=15), + Constant( + 'UUA', + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=39), + Constant( + 'UUG', + lineno=2, + col_offset=52, + end_lineno=2, + end_col_offset=57), + Constant( + 'UCU', + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=15), + Constant( + 'UCC', + lineno=3, + col_offset=27, + end_lineno=3, + end_col_offset=32), + Constant( + 'UCA', + lineno=3, + col_offset=44, + end_lineno=3, + end_col_offset=49), + Constant( + 'UCG', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=15), + Constant( + 'UAU', + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=32), + Constant( + 'UAC', + lineno=4, + col_offset=46, + end_lineno=4, + end_col_offset=51), + Constant( + 'UGU', + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=15), + Constant( + 'UGC', + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=34), + Constant( + 'UGG', + lineno=5, + col_offset=48, + end_lineno=5, + end_col_offset=53), + Constant( + 'UAA', + lineno=6, + col_offset=10, + end_lineno=6, + end_col_offset=15), + Constant( + 'UAG', + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=30), + Constant( + 'UGA', + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=45)], + [ + Constant( + 'Methionine', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=29), + Constant( + 'Phenylalanine', + lineno=1, + col_offset=38, + end_lineno=1, + end_col_offset=53), + Constant( + 'Phenylalanine', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=32), + Constant( + 'Leucine', + lineno=2, + col_offset=41, + end_lineno=2, + end_col_offset=50), + Constant( + 'Leucine', + lineno=2, + col_offset=59, + end_lineno=2, + end_col_offset=68), + Constant( + 'Serine', + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=25), + Constant( + 'Serine', + lineno=3, + col_offset=34, + end_lineno=3, + end_col_offset=42), + Constant( + 'Serine', + lineno=3, + col_offset=51, + end_lineno=3, + end_col_offset=59), + Constant( + 'Serine', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=25), + Constant( + 'Tyrosine', + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=44), + Constant( + 'Tyrosine', + lineno=4, + col_offset=53, + end_lineno=4, + end_col_offset=63), + Constant( + 'Cysteine', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=27), + Constant( + 'Cysteine', + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=46), + Constant( + 'Tryptophan', + lineno=5, + col_offset=55, + end_lineno=5, + end_col_offset=67), + Constant( + 'STOP', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=23), + Constant( + 'STOP', + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=38), + Constant( + 'STOP', + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=53)], + lineno=1, + col_offset=9, + end_lineno=6, + end_col_offset=54), + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=54), + FunctionDef( + 'of_codon', + arguments( + [], + [ + arg( + 'codon', + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'codon', + Load(), + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=12), + [ + NotIn()], + [ + Name( + 'CODONS', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=26)], + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=24), + [ + JoinedStr( + [ + Constant( + 'Invalid codon: ', + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=50), + FormattedValue( + Name( + 'codon', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=48), + -1, + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=50)], + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=50)], + [], + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=51), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=51)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=51), + Return( + Subscript( + Name( + 'CODONS', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=17), + Name( + 'codon', + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=23), + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=24), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=24)], + [], + lineno=9, + col_offset=0, + end_lineno=12, + end_col_offset=24), + FunctionDef( + 'proteins', + arguments( + [], + [ + arg( + 'strand', + lineno=15, + col_offset=13, + end_lineno=15, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'protein_list', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=16)], + List( + [], + Load(), + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=21), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=21), + For( + Name( + 'codon', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=13), + Call( + Name( + 'map', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=20), + [ + Name( + 'of_codon', + Load(), + lineno=17, + col_offset=21, + end_lineno=17, + end_col_offset=29), + Call( + Name( + '_chunkstring', + Load(), + lineno=17, + col_offset=31, + end_lineno=17, + end_col_offset=43), + [ + Name( + 'strand', + Load(), + lineno=17, + col_offset=44, + end_lineno=17, + end_col_offset=50), + Constant( + 3, + lineno=17, + col_offset=52, + end_lineno=17, + end_col_offset=53)], + [], + lineno=17, + col_offset=31, + end_lineno=17, + end_col_offset=54)], + [], + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=55), + [ + If( + Compare( + Name( + 'codon', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 'STOP', + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=26)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=26), + [ + Break( + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=17)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=17), + Expr( + Call( + Attribute( + Name( + 'protein_list', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=20), + 'append', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=27), + [ + Name( + 'codon', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=33)], + [], + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=34), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=34)], + [], + lineno=17, + col_offset=4, + end_lineno=20, + end_col_offset=34), + Return( + Name( + 'protein_list', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=23), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=23)], + [], + lineno=15, + col_offset=0, + end_lineno=21, + end_col_offset=23), + FunctionDef( + '_chunkstring', + arguments( + [], + [ + arg( + 'string', + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=23), + arg( + 'number', + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + GeneratorExp( + Subscript( + Name( + 'string', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=18), + Slice( + Name( + 'idx', + Load(), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=22), + BinOp( + Name( + 'number', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=29), + Add(), + Name( + 'idx', + Load(), + lineno=25, + col_offset=32, + end_lineno=25, + end_col_offset=35), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=35), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=35), + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=36), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=44), + Call( + Name( + 'range', + Load(), + lineno=25, + col_offset=48, + end_lineno=25, + end_col_offset=53), + [ + Constant( + 0, + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=55), + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=57, + end_lineno=25, + end_col_offset=60), + [ + Name( + 'string', + Load(), + lineno=25, + col_offset=61, + end_lineno=25, + end_col_offset=67)], + [], + lineno=25, + col_offset=57, + end_lineno=25, + end_col_offset=68), + Name( + 'number', + Load(), + lineno=25, + col_offset=70, + end_lineno=25, + end_col_offset=76)], + [], + lineno=25, + col_offset=48, + end_lineno=25, + end_col_offset=77), + [], + 0)], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=78), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=78)], + [], + lineno=24, + col_offset=0, + end_lineno=25, + end_col_offset=78)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + Dict( + [ + Constant( + 'AUG', + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=15), + Constant( + 'UUU', + lineno=1, + col_offset=31, + end_lineno=1, + end_col_offset=36), + Constant( + 'UUC', + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=15), + Constant( + 'UUA', + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=39), + Constant( + 'UUG', + lineno=2, + col_offset=52, + end_lineno=2, + end_col_offset=57), + Constant( + 'UCU', + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=15), + Constant( + 'UCC', + lineno=3, + col_offset=27, + end_lineno=3, + end_col_offset=32), + Constant( + 'UCA', + lineno=3, + col_offset=44, + end_lineno=3, + end_col_offset=49), + Constant( + 'UCG', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=15), + Constant( + 'UAU', + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=32), + Constant( + 'UAC', + lineno=4, + col_offset=46, + end_lineno=4, + end_col_offset=51), + Constant( + 'UGU', + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=15), + Constant( + 'UGC', + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=34), + Constant( + 'UGG', + lineno=5, + col_offset=48, + end_lineno=5, + end_col_offset=53), + Constant( + 'UAA', + lineno=6, + col_offset=10, + end_lineno=6, + end_col_offset=15), + Constant( + 'UAG', + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=30), + Constant( + 'UGA', + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=45)], + [ + Constant( + 'Methionine', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=29), + Constant( + 'Phenylalanine', + lineno=1, + col_offset=38, + end_lineno=1, + end_col_offset=53), + Constant( + 'Phenylalanine', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=32), + Constant( + 'Leucine', + lineno=2, + col_offset=41, + end_lineno=2, + end_col_offset=50), + Constant( + 'Leucine', + lineno=2, + col_offset=59, + end_lineno=2, + end_col_offset=68), + Constant( + 'Serine', + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=25), + Constant( + 'Serine', + lineno=3, + col_offset=34, + end_lineno=3, + end_col_offset=42), + Constant( + 'Serine', + lineno=3, + col_offset=51, + end_lineno=3, + end_col_offset=59), + Constant( + 'Serine', + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=25), + Constant( + 'Tyrosine', + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=44), + Constant( + 'Tyrosine', + lineno=4, + col_offset=53, + end_lineno=4, + end_col_offset=63), + Constant( + 'Cysteine', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=27), + Constant( + 'Cysteine', + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=46), + Constant( + 'Tryptophan', + lineno=5, + col_offset=55, + end_lineno=5, + end_col_offset=67), + Constant( + 'STOP', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=23), + Constant( + 'STOP', + lineno=6, + col_offset=32, + end_lineno=6, + end_col_offset=38), + Constant( + 'STOP', + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=53)], + lineno=1, + col_offset=9, + end_lineno=6, + end_col_offset=54), + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=54), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=12), + [ + NotIn()], + [ + Name( + 'placeholder_0', + Load(), + lineno=10, + col_offset=20, + end_lineno=10, + end_col_offset=26)], + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=24), + [ + JoinedStr( + [ + Constant( + 'Invalid codon: ', + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=50), + FormattedValue( + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=48), + -1, + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=50)], + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=50)], + [], + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=51), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=51)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=51), + Return( + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=17), + Name( + 'placeholder_2', + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=23), + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=24), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=24)], + [], + lineno=9, + col_offset=0, + end_lineno=12, + end_col_offset=24), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=15, + col_offset=13, + end_lineno=15, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=16)], + List( + [], + Load(), + lineno=16, + col_offset=19, + end_lineno=16, + end_col_offset=21), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=21), + For( + Name( + 'placeholder_2', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=13), + Call( + Name( + 'map', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=20), + [ + Name( + 'placeholder_1', + Load(), + lineno=17, + col_offset=21, + end_lineno=17, + end_col_offset=29), + Call( + Name( + '_chunkstring', + Load(), + lineno=17, + col_offset=31, + end_lineno=17, + end_col_offset=43), + [ + Name( + 'placeholder_4', + Load(), + lineno=17, + col_offset=44, + end_lineno=17, + end_col_offset=50), + Constant( + 3, + lineno=17, + col_offset=52, + end_lineno=17, + end_col_offset=53)], + [], + lineno=17, + col_offset=31, + end_lineno=17, + end_col_offset=54)], + [], + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=55), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 'STOP', + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=26)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=26), + [ + Break( + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=17)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=17), + Expr( + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=20), + 'append', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=27), + [ + Name( + 'placeholder_2', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=33)], + [], + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=34), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=34)], + [], + lineno=17, + col_offset=4, + end_lineno=20, + end_col_offset=34), + Return( + Name( + 'placeholder_5', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=23), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=23)], + [], + lineno=15, + col_offset=0, + end_lineno=21, + end_col_offset=23), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=24, + col_offset=17, + end_lineno=24, + end_col_offset=23), + arg( + 'placeholder_8', + lineno=24, + col_offset=25, + end_lineno=24, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + GeneratorExp( + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=18), + Slice( + Name( + 'placeholder_9', + Load(), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=22), + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=29), + Add(), + Name( + 'placeholder_9', + Load(), + lineno=25, + col_offset=32, + end_lineno=25, + end_col_offset=35), + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=35), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=35), + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=36), + [ + comprehension( + Name( + 'placeholder_9', + Store(), + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=44), + Call( + Name( + 'range', + Load(), + lineno=25, + col_offset=48, + end_lineno=25, + end_col_offset=53), + [ + Constant( + 0, + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=55), + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=57, + end_lineno=25, + end_col_offset=60), + [ + Name( + 'placeholder_7', + Load(), + lineno=25, + col_offset=61, + end_lineno=25, + end_col_offset=67)], + [], + lineno=25, + col_offset=57, + end_lineno=25, + end_col_offset=68), + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=70, + end_lineno=25, + end_col_offset=76)], + [], + lineno=25, + col_offset=48, + end_lineno=25, + end_col_offset=77), + [], + 0)], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=78), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=78)], + [], + lineno=24, + col_offset=0, + end_lineno=25, + end_col_offset=78)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-protein-translation/representation.txt b/test/practice-protein-translation/representation.txt new file mode 100644 index 0000000..7e6f2a5 --- /dev/null +++ b/test/practice-protein-translation/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=6)], Dict([Constant('AUG', lineno=1, col_offset=10, end_lineno=1, end_col_offset=15), Constant('UUU', lineno=1, col_offset=31, end_lineno=1, end_col_offset=36), Constant('UUC', lineno=2, col_offset=10, end_lineno=2, end_col_offset=15), Constant('UUA', lineno=2, col_offset=34, end_lineno=2, end_col_offset=39), Constant('UUG', lineno=2, col_offset=52, end_lineno=2, end_col_offset=57), Constant('UCU', lineno=3, col_offset=10, end_lineno=3, end_col_offset=15), Constant('UCC', lineno=3, col_offset=27, end_lineno=3, end_col_offset=32), Constant('UCA', lineno=3, col_offset=44, end_lineno=3, end_col_offset=49), Constant('UCG', lineno=4, col_offset=10, end_lineno=4, end_col_offset=15), Constant('UAU', lineno=4, col_offset=27, end_lineno=4, end_col_offset=32), Constant('UAC', lineno=4, col_offset=46, end_lineno=4, end_col_offset=51), Constant('UGU', lineno=5, col_offset=10, end_lineno=5, end_col_offset=15), Constant('UGC', lineno=5, col_offset=29, end_lineno=5, end_col_offset=34), Constant('UGG', lineno=5, col_offset=48, end_lineno=5, end_col_offset=53), Constant('UAA', lineno=6, col_offset=10, end_lineno=6, end_col_offset=15), Constant('UAG', lineno=6, col_offset=25, end_lineno=6, end_col_offset=30), Constant('UGA', lineno=6, col_offset=40, end_lineno=6, end_col_offset=45)], [Constant('Methionine', lineno=1, col_offset=17, end_lineno=1, end_col_offset=29), Constant('Phenylalanine', lineno=1, col_offset=38, end_lineno=1, end_col_offset=53), Constant('Phenylalanine', lineno=2, col_offset=17, end_lineno=2, end_col_offset=32), Constant('Leucine', lineno=2, col_offset=41, end_lineno=2, end_col_offset=50), Constant('Leucine', lineno=2, col_offset=59, end_lineno=2, end_col_offset=68), Constant('Serine', lineno=3, col_offset=17, end_lineno=3, end_col_offset=25), Constant('Serine', lineno=3, col_offset=34, end_lineno=3, end_col_offset=42), Constant('Serine', lineno=3, col_offset=51, end_lineno=3, end_col_offset=59), Constant('Serine', lineno=4, col_offset=17, end_lineno=4, end_col_offset=25), Constant('Tyrosine', lineno=4, col_offset=34, end_lineno=4, end_col_offset=44), Constant('Tyrosine', lineno=4, col_offset=53, end_lineno=4, end_col_offset=63), Constant('Cysteine', lineno=5, col_offset=17, end_lineno=5, end_col_offset=27), Constant('Cysteine', lineno=5, col_offset=36, end_lineno=5, end_col_offset=46), Constant('Tryptophan', lineno=5, col_offset=55, end_lineno=5, end_col_offset=67), Constant('STOP', lineno=6, col_offset=17, end_lineno=6, end_col_offset=23), Constant('STOP', lineno=6, col_offset=32, end_lineno=6, end_col_offset=38), Constant('STOP', lineno=6, col_offset=47, end_lineno=6, end_col_offset=53)], lineno=1, col_offset=9, end_lineno=6, end_col_offset=54), lineno=1, col_offset=0, end_lineno=6, end_col_offset=54), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=9, col_offset=13, end_lineno=9, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_2', Load(), lineno=10, col_offset=7, end_lineno=10, end_col_offset=12), [NotIn()], [Name('placeholder_0', Load(), lineno=10, col_offset=20, end_lineno=10, end_col_offset=26)], lineno=10, col_offset=7, end_lineno=10, end_col_offset=26), [Raise(Call(Name('ValueError', Load(), lineno=11, col_offset=14, end_lineno=11, end_col_offset=24), [JoinedStr([Constant('Invalid codon: ', lineno=11, col_offset=25, end_lineno=11, end_col_offset=50), FormattedValue(Name('placeholder_2', Load(), lineno=11, col_offset=43, end_lineno=11, end_col_offset=48), -1, lineno=11, col_offset=25, end_lineno=11, end_col_offset=50)], lineno=11, col_offset=25, end_lineno=11, end_col_offset=50)], [], lineno=11, col_offset=14, end_lineno=11, end_col_offset=51), lineno=11, col_offset=8, end_lineno=11, end_col_offset=51)], [], lineno=10, col_offset=4, end_lineno=11, end_col_offset=51), Return(Subscript(Name('placeholder_0', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=17), Name('placeholder_2', Load(), lineno=12, col_offset=18, end_lineno=12, end_col_offset=23), Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=24), lineno=12, col_offset=4, end_lineno=12, end_col_offset=24)], [], lineno=9, col_offset=0, end_lineno=12, end_col_offset=24), FunctionDef('placeholder_3', arguments([], [arg('placeholder_4', lineno=15, col_offset=13, end_lineno=15, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_5', Store(), lineno=16, col_offset=4, end_lineno=16, end_col_offset=16)], List([], Load(), lineno=16, col_offset=19, end_lineno=16, end_col_offset=21), lineno=16, col_offset=4, end_lineno=16, end_col_offset=21), For(Name('placeholder_2', Store(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=13), Call(Name('map', Load(), lineno=17, col_offset=17, end_lineno=17, end_col_offset=20), [Name('placeholder_1', Load(), lineno=17, col_offset=21, end_lineno=17, end_col_offset=29), Call(Name('_chunkstring', Load(), lineno=17, col_offset=31, end_lineno=17, end_col_offset=43), [Name('placeholder_4', Load(), lineno=17, col_offset=44, end_lineno=17, end_col_offset=50), Constant(3, lineno=17, col_offset=52, end_lineno=17, end_col_offset=53)], [], lineno=17, col_offset=31, end_lineno=17, end_col_offset=54)], [], lineno=17, col_offset=17, end_lineno=17, end_col_offset=55), [If(Compare(Name('placeholder_2', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=16), [Eq()], [Constant('STOP', lineno=18, col_offset=20, end_lineno=18, end_col_offset=26)], lineno=18, col_offset=11, end_lineno=18, end_col_offset=26), [Break(lineno=19, col_offset=12, end_lineno=19, end_col_offset=17)], [], lineno=18, col_offset=8, end_lineno=19, end_col_offset=17), Expr(Call(Attribute(Name('placeholder_5', Load(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=20), 'append', Load(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=27), [Name('placeholder_2', Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=33)], [], lineno=20, col_offset=8, end_lineno=20, end_col_offset=34), lineno=20, col_offset=8, end_lineno=20, end_col_offset=34)], [], lineno=17, col_offset=4, end_lineno=20, end_col_offset=34), Return(Name('placeholder_5', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=23), lineno=21, col_offset=4, end_lineno=21, end_col_offset=23)], [], lineno=15, col_offset=0, end_lineno=21, end_col_offset=23), FunctionDef('placeholder_6', arguments([], [arg('placeholder_7', lineno=24, col_offset=17, end_lineno=24, end_col_offset=23), arg('placeholder_8', lineno=24, col_offset=25, end_lineno=24, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(GeneratorExp(Subscript(Name('placeholder_7', Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=18), Slice(Name('placeholder_9', Load(), lineno=25, col_offset=19, end_lineno=25, end_col_offset=22), BinOp(Name('placeholder_8', Load(), lineno=25, col_offset=23, end_lineno=25, end_col_offset=29), Add(), Name('placeholder_9', Load(), lineno=25, col_offset=32, end_lineno=25, end_col_offset=35), lineno=25, col_offset=23, end_lineno=25, end_col_offset=35), lineno=25, col_offset=19, end_lineno=25, end_col_offset=35), Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=36), [comprehension(Name('placeholder_9', Store(), lineno=25, col_offset=41, end_lineno=25, end_col_offset=44), Call(Name('range', Load(), lineno=25, col_offset=48, end_lineno=25, end_col_offset=53), [Constant(0, lineno=25, col_offset=54, end_lineno=25, end_col_offset=55), Call(Name('len', Load(), lineno=25, col_offset=57, end_lineno=25, end_col_offset=60), [Name('placeholder_7', Load(), lineno=25, col_offset=61, end_lineno=25, end_col_offset=67)], [], lineno=25, col_offset=57, end_lineno=25, end_col_offset=68), Name('placeholder_8', Load(), lineno=25, col_offset=70, end_lineno=25, end_col_offset=76)], [], lineno=25, col_offset=48, end_lineno=25, end_col_offset=77), [], 0)], lineno=25, col_offset=11, end_lineno=25, end_col_offset=78), lineno=25, col_offset=4, end_lineno=25, end_col_offset=78)], [], lineno=24, col_offset=0, end_lineno=25, end_col_offset=78)], []) \ No newline at end of file diff --git a/test/practice-proverb/.meta/additional_tests.json b/test/practice-proverb/.meta/additional_tests.json new file mode 100644 index 0000000..0d1cac0 --- /dev/null +++ b/test/practice-proverb/.meta/additional_tests.json @@ -0,0 +1,36 @@ +{ + "cases": [ + { + "description": "an optional qualifier can be added", + "property": "proverb", + "input": { + "strings": ["nail"], + "extra": {"qualifier": "horseshoe"} + }, + "expected": ["And all for the want of a horseshoe nail."] + }, + { + "description": "an optional qualifier in the final consequences", + "property": "proverb", + "input": { + "strings": [ + "nail", + "shoe", + "horse", + "rider", + "message", + "battle", + "kingdom" + ], + "extra": {"qualifier": "horseshoe"} + }, + "expected": ["For want of a nail the shoe was lost.", + "For want of a shoe the horse was lost.", + "For want of a horse the rider was lost.", + "For want of a rider the message was lost.", + "For want of a message the battle was lost.", + "For want of a battle the kingdom was lost.", + "And all for the want of a horseshoe nail."] + } + ] +} diff --git a/test/practice-proverb/.meta/config.json b/test/practice-proverb/.meta/config.json new file mode 100644 index 0000000..d413b04 --- /dev/null +++ b/test/practice-proverb/.meta/config.json @@ -0,0 +1,32 @@ +{ + "blurb": "For want of a horseshoe nail, a kingdom was lost, or so the saying goes. Output the full text of this proverbial rhyme.", + "authors": [ + "betegelse", + "meatball133", + "BethanyG" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "mtroiani", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "proverb.py" + ], + "test": [ + "proverb_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/For_Want_of_a_Nail" +} diff --git a/test/practice-proverb/mapping.json b/test/practice-proverb/mapping.json new file mode 100644 index 0000000..e0849a8 --- /dev/null +++ b/test/practice-proverb/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "proverb", + "placeholder_1": "rhyme_items", + "placeholder_2": "qualifier", + "placeholder_3": "phrases", + "placeholder_4": "element_1", + "placeholder_5": "element_2" +} \ No newline at end of file diff --git a/test/practice-proverb/proverb.py b/test/practice-proverb/proverb.py new file mode 100644 index 0000000..8e6f30f --- /dev/null +++ b/test/practice-proverb/proverb.py @@ -0,0 +1,11 @@ +def proverb(*rhyme_items, qualifier): + print(rhyme_items) + if not rhyme_items: + return [] + phrases = [f'For want of a {element_1} the {element_2} was lost.' + for element_1, element_2 in zip(rhyme_items, rhyme_items[1:])] + if qualifier: + phrases.append(f'And all for the want of a {qualifier} {rhyme_items[0]}.') + else: + phrases.append(f'And all for the want of a {rhyme_items[0]}.') + return phrases diff --git a/test/practice-proverb/representation.json b/test/practice-proverb/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-proverb/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-proverb/representation.out b/test/practice-proverb/representation.out new file mode 100644 index 0000000..ba7c5ac --- /dev/null +++ b/test/practice-proverb/representation.out @@ -0,0 +1,815 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(*placeholder_1, placeholder_2): + if not placeholder_1: + return [] + placeholder_3 = [ + f"For want of a {placeholder_4} the {placeholder_5} was lost." + for placeholder_4, placeholder_5 in zip(placeholder_1, placeholder_1[1:]) + ] + if placeholder_2: + placeholder_3.append( + f"And all for the want of a {placeholder_2} {placeholder_1[0]}." + ) + else: + placeholder_3.append(f"And all for the want of a {placeholder_1[0]}.") + return placeholder_3 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'proverb', + arguments( + [], + [], + arg( + 'rhyme_items', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=24), + [ + arg( + 'qualifier', + lineno=1, + col_offset=26, + end_lineno=1, + end_col_offset=35)], + [ + None], + defaults=[]), + [ + Expr( + Call( + Name( + 'print', + Load(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9), + [ + Name( + 'rhyme_items', + Load(), + lineno=2, + col_offset=10, + end_lineno=2, + end_col_offset=21)], + [], + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=22), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=22), + If( + UnaryOp( + Not(), + Name( + 'rhyme_items', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=22), + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=22), + [ + Return( + List( + [], + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=17), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=17)], + [], + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=17), + Assign( + [ + Name( + 'phrases', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + ListComp( + JoinedStr( + [ + Constant( + 'For want of a ', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + FormattedValue( + Name( + 'element_1', + Load(), + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=41), + -1, + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + Constant( + ' the ', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + FormattedValue( + Name( + 'element_2', + Load(), + lineno=5, + col_offset=48, + end_lineno=5, + end_col_offset=57), + -1, + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + Constant( + ' was lost.', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + [ + comprehension( + Tuple( + [ + Name( + 'element_1', + Store(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=28), + Name( + 'element_2', + Store(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=39)], + Store(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=39), + Call( + Name( + 'zip', + Load(), + lineno=6, + col_offset=43, + end_lineno=6, + end_col_offset=46), + [ + Name( + 'rhyme_items', + Load(), + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=58), + Subscript( + Name( + 'rhyme_items', + Load(), + lineno=6, + col_offset=60, + end_lineno=6, + end_col_offset=71), + Slice( + Constant( + 1, + lineno=6, + col_offset=72, + end_lineno=6, + end_col_offset=73), + lineno=6, + col_offset=72, + end_lineno=6, + end_col_offset=74), + Load(), + lineno=6, + col_offset=60, + end_lineno=6, + end_col_offset=75)], + [], + lineno=6, + col_offset=43, + end_lineno=6, + end_col_offset=76), + [], + 0)], + lineno=5, + col_offset=14, + end_lineno=6, + end_col_offset=77), + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=77), + If( + Name( + 'qualifier', + Load(), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=16), + [ + Expr( + Call( + Attribute( + Name( + 'phrases', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=15), + 'append', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22), + [ + JoinedStr( + [ + Constant( + 'And all for the want of a ', + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81), + FormattedValue( + Name( + 'qualifier', + Load(), + lineno=8, + col_offset=52, + end_lineno=8, + end_col_offset=61), + -1, + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81), + Constant( + ' ', + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81), + FormattedValue( + Subscript( + Name( + 'rhyme_items', + Load(), + lineno=8, + col_offset=64, + end_lineno=8, + end_col_offset=75), + Constant( + 0, + lineno=8, + col_offset=76, + end_lineno=8, + end_col_offset=77), + Load(), + lineno=8, + col_offset=64, + end_lineno=8, + end_col_offset=78), + -1, + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81), + Constant( + '.', + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81)], + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81)], + [], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=82), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=82)], + [ + Expr( + Call( + Attribute( + Name( + 'phrases', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=15), + 'append', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=22), + [ + JoinedStr( + [ + Constant( + 'And all for the want of a ', + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=69), + FormattedValue( + Subscript( + Name( + 'rhyme_items', + Load(), + lineno=10, + col_offset=52, + end_lineno=10, + end_col_offset=63), + Constant( + 0, + lineno=10, + col_offset=64, + end_lineno=10, + end_col_offset=65), + Load(), + lineno=10, + col_offset=52, + end_lineno=10, + end_col_offset=66), + -1, + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=69), + Constant( + '.', + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=69)], + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=69)], + [], + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=70), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=70)], + lineno=7, + col_offset=4, + end_lineno=10, + end_col_offset=70), + Return( + Name( + 'phrases', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=18), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=18)], + [], + lineno=1, + col_offset=0, + end_lineno=11, + end_col_offset=18)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [], + arg( + 'placeholder_1', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=24), + [ + arg( + 'placeholder_2', + lineno=1, + col_offset=26, + end_lineno=1, + end_col_offset=35)], + [ + None], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=22), + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=22), + [ + Return( + List( + [], + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=17), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=17)], + [], + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + ListComp( + JoinedStr( + [ + Constant( + 'For want of a ', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + FormattedValue( + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=41), + -1, + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + Constant( + ' the ', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + FormattedValue( + Name( + 'placeholder_5', + Load(), + lineno=5, + col_offset=48, + end_lineno=5, + end_col_offset=57), + -1, + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + Constant( + ' was lost.', + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=69), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_4', + Store(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=28), + Name( + 'placeholder_5', + Store(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=39)], + Store(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=39), + Call( + Name( + 'zip', + Load(), + lineno=6, + col_offset=43, + end_lineno=6, + end_col_offset=46), + [ + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=47, + end_lineno=6, + end_col_offset=58), + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=60, + end_lineno=6, + end_col_offset=71), + Slice( + Constant( + 1, + lineno=6, + col_offset=72, + end_lineno=6, + end_col_offset=73), + lineno=6, + col_offset=72, + end_lineno=6, + end_col_offset=74), + Load(), + lineno=6, + col_offset=60, + end_lineno=6, + end_col_offset=75)], + [], + lineno=6, + col_offset=43, + end_lineno=6, + end_col_offset=76), + [], + 0)], + lineno=5, + col_offset=14, + end_lineno=6, + end_col_offset=77), + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=77), + If( + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=16), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=15), + 'append', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22), + [ + JoinedStr( + [ + Constant( + 'And all for the want of a ', + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81), + FormattedValue( + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=52, + end_lineno=8, + end_col_offset=61), + -1, + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81), + Constant( + ' ', + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81), + FormattedValue( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=64, + end_lineno=8, + end_col_offset=75), + Constant( + 0, + lineno=8, + col_offset=76, + end_lineno=8, + end_col_offset=77), + Load(), + lineno=8, + col_offset=64, + end_lineno=8, + end_col_offset=78), + -1, + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81), + Constant( + '.', + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81)], + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=81)], + [], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=82), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=82)], + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=15), + 'append', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=22), + [ + JoinedStr( + [ + Constant( + 'And all for the want of a ', + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=69), + FormattedValue( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=52, + end_lineno=10, + end_col_offset=63), + Constant( + 0, + lineno=10, + col_offset=64, + end_lineno=10, + end_col_offset=65), + Load(), + lineno=10, + col_offset=52, + end_lineno=10, + end_col_offset=66), + -1, + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=69), + Constant( + '.', + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=69)], + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=69)], + [], + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=70), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=70)], + lineno=7, + col_offset=4, + end_lineno=10, + end_col_offset=70), + Return( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=18), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=18)], + [], + lineno=1, + col_offset=0, + end_lineno=11, + end_col_offset=18)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-proverb/representation.txt b/test/practice-proverb/representation.txt new file mode 100644 index 0000000..46792be --- /dev/null +++ b/test/practice-proverb/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [], arg('placeholder_1', lineno=1, col_offset=13, end_lineno=1, end_col_offset=24), [arg('placeholder_2', lineno=1, col_offset=26, end_lineno=1, end_col_offset=35)], [None], defaults=[]), [If(UnaryOp(Not(), Name('placeholder_1', Load(), lineno=3, col_offset=11, end_lineno=3, end_col_offset=22), lineno=3, col_offset=7, end_lineno=3, end_col_offset=22), [Return(List([], Load(), lineno=4, col_offset=15, end_lineno=4, end_col_offset=17), lineno=4, col_offset=8, end_lineno=4, end_col_offset=17)], [], lineno=3, col_offset=4, end_lineno=4, end_col_offset=17), Assign([Name('placeholder_3', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=11)], ListComp(JoinedStr([Constant('For want of a ', lineno=5, col_offset=15, end_lineno=5, end_col_offset=69), FormattedValue(Name('placeholder_4', Load(), lineno=5, col_offset=32, end_lineno=5, end_col_offset=41), -1, lineno=5, col_offset=15, end_lineno=5, end_col_offset=69), Constant(' the ', lineno=5, col_offset=15, end_lineno=5, end_col_offset=69), FormattedValue(Name('placeholder_5', Load(), lineno=5, col_offset=48, end_lineno=5, end_col_offset=57), -1, lineno=5, col_offset=15, end_lineno=5, end_col_offset=69), Constant(' was lost.', lineno=5, col_offset=15, end_lineno=5, end_col_offset=69)], lineno=5, col_offset=15, end_lineno=5, end_col_offset=69), [comprehension(Tuple([Name('placeholder_4', Store(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=28), Name('placeholder_5', Store(), lineno=6, col_offset=30, end_lineno=6, end_col_offset=39)], Store(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=39), Call(Name('zip', Load(), lineno=6, col_offset=43, end_lineno=6, end_col_offset=46), [Name('placeholder_1', Load(), lineno=6, col_offset=47, end_lineno=6, end_col_offset=58), Subscript(Name('placeholder_1', Load(), lineno=6, col_offset=60, end_lineno=6, end_col_offset=71), Slice(Constant(1, lineno=6, col_offset=72, end_lineno=6, end_col_offset=73), lineno=6, col_offset=72, end_lineno=6, end_col_offset=74), Load(), lineno=6, col_offset=60, end_lineno=6, end_col_offset=75)], [], lineno=6, col_offset=43, end_lineno=6, end_col_offset=76), [], 0)], lineno=5, col_offset=14, end_lineno=6, end_col_offset=77), lineno=5, col_offset=4, end_lineno=6, end_col_offset=77), If(Name('placeholder_2', Load(), lineno=7, col_offset=7, end_lineno=7, end_col_offset=16), [Expr(Call(Attribute(Name('placeholder_3', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=15), 'append', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=22), [JoinedStr([Constant('And all for the want of a ', lineno=8, col_offset=23, end_lineno=8, end_col_offset=81), FormattedValue(Name('placeholder_2', Load(), lineno=8, col_offset=52, end_lineno=8, end_col_offset=61), -1, lineno=8, col_offset=23, end_lineno=8, end_col_offset=81), Constant(' ', lineno=8, col_offset=23, end_lineno=8, end_col_offset=81), FormattedValue(Subscript(Name('placeholder_1', Load(), lineno=8, col_offset=64, end_lineno=8, end_col_offset=75), Constant(0, lineno=8, col_offset=76, end_lineno=8, end_col_offset=77), Load(), lineno=8, col_offset=64, end_lineno=8, end_col_offset=78), -1, lineno=8, col_offset=23, end_lineno=8, end_col_offset=81), Constant('.', lineno=8, col_offset=23, end_lineno=8, end_col_offset=81)], lineno=8, col_offset=23, end_lineno=8, end_col_offset=81)], [], lineno=8, col_offset=8, end_lineno=8, end_col_offset=82), lineno=8, col_offset=8, end_lineno=8, end_col_offset=82)], [Expr(Call(Attribute(Name('placeholder_3', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=15), 'append', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=22), [JoinedStr([Constant('And all for the want of a ', lineno=10, col_offset=23, end_lineno=10, end_col_offset=69), FormattedValue(Subscript(Name('placeholder_1', Load(), lineno=10, col_offset=52, end_lineno=10, end_col_offset=63), Constant(0, lineno=10, col_offset=64, end_lineno=10, end_col_offset=65), Load(), lineno=10, col_offset=52, end_lineno=10, end_col_offset=66), -1, lineno=10, col_offset=23, end_lineno=10, end_col_offset=69), Constant('.', lineno=10, col_offset=23, end_lineno=10, end_col_offset=69)], lineno=10, col_offset=23, end_lineno=10, end_col_offset=69)], [], lineno=10, col_offset=8, end_lineno=10, end_col_offset=70), lineno=10, col_offset=8, end_lineno=10, end_col_offset=70)], lineno=7, col_offset=4, end_lineno=10, end_col_offset=70), Return(Name('placeholder_3', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=18), lineno=11, col_offset=4, end_lineno=11, end_col_offset=18)], [], lineno=1, col_offset=0, end_lineno=11, end_col_offset=18)], []) \ No newline at end of file diff --git a/test/practice-pythagorean-triplet/.meta/config.json b/test/practice-pythagorean-triplet/.meta/config.json new file mode 100644 index 0000000..03d3513 --- /dev/null +++ b/test/practice-pythagorean-triplet/.meta/config.json @@ -0,0 +1,37 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "morganpartee", + "N-Parsons", + "olufotebig", + "omer-g", + "parinporecha", + "pheanex", + "rootulp", + "sjakobi", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "pythagorean_triplet.py" + ], + "test": [ + "pythagorean_triplet_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product a * b * c.", + "source": "Problem 9 at Project Euler", + "source_url": "https://projecteuler.net/problem=9" +} diff --git a/test/practice-pythagorean-triplet/mapping.json b/test/practice-pythagorean-triplet/mapping.json new file mode 100644 index 0000000..0b892a9 --- /dev/null +++ b/test/practice-pythagorean-triplet/mapping.json @@ -0,0 +1,24 @@ +{ + "placeholder_0": "triplets_in_range", + "placeholder_1": "start", + "placeholder_2": "end", + "placeholder_3": "limit", + "placeholder_4": "x_pos", + "placeholder_5": "y_pos", + "placeholder_6": "z_pos", + "placeholder_7": "alpha", + "placeholder_8": "beta", + "placeholder_9": "gamma", + "placeholder_10": "euclidian_coprimes", + "placeholder_11": "mean", + "placeholder_12": "idx", + "placeholder_13": "member", + "placeholder_14": "primitive_triplets", + "placeholder_15": "member_1", + "placeholder_16": "member_2", + "placeholder_17": "calc_1", + "placeholder_18": "calc_2", + "placeholder_19": "triplets_with_sum", + "placeholder_20": "number", + "placeholder_21": "triplet" +} \ No newline at end of file diff --git a/test/practice-pythagorean-triplet/pythagorean_triplet.py b/test/practice-pythagorean-triplet/pythagorean_triplet.py new file mode 100644 index 0000000..40b9144 --- /dev/null +++ b/test/practice-pythagorean-triplet/pythagorean_triplet.py @@ -0,0 +1,57 @@ +from math import sqrt, ceil, gcd + + +def triplets_in_range(start, end): + for limit in range(4, end + 1, 4): + for x_pos, y_pos, z_pos in primitive_triplets(limit): + alpha = x_pos + beta = y_pos + gamma = z_pos + + while alpha < start: + alpha = alpha + x_pos + beta = beta + y_pos + gamma = gamma + z_pos + + while gamma <= end: + yield [alpha, beta, gamma] + + alpha = alpha + x_pos + beta = beta + y_pos + gamma = gamma + z_pos + + +def euclidian_coprimes(limit): + mean = limit // 2 + for idx in range(1, int(ceil(sqrt(mean)))): + if mean % idx == 0: + member = mean // idx + if (member - idx) % 2 == 1 and gcd(member, idx) == 1: + yield member, idx + + +def primitive_triplets(limit): + """See Euclid's formula + (https://en.wikipedia.org/wiki/Pythagorean_triple#Generating_a_triple) + for more information + """ + for member_1, member_2 in euclidian_coprimes(limit): + calc_1 = member_1 ** 2 + calc_2 = member_2 ** 2 + + alpha = calc_1 - calc_2 + beta = 2 * member_1 * member_2 + gamma = calc_1 + calc_2 + + if alpha > beta: + alpha, beta = beta, alpha + + yield alpha, beta, gamma + + +def triplets_with_sum(number): + return [ + triplet for triplet + in triplets_in_range(1, number // 2) + if sum(triplet) == number + ] diff --git a/test/practice-pythagorean-triplet/representation.json b/test/practice-pythagorean-triplet/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-pythagorean-triplet/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-pythagorean-triplet/representation.out b/test/practice-pythagorean-triplet/representation.out new file mode 100644 index 0000000..9c3713a --- /dev/null +++ b/test/practice-pythagorean-triplet/representation.out @@ -0,0 +1,2767 @@ +## BEGIN NORMALIZED CODE ## +from math import sqrt, ceil, gcd + + +def placeholder_0(placeholder_1, placeholder_2): + for placeholder_3 in range(4, placeholder_2 + 1, 4): + for placeholder_4, placeholder_5, placeholder_6 in primitive_triplets( + placeholder_3 + ): + placeholder_7 = placeholder_4 + placeholder_8 = placeholder_5 + placeholder_9 = placeholder_6 + while placeholder_7 < placeholder_1: + placeholder_7 = placeholder_7 + placeholder_4 + placeholder_8 = placeholder_8 + placeholder_5 + placeholder_9 = placeholder_9 + placeholder_6 + while placeholder_9 <= placeholder_2: + yield [alpha, beta, gamma] + placeholder_7 = placeholder_7 + placeholder_4 + placeholder_8 = placeholder_8 + placeholder_5 + placeholder_9 = placeholder_9 + placeholder_6 + + +def placeholder_10(placeholder_3): + placeholder_11 = placeholder_3 // 2 + for placeholder_12 in range(1, int(ceil(sqrt(placeholder_11)))): + if placeholder_11 % placeholder_12 == 0: + placeholder_13 = placeholder_11 // placeholder_12 + if (placeholder_13 - placeholder_12) % 2 == 1 and gcd( + placeholder_13, placeholder_12 + ) == 1: + yield (member, idx) + + +def placeholder_14(placeholder_3): + for placeholder_15, placeholder_16 in placeholder_10(placeholder_3): + placeholder_17 = placeholder_15**2 + placeholder_18 = placeholder_16**2 + placeholder_7 = placeholder_17 - placeholder_18 + placeholder_8 = 2 * placeholder_15 * placeholder_16 + placeholder_9 = placeholder_17 + placeholder_18 + if placeholder_7 > placeholder_8: + placeholder_7, placeholder_8 = (placeholder_8, placeholder_7) + yield (alpha, beta, gamma) + + +def placeholder_19(placeholder_20): + return [ + placeholder_21 + for placeholder_21 in placeholder_0(1, placeholder_20 // 2) + if sum(placeholder_21) == placeholder_20 + ] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'sqrt', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21), + alias( + 'ceil', + lineno=1, + col_offset=23, + end_lineno=1, + end_col_offset=27), + alias( + 'gcd', + lineno=1, + col_offset=29, + end_lineno=1, + end_col_offset=32)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=32), + FunctionDef( + 'triplets_in_range', + arguments( + [], + [ + arg( + 'start', + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=27), + arg( + 'end', + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'limit', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=22), + [ + Constant( + 4, + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=24), + BinOp( + Name( + 'end', + Load(), + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=29), + Add(), + Constant( + 1, + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=33), + Constant( + 4, + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=36)], + [], + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=37), + [ + For( + Tuple( + [ + Name( + 'x_pos', + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=17), + Name( + 'y_pos', + Store(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=24), + Name( + 'z_pos', + Store(), + lineno=6, + col_offset=26, + end_lineno=6, + end_col_offset=31)], + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=31), + Call( + Name( + 'primitive_triplets', + Load(), + lineno=6, + col_offset=35, + end_lineno=6, + end_col_offset=53), + [ + Name( + 'limit', + Load(), + lineno=6, + col_offset=54, + end_lineno=6, + end_col_offset=59)], + [], + lineno=6, + col_offset=35, + end_lineno=6, + end_col_offset=60), + [ + Assign( + [ + Name( + 'alpha', + Store(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=17)], + Name( + 'x_pos', + Load(), + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=25), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=25), + Assign( + [ + Name( + 'beta', + Store(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=16)], + Name( + 'y_pos', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=24), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=24), + Assign( + [ + Name( + 'gamma', + Store(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=17)], + Name( + 'z_pos', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=25), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=25), + While( + Compare( + Name( + 'alpha', + Load(), + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=23), + [ + Lt()], + [ + Name( + 'start', + Load(), + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=31)], + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=31), + [ + Assign( + [ + Name( + 'alpha', + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=21)], + BinOp( + Name( + 'alpha', + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=29), + Add(), + Name( + 'x_pos', + Load(), + lineno=12, + col_offset=32, + end_lineno=12, + end_col_offset=37), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=37), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=37), + Assign( + [ + Name( + 'beta', + Store(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=20)], + BinOp( + Name( + 'beta', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=27), + Add(), + Name( + 'y_pos', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=35), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=35), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=35), + Assign( + [ + Name( + 'gamma', + Store(), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=21)], + BinOp( + Name( + 'gamma', + Load(), + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=29), + Add(), + Name( + 'z_pos', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=37)], + [], + lineno=11, + col_offset=12, + end_lineno=14, + end_col_offset=37), + While( + Compare( + Name( + 'gamma', + Load(), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=23), + [ + LtE()], + [ + Name( + 'end', + Load(), + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=30)], + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=30), + [ + Expr( + Yield( + List( + [ + Name( + 'alpha', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=28), + Name( + 'beta', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=34), + Name( + 'gamma', + Load(), + lineno=17, + col_offset=36, + end_lineno=17, + end_col_offset=41)], + Load(), + lineno=17, + col_offset=22, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=42), + Assign( + [ + Name( + 'alpha', + Store(), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=21)], + BinOp( + Name( + 'alpha', + Load(), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=29), + Add(), + Name( + 'x_pos', + Load(), + lineno=19, + col_offset=32, + end_lineno=19, + end_col_offset=37), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=37), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=37), + Assign( + [ + Name( + 'beta', + Store(), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=20)], + BinOp( + Name( + 'beta', + Load(), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=27), + Add(), + Name( + 'y_pos', + Load(), + lineno=20, + col_offset=30, + end_lineno=20, + end_col_offset=35), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=35), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=35), + Assign( + [ + Name( + 'gamma', + Store(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=21)], + BinOp( + Name( + 'gamma', + Load(), + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=29), + Add(), + Name( + 'z_pos', + Load(), + lineno=21, + col_offset=32, + end_lineno=21, + end_col_offset=37), + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=37), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=37)], + [], + lineno=16, + col_offset=12, + end_lineno=21, + end_col_offset=37)], + [], + lineno=6, + col_offset=8, + end_lineno=21, + end_col_offset=37)], + [], + lineno=5, + col_offset=4, + end_lineno=21, + end_col_offset=37)], + [], + lineno=4, + col_offset=0, + end_lineno=21, + end_col_offset=37), + FunctionDef( + 'euclidian_coprimes', + arguments( + [], + [ + arg( + 'limit', + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'mean', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=8)], + BinOp( + Name( + 'limit', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=16), + FloorDiv(), + Constant( + 2, + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=21), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=21), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=21), + For( + Name( + 'idx', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=20), + [ + Constant( + 1, + lineno=26, + col_offset=21, + end_lineno=26, + end_col_offset=22), + Call( + Name( + 'int', + Load(), + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=27), + [ + Call( + Name( + 'ceil', + Load(), + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=32), + [ + Call( + Name( + 'sqrt', + Load(), + lineno=26, + col_offset=33, + end_lineno=26, + end_col_offset=37), + [ + Name( + 'mean', + Load(), + lineno=26, + col_offset=38, + end_lineno=26, + end_col_offset=42)], + [], + lineno=26, + col_offset=33, + end_lineno=26, + end_col_offset=43)], + [], + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=44)], + [], + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=45)], + [], + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=46), + [ + If( + Compare( + BinOp( + Name( + 'mean', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=15), + Mod(), + Name( + 'idx', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=21), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 0, + lineno=27, + col_offset=25, + end_lineno=27, + end_col_offset=26)], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=26), + [ + Assign( + [ + Name( + 'member', + Store(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=18)], + BinOp( + Name( + 'mean', + Load(), + lineno=28, + col_offset=21, + end_lineno=28, + end_col_offset=25), + FloorDiv(), + Name( + 'idx', + Load(), + lineno=28, + col_offset=29, + end_lineno=28, + end_col_offset=32), + lineno=28, + col_offset=21, + end_lineno=28, + end_col_offset=32), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=32), + If( + BoolOp( + And(), + [ + Compare( + BinOp( + BinOp( + Name( + 'member', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=22), + Sub(), + Name( + 'idx', + Load(), + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=28), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=28), + Mod(), + Constant( + 2, + lineno=29, + col_offset=32, + end_lineno=29, + end_col_offset=33), + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=33), + [ + Eq()], + [ + Constant( + 1, + lineno=29, + col_offset=37, + end_lineno=29, + end_col_offset=38)], + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=38), + Compare( + Call( + Name( + 'gcd', + Load(), + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=46), + [ + Name( + 'member', + Load(), + lineno=29, + col_offset=47, + end_lineno=29, + end_col_offset=53), + Name( + 'idx', + Load(), + lineno=29, + col_offset=55, + end_lineno=29, + end_col_offset=58)], + [], + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=59), + [ + Eq()], + [ + Constant( + 1, + lineno=29, + col_offset=63, + end_lineno=29, + end_col_offset=64)], + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=64)], + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=64), + [ + Expr( + Yield( + Tuple( + [ + Name( + 'member', + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=28), + Name( + 'idx', + Load(), + lineno=30, + col_offset=30, + end_lineno=30, + end_col_offset=33)], + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=33), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=33), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=33)], + [], + lineno=29, + col_offset=12, + end_lineno=30, + end_col_offset=33)], + [], + lineno=27, + col_offset=8, + end_lineno=30, + end_col_offset=33)], + [], + lineno=26, + col_offset=4, + end_lineno=30, + end_col_offset=33)], + [], + lineno=24, + col_offset=0, + end_lineno=30, + end_col_offset=33), + FunctionDef( + 'primitive_triplets', + arguments( + [], + [ + arg( + 'limit', + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + "See Euclid's formula\n (https://en.wikipedia.org/wiki/Pythagorean_triple#Generating_a_triple)\n for more information\n ", + lineno=34, + col_offset=4, + end_lineno=37, + end_col_offset=7), + lineno=34, + col_offset=4, + end_lineno=37, + end_col_offset=7), + For( + Tuple( + [ + Name( + 'member_1', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=16), + Name( + 'member_2', + Store(), + lineno=38, + col_offset=18, + end_lineno=38, + end_col_offset=26)], + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=26), + Call( + Name( + 'euclidian_coprimes', + Load(), + lineno=38, + col_offset=30, + end_lineno=38, + end_col_offset=48), + [ + Name( + 'limit', + Load(), + lineno=38, + col_offset=49, + end_lineno=38, + end_col_offset=54)], + [], + lineno=38, + col_offset=30, + end_lineno=38, + end_col_offset=55), + [ + Assign( + [ + Name( + 'calc_1', + Store(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=14)], + BinOp( + Name( + 'member_1', + Load(), + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=25), + Pow(), + Constant( + 2, + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=30), + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=30), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=30), + Assign( + [ + Name( + 'calc_2', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=14)], + BinOp( + Name( + 'member_2', + Load(), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=25), + Pow(), + Constant( + 2, + lineno=40, + col_offset=29, + end_lineno=40, + end_col_offset=30), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=30), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=30), + Assign( + [ + Name( + 'alpha', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=13)], + BinOp( + Name( + 'calc_1', + Load(), + lineno=42, + col_offset=16, + end_lineno=42, + end_col_offset=22), + Sub(), + Name( + 'calc_2', + Load(), + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=31), + lineno=42, + col_offset=16, + end_lineno=42, + end_col_offset=31), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=31), + Assign( + [ + Name( + 'beta', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=12)], + BinOp( + BinOp( + Constant( + 2, + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=16), + Mult(), + Name( + 'member_1', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=27), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=27), + Mult(), + Name( + 'member_2', + Load(), + lineno=43, + col_offset=30, + end_lineno=43, + end_col_offset=38), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=38), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=38), + Assign( + [ + Name( + 'gamma', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=13)], + BinOp( + Name( + 'calc_1', + Load(), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=22), + Add(), + Name( + 'calc_2', + Load(), + lineno=44, + col_offset=25, + end_lineno=44, + end_col_offset=31), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=31), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=31), + If( + Compare( + Name( + 'alpha', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=16), + [ + Gt()], + [ + Name( + 'beta', + Load(), + lineno=46, + col_offset=19, + end_lineno=46, + end_col_offset=23)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=23), + [ + Assign( + [ + Tuple( + [ + Name( + 'alpha', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=17), + Name( + 'beta', + Store(), + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=23)], + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=23)], + Tuple( + [ + Name( + 'beta', + Load(), + lineno=47, + col_offset=26, + end_lineno=47, + end_col_offset=30), + Name( + 'alpha', + Load(), + lineno=47, + col_offset=32, + end_lineno=47, + end_col_offset=37)], + Load(), + lineno=47, + col_offset=26, + end_lineno=47, + end_col_offset=37), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=37)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=37), + Expr( + Yield( + Tuple( + [ + Name( + 'alpha', + Load(), + lineno=49, + col_offset=14, + end_lineno=49, + end_col_offset=19), + Name( + 'beta', + Load(), + lineno=49, + col_offset=21, + end_lineno=49, + end_col_offset=25), + Name( + 'gamma', + Load(), + lineno=49, + col_offset=27, + end_lineno=49, + end_col_offset=32)], + Load(), + lineno=49, + col_offset=14, + end_lineno=49, + end_col_offset=32), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=32), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=32)], + [], + lineno=38, + col_offset=4, + end_lineno=49, + end_col_offset=32)], + [], + lineno=33, + col_offset=0, + end_lineno=49, + end_col_offset=32), + FunctionDef( + 'triplets_with_sum', + arguments( + [], + [ + arg( + 'number', + lineno=52, + col_offset=22, + end_lineno=52, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'triplet', + Load(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=15), + [ + comprehension( + Name( + 'triplet', + Store(), + lineno=54, + col_offset=20, + end_lineno=54, + end_col_offset=27), + Call( + Name( + 'triplets_in_range', + Load(), + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=28), + [ + Constant( + 1, + lineno=55, + col_offset=29, + end_lineno=55, + end_col_offset=30), + BinOp( + Name( + 'number', + Load(), + lineno=55, + col_offset=32, + end_lineno=55, + end_col_offset=38), + FloorDiv(), + Constant( + 2, + lineno=55, + col_offset=42, + end_lineno=55, + end_col_offset=43), + lineno=55, + col_offset=32, + end_lineno=55, + end_col_offset=43)], + [], + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=44), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=56, + col_offset=11, + end_lineno=56, + end_col_offset=14), + [ + Name( + 'triplet', + Load(), + lineno=56, + col_offset=15, + end_lineno=56, + end_col_offset=22)], + [], + lineno=56, + col_offset=11, + end_lineno=56, + end_col_offset=23), + [ + Eq()], + [ + Name( + 'number', + Load(), + lineno=56, + col_offset=27, + end_lineno=56, + end_col_offset=33)], + lineno=56, + col_offset=11, + end_lineno=56, + end_col_offset=33)], + 0)], + lineno=53, + col_offset=11, + end_lineno=57, + end_col_offset=9), + lineno=53, + col_offset=4, + end_lineno=57, + end_col_offset=9)], + [], + lineno=52, + col_offset=0, + end_lineno=57, + end_col_offset=9)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'sqrt', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21), + alias( + 'ceil', + lineno=1, + col_offset=23, + end_lineno=1, + end_col_offset=27), + alias( + 'gcd', + lineno=1, + col_offset=29, + end_lineno=1, + end_col_offset=32)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=32), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=27), + arg( + 'placeholder_2', + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=22), + [ + Constant( + 4, + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=24), + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=29), + Add(), + Constant( + 1, + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=33), + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=33), + Constant( + 4, + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=36)], + [], + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=37), + [ + For( + Tuple( + [ + Name( + 'placeholder_4', + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=17), + Name( + 'placeholder_5', + Store(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=24), + Name( + 'placeholder_6', + Store(), + lineno=6, + col_offset=26, + end_lineno=6, + end_col_offset=31)], + Store(), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=31), + Call( + Name( + 'primitive_triplets', + Load(), + lineno=6, + col_offset=35, + end_lineno=6, + end_col_offset=53), + [ + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=54, + end_lineno=6, + end_col_offset=59)], + [], + lineno=6, + col_offset=35, + end_lineno=6, + end_col_offset=60), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=17)], + Name( + 'placeholder_4', + Load(), + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=25), + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=25), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=16)], + Name( + 'placeholder_5', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=24), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=24), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=17)], + Name( + 'placeholder_6', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=25), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=25), + While( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=23), + [ + Lt()], + [ + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=31)], + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=31), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=21)], + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=29), + Add(), + Name( + 'placeholder_4', + Load(), + lineno=12, + col_offset=32, + end_lineno=12, + end_col_offset=37), + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=37), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=37), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=20)], + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=27), + Add(), + Name( + 'placeholder_5', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=35), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=35), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=35), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=21)], + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=29), + Add(), + Name( + 'placeholder_6', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=37), + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=37)], + [], + lineno=11, + col_offset=12, + end_lineno=14, + end_col_offset=37), + While( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=23), + [ + LtE()], + [ + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=30)], + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=30), + [ + Expr( + Yield( + List( + [ + Name( + 'alpha', + Load(), + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=28), + Name( + 'beta', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=34), + Name( + 'gamma', + Load(), + lineno=17, + col_offset=36, + end_lineno=17, + end_col_offset=41)], + Load(), + lineno=17, + col_offset=22, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=21)], + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=29), + Add(), + Name( + 'placeholder_4', + Load(), + lineno=19, + col_offset=32, + end_lineno=19, + end_col_offset=37), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=37), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=37), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=20)], + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=27), + Add(), + Name( + 'placeholder_5', + Load(), + lineno=20, + col_offset=30, + end_lineno=20, + end_col_offset=35), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=35), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=35), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=21)], + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=29), + Add(), + Name( + 'placeholder_6', + Load(), + lineno=21, + col_offset=32, + end_lineno=21, + end_col_offset=37), + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=37), + lineno=21, + col_offset=16, + end_lineno=21, + end_col_offset=37)], + [], + lineno=16, + col_offset=12, + end_lineno=21, + end_col_offset=37)], + [], + lineno=6, + col_offset=8, + end_lineno=21, + end_col_offset=37)], + [], + lineno=5, + col_offset=4, + end_lineno=21, + end_col_offset=37)], + [], + lineno=4, + col_offset=0, + end_lineno=21, + end_col_offset=37), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=8)], + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=16), + FloorDiv(), + Constant( + 2, + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=21), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=21), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=21), + For( + Name( + 'placeholder_12', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=20), + [ + Constant( + 1, + lineno=26, + col_offset=21, + end_lineno=26, + end_col_offset=22), + Call( + Name( + 'int', + Load(), + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=27), + [ + Call( + Name( + 'ceil', + Load(), + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=32), + [ + Call( + Name( + 'sqrt', + Load(), + lineno=26, + col_offset=33, + end_lineno=26, + end_col_offset=37), + [ + Name( + 'placeholder_11', + Load(), + lineno=26, + col_offset=38, + end_lineno=26, + end_col_offset=42)], + [], + lineno=26, + col_offset=33, + end_lineno=26, + end_col_offset=43)], + [], + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=44)], + [], + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=45)], + [], + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=46), + [ + If( + Compare( + BinOp( + Name( + 'placeholder_11', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=15), + Mod(), + Name( + 'placeholder_12', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=21), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=21), + [ + Eq()], + [ + Constant( + 0, + lineno=27, + col_offset=25, + end_lineno=27, + end_col_offset=26)], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=26), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=18)], + BinOp( + Name( + 'placeholder_11', + Load(), + lineno=28, + col_offset=21, + end_lineno=28, + end_col_offset=25), + FloorDiv(), + Name( + 'placeholder_12', + Load(), + lineno=28, + col_offset=29, + end_lineno=28, + end_col_offset=32), + lineno=28, + col_offset=21, + end_lineno=28, + end_col_offset=32), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=32), + If( + BoolOp( + And(), + [ + Compare( + BinOp( + BinOp( + Name( + 'placeholder_13', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=22), + Sub(), + Name( + 'placeholder_12', + Load(), + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=28), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=28), + Mod(), + Constant( + 2, + lineno=29, + col_offset=32, + end_lineno=29, + end_col_offset=33), + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=33), + [ + Eq()], + [ + Constant( + 1, + lineno=29, + col_offset=37, + end_lineno=29, + end_col_offset=38)], + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=38), + Compare( + Call( + Name( + 'gcd', + Load(), + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=46), + [ + Name( + 'placeholder_13', + Load(), + lineno=29, + col_offset=47, + end_lineno=29, + end_col_offset=53), + Name( + 'placeholder_12', + Load(), + lineno=29, + col_offset=55, + end_lineno=29, + end_col_offset=58)], + [], + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=59), + [ + Eq()], + [ + Constant( + 1, + lineno=29, + col_offset=63, + end_lineno=29, + end_col_offset=64)], + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=64)], + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=64), + [ + Expr( + Yield( + Tuple( + [ + Name( + 'member', + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=28), + Name( + 'idx', + Load(), + lineno=30, + col_offset=30, + end_lineno=30, + end_col_offset=33)], + Load(), + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=33), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=33), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=33)], + [], + lineno=29, + col_offset=12, + end_lineno=30, + end_col_offset=33)], + [], + lineno=27, + col_offset=8, + end_lineno=30, + end_col_offset=33)], + [], + lineno=26, + col_offset=4, + end_lineno=30, + end_col_offset=33)], + [], + lineno=24, + col_offset=0, + end_lineno=30, + end_col_offset=33), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Tuple( + [ + Name( + 'placeholder_15', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=16), + Name( + 'placeholder_16', + Store(), + lineno=38, + col_offset=18, + end_lineno=38, + end_col_offset=26)], + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=26), + Call( + Name( + 'placeholder_10', + Load(), + lineno=38, + col_offset=30, + end_lineno=38, + end_col_offset=48), + [ + Name( + 'placeholder_3', + Load(), + lineno=38, + col_offset=49, + end_lineno=38, + end_col_offset=54)], + [], + lineno=38, + col_offset=30, + end_lineno=38, + end_col_offset=55), + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=14)], + BinOp( + Name( + 'placeholder_15', + Load(), + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=25), + Pow(), + Constant( + 2, + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=30), + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=30), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=14)], + BinOp( + Name( + 'placeholder_16', + Load(), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=25), + Pow(), + Constant( + 2, + lineno=40, + col_offset=29, + end_lineno=40, + end_col_offset=30), + lineno=40, + col_offset=17, + end_lineno=40, + end_col_offset=30), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=13)], + BinOp( + Name( + 'placeholder_17', + Load(), + lineno=42, + col_offset=16, + end_lineno=42, + end_col_offset=22), + Sub(), + Name( + 'placeholder_18', + Load(), + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=31), + lineno=42, + col_offset=16, + end_lineno=42, + end_col_offset=31), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=31), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=12)], + BinOp( + BinOp( + Constant( + 2, + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=16), + Mult(), + Name( + 'placeholder_15', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=27), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=27), + Mult(), + Name( + 'placeholder_16', + Load(), + lineno=43, + col_offset=30, + end_lineno=43, + end_col_offset=38), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=38), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=38), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=13)], + BinOp( + Name( + 'placeholder_17', + Load(), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=22), + Add(), + Name( + 'placeholder_18', + Load(), + lineno=44, + col_offset=25, + end_lineno=44, + end_col_offset=31), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=31), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=31), + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=16), + [ + Gt()], + [ + Name( + 'placeholder_8', + Load(), + lineno=46, + col_offset=19, + end_lineno=46, + end_col_offset=23)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=23), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=17), + Name( + 'placeholder_8', + Store(), + lineno=47, + col_offset=19, + end_lineno=47, + end_col_offset=23)], + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=23)], + Tuple( + [ + Name( + 'placeholder_8', + Load(), + lineno=47, + col_offset=26, + end_lineno=47, + end_col_offset=30), + Name( + 'placeholder_7', + Load(), + lineno=47, + col_offset=32, + end_lineno=47, + end_col_offset=37)], + Load(), + lineno=47, + col_offset=26, + end_lineno=47, + end_col_offset=37), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=37)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=37), + Expr( + Yield( + Tuple( + [ + Name( + 'alpha', + Load(), + lineno=49, + col_offset=14, + end_lineno=49, + end_col_offset=19), + Name( + 'beta', + Load(), + lineno=49, + col_offset=21, + end_lineno=49, + end_col_offset=25), + Name( + 'gamma', + Load(), + lineno=49, + col_offset=27, + end_lineno=49, + end_col_offset=32)], + Load(), + lineno=49, + col_offset=14, + end_lineno=49, + end_col_offset=32), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=32), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=32)], + [], + lineno=38, + col_offset=4, + end_lineno=49, + end_col_offset=32)], + [], + lineno=33, + col_offset=0, + end_lineno=49, + end_col_offset=32), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'placeholder_20', + lineno=52, + col_offset=22, + end_lineno=52, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'placeholder_21', + Load(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=15), + [ + comprehension( + Name( + 'placeholder_21', + Store(), + lineno=54, + col_offset=20, + end_lineno=54, + end_col_offset=27), + Call( + Name( + 'placeholder_0', + Load(), + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=28), + [ + Constant( + 1, + lineno=55, + col_offset=29, + end_lineno=55, + end_col_offset=30), + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=55, + col_offset=32, + end_lineno=55, + end_col_offset=38), + FloorDiv(), + Constant( + 2, + lineno=55, + col_offset=42, + end_lineno=55, + end_col_offset=43), + lineno=55, + col_offset=32, + end_lineno=55, + end_col_offset=43)], + [], + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=44), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=56, + col_offset=11, + end_lineno=56, + end_col_offset=14), + [ + Name( + 'placeholder_21', + Load(), + lineno=56, + col_offset=15, + end_lineno=56, + end_col_offset=22)], + [], + lineno=56, + col_offset=11, + end_lineno=56, + end_col_offset=23), + [ + Eq()], + [ + Name( + 'placeholder_20', + Load(), + lineno=56, + col_offset=27, + end_lineno=56, + end_col_offset=33)], + lineno=56, + col_offset=11, + end_lineno=56, + end_col_offset=33)], + 0)], + lineno=53, + col_offset=11, + end_lineno=57, + end_col_offset=9), + lineno=53, + col_offset=4, + end_lineno=57, + end_col_offset=9)], + [], + lineno=52, + col_offset=0, + end_lineno=57, + end_col_offset=9)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-pythagorean-triplet/representation.txt b/test/practice-pythagorean-triplet/representation.txt new file mode 100644 index 0000000..92937ef --- /dev/null +++ b/test/practice-pythagorean-triplet/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('math', [alias('sqrt', lineno=1, col_offset=17, end_lineno=1, end_col_offset=21), alias('ceil', lineno=1, col_offset=23, end_lineno=1, end_col_offset=27), alias('gcd', lineno=1, col_offset=29, end_lineno=1, end_col_offset=32)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=32), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=22, end_lineno=4, end_col_offset=27), arg('placeholder_2', lineno=4, col_offset=29, end_lineno=4, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_3', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=13), Call(Name('range', Load(), lineno=5, col_offset=17, end_lineno=5, end_col_offset=22), [Constant(4, lineno=5, col_offset=23, end_lineno=5, end_col_offset=24), BinOp(Name('placeholder_2', Load(), lineno=5, col_offset=26, end_lineno=5, end_col_offset=29), Add(), Constant(1, lineno=5, col_offset=32, end_lineno=5, end_col_offset=33), lineno=5, col_offset=26, end_lineno=5, end_col_offset=33), Constant(4, lineno=5, col_offset=35, end_lineno=5, end_col_offset=36)], [], lineno=5, col_offset=17, end_lineno=5, end_col_offset=37), [For(Tuple([Name('placeholder_4', Store(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=17), Name('placeholder_5', Store(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=24), Name('placeholder_6', Store(), lineno=6, col_offset=26, end_lineno=6, end_col_offset=31)], Store(), lineno=6, col_offset=12, end_lineno=6, end_col_offset=31), Call(Name('primitive_triplets', Load(), lineno=6, col_offset=35, end_lineno=6, end_col_offset=53), [Name('placeholder_3', Load(), lineno=6, col_offset=54, end_lineno=6, end_col_offset=59)], [], lineno=6, col_offset=35, end_lineno=6, end_col_offset=60), [Assign([Name('placeholder_7', Store(), lineno=7, col_offset=12, end_lineno=7, end_col_offset=17)], Name('placeholder_4', Load(), lineno=7, col_offset=20, end_lineno=7, end_col_offset=25), lineno=7, col_offset=12, end_lineno=7, end_col_offset=25), Assign([Name('placeholder_8', Store(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=16)], Name('placeholder_5', Load(), lineno=8, col_offset=19, end_lineno=8, end_col_offset=24), lineno=8, col_offset=12, end_lineno=8, end_col_offset=24), Assign([Name('placeholder_9', Store(), lineno=9, col_offset=12, end_lineno=9, end_col_offset=17)], Name('placeholder_6', Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=25), lineno=9, col_offset=12, end_lineno=9, end_col_offset=25), While(Compare(Name('placeholder_7', Load(), lineno=11, col_offset=18, end_lineno=11, end_col_offset=23), [Lt()], [Name('placeholder_1', Load(), lineno=11, col_offset=26, end_lineno=11, end_col_offset=31)], lineno=11, col_offset=18, end_lineno=11, end_col_offset=31), [Assign([Name('placeholder_7', Store(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=21)], BinOp(Name('placeholder_7', Load(), lineno=12, col_offset=24, end_lineno=12, end_col_offset=29), Add(), Name('placeholder_4', Load(), lineno=12, col_offset=32, end_lineno=12, end_col_offset=37), lineno=12, col_offset=24, end_lineno=12, end_col_offset=37), lineno=12, col_offset=16, end_lineno=12, end_col_offset=37), Assign([Name('placeholder_8', Store(), lineno=13, col_offset=16, end_lineno=13, end_col_offset=20)], BinOp(Name('placeholder_8', Load(), lineno=13, col_offset=23, end_lineno=13, end_col_offset=27), Add(), Name('placeholder_5', Load(), lineno=13, col_offset=30, end_lineno=13, end_col_offset=35), lineno=13, col_offset=23, end_lineno=13, end_col_offset=35), lineno=13, col_offset=16, end_lineno=13, end_col_offset=35), Assign([Name('placeholder_9', Store(), lineno=14, col_offset=16, end_lineno=14, end_col_offset=21)], BinOp(Name('placeholder_9', Load(), lineno=14, col_offset=24, end_lineno=14, end_col_offset=29), Add(), Name('placeholder_6', Load(), lineno=14, col_offset=32, end_lineno=14, end_col_offset=37), lineno=14, col_offset=24, end_lineno=14, end_col_offset=37), lineno=14, col_offset=16, end_lineno=14, end_col_offset=37)], [], lineno=11, col_offset=12, end_lineno=14, end_col_offset=37), While(Compare(Name('placeholder_9', Load(), lineno=16, col_offset=18, end_lineno=16, end_col_offset=23), [LtE()], [Name('placeholder_2', Load(), lineno=16, col_offset=27, end_lineno=16, end_col_offset=30)], lineno=16, col_offset=18, end_lineno=16, end_col_offset=30), [Expr(Yield(List([Name('alpha', Load(), lineno=17, col_offset=23, end_lineno=17, end_col_offset=28), Name('beta', Load(), lineno=17, col_offset=30, end_lineno=17, end_col_offset=34), Name('gamma', Load(), lineno=17, col_offset=36, end_lineno=17, end_col_offset=41)], Load(), lineno=17, col_offset=22, end_lineno=17, end_col_offset=42), lineno=17, col_offset=16, end_lineno=17, end_col_offset=42), lineno=17, col_offset=16, end_lineno=17, end_col_offset=42), Assign([Name('placeholder_7', Store(), lineno=19, col_offset=16, end_lineno=19, end_col_offset=21)], BinOp(Name('placeholder_7', Load(), lineno=19, col_offset=24, end_lineno=19, end_col_offset=29), Add(), Name('placeholder_4', Load(), lineno=19, col_offset=32, end_lineno=19, end_col_offset=37), lineno=19, col_offset=24, end_lineno=19, end_col_offset=37), lineno=19, col_offset=16, end_lineno=19, end_col_offset=37), Assign([Name('placeholder_8', Store(), lineno=20, col_offset=16, end_lineno=20, end_col_offset=20)], BinOp(Name('placeholder_8', Load(), lineno=20, col_offset=23, end_lineno=20, end_col_offset=27), Add(), Name('placeholder_5', Load(), lineno=20, col_offset=30, end_lineno=20, end_col_offset=35), lineno=20, col_offset=23, end_lineno=20, end_col_offset=35), lineno=20, col_offset=16, end_lineno=20, end_col_offset=35), Assign([Name('placeholder_9', Store(), lineno=21, col_offset=16, end_lineno=21, end_col_offset=21)], BinOp(Name('placeholder_9', Load(), lineno=21, col_offset=24, end_lineno=21, end_col_offset=29), Add(), Name('placeholder_6', Load(), lineno=21, col_offset=32, end_lineno=21, end_col_offset=37), lineno=21, col_offset=24, end_lineno=21, end_col_offset=37), lineno=21, col_offset=16, end_lineno=21, end_col_offset=37)], [], lineno=16, col_offset=12, end_lineno=21, end_col_offset=37)], [], lineno=6, col_offset=8, end_lineno=21, end_col_offset=37)], [], lineno=5, col_offset=4, end_lineno=21, end_col_offset=37)], [], lineno=4, col_offset=0, end_lineno=21, end_col_offset=37), FunctionDef('placeholder_10', arguments([], [arg('placeholder_3', lineno=24, col_offset=23, end_lineno=24, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_11', Store(), lineno=25, col_offset=4, end_lineno=25, end_col_offset=8)], BinOp(Name('placeholder_3', Load(), lineno=25, col_offset=11, end_lineno=25, end_col_offset=16), FloorDiv(), Constant(2, lineno=25, col_offset=20, end_lineno=25, end_col_offset=21), lineno=25, col_offset=11, end_lineno=25, end_col_offset=21), lineno=25, col_offset=4, end_lineno=25, end_col_offset=21), For(Name('placeholder_12', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=11), Call(Name('range', Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=20), [Constant(1, lineno=26, col_offset=21, end_lineno=26, end_col_offset=22), Call(Name('int', Load(), lineno=26, col_offset=24, end_lineno=26, end_col_offset=27), [Call(Name('ceil', Load(), lineno=26, col_offset=28, end_lineno=26, end_col_offset=32), [Call(Name('sqrt', Load(), lineno=26, col_offset=33, end_lineno=26, end_col_offset=37), [Name('placeholder_11', Load(), lineno=26, col_offset=38, end_lineno=26, end_col_offset=42)], [], lineno=26, col_offset=33, end_lineno=26, end_col_offset=43)], [], lineno=26, col_offset=28, end_lineno=26, end_col_offset=44)], [], lineno=26, col_offset=24, end_lineno=26, end_col_offset=45)], [], lineno=26, col_offset=15, end_lineno=26, end_col_offset=46), [If(Compare(BinOp(Name('placeholder_11', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=15), Mod(), Name('placeholder_12', Load(), lineno=27, col_offset=18, end_lineno=27, end_col_offset=21), lineno=27, col_offset=11, end_lineno=27, end_col_offset=21), [Eq()], [Constant(0, lineno=27, col_offset=25, end_lineno=27, end_col_offset=26)], lineno=27, col_offset=11, end_lineno=27, end_col_offset=26), [Assign([Name('placeholder_13', Store(), lineno=28, col_offset=12, end_lineno=28, end_col_offset=18)], BinOp(Name('placeholder_11', Load(), lineno=28, col_offset=21, end_lineno=28, end_col_offset=25), FloorDiv(), Name('placeholder_12', Load(), lineno=28, col_offset=29, end_lineno=28, end_col_offset=32), lineno=28, col_offset=21, end_lineno=28, end_col_offset=32), lineno=28, col_offset=12, end_lineno=28, end_col_offset=32), If(BoolOp(And(), [Compare(BinOp(BinOp(Name('placeholder_13', Load(), lineno=29, col_offset=16, end_lineno=29, end_col_offset=22), Sub(), Name('placeholder_12', Load(), lineno=29, col_offset=25, end_lineno=29, end_col_offset=28), lineno=29, col_offset=16, end_lineno=29, end_col_offset=28), Mod(), Constant(2, lineno=29, col_offset=32, end_lineno=29, end_col_offset=33), lineno=29, col_offset=15, end_lineno=29, end_col_offset=33), [Eq()], [Constant(1, lineno=29, col_offset=37, end_lineno=29, end_col_offset=38)], lineno=29, col_offset=15, end_lineno=29, end_col_offset=38), Compare(Call(Name('gcd', Load(), lineno=29, col_offset=43, end_lineno=29, end_col_offset=46), [Name('placeholder_13', Load(), lineno=29, col_offset=47, end_lineno=29, end_col_offset=53), Name('placeholder_12', Load(), lineno=29, col_offset=55, end_lineno=29, end_col_offset=58)], [], lineno=29, col_offset=43, end_lineno=29, end_col_offset=59), [Eq()], [Constant(1, lineno=29, col_offset=63, end_lineno=29, end_col_offset=64)], lineno=29, col_offset=43, end_lineno=29, end_col_offset=64)], lineno=29, col_offset=15, end_lineno=29, end_col_offset=64), [Expr(Yield(Tuple([Name('member', Load(), lineno=30, col_offset=22, end_lineno=30, end_col_offset=28), Name('idx', Load(), lineno=30, col_offset=30, end_lineno=30, end_col_offset=33)], Load(), lineno=30, col_offset=22, end_lineno=30, end_col_offset=33), lineno=30, col_offset=16, end_lineno=30, end_col_offset=33), lineno=30, col_offset=16, end_lineno=30, end_col_offset=33)], [], lineno=29, col_offset=12, end_lineno=30, end_col_offset=33)], [], lineno=27, col_offset=8, end_lineno=30, end_col_offset=33)], [], lineno=26, col_offset=4, end_lineno=30, end_col_offset=33)], [], lineno=24, col_offset=0, end_lineno=30, end_col_offset=33), FunctionDef('placeholder_14', arguments([], [arg('placeholder_3', lineno=33, col_offset=23, end_lineno=33, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Tuple([Name('placeholder_15', Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=16), Name('placeholder_16', Store(), lineno=38, col_offset=18, end_lineno=38, end_col_offset=26)], Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=26), Call(Name('placeholder_10', Load(), lineno=38, col_offset=30, end_lineno=38, end_col_offset=48), [Name('placeholder_3', Load(), lineno=38, col_offset=49, end_lineno=38, end_col_offset=54)], [], lineno=38, col_offset=30, end_lineno=38, end_col_offset=55), [Assign([Name('placeholder_17', Store(), lineno=39, col_offset=8, end_lineno=39, end_col_offset=14)], BinOp(Name('placeholder_15', Load(), lineno=39, col_offset=17, end_lineno=39, end_col_offset=25), Pow(), Constant(2, lineno=39, col_offset=29, end_lineno=39, end_col_offset=30), lineno=39, col_offset=17, end_lineno=39, end_col_offset=30), lineno=39, col_offset=8, end_lineno=39, end_col_offset=30), Assign([Name('placeholder_18', Store(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=14)], BinOp(Name('placeholder_16', Load(), lineno=40, col_offset=17, end_lineno=40, end_col_offset=25), Pow(), Constant(2, lineno=40, col_offset=29, end_lineno=40, end_col_offset=30), lineno=40, col_offset=17, end_lineno=40, end_col_offset=30), lineno=40, col_offset=8, end_lineno=40, end_col_offset=30), Assign([Name('placeholder_7', Store(), lineno=42, col_offset=8, end_lineno=42, end_col_offset=13)], BinOp(Name('placeholder_17', Load(), lineno=42, col_offset=16, end_lineno=42, end_col_offset=22), Sub(), Name('placeholder_18', Load(), lineno=42, col_offset=25, end_lineno=42, end_col_offset=31), lineno=42, col_offset=16, end_lineno=42, end_col_offset=31), lineno=42, col_offset=8, end_lineno=42, end_col_offset=31), Assign([Name('placeholder_8', Store(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=12)], BinOp(BinOp(Constant(2, lineno=43, col_offset=15, end_lineno=43, end_col_offset=16), Mult(), Name('placeholder_15', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=27), lineno=43, col_offset=15, end_lineno=43, end_col_offset=27), Mult(), Name('placeholder_16', Load(), lineno=43, col_offset=30, end_lineno=43, end_col_offset=38), lineno=43, col_offset=15, end_lineno=43, end_col_offset=38), lineno=43, col_offset=8, end_lineno=43, end_col_offset=38), Assign([Name('placeholder_9', Store(), lineno=44, col_offset=8, end_lineno=44, end_col_offset=13)], BinOp(Name('placeholder_17', Load(), lineno=44, col_offset=16, end_lineno=44, end_col_offset=22), Add(), Name('placeholder_18', Load(), lineno=44, col_offset=25, end_lineno=44, end_col_offset=31), lineno=44, col_offset=16, end_lineno=44, end_col_offset=31), lineno=44, col_offset=8, end_lineno=44, end_col_offset=31), If(Compare(Name('placeholder_7', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=16), [Gt()], [Name('placeholder_8', Load(), lineno=46, col_offset=19, end_lineno=46, end_col_offset=23)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=23), [Assign([Tuple([Name('placeholder_7', Store(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=17), Name('placeholder_8', Store(), lineno=47, col_offset=19, end_lineno=47, end_col_offset=23)], Store(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=23)], Tuple([Name('placeholder_8', Load(), lineno=47, col_offset=26, end_lineno=47, end_col_offset=30), Name('placeholder_7', Load(), lineno=47, col_offset=32, end_lineno=47, end_col_offset=37)], Load(), lineno=47, col_offset=26, end_lineno=47, end_col_offset=37), lineno=47, col_offset=12, end_lineno=47, end_col_offset=37)], [], lineno=46, col_offset=8, end_lineno=47, end_col_offset=37), Expr(Yield(Tuple([Name('alpha', Load(), lineno=49, col_offset=14, end_lineno=49, end_col_offset=19), Name('beta', Load(), lineno=49, col_offset=21, end_lineno=49, end_col_offset=25), Name('gamma', Load(), lineno=49, col_offset=27, end_lineno=49, end_col_offset=32)], Load(), lineno=49, col_offset=14, end_lineno=49, end_col_offset=32), lineno=49, col_offset=8, end_lineno=49, end_col_offset=32), lineno=49, col_offset=8, end_lineno=49, end_col_offset=32)], [], lineno=38, col_offset=4, end_lineno=49, end_col_offset=32)], [], lineno=33, col_offset=0, end_lineno=49, end_col_offset=32), FunctionDef('placeholder_19', arguments([], [arg('placeholder_20', lineno=52, col_offset=22, end_lineno=52, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Name('placeholder_21', Load(), lineno=54, col_offset=8, end_lineno=54, end_col_offset=15), [comprehension(Name('placeholder_21', Store(), lineno=54, col_offset=20, end_lineno=54, end_col_offset=27), Call(Name('placeholder_0', Load(), lineno=55, col_offset=11, end_lineno=55, end_col_offset=28), [Constant(1, lineno=55, col_offset=29, end_lineno=55, end_col_offset=30), BinOp(Name('placeholder_20', Load(), lineno=55, col_offset=32, end_lineno=55, end_col_offset=38), FloorDiv(), Constant(2, lineno=55, col_offset=42, end_lineno=55, end_col_offset=43), lineno=55, col_offset=32, end_lineno=55, end_col_offset=43)], [], lineno=55, col_offset=11, end_lineno=55, end_col_offset=44), [Compare(Call(Name('sum', Load(), lineno=56, col_offset=11, end_lineno=56, end_col_offset=14), [Name('placeholder_21', Load(), lineno=56, col_offset=15, end_lineno=56, end_col_offset=22)], [], lineno=56, col_offset=11, end_lineno=56, end_col_offset=23), [Eq()], [Name('placeholder_20', Load(), lineno=56, col_offset=27, end_lineno=56, end_col_offset=33)], lineno=56, col_offset=11, end_lineno=56, end_col_offset=33)], 0)], lineno=53, col_offset=11, end_lineno=57, end_col_offset=9), lineno=53, col_offset=4, end_lineno=57, end_col_offset=9)], [], lineno=52, col_offset=0, end_lineno=57, end_col_offset=9)], []) \ No newline at end of file diff --git a/test/practice-queen-attack/.meta/additional_tests.json b/test/practice-queen-attack/.meta/additional_tests.json new file mode 100644 index 0000000..510d9cd --- /dev/null +++ b/test/practice-queen-attack/.meta/additional_tests.json @@ -0,0 +1,25 @@ +{ + "cases": [ + { + "description": "queens same position can attack", + "property": "canAttack", + "input": { + "white_queen": { + "position": { + "row": 2, + "column": 2 + } + }, + "black_queen": { + "position": { + "row": 2, + "column": 2 + } + } + }, + "expected": { + "error": "Invalid queen position: both queens in the same square" + } + } + ] +} diff --git a/test/practice-queen-attack/.meta/config.json b/test/practice-queen-attack/.meta/config.json new file mode 100644 index 0000000..91336ad --- /dev/null +++ b/test/practice-queen-attack/.meta/config.json @@ -0,0 +1,37 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "beatorizu", + "behrtam", + "BethanyG", + "cmccandless", + "denislooby", + "Dog", + "fortrieb", + "ikhadykin", + "jnaulty", + "kytrinyx", + "N-Parsons", + "olufotebig", + "pheanex", + "sjakobi", + "tqa236", + "xitanggg" + ], + "files": { + "solution": [ + "queen_attack.py" + ], + "test": [ + "queen_attack_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given the position of two queens on a chess board, indicate whether or not they are positioned so that they can attack each other.", + "source": "J Dalbey's Programming Practice problems", + "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" +} diff --git a/test/practice-queen-attack/mapping.json b/test/practice-queen-attack/mapping.json new file mode 100644 index 0000000..055ceae --- /dev/null +++ b/test/practice-queen-attack/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "Queen", + "placeholder_1": "__init__", + "placeholder_2": "row", + "placeholder_3": "column", + "placeholder_4": "can_attack", + "placeholder_5": "another_queen", + "placeholder_6": "idx", + "placeholder_7": "edx" +} \ No newline at end of file diff --git a/test/practice-queen-attack/queen_attack.py b/test/practice-queen-attack/queen_attack.py new file mode 100644 index 0000000..e9ae242 --- /dev/null +++ b/test/practice-queen-attack/queen_attack.py @@ -0,0 +1,22 @@ +class Queen: + def __init__(self, row, column): + if row < 0: + raise ValueError('row not positive') + if not 0 <= row <= 7: + raise ValueError('row not on board') + if column < 0: + raise ValueError('column not positive') + if not 0 <= column <= 7: + raise ValueError('column not on board') + self.row = row + self.column = column + + def can_attack(self, another_queen): + idx = abs(self.row - another_queen.row) + edx = abs(self.column - another_queen.column) + if idx == edx == 0: + raise ValueError('Invalid queen position: both queens in the same square') + elif idx == edx or idx == 0 or edx == 0: + return True + else: + return False diff --git a/test/practice-queen-attack/representation.json b/test/practice-queen-attack/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-queen-attack/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-queen-attack/representation.out b/test/practice-queen-attack/representation.out new file mode 100644 index 0000000..07b4b6d --- /dev/null +++ b/test/practice-queen-attack/representation.out @@ -0,0 +1,1323 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3): + if placeholder_2 < 0: + raise ValueError("row not positive") + if not 0 <= placeholder_2 <= 7: + raise ValueError("row not on board") + if placeholder_3 < 0: + raise ValueError("column not positive") + if not 0 <= placeholder_3 <= 7: + raise ValueError("column not on board") + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 + + def placeholder_4(self, placeholder_5): + placeholder_6 = abs(self.placeholder_2 - placeholder_5.placeholder_2) + placeholder_7 = abs(self.placeholder_3 - placeholder_5.placeholder_3) + if placeholder_6 == placeholder_7 == 0: + raise ValueError("Invalid queen position: both queens in the same square") + elif placeholder_6 == placeholder_7 or placeholder_6 == 0 or placeholder_7 == 0: + return True + else: + return False + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Queen', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'row', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=26), + arg( + 'column', + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'row', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=14), + [ + Lt()], + [ + Constant( + 0, + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=18)], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=28), + [ + Constant( + 'row not positive', + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=47)], + [], + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=48), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=48)], + [], + lineno=3, + col_offset=8, + end_lineno=4, + end_col_offset=48), + If( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=16), + [ + LtE(), + LtE()], + [ + Name( + 'row', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=23), + Constant( + 7, + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=28)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=28), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=28), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=28), + [ + Constant( + 'row not on board', + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=47)], + [], + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=48), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=48)], + [], + lineno=5, + col_offset=8, + end_lineno=6, + end_col_offset=48), + If( + Compare( + Name( + 'column', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=17), + [ + Lt()], + [ + Constant( + 0, + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=21)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=21), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=28), + [ + Constant( + 'column not positive', + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=50)], + [], + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=51), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=51)], + [], + lineno=7, + col_offset=8, + end_lineno=8, + end_col_offset=51), + If( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16), + [ + LtE(), + LtE()], + [ + Name( + 'column', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=26), + Constant( + 7, + lineno=9, + col_offset=30, + end_lineno=9, + end_col_offset=31)], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=31), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=28), + [ + Constant( + 'column not on board', + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=50)], + [], + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=51), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=51)], + [], + lineno=9, + col_offset=8, + end_lineno=10, + end_col_offset=51), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'row', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=16)], + Name( + 'row', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'column', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=19)], + Name( + 'column', + Load(), + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=28), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=28)], + [], + lineno=2, + col_offset=4, + end_lineno=12, + end_col_offset=28), + FunctionDef( + 'can_attack', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=23), + arg( + 'another_queen', + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'idx', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=11)], + Call( + Name( + 'abs', + Load(), + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=17), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=22), + 'row', + Load(), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=26), + Sub(), + Attribute( + Name( + 'another_queen', + Load(), + lineno=15, + col_offset=29, + end_lineno=15, + end_col_offset=42), + 'row', + Load(), + lineno=15, + col_offset=29, + end_lineno=15, + end_col_offset=46), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=46)], + [], + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=47), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=47), + Assign( + [ + Name( + 'edx', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=11)], + Call( + Name( + 'abs', + Load(), + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=17), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=22), + 'column', + Load(), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=29), + Sub(), + Attribute( + Name( + 'another_queen', + Load(), + lineno=16, + col_offset=32, + end_lineno=16, + end_col_offset=45), + 'column', + Load(), + lineno=16, + col_offset=32, + end_lineno=16, + end_col_offset=52), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=52)], + [], + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=53), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=53), + If( + Compare( + Name( + 'idx', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=14), + [ + Eq(), + Eq()], + [ + Name( + 'edx', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=21), + Constant( + 0, + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=26)], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=28), + [ + Constant( + 'Invalid queen position: both queens in the same square', + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=85)], + [], + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=86), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=86)], + [ + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'idx', + Load(), + lineno=19, + col_offset=13, + end_lineno=19, + end_col_offset=16), + [ + Eq()], + [ + Name( + 'edx', + Load(), + lineno=19, + col_offset=20, + end_lineno=19, + end_col_offset=23)], + lineno=19, + col_offset=13, + end_lineno=19, + end_col_offset=23), + Compare( + Name( + 'idx', + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 0, + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=35)], + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=35), + Compare( + Name( + 'edx', + Load(), + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=42), + [ + Eq()], + [ + Constant( + 0, + lineno=19, + col_offset=46, + end_lineno=19, + end_col_offset=47)], + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=47)], + lineno=19, + col_offset=13, + end_lineno=19, + end_col_offset=47), + [ + Return( + Constant( + True, + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=23), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=23)], + [ + Return( + Constant( + False, + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=24), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=24)], + lineno=19, + col_offset=8, + end_lineno=22, + end_col_offset=24)], + lineno=17, + col_offset=8, + end_lineno=22, + end_col_offset=24)], + [], + lineno=14, + col_offset=4, + end_lineno=22, + end_col_offset=24)], + [], + lineno=1, + col_offset=0, + end_lineno=22, + end_col_offset=24)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=26), + arg( + 'placeholder_3', + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=14), + [ + Lt()], + [ + Constant( + 0, + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=18)], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=18), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=28), + [ + Constant( + 'row not positive', + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=47)], + [], + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=48), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=48)], + [], + lineno=3, + col_offset=8, + end_lineno=4, + end_col_offset=48), + If( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=16), + [ + LtE(), + LtE()], + [ + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=23), + Constant( + 7, + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=28)], + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=28), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=28), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=28), + [ + Constant( + 'row not on board', + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=47)], + [], + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=48), + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=48)], + [], + lineno=5, + col_offset=8, + end_lineno=6, + end_col_offset=48), + If( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=17), + [ + Lt()], + [ + Constant( + 0, + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=21)], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=21), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=28), + [ + Constant( + 'column not positive', + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=50)], + [], + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=51), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=51)], + [], + lineno=7, + col_offset=8, + end_lineno=8, + end_col_offset=51), + If( + UnaryOp( + Not(), + Compare( + Constant( + 0, + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=16), + [ + LtE(), + LtE()], + [ + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=26), + Constant( + 7, + lineno=9, + col_offset=30, + end_lineno=9, + end_col_offset=31)], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=31), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=28), + [ + Constant( + 'column not on board', + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=50)], + [], + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=51), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=51)], + [], + lineno=9, + col_offset=8, + end_lineno=10, + end_col_offset=51), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=16)], + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=22), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=19)], + Name( + 'placeholder_3', + Load(), + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=28), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=28)], + [], + lineno=2, + col_offset=4, + end_lineno=12, + end_col_offset=28), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=23), + arg( + 'placeholder_5', + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=11)], + Call( + Name( + 'abs', + Load(), + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=17), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=22), + 'placeholder_2', + Load(), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=26), + Sub(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=29, + end_lineno=15, + end_col_offset=42), + 'placeholder_2', + Load(), + lineno=15, + col_offset=29, + end_lineno=15, + end_col_offset=46), + lineno=15, + col_offset=18, + end_lineno=15, + end_col_offset=46)], + [], + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=47), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=47), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=11)], + Call( + Name( + 'abs', + Load(), + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=17), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=22), + 'placeholder_3', + Load(), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=29), + Sub(), + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=32, + end_lineno=16, + end_col_offset=45), + 'placeholder_3', + Load(), + lineno=16, + col_offset=32, + end_lineno=16, + end_col_offset=52), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=52)], + [], + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=53), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=53), + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=14), + [ + Eq(), + Eq()], + [ + Name( + 'placeholder_7', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=21), + Constant( + 0, + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=26)], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=26), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=28), + [ + Constant( + 'Invalid queen position: both queens in the same square', + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=85)], + [], + lineno=18, + col_offset=18, + end_lineno=18, + end_col_offset=86), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=86)], + [ + If( + BoolOp( + Or(), + [ + Compare( + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=13, + end_lineno=19, + end_col_offset=16), + [ + Eq()], + [ + Name( + 'placeholder_7', + Load(), + lineno=19, + col_offset=20, + end_lineno=19, + end_col_offset=23)], + lineno=19, + col_offset=13, + end_lineno=19, + end_col_offset=23), + Compare( + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 0, + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=35)], + lineno=19, + col_offset=27, + end_lineno=19, + end_col_offset=35), + Compare( + Name( + 'placeholder_7', + Load(), + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=42), + [ + Eq()], + [ + Constant( + 0, + lineno=19, + col_offset=46, + end_lineno=19, + end_col_offset=47)], + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=47)], + lineno=19, + col_offset=13, + end_lineno=19, + end_col_offset=47), + [ + Return( + Constant( + True, + lineno=20, + col_offset=19, + end_lineno=20, + end_col_offset=23), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=23)], + [ + Return( + Constant( + False, + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=24), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=24)], + lineno=19, + col_offset=8, + end_lineno=22, + end_col_offset=24)], + lineno=17, + col_offset=8, + end_lineno=22, + end_col_offset=24)], + [], + lineno=14, + col_offset=4, + end_lineno=22, + end_col_offset=24)], + [], + lineno=1, + col_offset=0, + end_lineno=22, + end_col_offset=24)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-queen-attack/representation.txt b/test/practice-queen-attack/representation.txt new file mode 100644 index 0000000..e5dc4d2 --- /dev/null +++ b/test/practice-queen-attack/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=26), arg('placeholder_3', lineno=2, col_offset=28, end_lineno=2, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_2', Load(), lineno=3, col_offset=11, end_lineno=3, end_col_offset=14), [Lt()], [Constant(0, lineno=3, col_offset=17, end_lineno=3, end_col_offset=18)], lineno=3, col_offset=11, end_lineno=3, end_col_offset=18), [Raise(Call(Name('ValueError', Load(), lineno=4, col_offset=18, end_lineno=4, end_col_offset=28), [Constant('row not positive', lineno=4, col_offset=29, end_lineno=4, end_col_offset=47)], [], lineno=4, col_offset=18, end_lineno=4, end_col_offset=48), lineno=4, col_offset=12, end_lineno=4, end_col_offset=48)], [], lineno=3, col_offset=8, end_lineno=4, end_col_offset=48), If(UnaryOp(Not(), Compare(Constant(0, lineno=5, col_offset=15, end_lineno=5, end_col_offset=16), [LtE(), LtE()], [Name('placeholder_2', Load(), lineno=5, col_offset=20, end_lineno=5, end_col_offset=23), Constant(7, lineno=5, col_offset=27, end_lineno=5, end_col_offset=28)], lineno=5, col_offset=15, end_lineno=5, end_col_offset=28), lineno=5, col_offset=11, end_lineno=5, end_col_offset=28), [Raise(Call(Name('ValueError', Load(), lineno=6, col_offset=18, end_lineno=6, end_col_offset=28), [Constant('row not on board', lineno=6, col_offset=29, end_lineno=6, end_col_offset=47)], [], lineno=6, col_offset=18, end_lineno=6, end_col_offset=48), lineno=6, col_offset=12, end_lineno=6, end_col_offset=48)], [], lineno=5, col_offset=8, end_lineno=6, end_col_offset=48), If(Compare(Name('placeholder_3', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=17), [Lt()], [Constant(0, lineno=7, col_offset=20, end_lineno=7, end_col_offset=21)], lineno=7, col_offset=11, end_lineno=7, end_col_offset=21), [Raise(Call(Name('ValueError', Load(), lineno=8, col_offset=18, end_lineno=8, end_col_offset=28), [Constant('column not positive', lineno=8, col_offset=29, end_lineno=8, end_col_offset=50)], [], lineno=8, col_offset=18, end_lineno=8, end_col_offset=51), lineno=8, col_offset=12, end_lineno=8, end_col_offset=51)], [], lineno=7, col_offset=8, end_lineno=8, end_col_offset=51), If(UnaryOp(Not(), Compare(Constant(0, lineno=9, col_offset=15, end_lineno=9, end_col_offset=16), [LtE(), LtE()], [Name('placeholder_3', Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=26), Constant(7, lineno=9, col_offset=30, end_lineno=9, end_col_offset=31)], lineno=9, col_offset=15, end_lineno=9, end_col_offset=31), lineno=9, col_offset=11, end_lineno=9, end_col_offset=31), [Raise(Call(Name('ValueError', Load(), lineno=10, col_offset=18, end_lineno=10, end_col_offset=28), [Constant('column not on board', lineno=10, col_offset=29, end_lineno=10, end_col_offset=50)], [], lineno=10, col_offset=18, end_lineno=10, end_col_offset=51), lineno=10, col_offset=12, end_lineno=10, end_col_offset=51)], [], lineno=9, col_offset=8, end_lineno=10, end_col_offset=51), Assign([Attribute(Name('self', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), 'placeholder_2', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=16)], Name('placeholder_2', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=22), lineno=11, col_offset=8, end_lineno=11, end_col_offset=22), Assign([Attribute(Name('self', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), 'placeholder_3', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=19)], Name('placeholder_3', Load(), lineno=12, col_offset=22, end_lineno=12, end_col_offset=28), lineno=12, col_offset=8, end_lineno=12, end_col_offset=28)], [], lineno=2, col_offset=4, end_lineno=12, end_col_offset=28), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=14, col_offset=19, end_lineno=14, end_col_offset=23), arg('placeholder_5', lineno=14, col_offset=25, end_lineno=14, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=11)], Call(Name('abs', Load(), lineno=15, col_offset=14, end_lineno=15, end_col_offset=17), [BinOp(Attribute(Name('self', Load(), lineno=15, col_offset=18, end_lineno=15, end_col_offset=22), 'placeholder_2', Load(), lineno=15, col_offset=18, end_lineno=15, end_col_offset=26), Sub(), Attribute(Name('placeholder_5', Load(), lineno=15, col_offset=29, end_lineno=15, end_col_offset=42), 'placeholder_2', Load(), lineno=15, col_offset=29, end_lineno=15, end_col_offset=46), lineno=15, col_offset=18, end_lineno=15, end_col_offset=46)], [], lineno=15, col_offset=14, end_lineno=15, end_col_offset=47), lineno=15, col_offset=8, end_lineno=15, end_col_offset=47), Assign([Name('placeholder_7', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=11)], Call(Name('abs', Load(), lineno=16, col_offset=14, end_lineno=16, end_col_offset=17), [BinOp(Attribute(Name('self', Load(), lineno=16, col_offset=18, end_lineno=16, end_col_offset=22), 'placeholder_3', Load(), lineno=16, col_offset=18, end_lineno=16, end_col_offset=29), Sub(), Attribute(Name('placeholder_5', Load(), lineno=16, col_offset=32, end_lineno=16, end_col_offset=45), 'placeholder_3', Load(), lineno=16, col_offset=32, end_lineno=16, end_col_offset=52), lineno=16, col_offset=18, end_lineno=16, end_col_offset=52)], [], lineno=16, col_offset=14, end_lineno=16, end_col_offset=53), lineno=16, col_offset=8, end_lineno=16, end_col_offset=53), If(Compare(Name('placeholder_6', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=14), [Eq(), Eq()], [Name('placeholder_7', Load(), lineno=17, col_offset=18, end_lineno=17, end_col_offset=21), Constant(0, lineno=17, col_offset=25, end_lineno=17, end_col_offset=26)], lineno=17, col_offset=11, end_lineno=17, end_col_offset=26), [Raise(Call(Name('ValueError', Load(), lineno=18, col_offset=18, end_lineno=18, end_col_offset=28), [Constant('Invalid queen position: both queens in the same square', lineno=18, col_offset=29, end_lineno=18, end_col_offset=85)], [], lineno=18, col_offset=18, end_lineno=18, end_col_offset=86), lineno=18, col_offset=12, end_lineno=18, end_col_offset=86)], [If(BoolOp(Or(), [Compare(Name('placeholder_6', Load(), lineno=19, col_offset=13, end_lineno=19, end_col_offset=16), [Eq()], [Name('placeholder_7', Load(), lineno=19, col_offset=20, end_lineno=19, end_col_offset=23)], lineno=19, col_offset=13, end_lineno=19, end_col_offset=23), Compare(Name('placeholder_6', Load(), lineno=19, col_offset=27, end_lineno=19, end_col_offset=30), [Eq()], [Constant(0, lineno=19, col_offset=34, end_lineno=19, end_col_offset=35)], lineno=19, col_offset=27, end_lineno=19, end_col_offset=35), Compare(Name('placeholder_7', Load(), lineno=19, col_offset=39, end_lineno=19, end_col_offset=42), [Eq()], [Constant(0, lineno=19, col_offset=46, end_lineno=19, end_col_offset=47)], lineno=19, col_offset=39, end_lineno=19, end_col_offset=47)], lineno=19, col_offset=13, end_lineno=19, end_col_offset=47), [Return(Constant(True, lineno=20, col_offset=19, end_lineno=20, end_col_offset=23), lineno=20, col_offset=12, end_lineno=20, end_col_offset=23)], [Return(Constant(False, lineno=22, col_offset=19, end_lineno=22, end_col_offset=24), lineno=22, col_offset=12, end_lineno=22, end_col_offset=24)], lineno=19, col_offset=8, end_lineno=22, end_col_offset=24)], lineno=17, col_offset=8, end_lineno=22, end_col_offset=24)], [], lineno=14, col_offset=4, end_lineno=22, end_col_offset=24)], [], lineno=1, col_offset=0, end_lineno=22, end_col_offset=24)], []) \ No newline at end of file diff --git a/test/practice-rail-fence-cipher/.meta/config.json b/test/practice-rail-fence-cipher/.meta/config.json new file mode 100644 index 0000000..9a904ef --- /dev/null +++ b/test/practice-rail-fence-cipher/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "akashsara", + "cmccandless", + "Dog", + "ikhadykin", + "jesserizzo", + "N-Parsons", + "pheanex", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "rail_fence_cipher.py" + ], + "test": [ + "rail_fence_cipher_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement encoding and decoding for the rail fence cipher.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher" +} diff --git a/test/practice-rail-fence-cipher/mapping.json b/test/practice-rail-fence-cipher/mapping.json new file mode 100644 index 0000000..6a4f7d9 --- /dev/null +++ b/test/practice-rail-fence-cipher/mapping.json @@ -0,0 +1,16 @@ +{ + "placeholder_0": "fence_pattern", + "placeholder_1": "rails", + "placeholder_2": "size", + "placeholder_3": "zig_zag", + "placeholder_4": "encode", + "placeholder_5": "msg", + "placeholder_6": "fence", + "placeholder_7": "_", + "placeholder_8": "idx", + "placeholder_9": "decode", + "placeholder_10": "fence_msg", + "placeholder_11": "char", + "placeholder_12": "key", + "placeholder_13": "item" +} \ No newline at end of file diff --git a/test/practice-rail-fence-cipher/rail_fence_cipher.py b/test/practice-rail-fence-cipher/rail_fence_cipher.py new file mode 100644 index 0000000..a27bd26 --- /dev/null +++ b/test/practice-rail-fence-cipher/rail_fence_cipher.py @@ -0,0 +1,17 @@ +from itertools import cycle, chain + + +def fence_pattern(rails, size): + zig_zag = cycle(chain(range(rails), range(rails - 2, 0, -1))) + return zip(zig_zag, range(size)) + + +def encode(msg, rails): + fence = fence_pattern(rails, len(msg)) + return ''.join(msg[idx] for _, idx in sorted(fence)) + + +def decode(msg, rails): + fence = fence_pattern(rails, len(msg)) + fence_msg = zip(msg, sorted(fence)) + return ''.join(char for char, _ in sorted(fence_msg, key=lambda item: item[1][1])) diff --git a/test/practice-rail-fence-cipher/representation.json b/test/practice-rail-fence-cipher/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-rail-fence-cipher/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-rail-fence-cipher/representation.out b/test/practice-rail-fence-cipher/representation.out new file mode 100644 index 0000000..be740b9 --- /dev/null +++ b/test/practice-rail-fence-cipher/representation.out @@ -0,0 +1,1357 @@ +## BEGIN NORMALIZED CODE ## +from itertools import cycle, chain + + +def placeholder_0(placeholder_1, placeholder_2): + placeholder_3 = cycle(chain(range(placeholder_1), range(placeholder_1 - 2, 0, -1))) + return zip(placeholder_3, range(placeholder_2)) + + +def placeholder_4(placeholder_5, placeholder_1): + placeholder_6 = placeholder_0(placeholder_1, len(placeholder_5)) + return "".join( + ( + placeholder_5[placeholder_8] + for placeholder_7, placeholder_8 in sorted(placeholder_6) + ) + ) + + +def placeholder_9(placeholder_5, placeholder_1): + placeholder_6 = placeholder_0(placeholder_1, len(placeholder_5)) + placeholder_10 = zip(placeholder_5, sorted(placeholder_6)) + return "".join( + ( + placeholder_11 + for placeholder_11, placeholder_7 in sorted( + placeholder_10, + placeholder_12=lambda placeholder_13: placeholder_13[1][1], + ) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'cycle', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27), + alias( + 'chain', + lineno=1, + col_offset=29, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + FunctionDef( + 'fence_pattern', + arguments( + [], + [ + arg( + 'rails', + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=23), + arg( + 'size', + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'zig_zag', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + Call( + Name( + 'cycle', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=19), + [ + Call( + Name( + 'chain', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=25), + [ + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=31), + [ + Name( + 'rails', + Load(), + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=37)], + [], + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=38), + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=40, + end_lineno=5, + end_col_offset=45), + [ + BinOp( + Name( + 'rails', + Load(), + lineno=5, + col_offset=46, + end_lineno=5, + end_col_offset=51), + Sub(), + Constant( + 2, + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=55), + lineno=5, + col_offset=46, + end_lineno=5, + end_col_offset=55), + Constant( + 0, + lineno=5, + col_offset=57, + end_lineno=5, + end_col_offset=58), + UnaryOp( + USub(), + Constant( + 1, + lineno=5, + col_offset=61, + end_lineno=5, + end_col_offset=62), + lineno=5, + col_offset=60, + end_lineno=5, + end_col_offset=62)], + [], + lineno=5, + col_offset=40, + end_lineno=5, + end_col_offset=63)], + [], + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=64)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=65), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=65), + Return( + Call( + Name( + 'zip', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=14), + [ + Name( + 'zig_zag', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=22), + Call( + Name( + 'range', + Load(), + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=29), + [ + Name( + 'size', + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=34)], + [], + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=35)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=36), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=36)], + [], + lineno=4, + col_offset=0, + end_lineno=6, + end_col_offset=36), + FunctionDef( + 'encode', + arguments( + [], + [ + arg( + 'msg', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=14), + arg( + 'rails', + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'fence', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=9)], + Call( + Name( + 'fence_pattern', + Load(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=25), + [ + Name( + 'rails', + Load(), + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=31), + Call( + Name( + 'len', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=36), + [ + Name( + 'msg', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=40)], + [], + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=41)], + [], + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=42), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=42), + Return( + Call( + Attribute( + Constant( + '', + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=13), + 'join', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=18), + [ + GeneratorExp( + Subscript( + Name( + 'msg', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=22), + Name( + 'idx', + Load(), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=26), + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=27), + [ + comprehension( + Tuple( + [ + Name( + '_', + Store(), + lineno=11, + col_offset=32, + end_lineno=11, + end_col_offset=33), + Name( + 'idx', + Store(), + lineno=11, + col_offset=35, + end_lineno=11, + end_col_offset=38)], + Store(), + lineno=11, + col_offset=32, + end_lineno=11, + end_col_offset=38), + Call( + Name( + 'sorted', + Load(), + lineno=11, + col_offset=42, + end_lineno=11, + end_col_offset=48), + [ + Name( + 'fence', + Load(), + lineno=11, + col_offset=49, + end_lineno=11, + end_col_offset=54)], + [], + lineno=11, + col_offset=42, + end_lineno=11, + end_col_offset=55), + [], + 0)], + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=56)], + [], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=56), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=56)], + [], + lineno=9, + col_offset=0, + end_lineno=11, + end_col_offset=56), + FunctionDef( + 'decode', + arguments( + [], + [ + arg( + 'msg', + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + arg( + 'rails', + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'fence', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=9)], + Call( + Name( + 'fence_pattern', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=25), + [ + Name( + 'rails', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=31), + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=36), + [ + Name( + 'msg', + Load(), + lineno=15, + col_offset=37, + end_lineno=15, + end_col_offset=40)], + [], + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=41)], + [], + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=42), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=42), + Assign( + [ + Name( + 'fence_msg', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=13)], + Call( + Name( + 'zip', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=19), + [ + Name( + 'msg', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=23), + Call( + Name( + 'sorted', + Load(), + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=31), + [ + Name( + 'fence', + Load(), + lineno=16, + col_offset=32, + end_lineno=16, + end_col_offset=37)], + [], + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=38)], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=39), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=39), + Return( + Call( + Attribute( + Constant( + '', + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=13), + 'join', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=18), + [ + GeneratorExp( + Name( + 'char', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=23), + [ + comprehension( + Tuple( + [ + Name( + 'char', + Store(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=32), + Name( + '_', + Store(), + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=35)], + Store(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=35), + Call( + Name( + 'sorted', + Load(), + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=45), + [ + Name( + 'fence_msg', + Load(), + lineno=17, + col_offset=46, + end_lineno=17, + end_col_offset=55)], + [ + keyword( + 'key', + Lambda( + arguments( + [], + [ + arg( + 'item', + lineno=17, + col_offset=68, + end_lineno=17, + end_col_offset=72)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Subscript( + Subscript( + Name( + 'item', + Load(), + lineno=17, + col_offset=74, + end_lineno=17, + end_col_offset=78), + Constant( + 1, + lineno=17, + col_offset=79, + end_lineno=17, + end_col_offset=80), + Load(), + lineno=17, + col_offset=74, + end_lineno=17, + end_col_offset=81), + Constant( + 1, + lineno=17, + col_offset=82, + end_lineno=17, + end_col_offset=83), + Load(), + lineno=17, + col_offset=74, + end_lineno=17, + end_col_offset=84), + lineno=17, + col_offset=61, + end_lineno=17, + end_col_offset=84), + lineno=17, + col_offset=57, + end_lineno=17, + end_col_offset=84)], + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=85), + [], + 0)], + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=86)], + [], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=86), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=86)], + [], + lineno=14, + col_offset=0, + end_lineno=17, + end_col_offset=86)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'cycle', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=27), + alias( + 'chain', + lineno=1, + col_offset=29, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=18, + end_lineno=4, + end_col_offset=23), + arg( + 'placeholder_2', + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + Call( + Name( + 'cycle', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=19), + [ + Call( + Name( + 'chain', + Load(), + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=25), + [ + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=31), + [ + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=37)], + [], + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=38), + Call( + Name( + 'range', + Load(), + lineno=5, + col_offset=40, + end_lineno=5, + end_col_offset=45), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=46, + end_lineno=5, + end_col_offset=51), + Sub(), + Constant( + 2, + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=55), + lineno=5, + col_offset=46, + end_lineno=5, + end_col_offset=55), + Constant( + 0, + lineno=5, + col_offset=57, + end_lineno=5, + end_col_offset=58), + UnaryOp( + USub(), + Constant( + 1, + lineno=5, + col_offset=61, + end_lineno=5, + end_col_offset=62), + lineno=5, + col_offset=60, + end_lineno=5, + end_col_offset=62)], + [], + lineno=5, + col_offset=40, + end_lineno=5, + end_col_offset=63)], + [], + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=64)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=65), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=65), + Return( + Call( + Name( + 'zip', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=14), + [ + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=22), + Call( + Name( + 'range', + Load(), + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=29), + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=30, + end_lineno=6, + end_col_offset=34)], + [], + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=35)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=36), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=36)], + [], + lineno=4, + col_offset=0, + end_lineno=6, + end_col_offset=36), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=14), + arg( + 'placeholder_1', + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=9)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=25), + [ + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=31), + Call( + Name( + 'len', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=36), + [ + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=37, + end_lineno=10, + end_col_offset=40)], + [], + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=41)], + [], + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=42), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=42), + Return( + Call( + Attribute( + Constant( + '', + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=13), + 'join', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=18), + [ + GeneratorExp( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=22), + Name( + 'placeholder_8', + Load(), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=26), + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=27), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=11, + col_offset=32, + end_lineno=11, + end_col_offset=33), + Name( + 'placeholder_8', + Store(), + lineno=11, + col_offset=35, + end_lineno=11, + end_col_offset=38)], + Store(), + lineno=11, + col_offset=32, + end_lineno=11, + end_col_offset=38), + Call( + Name( + 'sorted', + Load(), + lineno=11, + col_offset=42, + end_lineno=11, + end_col_offset=48), + [ + Name( + 'placeholder_6', + Load(), + lineno=11, + col_offset=49, + end_lineno=11, + end_col_offset=54)], + [], + lineno=11, + col_offset=42, + end_lineno=11, + end_col_offset=55), + [], + 0)], + lineno=11, + col_offset=18, + end_lineno=11, + end_col_offset=56)], + [], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=56), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=56)], + [], + lineno=9, + col_offset=0, + end_lineno=11, + end_col_offset=56), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + arg( + 'placeholder_1', + lineno=14, + col_offset=16, + end_lineno=14, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=9)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=25), + [ + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=26, + end_lineno=15, + end_col_offset=31), + Call( + Name( + 'len', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=36), + [ + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=37, + end_lineno=15, + end_col_offset=40)], + [], + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=41)], + [], + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=42), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=13)], + Call( + Name( + 'zip', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=19), + [ + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=23), + Call( + Name( + 'sorted', + Load(), + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=31), + [ + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=32, + end_lineno=16, + end_col_offset=37)], + [], + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=38)], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=39), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=39), + Return( + Call( + Attribute( + Constant( + '', + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=13), + 'join', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=18), + [ + GeneratorExp( + Name( + 'placeholder_11', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=23), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_11', + Store(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=32), + Name( + 'placeholder_7', + Store(), + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=35)], + Store(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=35), + Call( + Name( + 'sorted', + Load(), + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=45), + [ + Name( + 'placeholder_10', + Load(), + lineno=17, + col_offset=46, + end_lineno=17, + end_col_offset=55)], + [ + keyword( + 'placeholder_12', + Lambda( + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=17, + col_offset=68, + end_lineno=17, + end_col_offset=72)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Subscript( + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=17, + col_offset=74, + end_lineno=17, + end_col_offset=78), + Constant( + 1, + lineno=17, + col_offset=79, + end_lineno=17, + end_col_offset=80), + Load(), + lineno=17, + col_offset=74, + end_lineno=17, + end_col_offset=81), + Constant( + 1, + lineno=17, + col_offset=82, + end_lineno=17, + end_col_offset=83), + Load(), + lineno=17, + col_offset=74, + end_lineno=17, + end_col_offset=84), + lineno=17, + col_offset=61, + end_lineno=17, + end_col_offset=84), + lineno=17, + col_offset=57, + end_lineno=17, + end_col_offset=84)], + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=85), + [], + 0)], + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=86)], + [], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=86), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=86)], + [], + lineno=14, + col_offset=0, + end_lineno=17, + end_col_offset=86)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-rail-fence-cipher/representation.txt b/test/practice-rail-fence-cipher/representation.txt new file mode 100644 index 0000000..d3020e5 --- /dev/null +++ b/test/practice-rail-fence-cipher/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('itertools', [alias('cycle', lineno=1, col_offset=22, end_lineno=1, end_col_offset=27), alias('chain', lineno=1, col_offset=29, end_lineno=1, end_col_offset=34)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=34), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=18, end_lineno=4, end_col_offset=23), arg('placeholder_2', lineno=4, col_offset=25, end_lineno=4, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=11)], Call(Name('cycle', Load(), lineno=5, col_offset=14, end_lineno=5, end_col_offset=19), [Call(Name('chain', Load(), lineno=5, col_offset=20, end_lineno=5, end_col_offset=25), [Call(Name('range', Load(), lineno=5, col_offset=26, end_lineno=5, end_col_offset=31), [Name('placeholder_1', Load(), lineno=5, col_offset=32, end_lineno=5, end_col_offset=37)], [], lineno=5, col_offset=26, end_lineno=5, end_col_offset=38), Call(Name('range', Load(), lineno=5, col_offset=40, end_lineno=5, end_col_offset=45), [BinOp(Name('placeholder_1', Load(), lineno=5, col_offset=46, end_lineno=5, end_col_offset=51), Sub(), Constant(2, lineno=5, col_offset=54, end_lineno=5, end_col_offset=55), lineno=5, col_offset=46, end_lineno=5, end_col_offset=55), Constant(0, lineno=5, col_offset=57, end_lineno=5, end_col_offset=58), UnaryOp(USub(), Constant(1, lineno=5, col_offset=61, end_lineno=5, end_col_offset=62), lineno=5, col_offset=60, end_lineno=5, end_col_offset=62)], [], lineno=5, col_offset=40, end_lineno=5, end_col_offset=63)], [], lineno=5, col_offset=20, end_lineno=5, end_col_offset=64)], [], lineno=5, col_offset=14, end_lineno=5, end_col_offset=65), lineno=5, col_offset=4, end_lineno=5, end_col_offset=65), Return(Call(Name('zip', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=14), [Name('placeholder_3', Load(), lineno=6, col_offset=15, end_lineno=6, end_col_offset=22), Call(Name('range', Load(), lineno=6, col_offset=24, end_lineno=6, end_col_offset=29), [Name('placeholder_2', Load(), lineno=6, col_offset=30, end_lineno=6, end_col_offset=34)], [], lineno=6, col_offset=24, end_lineno=6, end_col_offset=35)], [], lineno=6, col_offset=11, end_lineno=6, end_col_offset=36), lineno=6, col_offset=4, end_lineno=6, end_col_offset=36)], [], lineno=4, col_offset=0, end_lineno=6, end_col_offset=36), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=9, col_offset=11, end_lineno=9, end_col_offset=14), arg('placeholder_1', lineno=9, col_offset=16, end_lineno=9, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=10, col_offset=4, end_lineno=10, end_col_offset=9)], Call(Name('placeholder_0', Load(), lineno=10, col_offset=12, end_lineno=10, end_col_offset=25), [Name('placeholder_1', Load(), lineno=10, col_offset=26, end_lineno=10, end_col_offset=31), Call(Name('len', Load(), lineno=10, col_offset=33, end_lineno=10, end_col_offset=36), [Name('placeholder_5', Load(), lineno=10, col_offset=37, end_lineno=10, end_col_offset=40)], [], lineno=10, col_offset=33, end_lineno=10, end_col_offset=41)], [], lineno=10, col_offset=12, end_lineno=10, end_col_offset=42), lineno=10, col_offset=4, end_lineno=10, end_col_offset=42), Return(Call(Attribute(Constant('', lineno=11, col_offset=11, end_lineno=11, end_col_offset=13), 'join', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=18), [GeneratorExp(Subscript(Name('placeholder_5', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=22), Name('placeholder_8', Load(), lineno=11, col_offset=23, end_lineno=11, end_col_offset=26), Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=27), [comprehension(Tuple([Name('placeholder_7', Store(), lineno=11, col_offset=32, end_lineno=11, end_col_offset=33), Name('placeholder_8', Store(), lineno=11, col_offset=35, end_lineno=11, end_col_offset=38)], Store(), lineno=11, col_offset=32, end_lineno=11, end_col_offset=38), Call(Name('sorted', Load(), lineno=11, col_offset=42, end_lineno=11, end_col_offset=48), [Name('placeholder_6', Load(), lineno=11, col_offset=49, end_lineno=11, end_col_offset=54)], [], lineno=11, col_offset=42, end_lineno=11, end_col_offset=55), [], 0)], lineno=11, col_offset=18, end_lineno=11, end_col_offset=56)], [], lineno=11, col_offset=11, end_lineno=11, end_col_offset=56), lineno=11, col_offset=4, end_lineno=11, end_col_offset=56)], [], lineno=9, col_offset=0, end_lineno=11, end_col_offset=56), FunctionDef('placeholder_9', arguments([], [arg('placeholder_5', lineno=14, col_offset=11, end_lineno=14, end_col_offset=14), arg('placeholder_1', lineno=14, col_offset=16, end_lineno=14, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_6', Store(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=9)], Call(Name('placeholder_0', Load(), lineno=15, col_offset=12, end_lineno=15, end_col_offset=25), [Name('placeholder_1', Load(), lineno=15, col_offset=26, end_lineno=15, end_col_offset=31), Call(Name('len', Load(), lineno=15, col_offset=33, end_lineno=15, end_col_offset=36), [Name('placeholder_5', Load(), lineno=15, col_offset=37, end_lineno=15, end_col_offset=40)], [], lineno=15, col_offset=33, end_lineno=15, end_col_offset=41)], [], lineno=15, col_offset=12, end_lineno=15, end_col_offset=42), lineno=15, col_offset=4, end_lineno=15, end_col_offset=42), Assign([Name('placeholder_10', Store(), lineno=16, col_offset=4, end_lineno=16, end_col_offset=13)], Call(Name('zip', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=19), [Name('placeholder_5', Load(), lineno=16, col_offset=20, end_lineno=16, end_col_offset=23), Call(Name('sorted', Load(), lineno=16, col_offset=25, end_lineno=16, end_col_offset=31), [Name('placeholder_6', Load(), lineno=16, col_offset=32, end_lineno=16, end_col_offset=37)], [], lineno=16, col_offset=25, end_lineno=16, end_col_offset=38)], [], lineno=16, col_offset=16, end_lineno=16, end_col_offset=39), lineno=16, col_offset=4, end_lineno=16, end_col_offset=39), Return(Call(Attribute(Constant('', lineno=17, col_offset=11, end_lineno=17, end_col_offset=13), 'join', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=18), [GeneratorExp(Name('placeholder_11', Load(), lineno=17, col_offset=19, end_lineno=17, end_col_offset=23), [comprehension(Tuple([Name('placeholder_11', Store(), lineno=17, col_offset=28, end_lineno=17, end_col_offset=32), Name('placeholder_7', Store(), lineno=17, col_offset=34, end_lineno=17, end_col_offset=35)], Store(), lineno=17, col_offset=28, end_lineno=17, end_col_offset=35), Call(Name('sorted', Load(), lineno=17, col_offset=39, end_lineno=17, end_col_offset=45), [Name('placeholder_10', Load(), lineno=17, col_offset=46, end_lineno=17, end_col_offset=55)], [keyword('placeholder_12', Lambda(arguments([], [arg('placeholder_13', lineno=17, col_offset=68, end_lineno=17, end_col_offset=72)], kwonlyargs=[], kw_defaults=[], defaults=[]), Subscript(Subscript(Name('placeholder_13', Load(), lineno=17, col_offset=74, end_lineno=17, end_col_offset=78), Constant(1, lineno=17, col_offset=79, end_lineno=17, end_col_offset=80), Load(), lineno=17, col_offset=74, end_lineno=17, end_col_offset=81), Constant(1, lineno=17, col_offset=82, end_lineno=17, end_col_offset=83), Load(), lineno=17, col_offset=74, end_lineno=17, end_col_offset=84), lineno=17, col_offset=61, end_lineno=17, end_col_offset=84), lineno=17, col_offset=57, end_lineno=17, end_col_offset=84)], lineno=17, col_offset=39, end_lineno=17, end_col_offset=85), [], 0)], lineno=17, col_offset=18, end_lineno=17, end_col_offset=86)], [], lineno=17, col_offset=11, end_lineno=17, end_col_offset=86), lineno=17, col_offset=4, end_lineno=17, end_col_offset=86)], [], lineno=14, col_offset=0, end_lineno=17, end_col_offset=86)], []) \ No newline at end of file diff --git a/test/practice-raindrops/.meta/config.json b/test/practice-raindrops/.meta/config.json new file mode 100644 index 0000000..463a523 --- /dev/null +++ b/test/practice-raindrops/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "BethanyG", + "bsoyka", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "lowks", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "raindrops.py" + ], + "test": [ + "raindrops_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Convert a number to a string, the content of which depends on the number's factors.", + "source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.", + "source_url": "https://en.wikipedia.org/wiki/Fizz_buzz" +} diff --git a/test/practice-raindrops/mapping.json b/test/practice-raindrops/mapping.json new file mode 100644 index 0000000..5c71405 --- /dev/null +++ b/test/practice-raindrops/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "convert", + "placeholder_1": "number", + "placeholder_2": "result" +} \ No newline at end of file diff --git a/test/practice-raindrops/raindrops.py b/test/practice-raindrops/raindrops.py new file mode 100644 index 0000000..97eeadc --- /dev/null +++ b/test/practice-raindrops/raindrops.py @@ -0,0 +1,16 @@ +def convert(number): + """ + Converts a number to a string according to the raindrop sounds. + """ + + result = '' + if number % 3 == 0: + result += 'Pling' + if number % 5 == 0: + result += 'Plang' + if number % 7 == 0: + result += 'Plong' + + if not result: + result = str(number) + return result diff --git a/test/practice-raindrops/representation.json b/test/practice-raindrops/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-raindrops/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-raindrops/representation.out b/test/practice-raindrops/representation.out new file mode 100644 index 0000000..e35f004 --- /dev/null +++ b/test/practice-raindrops/representation.out @@ -0,0 +1,601 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = "" + if placeholder_1 % 3 == 0: + placeholder_2 += "Pling" + if placeholder_1 % 5 == 0: + placeholder_2 += "Plang" + if placeholder_1 % 7 == 0: + placeholder_2 += "Plong" + if not placeholder_2: + placeholder_2 = str(placeholder_1) + return placeholder_2 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'convert', + arguments( + [], + [ + arg( + 'number', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + '\n Converts a number to a string according to the raindrop sounds.\n ', + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=7), + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=7), + Assign( + [ + Name( + 'result', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=10)], + Constant( + '', + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=15), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15), + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=13), + Mod(), + Constant( + 3, + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=17), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 0, + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=22)], + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=22), + [ + AugAssign( + Name( + 'result', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=14), + Add(), + Constant( + 'Pling', + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=25), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=25)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=25), + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=13), + Mod(), + Constant( + 5, + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=17), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 0, + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=22)], + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=22), + [ + AugAssign( + Name( + 'result', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14), + Add(), + Constant( + 'Plang', + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=25), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=25)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=25), + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=11, + col_offset=7, + end_lineno=11, + end_col_offset=13), + Mod(), + Constant( + 7, + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=17), + lineno=11, + col_offset=7, + end_lineno=11, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 0, + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=22)], + lineno=11, + col_offset=7, + end_lineno=11, + end_col_offset=22), + [ + AugAssign( + Name( + 'result', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=14), + Add(), + Constant( + 'Plong', + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=25), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=25)], + [], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=25), + If( + UnaryOp( + Not(), + Name( + 'result', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=17), + lineno=14, + col_offset=7, + end_lineno=14, + end_col_offset=17), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=14)], + Call( + Name( + 'str', + Load(), + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=20), + [ + Name( + 'number', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=27)], + [], + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=28), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=28)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=28), + Return( + Name( + 'result', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=17)], + [], + lineno=1, + col_offset=0, + end_lineno=16, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=10)], + Constant( + '', + lineno=6, + col_offset=13, + end_lineno=6, + end_col_offset=15), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15), + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=13), + Mod(), + Constant( + 3, + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=17), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 0, + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=22)], + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=22), + [ + AugAssign( + Name( + 'placeholder_2', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=14), + Add(), + Constant( + 'Pling', + lineno=8, + col_offset=18, + end_lineno=8, + end_col_offset=25), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=25)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=25), + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=13), + Mod(), + Constant( + 5, + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=17), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 0, + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=22)], + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=22), + [ + AugAssign( + Name( + 'placeholder_2', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14), + Add(), + Constant( + 'Plang', + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=25), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=25)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=25), + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=7, + end_lineno=11, + end_col_offset=13), + Mod(), + Constant( + 7, + lineno=11, + col_offset=16, + end_lineno=11, + end_col_offset=17), + lineno=11, + col_offset=7, + end_lineno=11, + end_col_offset=17), + [ + Eq()], + [ + Constant( + 0, + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=22)], + lineno=11, + col_offset=7, + end_lineno=11, + end_col_offset=22), + [ + AugAssign( + Name( + 'placeholder_2', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=14), + Add(), + Constant( + 'Plong', + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=25), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=25)], + [], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=25), + If( + UnaryOp( + Not(), + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=17), + lineno=14, + col_offset=7, + end_lineno=14, + end_col_offset=17), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=14)], + Call( + Name( + 'str', + Load(), + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=20), + [ + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=27)], + [], + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=28), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=28)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=28), + Return( + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=17)], + [], + lineno=1, + col_offset=0, + end_lineno=16, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-raindrops/representation.txt b/test/practice-raindrops/representation.txt new file mode 100644 index 0000000..4e5cf69 --- /dev/null +++ b/test/practice-raindrops/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=12, end_lineno=1, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=10)], Constant('', lineno=6, col_offset=13, end_lineno=6, end_col_offset=15), lineno=6, col_offset=4, end_lineno=6, end_col_offset=15), If(Compare(BinOp(Name('placeholder_1', Load(), lineno=7, col_offset=7, end_lineno=7, end_col_offset=13), Mod(), Constant(3, lineno=7, col_offset=16, end_lineno=7, end_col_offset=17), lineno=7, col_offset=7, end_lineno=7, end_col_offset=17), [Eq()], [Constant(0, lineno=7, col_offset=21, end_lineno=7, end_col_offset=22)], lineno=7, col_offset=7, end_lineno=7, end_col_offset=22), [AugAssign(Name('placeholder_2', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=14), Add(), Constant('Pling', lineno=8, col_offset=18, end_lineno=8, end_col_offset=25), lineno=8, col_offset=8, end_lineno=8, end_col_offset=25)], [], lineno=7, col_offset=4, end_lineno=8, end_col_offset=25), If(Compare(BinOp(Name('placeholder_1', Load(), lineno=9, col_offset=7, end_lineno=9, end_col_offset=13), Mod(), Constant(5, lineno=9, col_offset=16, end_lineno=9, end_col_offset=17), lineno=9, col_offset=7, end_lineno=9, end_col_offset=17), [Eq()], [Constant(0, lineno=9, col_offset=21, end_lineno=9, end_col_offset=22)], lineno=9, col_offset=7, end_lineno=9, end_col_offset=22), [AugAssign(Name('placeholder_2', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=14), Add(), Constant('Plang', lineno=10, col_offset=18, end_lineno=10, end_col_offset=25), lineno=10, col_offset=8, end_lineno=10, end_col_offset=25)], [], lineno=9, col_offset=4, end_lineno=10, end_col_offset=25), If(Compare(BinOp(Name('placeholder_1', Load(), lineno=11, col_offset=7, end_lineno=11, end_col_offset=13), Mod(), Constant(7, lineno=11, col_offset=16, end_lineno=11, end_col_offset=17), lineno=11, col_offset=7, end_lineno=11, end_col_offset=17), [Eq()], [Constant(0, lineno=11, col_offset=21, end_lineno=11, end_col_offset=22)], lineno=11, col_offset=7, end_lineno=11, end_col_offset=22), [AugAssign(Name('placeholder_2', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=14), Add(), Constant('Plong', lineno=12, col_offset=18, end_lineno=12, end_col_offset=25), lineno=12, col_offset=8, end_lineno=12, end_col_offset=25)], [], lineno=11, col_offset=4, end_lineno=12, end_col_offset=25), If(UnaryOp(Not(), Name('placeholder_2', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=17), lineno=14, col_offset=7, end_lineno=14, end_col_offset=17), [Assign([Name('placeholder_2', Store(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=14)], Call(Name('str', Load(), lineno=15, col_offset=17, end_lineno=15, end_col_offset=20), [Name('placeholder_1', Load(), lineno=15, col_offset=21, end_lineno=15, end_col_offset=27)], [], lineno=15, col_offset=17, end_lineno=15, end_col_offset=28), lineno=15, col_offset=8, end_lineno=15, end_col_offset=28)], [], lineno=14, col_offset=4, end_lineno=15, end_col_offset=28), Return(Name('placeholder_2', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=17), lineno=16, col_offset=4, end_lineno=16, end_col_offset=17)], [], lineno=1, col_offset=0, end_lineno=16, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-rational-numbers/.meta/config.json b/test/practice-rational-numbers/.meta/config.json new file mode 100644 index 0000000..67afa13 --- /dev/null +++ b/test/practice-rational-numbers/.meta/config.json @@ -0,0 +1,26 @@ +{ + "authors": [], + "contributors": [ + "AnAccountForReportingBugs", + "BethanyG", + "cmccandless", + "Dog", + "GKotfis", + "omer-g", + "tqa236" + ], + "files": { + "solution": [ + "rational_numbers.py" + ], + "test": [ + "rational_numbers_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement rational numbers.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Rational_number" +} diff --git a/test/practice-rational-numbers/mapping.json b/test/practice-rational-numbers/mapping.json new file mode 100644 index 0000000..8c6025a --- /dev/null +++ b/test/practice-rational-numbers/mapping.json @@ -0,0 +1,20 @@ +{ + "placeholder_0": "Rational", + "placeholder_1": "__init__", + "placeholder_2": "numer", + "placeholder_3": "denom", + "placeholder_4": "gcd_num", + "placeholder_5": "__eq__", + "placeholder_6": "other", + "placeholder_7": "__repr__", + "placeholder_8": "__add__", + "placeholder_9": "__sub__", + "placeholder_10": "__mul__", + "placeholder_11": "__truediv__", + "placeholder_12": "__abs__", + "placeholder_13": "__pow__", + "placeholder_14": "power", + "placeholder_15": "__rpow__", + "placeholder_16": "base", + "placeholder_17": "__neg__" +} \ No newline at end of file diff --git a/test/practice-rational-numbers/rational_numbers.py b/test/practice-rational-numbers/rational_numbers.py new file mode 100644 index 0000000..d8a0b87 --- /dev/null +++ b/test/practice-rational-numbers/rational_numbers.py @@ -0,0 +1,49 @@ +from math import gcd + + +class Rational: + def __init__(self, numer, denom): + # abs used for backward compatibility with fractions.gcd + gcd_num = abs(gcd(numer, denom)) + + self.numer = numer // gcd_num + self.denom = denom // gcd_num + + if self.denom < 0: + self.numer *= -1 + self.denom *= -1 + + def __eq__(self, other): + return self.numer == other.numer and self.denom == other.denom + + def __repr__(self): + return f'{self.numer}/{self.denom}' + + def __add__(self, other): + numer = (self.numer * other.denom) + (other.numer * self.denom) + return Rational(numer, other.denom * self.denom) + + def __sub__(self, other): + return self + (-other) + + def __mul__(self, other): + return Rational(self.numer * other.numer, self.denom * other.denom) + + def __truediv__(self, other): + return Rational(self.numer * other.denom, self.denom * other.numer) + + def __abs__(self): + return Rational(abs(self.numer), self.denom) + + def __pow__(self, power): + if power < 0: + return Rational(pow(self.denom, -power), pow(self.numer, -power)) + + else: + return Rational(pow(self.numer, power), pow(self.denom, power)) + + def __rpow__(self, base): + return base ** (self.numer / self.denom) + + def __neg__(self): + return Rational(self.numer * (-1), self.denom) diff --git a/test/practice-rational-numbers/representation.json b/test/practice-rational-numbers/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-rational-numbers/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-rational-numbers/representation.out b/test/practice-rational-numbers/representation.out new file mode 100644 index 0000000..752a152 --- /dev/null +++ b/test/practice-rational-numbers/representation.out @@ -0,0 +1,2922 @@ +## BEGIN NORMALIZED CODE ## +from math import gcd + + +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3): + placeholder_4 = abs(gcd(placeholder_2, placeholder_3)) + self.placeholder_2 = placeholder_2 // placeholder_4 + self.placeholder_3 = placeholder_3 // placeholder_4 + if self.placeholder_3 < 0: + self.placeholder_2 *= -1 + self.placeholder_3 *= -1 + + def placeholder_5(self, placeholder_6): + return ( + self.placeholder_2 == placeholder_6.placeholder_2 + and self.placeholder_3 == placeholder_6.placeholder_3 + ) + + def placeholder_7(self): + return f"{self.placeholder_2}/{self.placeholder_3}" + + def placeholder_8(self, placeholder_6): + placeholder_2 = ( + self.placeholder_2 * placeholder_6.placeholder_3 + + placeholder_6.placeholder_2 * self.placeholder_3 + ) + return placeholder_0( + placeholder_2, placeholder_6.placeholder_3 * self.placeholder_3 + ) + + def placeholder_9(self, placeholder_6): + return self + -placeholder_6 + + def placeholder_10(self, placeholder_6): + return placeholder_0( + self.placeholder_2 * placeholder_6.placeholder_2, + self.placeholder_3 * placeholder_6.placeholder_3, + ) + + def placeholder_11(self, placeholder_6): + return placeholder_0( + self.placeholder_2 * placeholder_6.placeholder_3, + self.placeholder_3 * placeholder_6.placeholder_2, + ) + + def placeholder_12(self): + return placeholder_0(abs(self.placeholder_2), self.placeholder_3) + + def placeholder_13(self, placeholder_14): + if placeholder_14 < 0: + return placeholder_0( + pow(self.placeholder_3, -placeholder_14), + pow(self.placeholder_2, -placeholder_14), + ) + else: + return placeholder_0( + pow(self.placeholder_2, placeholder_14), + pow(self.placeholder_3, placeholder_14), + ) + + def placeholder_15(self, placeholder_16): + return placeholder_16 ** (self.placeholder_2 / self.placeholder_3) + + def placeholder_17(self): + return placeholder_0(self.placeholder_2 * -1, self.placeholder_3) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'gcd', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=20)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=20), + ClassDef( + 'Rational', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'numer', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=28), + arg( + 'denom', + lineno=5, + col_offset=30, + end_lineno=5, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'gcd_num', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=15)], + Call( + Name( + 'abs', + Load(), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=21), + [ + Call( + Name( + 'gcd', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=25), + [ + Name( + 'numer', + Load(), + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=31), + Name( + 'denom', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=38)], + [], + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=39)], + [], + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=40), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'numer', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=18)], + BinOp( + Name( + 'numer', + Load(), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=26), + FloorDiv(), + Name( + 'gcd_num', + Load(), + lineno=9, + col_offset=30, + end_lineno=9, + end_col_offset=37), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=37), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=37), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'denom', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=18)], + BinOp( + Name( + 'denom', + Load(), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=26), + FloorDiv(), + Name( + 'gcd_num', + Load(), + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=37), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=37), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=37), + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=15), + 'denom', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=21), + [ + Lt()], + [ + Constant( + 0, + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=25)], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=25), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=16), + 'numer', + Store(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=22), + Mult(), + UnaryOp( + USub(), + Constant( + 1, + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=28), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=16), + 'denom', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=22), + Mult(), + UnaryOp( + USub(), + Constant( + 1, + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=28), + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=28), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=28)], + [], + lineno=12, + col_offset=8, + end_lineno=14, + end_col_offset=28)], + [], + lineno=5, + col_offset=4, + end_lineno=14, + end_col_offset=28), + FunctionDef( + '__eq__', + arguments( + [], + [ + arg( + 'self', + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + arg( + 'other', + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=19), + 'numer', + Load(), + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=25), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=34), + 'numer', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=40)], + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=40), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=45, + end_lineno=17, + end_col_offset=49), + 'denom', + Load(), + lineno=17, + col_offset=45, + end_lineno=17, + end_col_offset=55), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=17, + col_offset=59, + end_lineno=17, + end_col_offset=64), + 'denom', + Load(), + lineno=17, + col_offset=59, + end_lineno=17, + end_col_offset=70)], + lineno=17, + col_offset=45, + end_lineno=17, + end_col_offset=70)], + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=70), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=70)], + [], + lineno=16, + col_offset=4, + end_lineno=17, + end_col_offset=70), + FunctionDef( + '__repr__', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=22), + 'numer', + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=28), + -1, + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=43), + Constant( + '/', + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=43), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=31, + end_lineno=20, + end_col_offset=35), + 'denom', + Load(), + lineno=20, + col_offset=31, + end_lineno=20, + end_col_offset=41), + -1, + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=43)], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=43), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=43)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=43), + FunctionDef( + '__add__', + arguments( + [], + [ + arg( + 'self', + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20), + arg( + 'other', + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'numer', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=13)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + 'numer', + Load(), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=27), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=23, + col_offset=30, + end_lineno=23, + end_col_offset=35), + 'denom', + Load(), + lineno=23, + col_offset=30, + end_lineno=23, + end_col_offset=41), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=41), + Add(), + BinOp( + Attribute( + Name( + 'other', + Load(), + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=51), + 'numer', + Load(), + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=57), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=60, + end_lineno=23, + end_col_offset=64), + 'denom', + Load(), + lineno=23, + col_offset=60, + end_lineno=23, + end_col_offset=70), + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=70), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=71), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=71), + Return( + Call( + Name( + 'Rational', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=23), + [ + Name( + 'numer', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=29), + BinOp( + Attribute( + Name( + 'other', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=36), + 'denom', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=42), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=45, + end_lineno=24, + end_col_offset=49), + 'denom', + Load(), + lineno=24, + col_offset=45, + end_lineno=24, + end_col_offset=55), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=55)], + [], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=56), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=56)], + [], + lineno=22, + col_offset=4, + end_lineno=24, + end_col_offset=56), + FunctionDef( + '__sub__', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=20), + arg( + 'other', + lineno=26, + col_offset=22, + end_lineno=26, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'self', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=19), + Add(), + UnaryOp( + USub(), + Name( + 'other', + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=29), + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=29), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=30), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=30)], + [], + lineno=26, + col_offset=4, + end_lineno=27, + end_col_offset=30), + FunctionDef( + '__mul__', + arguments( + [], + [ + arg( + 'self', + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=20), + arg( + 'other', + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Rational', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=23), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=28), + 'numer', + Load(), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=34), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=30, + col_offset=37, + end_lineno=30, + end_col_offset=42), + 'numer', + Load(), + lineno=30, + col_offset=37, + end_lineno=30, + end_col_offset=48), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=48), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=50, + end_lineno=30, + end_col_offset=54), + 'denom', + Load(), + lineno=30, + col_offset=50, + end_lineno=30, + end_col_offset=60), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=30, + col_offset=63, + end_lineno=30, + end_col_offset=68), + 'denom', + Load(), + lineno=30, + col_offset=63, + end_lineno=30, + end_col_offset=74), + lineno=30, + col_offset=50, + end_lineno=30, + end_col_offset=74)], + [], + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=75), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=75)], + [], + lineno=29, + col_offset=4, + end_lineno=30, + end_col_offset=75), + FunctionDef( + '__truediv__', + arguments( + [], + [ + arg( + 'self', + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=24), + arg( + 'other', + lineno=32, + col_offset=26, + end_lineno=32, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Rational', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=23), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=28), + 'numer', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=34), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=42), + 'denom', + Load(), + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=48), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=48), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=50, + end_lineno=33, + end_col_offset=54), + 'denom', + Load(), + lineno=33, + col_offset=50, + end_lineno=33, + end_col_offset=60), + Mult(), + Attribute( + Name( + 'other', + Load(), + lineno=33, + col_offset=63, + end_lineno=33, + end_col_offset=68), + 'numer', + Load(), + lineno=33, + col_offset=63, + end_lineno=33, + end_col_offset=74), + lineno=33, + col_offset=50, + end_lineno=33, + end_col_offset=74)], + [], + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=75), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=75)], + [], + lineno=32, + col_offset=4, + end_lineno=33, + end_col_offset=75), + FunctionDef( + '__abs__', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Rational', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=23), + [ + Call( + Name( + 'abs', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=27), + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=28, + end_lineno=36, + end_col_offset=32), + 'numer', + Load(), + lineno=36, + col_offset=28, + end_lineno=36, + end_col_offset=38)], + [], + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=39), + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=45), + 'denom', + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=51)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=52), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=52)], + [], + lineno=35, + col_offset=4, + end_lineno=36, + end_col_offset=52), + FunctionDef( + '__pow__', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=20), + arg( + 'power', + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'power', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=16), + [ + Lt()], + [ + Constant( + 0, + lineno=39, + col_offset=19, + end_lineno=39, + end_col_offset=20)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=20), + [ + Return( + Call( + Name( + 'Rational', + Load(), + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=27), + [ + Call( + Name( + 'pow', + Load(), + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=31), + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=36), + 'denom', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=42), + UnaryOp( + USub(), + Name( + 'power', + Load(), + lineno=40, + col_offset=45, + end_lineno=40, + end_col_offset=50), + lineno=40, + col_offset=44, + end_lineno=40, + end_col_offset=50)], + [], + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=51), + Call( + Name( + 'pow', + Load(), + lineno=40, + col_offset=53, + end_lineno=40, + end_col_offset=56), + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=57, + end_lineno=40, + end_col_offset=61), + 'numer', + Load(), + lineno=40, + col_offset=57, + end_lineno=40, + end_col_offset=67), + UnaryOp( + USub(), + Name( + 'power', + Load(), + lineno=40, + col_offset=70, + end_lineno=40, + end_col_offset=75), + lineno=40, + col_offset=69, + end_lineno=40, + end_col_offset=75)], + [], + lineno=40, + col_offset=53, + end_lineno=40, + end_col_offset=76)], + [], + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=77), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=77)], + [ + Return( + Call( + Name( + 'Rational', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=27), + [ + Call( + Name( + 'pow', + Load(), + lineno=43, + col_offset=28, + end_lineno=43, + end_col_offset=31), + [ + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=36), + 'numer', + Load(), + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=42), + Name( + 'power', + Load(), + lineno=43, + col_offset=44, + end_lineno=43, + end_col_offset=49)], + [], + lineno=43, + col_offset=28, + end_lineno=43, + end_col_offset=50), + Call( + Name( + 'pow', + Load(), + lineno=43, + col_offset=52, + end_lineno=43, + end_col_offset=55), + [ + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=56, + end_lineno=43, + end_col_offset=60), + 'denom', + Load(), + lineno=43, + col_offset=56, + end_lineno=43, + end_col_offset=66), + Name( + 'power', + Load(), + lineno=43, + col_offset=68, + end_lineno=43, + end_col_offset=73)], + [], + lineno=43, + col_offset=52, + end_lineno=43, + end_col_offset=74)], + [], + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=75), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=75)], + lineno=39, + col_offset=8, + end_lineno=43, + end_col_offset=75)], + [], + lineno=38, + col_offset=4, + end_lineno=43, + end_col_offset=75), + FunctionDef( + '__rpow__', + arguments( + [], + [ + arg( + 'self', + lineno=45, + col_offset=17, + end_lineno=45, + end_col_offset=21), + arg( + 'base', + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'base', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19), + Pow(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=24, + end_lineno=46, + end_col_offset=28), + 'numer', + Load(), + lineno=46, + col_offset=24, + end_lineno=46, + end_col_offset=34), + Div(), + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=37, + end_lineno=46, + end_col_offset=41), + 'denom', + Load(), + lineno=46, + col_offset=37, + end_lineno=46, + end_col_offset=47), + lineno=46, + col_offset=24, + end_lineno=46, + end_col_offset=47), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=48), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=48)], + [], + lineno=45, + col_offset=4, + end_lineno=46, + end_col_offset=48), + FunctionDef( + '__neg__', + arguments( + [], + [ + arg( + 'self', + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Rational', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=23), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=28), + 'numer', + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=34), + Mult(), + UnaryOp( + USub(), + Constant( + 1, + lineno=49, + col_offset=39, + end_lineno=49, + end_col_offset=40), + lineno=49, + col_offset=38, + end_lineno=49, + end_col_offset=40), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=41), + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=43, + end_lineno=49, + end_col_offset=47), + 'denom', + Load(), + lineno=49, + col_offset=43, + end_lineno=49, + end_col_offset=53)], + [], + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=54), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=54)], + [], + lineno=48, + col_offset=4, + end_lineno=49, + end_col_offset=54)], + [], + lineno=4, + col_offset=0, + end_lineno=49, + end_col_offset=54)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'math', + [ + alias( + 'gcd', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=20)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=20), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=28), + arg( + 'placeholder_3', + lineno=5, + col_offset=30, + end_lineno=5, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=15)], + Call( + Name( + 'abs', + Load(), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=21), + [ + Call( + Name( + 'gcd', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=25), + [ + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=31), + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=38)], + [], + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=39)], + [], + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=40), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=40), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=18)], + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=26), + FloorDiv(), + Name( + 'placeholder_4', + Load(), + lineno=9, + col_offset=30, + end_lineno=9, + end_col_offset=37), + lineno=9, + col_offset=21, + end_lineno=9, + end_col_offset=37), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=37), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=18)], + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=26), + FloorDiv(), + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=37), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=37), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=37), + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=15), + 'placeholder_3', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=21), + [ + Lt()], + [ + Constant( + 0, + lineno=12, + col_offset=24, + end_lineno=12, + end_col_offset=25)], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=25), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=16), + 'placeholder_2', + Store(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=22), + Mult(), + UnaryOp( + USub(), + Constant( + 1, + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=28), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=16), + 'placeholder_3', + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=22), + Mult(), + UnaryOp( + USub(), + Constant( + 1, + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=28), + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=28), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=28)], + [], + lineno=12, + col_offset=8, + end_lineno=14, + end_col_offset=28)], + [], + lineno=5, + col_offset=4, + end_lineno=14, + end_col_offset=28), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=19), + arg( + 'placeholder_6', + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=25), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=34), + 'placeholder_2', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=40)], + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=40), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=45, + end_lineno=17, + end_col_offset=49), + 'placeholder_3', + Load(), + lineno=17, + col_offset=45, + end_lineno=17, + end_col_offset=55), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=59, + end_lineno=17, + end_col_offset=64), + 'placeholder_3', + Load(), + lineno=17, + col_offset=59, + end_lineno=17, + end_col_offset=70)], + lineno=17, + col_offset=45, + end_lineno=17, + end_col_offset=70)], + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=70), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=70)], + [], + lineno=16, + col_offset=4, + end_lineno=17, + end_col_offset=70), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=22), + 'placeholder_2', + Load(), + lineno=20, + col_offset=18, + end_lineno=20, + end_col_offset=28), + -1, + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=43), + Constant( + '/', + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=43), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=31, + end_lineno=20, + end_col_offset=35), + 'placeholder_3', + Load(), + lineno=20, + col_offset=31, + end_lineno=20, + end_col_offset=41), + -1, + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=43)], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=43), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=43)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=43), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20), + arg( + 'placeholder_6', + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=13)], + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + 'placeholder_2', + Load(), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=27), + Mult(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=30, + end_lineno=23, + end_col_offset=35), + 'placeholder_3', + Load(), + lineno=23, + col_offset=30, + end_lineno=23, + end_col_offset=41), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=41), + Add(), + BinOp( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=51), + 'placeholder_2', + Load(), + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=57), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=60, + end_lineno=23, + end_col_offset=64), + 'placeholder_3', + Load(), + lineno=23, + col_offset=60, + end_lineno=23, + end_col_offset=70), + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=70), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=71), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=71), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=23), + [ + Name( + 'placeholder_2', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=29), + BinOp( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=36), + 'placeholder_3', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=42), + Mult(), + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=45, + end_lineno=24, + end_col_offset=49), + 'placeholder_3', + Load(), + lineno=24, + col_offset=45, + end_lineno=24, + end_col_offset=55), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=55)], + [], + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=56), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=56)], + [], + lineno=22, + col_offset=4, + end_lineno=24, + end_col_offset=56), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=20), + arg( + 'placeholder_6', + lineno=26, + col_offset=22, + end_lineno=26, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'self', + Load(), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=19), + Add(), + UnaryOp( + USub(), + Name( + 'placeholder_6', + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=29), + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=29), + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=30), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=30)], + [], + lineno=26, + col_offset=4, + end_lineno=27, + end_col_offset=30), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=20), + arg( + 'placeholder_6', + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=23), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=34), + Mult(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=30, + col_offset=37, + end_lineno=30, + end_col_offset=42), + 'placeholder_2', + Load(), + lineno=30, + col_offset=37, + end_lineno=30, + end_col_offset=48), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=48), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=50, + end_lineno=30, + end_col_offset=54), + 'placeholder_3', + Load(), + lineno=30, + col_offset=50, + end_lineno=30, + end_col_offset=60), + Mult(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=30, + col_offset=63, + end_lineno=30, + end_col_offset=68), + 'placeholder_3', + Load(), + lineno=30, + col_offset=63, + end_lineno=30, + end_col_offset=74), + lineno=30, + col_offset=50, + end_lineno=30, + end_col_offset=74)], + [], + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=75), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=75)], + [], + lineno=29, + col_offset=4, + end_lineno=30, + end_col_offset=75), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=24), + arg( + 'placeholder_6', + lineno=32, + col_offset=26, + end_lineno=32, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=23), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=34), + Mult(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=42), + 'placeholder_3', + Load(), + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=48), + lineno=33, + col_offset=24, + end_lineno=33, + end_col_offset=48), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=50, + end_lineno=33, + end_col_offset=54), + 'placeholder_3', + Load(), + lineno=33, + col_offset=50, + end_lineno=33, + end_col_offset=60), + Mult(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=33, + col_offset=63, + end_lineno=33, + end_col_offset=68), + 'placeholder_2', + Load(), + lineno=33, + col_offset=63, + end_lineno=33, + end_col_offset=74), + lineno=33, + col_offset=50, + end_lineno=33, + end_col_offset=74)], + [], + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=75), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=75)], + [], + lineno=32, + col_offset=4, + end_lineno=33, + end_col_offset=75), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=16, + end_lineno=35, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=23), + [ + Call( + Name( + 'abs', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=27), + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=28, + end_lineno=36, + end_col_offset=32), + 'placeholder_2', + Load(), + lineno=36, + col_offset=28, + end_lineno=36, + end_col_offset=38)], + [], + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=39), + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=45), + 'placeholder_3', + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=51)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=52), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=52)], + [], + lineno=35, + col_offset=4, + end_lineno=36, + end_col_offset=52), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=20), + arg( + 'placeholder_14', + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_14', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=16), + [ + Lt()], + [ + Constant( + 0, + lineno=39, + col_offset=19, + end_lineno=39, + end_col_offset=20)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=20), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=27), + [ + Call( + Name( + 'pow', + Load(), + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=31), + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=36), + 'placeholder_3', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=42), + UnaryOp( + USub(), + Name( + 'placeholder_14', + Load(), + lineno=40, + col_offset=45, + end_lineno=40, + end_col_offset=50), + lineno=40, + col_offset=44, + end_lineno=40, + end_col_offset=50)], + [], + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=51), + Call( + Name( + 'pow', + Load(), + lineno=40, + col_offset=53, + end_lineno=40, + end_col_offset=56), + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=57, + end_lineno=40, + end_col_offset=61), + 'placeholder_2', + Load(), + lineno=40, + col_offset=57, + end_lineno=40, + end_col_offset=67), + UnaryOp( + USub(), + Name( + 'placeholder_14', + Load(), + lineno=40, + col_offset=70, + end_lineno=40, + end_col_offset=75), + lineno=40, + col_offset=69, + end_lineno=40, + end_col_offset=75)], + [], + lineno=40, + col_offset=53, + end_lineno=40, + end_col_offset=76)], + [], + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=77), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=77)], + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=27), + [ + Call( + Name( + 'pow', + Load(), + lineno=43, + col_offset=28, + end_lineno=43, + end_col_offset=31), + [ + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=36), + 'placeholder_2', + Load(), + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=42), + Name( + 'placeholder_14', + Load(), + lineno=43, + col_offset=44, + end_lineno=43, + end_col_offset=49)], + [], + lineno=43, + col_offset=28, + end_lineno=43, + end_col_offset=50), + Call( + Name( + 'pow', + Load(), + lineno=43, + col_offset=52, + end_lineno=43, + end_col_offset=55), + [ + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=56, + end_lineno=43, + end_col_offset=60), + 'placeholder_3', + Load(), + lineno=43, + col_offset=56, + end_lineno=43, + end_col_offset=66), + Name( + 'placeholder_14', + Load(), + lineno=43, + col_offset=68, + end_lineno=43, + end_col_offset=73)], + [], + lineno=43, + col_offset=52, + end_lineno=43, + end_col_offset=74)], + [], + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=75), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=75)], + lineno=39, + col_offset=8, + end_lineno=43, + end_col_offset=75)], + [], + lineno=38, + col_offset=4, + end_lineno=43, + end_col_offset=75), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=45, + col_offset=17, + end_lineno=45, + end_col_offset=21), + arg( + 'placeholder_16', + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + Name( + 'placeholder_16', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=19), + Pow(), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=24, + end_lineno=46, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=46, + col_offset=24, + end_lineno=46, + end_col_offset=34), + Div(), + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=37, + end_lineno=46, + end_col_offset=41), + 'placeholder_3', + Load(), + lineno=46, + col_offset=37, + end_lineno=46, + end_col_offset=47), + lineno=46, + col_offset=24, + end_lineno=46, + end_col_offset=47), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=48), + lineno=46, + col_offset=8, + end_lineno=46, + end_col_offset=48)], + [], + lineno=45, + col_offset=4, + end_lineno=46, + end_col_offset=48), + FunctionDef( + 'placeholder_17', + arguments( + [], + [ + arg( + 'self', + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=23), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=34), + Mult(), + UnaryOp( + USub(), + Constant( + 1, + lineno=49, + col_offset=39, + end_lineno=49, + end_col_offset=40), + lineno=49, + col_offset=38, + end_lineno=49, + end_col_offset=40), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=41), + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=43, + end_lineno=49, + end_col_offset=47), + 'placeholder_3', + Load(), + lineno=49, + col_offset=43, + end_lineno=49, + end_col_offset=53)], + [], + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=54), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=54)], + [], + lineno=48, + col_offset=4, + end_lineno=49, + end_col_offset=54)], + [], + lineno=4, + col_offset=0, + end_lineno=49, + end_col_offset=54)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-rational-numbers/representation.txt b/test/practice-rational-numbers/representation.txt new file mode 100644 index 0000000..9851d30 --- /dev/null +++ b/test/practice-rational-numbers/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('math', [alias('gcd', lineno=1, col_offset=17, end_lineno=1, end_col_offset=20)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=20), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21), arg('placeholder_2', lineno=5, col_offset=23, end_lineno=5, end_col_offset=28), arg('placeholder_3', lineno=5, col_offset=30, end_lineno=5, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=15)], Call(Name('abs', Load(), lineno=7, col_offset=18, end_lineno=7, end_col_offset=21), [Call(Name('gcd', Load(), lineno=7, col_offset=22, end_lineno=7, end_col_offset=25), [Name('placeholder_2', Load(), lineno=7, col_offset=26, end_lineno=7, end_col_offset=31), Name('placeholder_3', Load(), lineno=7, col_offset=33, end_lineno=7, end_col_offset=38)], [], lineno=7, col_offset=22, end_lineno=7, end_col_offset=39)], [], lineno=7, col_offset=18, end_lineno=7, end_col_offset=40), lineno=7, col_offset=8, end_lineno=7, end_col_offset=40), Assign([Attribute(Name('self', Load(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), 'placeholder_2', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=18)], BinOp(Name('placeholder_2', Load(), lineno=9, col_offset=21, end_lineno=9, end_col_offset=26), FloorDiv(), Name('placeholder_4', Load(), lineno=9, col_offset=30, end_lineno=9, end_col_offset=37), lineno=9, col_offset=21, end_lineno=9, end_col_offset=37), lineno=9, col_offset=8, end_lineno=9, end_col_offset=37), Assign([Attribute(Name('self', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=12), 'placeholder_3', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=18)], BinOp(Name('placeholder_3', Load(), lineno=10, col_offset=21, end_lineno=10, end_col_offset=26), FloorDiv(), Name('placeholder_4', Load(), lineno=10, col_offset=30, end_lineno=10, end_col_offset=37), lineno=10, col_offset=21, end_lineno=10, end_col_offset=37), lineno=10, col_offset=8, end_lineno=10, end_col_offset=37), If(Compare(Attribute(Name('self', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=15), 'placeholder_3', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=21), [Lt()], [Constant(0, lineno=12, col_offset=24, end_lineno=12, end_col_offset=25)], lineno=12, col_offset=11, end_lineno=12, end_col_offset=25), [AugAssign(Attribute(Name('self', Load(), lineno=13, col_offset=12, end_lineno=13, end_col_offset=16), 'placeholder_2', Store(), lineno=13, col_offset=12, end_lineno=13, end_col_offset=22), Mult(), UnaryOp(USub(), Constant(1, lineno=13, col_offset=27, end_lineno=13, end_col_offset=28), lineno=13, col_offset=26, end_lineno=13, end_col_offset=28), lineno=13, col_offset=12, end_lineno=13, end_col_offset=28), AugAssign(Attribute(Name('self', Load(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=16), 'placeholder_3', Store(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=22), Mult(), UnaryOp(USub(), Constant(1, lineno=14, col_offset=27, end_lineno=14, end_col_offset=28), lineno=14, col_offset=26, end_lineno=14, end_col_offset=28), lineno=14, col_offset=12, end_lineno=14, end_col_offset=28)], [], lineno=12, col_offset=8, end_lineno=14, end_col_offset=28)], [], lineno=5, col_offset=4, end_lineno=14, end_col_offset=28), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=16, col_offset=15, end_lineno=16, end_col_offset=19), arg('placeholder_6', lineno=16, col_offset=21, end_lineno=16, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=17, col_offset=15, end_lineno=17, end_col_offset=19), 'placeholder_2', Load(), lineno=17, col_offset=15, end_lineno=17, end_col_offset=25), [Eq()], [Attribute(Name('placeholder_6', Load(), lineno=17, col_offset=29, end_lineno=17, end_col_offset=34), 'placeholder_2', Load(), lineno=17, col_offset=29, end_lineno=17, end_col_offset=40)], lineno=17, col_offset=15, end_lineno=17, end_col_offset=40), Compare(Attribute(Name('self', Load(), lineno=17, col_offset=45, end_lineno=17, end_col_offset=49), 'placeholder_3', Load(), lineno=17, col_offset=45, end_lineno=17, end_col_offset=55), [Eq()], [Attribute(Name('placeholder_6', Load(), lineno=17, col_offset=59, end_lineno=17, end_col_offset=64), 'placeholder_3', Load(), lineno=17, col_offset=59, end_lineno=17, end_col_offset=70)], lineno=17, col_offset=45, end_lineno=17, end_col_offset=70)], lineno=17, col_offset=15, end_lineno=17, end_col_offset=70), lineno=17, col_offset=8, end_lineno=17, end_col_offset=70)], [], lineno=16, col_offset=4, end_lineno=17, end_col_offset=70), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=19, col_offset=17, end_lineno=19, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(JoinedStr([FormattedValue(Attribute(Name('self', Load(), lineno=20, col_offset=18, end_lineno=20, end_col_offset=22), 'placeholder_2', Load(), lineno=20, col_offset=18, end_lineno=20, end_col_offset=28), -1, lineno=20, col_offset=15, end_lineno=20, end_col_offset=43), Constant('/', lineno=20, col_offset=15, end_lineno=20, end_col_offset=43), FormattedValue(Attribute(Name('self', Load(), lineno=20, col_offset=31, end_lineno=20, end_col_offset=35), 'placeholder_3', Load(), lineno=20, col_offset=31, end_lineno=20, end_col_offset=41), -1, lineno=20, col_offset=15, end_lineno=20, end_col_offset=43)], lineno=20, col_offset=15, end_lineno=20, end_col_offset=43), lineno=20, col_offset=8, end_lineno=20, end_col_offset=43)], [], lineno=19, col_offset=4, end_lineno=20, end_col_offset=43), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=22, col_offset=16, end_lineno=22, end_col_offset=20), arg('placeholder_6', lineno=22, col_offset=22, end_lineno=22, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=13)], BinOp(BinOp(Attribute(Name('self', Load(), lineno=23, col_offset=17, end_lineno=23, end_col_offset=21), 'placeholder_2', Load(), lineno=23, col_offset=17, end_lineno=23, end_col_offset=27), Mult(), Attribute(Name('placeholder_6', Load(), lineno=23, col_offset=30, end_lineno=23, end_col_offset=35), 'placeholder_3', Load(), lineno=23, col_offset=30, end_lineno=23, end_col_offset=41), lineno=23, col_offset=17, end_lineno=23, end_col_offset=41), Add(), BinOp(Attribute(Name('placeholder_6', Load(), lineno=23, col_offset=46, end_lineno=23, end_col_offset=51), 'placeholder_2', Load(), lineno=23, col_offset=46, end_lineno=23, end_col_offset=57), Mult(), Attribute(Name('self', Load(), lineno=23, col_offset=60, end_lineno=23, end_col_offset=64), 'placeholder_3', Load(), lineno=23, col_offset=60, end_lineno=23, end_col_offset=70), lineno=23, col_offset=46, end_lineno=23, end_col_offset=70), lineno=23, col_offset=16, end_lineno=23, end_col_offset=71), lineno=23, col_offset=8, end_lineno=23, end_col_offset=71), Return(Call(Name('placeholder_0', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=23), [Name('placeholder_2', Load(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=29), BinOp(Attribute(Name('placeholder_6', Load(), lineno=24, col_offset=31, end_lineno=24, end_col_offset=36), 'placeholder_3', Load(), lineno=24, col_offset=31, end_lineno=24, end_col_offset=42), Mult(), Attribute(Name('self', Load(), lineno=24, col_offset=45, end_lineno=24, end_col_offset=49), 'placeholder_3', Load(), lineno=24, col_offset=45, end_lineno=24, end_col_offset=55), lineno=24, col_offset=31, end_lineno=24, end_col_offset=55)], [], lineno=24, col_offset=15, end_lineno=24, end_col_offset=56), lineno=24, col_offset=8, end_lineno=24, end_col_offset=56)], [], lineno=22, col_offset=4, end_lineno=24, end_col_offset=56), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=26, col_offset=16, end_lineno=26, end_col_offset=20), arg('placeholder_6', lineno=26, col_offset=22, end_lineno=26, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('self', Load(), lineno=27, col_offset=15, end_lineno=27, end_col_offset=19), Add(), UnaryOp(USub(), Name('placeholder_6', Load(), lineno=27, col_offset=24, end_lineno=27, end_col_offset=29), lineno=27, col_offset=23, end_lineno=27, end_col_offset=29), lineno=27, col_offset=15, end_lineno=27, end_col_offset=30), lineno=27, col_offset=8, end_lineno=27, end_col_offset=30)], [], lineno=26, col_offset=4, end_lineno=27, end_col_offset=30), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=29, col_offset=16, end_lineno=29, end_col_offset=20), arg('placeholder_6', lineno=29, col_offset=22, end_lineno=29, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=30, col_offset=15, end_lineno=30, end_col_offset=23), [BinOp(Attribute(Name('self', Load(), lineno=30, col_offset=24, end_lineno=30, end_col_offset=28), 'placeholder_2', Load(), lineno=30, col_offset=24, end_lineno=30, end_col_offset=34), Mult(), Attribute(Name('placeholder_6', Load(), lineno=30, col_offset=37, end_lineno=30, end_col_offset=42), 'placeholder_2', Load(), lineno=30, col_offset=37, end_lineno=30, end_col_offset=48), lineno=30, col_offset=24, end_lineno=30, end_col_offset=48), BinOp(Attribute(Name('self', Load(), lineno=30, col_offset=50, end_lineno=30, end_col_offset=54), 'placeholder_3', Load(), lineno=30, col_offset=50, end_lineno=30, end_col_offset=60), Mult(), Attribute(Name('placeholder_6', Load(), lineno=30, col_offset=63, end_lineno=30, end_col_offset=68), 'placeholder_3', Load(), lineno=30, col_offset=63, end_lineno=30, end_col_offset=74), lineno=30, col_offset=50, end_lineno=30, end_col_offset=74)], [], lineno=30, col_offset=15, end_lineno=30, end_col_offset=75), lineno=30, col_offset=8, end_lineno=30, end_col_offset=75)], [], lineno=29, col_offset=4, end_lineno=30, end_col_offset=75), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=32, col_offset=20, end_lineno=32, end_col_offset=24), arg('placeholder_6', lineno=32, col_offset=26, end_lineno=32, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=33, col_offset=15, end_lineno=33, end_col_offset=23), [BinOp(Attribute(Name('self', Load(), lineno=33, col_offset=24, end_lineno=33, end_col_offset=28), 'placeholder_2', Load(), lineno=33, col_offset=24, end_lineno=33, end_col_offset=34), Mult(), Attribute(Name('placeholder_6', Load(), lineno=33, col_offset=37, end_lineno=33, end_col_offset=42), 'placeholder_3', Load(), lineno=33, col_offset=37, end_lineno=33, end_col_offset=48), lineno=33, col_offset=24, end_lineno=33, end_col_offset=48), BinOp(Attribute(Name('self', Load(), lineno=33, col_offset=50, end_lineno=33, end_col_offset=54), 'placeholder_3', Load(), lineno=33, col_offset=50, end_lineno=33, end_col_offset=60), Mult(), Attribute(Name('placeholder_6', Load(), lineno=33, col_offset=63, end_lineno=33, end_col_offset=68), 'placeholder_2', Load(), lineno=33, col_offset=63, end_lineno=33, end_col_offset=74), lineno=33, col_offset=50, end_lineno=33, end_col_offset=74)], [], lineno=33, col_offset=15, end_lineno=33, end_col_offset=75), lineno=33, col_offset=8, end_lineno=33, end_col_offset=75)], [], lineno=32, col_offset=4, end_lineno=33, end_col_offset=75), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=35, col_offset=16, end_lineno=35, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=23), [Call(Name('abs', Load(), lineno=36, col_offset=24, end_lineno=36, end_col_offset=27), [Attribute(Name('self', Load(), lineno=36, col_offset=28, end_lineno=36, end_col_offset=32), 'placeholder_2', Load(), lineno=36, col_offset=28, end_lineno=36, end_col_offset=38)], [], lineno=36, col_offset=24, end_lineno=36, end_col_offset=39), Attribute(Name('self', Load(), lineno=36, col_offset=41, end_lineno=36, end_col_offset=45), 'placeholder_3', Load(), lineno=36, col_offset=41, end_lineno=36, end_col_offset=51)], [], lineno=36, col_offset=15, end_lineno=36, end_col_offset=52), lineno=36, col_offset=8, end_lineno=36, end_col_offset=52)], [], lineno=35, col_offset=4, end_lineno=36, end_col_offset=52), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=38, col_offset=16, end_lineno=38, end_col_offset=20), arg('placeholder_14', lineno=38, col_offset=22, end_lineno=38, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_14', Load(), lineno=39, col_offset=11, end_lineno=39, end_col_offset=16), [Lt()], [Constant(0, lineno=39, col_offset=19, end_lineno=39, end_col_offset=20)], lineno=39, col_offset=11, end_lineno=39, end_col_offset=20), [Return(Call(Name('placeholder_0', Load(), lineno=40, col_offset=19, end_lineno=40, end_col_offset=27), [Call(Name('pow', Load(), lineno=40, col_offset=28, end_lineno=40, end_col_offset=31), [Attribute(Name('self', Load(), lineno=40, col_offset=32, end_lineno=40, end_col_offset=36), 'placeholder_3', Load(), lineno=40, col_offset=32, end_lineno=40, end_col_offset=42), UnaryOp(USub(), Name('placeholder_14', Load(), lineno=40, col_offset=45, end_lineno=40, end_col_offset=50), lineno=40, col_offset=44, end_lineno=40, end_col_offset=50)], [], lineno=40, col_offset=28, end_lineno=40, end_col_offset=51), Call(Name('pow', Load(), lineno=40, col_offset=53, end_lineno=40, end_col_offset=56), [Attribute(Name('self', Load(), lineno=40, col_offset=57, end_lineno=40, end_col_offset=61), 'placeholder_2', Load(), lineno=40, col_offset=57, end_lineno=40, end_col_offset=67), UnaryOp(USub(), Name('placeholder_14', Load(), lineno=40, col_offset=70, end_lineno=40, end_col_offset=75), lineno=40, col_offset=69, end_lineno=40, end_col_offset=75)], [], lineno=40, col_offset=53, end_lineno=40, end_col_offset=76)], [], lineno=40, col_offset=19, end_lineno=40, end_col_offset=77), lineno=40, col_offset=12, end_lineno=40, end_col_offset=77)], [Return(Call(Name('placeholder_0', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=27), [Call(Name('pow', Load(), lineno=43, col_offset=28, end_lineno=43, end_col_offset=31), [Attribute(Name('self', Load(), lineno=43, col_offset=32, end_lineno=43, end_col_offset=36), 'placeholder_2', Load(), lineno=43, col_offset=32, end_lineno=43, end_col_offset=42), Name('placeholder_14', Load(), lineno=43, col_offset=44, end_lineno=43, end_col_offset=49)], [], lineno=43, col_offset=28, end_lineno=43, end_col_offset=50), Call(Name('pow', Load(), lineno=43, col_offset=52, end_lineno=43, end_col_offset=55), [Attribute(Name('self', Load(), lineno=43, col_offset=56, end_lineno=43, end_col_offset=60), 'placeholder_3', Load(), lineno=43, col_offset=56, end_lineno=43, end_col_offset=66), Name('placeholder_14', Load(), lineno=43, col_offset=68, end_lineno=43, end_col_offset=73)], [], lineno=43, col_offset=52, end_lineno=43, end_col_offset=74)], [], lineno=43, col_offset=19, end_lineno=43, end_col_offset=75), lineno=43, col_offset=12, end_lineno=43, end_col_offset=75)], lineno=39, col_offset=8, end_lineno=43, end_col_offset=75)], [], lineno=38, col_offset=4, end_lineno=43, end_col_offset=75), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=45, col_offset=17, end_lineno=45, end_col_offset=21), arg('placeholder_16', lineno=45, col_offset=23, end_lineno=45, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(Name('placeholder_16', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=19), Pow(), BinOp(Attribute(Name('self', Load(), lineno=46, col_offset=24, end_lineno=46, end_col_offset=28), 'placeholder_2', Load(), lineno=46, col_offset=24, end_lineno=46, end_col_offset=34), Div(), Attribute(Name('self', Load(), lineno=46, col_offset=37, end_lineno=46, end_col_offset=41), 'placeholder_3', Load(), lineno=46, col_offset=37, end_lineno=46, end_col_offset=47), lineno=46, col_offset=24, end_lineno=46, end_col_offset=47), lineno=46, col_offset=15, end_lineno=46, end_col_offset=48), lineno=46, col_offset=8, end_lineno=46, end_col_offset=48)], [], lineno=45, col_offset=4, end_lineno=46, end_col_offset=48), FunctionDef('placeholder_17', arguments([], [arg('self', lineno=48, col_offset=16, end_lineno=48, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=23), [BinOp(Attribute(Name('self', Load(), lineno=49, col_offset=24, end_lineno=49, end_col_offset=28), 'placeholder_2', Load(), lineno=49, col_offset=24, end_lineno=49, end_col_offset=34), Mult(), UnaryOp(USub(), Constant(1, lineno=49, col_offset=39, end_lineno=49, end_col_offset=40), lineno=49, col_offset=38, end_lineno=49, end_col_offset=40), lineno=49, col_offset=24, end_lineno=49, end_col_offset=41), Attribute(Name('self', Load(), lineno=49, col_offset=43, end_lineno=49, end_col_offset=47), 'placeholder_3', Load(), lineno=49, col_offset=43, end_lineno=49, end_col_offset=53)], [], lineno=49, col_offset=15, end_lineno=49, end_col_offset=54), lineno=49, col_offset=8, end_lineno=49, end_col_offset=54)], [], lineno=48, col_offset=4, end_lineno=49, end_col_offset=54)], [], lineno=4, col_offset=0, end_lineno=49, end_col_offset=54)], []) \ No newline at end of file diff --git a/test/practice-react/.meta/config.json b/test/practice-react/.meta/config.json new file mode 100644 index 0000000..6ecc142 --- /dev/null +++ b/test/practice-react/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "Dog", + "N-Parsons", + "Nishant23", + "tqa236", + "meatball133", + "Bethanyg" + ], + "files": { + "solution": [ + "react.py" + ], + "test": [ + "react_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement a basic reactive system." +} diff --git a/test/practice-react/mapping.json b/test/practice-react/mapping.json new file mode 100644 index 0000000..432da4e --- /dev/null +++ b/test/practice-react/mapping.json @@ -0,0 +1,26 @@ +{ + "placeholder_0": "Cell", + "placeholder_1": "__init__", + "placeholder_2": "_watchers", + "placeholder_3": "_value", + "placeholder_4": "counter", + "placeholder_5": "add_watcher", + "placeholder_6": "cell", + "placeholder_7": "value", + "placeholder_8": "new_value", + "placeholder_9": "InputCell", + "placeholder_10": "initial_value", + "placeholder_11": "ComputeCell", + "placeholder_12": "inputs", + "placeholder_13": "compute_function", + "placeholder_14": "func", + "placeholder_15": "callbacks", + "placeholder_16": "_register_inputs", + "placeholder_17": "inp", + "placeholder_18": "compute", + "placeholder_19": "new_val", + "placeholder_20": "cb", + "placeholder_21": "add_callback", + "placeholder_22": "callback", + "placeholder_23": "remove_callback" +} \ No newline at end of file diff --git a/test/practice-react/react.py b/test/practice-react/react.py new file mode 100644 index 0000000..48d36db --- /dev/null +++ b/test/practice-react/react.py @@ -0,0 +1,56 @@ +class Cell: + def __init__(self): + self._watchers = [] + self._value = None + self.counter = 0 + + def add_watcher(self, cell): + self._watchers.append(cell) + + @property + def value(self): + return self._value + + @value.setter + def value(self, new_value): + self._value = new_value + self.counter += 1 + for cell in self._watchers: + cell.compute() + + +class InputCell(Cell): + def __init__(self, initial_value): + super().__init__() + self._value = initial_value + + +class ComputeCell(Cell): + def __init__(self, inputs, compute_function): + super().__init__() + self.inputs = inputs + self.func = compute_function + self.callbacks = set() + self.compute() + self._register_inputs() + + def _register_inputs(self): + for inp in self.inputs: + inp.add_watcher(self) + + def compute(self): + # Only compute this cell when all inputs have same counters + if len({inp.counter for inp in self.inputs}) > 1: + return + new_val = self.func([inp.value for inp in self.inputs]) + if new_val != self._value: + self.value = new_val + for cb in self.callbacks: + cb(new_val) + + def add_callback(self, callback): + self.callbacks.add(callback) + + def remove_callback(self, callback): + if callback in self.callbacks: + self.callbacks.remove(callback) diff --git a/test/practice-react/representation.json b/test/practice-react/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-react/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-react/representation.out b/test/practice-react/representation.out new file mode 100644 index 0000000..b575fac --- /dev/null +++ b/test/practice-react/representation.out @@ -0,0 +1,2559 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self): + self.placeholder_2 = [] + self.placeholder_3 = None + self.placeholder_4 = 0 + + def placeholder_5(self, placeholder_6): + self.placeholder_2.append(placeholder_6) + + @property + def placeholder_7(self): + return self.placeholder_3 + + @placeholder_7.setter + def placeholder_7(self, placeholder_8): + self.placeholder_3 = placeholder_8 + self.placeholder_4 += 1 + for placeholder_6 in self.placeholder_2: + placeholder_6.compute() + + +class placeholder_9(placeholder_0): + def placeholder_1(self, placeholder_10): + super().placeholder_1() + self.placeholder_3 = placeholder_10 + + +class placeholder_11(placeholder_0): + def placeholder_1(self, placeholder_12, placeholder_13): + super().placeholder_1() + self.placeholder_12 = placeholder_12 + self.placeholder_14 = placeholder_13 + self.placeholder_15 = set() + self.compute() + self._register_inputs() + + def placeholder_16(self): + for placeholder_17 in self.placeholder_12: + placeholder_17.placeholder_5(self) + + def placeholder_18(self): + if ( + len( + {placeholder_17.placeholder_4 for placeholder_17 in self.placeholder_12} + ) + > 1 + ): + return + placeholder_19 = self.placeholder_14( + [placeholder_17.placeholder_7 for placeholder_17 in self.placeholder_12] + ) + if placeholder_19 != self.placeholder_3: + self.placeholder_7 = placeholder_19 + for placeholder_20 in self.placeholder_15: + placeholder_20(placeholder_19) + + def placeholder_21(self, placeholder_22): + self.placeholder_15.add(placeholder_22) + + def placeholder_23(self, placeholder_22): + if placeholder_22 in self.placeholder_15: + self.placeholder_15.remove(placeholder_22) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Cell', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + '_watchers', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=22)], + List( + [], + Load(), + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + '_value', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=19)], + Constant( + None, + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=26), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'counter', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=20)], + Constant( + 0, + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=24), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=24)], + [], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=24), + FunctionDef( + 'add_watcher', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=24), + arg( + 'cell', + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + '_watchers', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22), + 'append', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=29), + [ + Name( + 'cell', + Load(), + lineno=8, + col_offset=30, + end_lineno=8, + end_col_offset=34)], + [], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=35), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=35)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=35), + FunctionDef( + 'value', + arguments( + [], + [ + arg( + 'self', + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=19), + '_value', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=26), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=26)], + [ + Name( + 'property', + Load(), + lineno=10, + col_offset=5, + end_lineno=10, + end_col_offset=13)], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=26), + FunctionDef( + 'value', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=18), + arg( + 'new_value', + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=12), + '_value', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=19)], + Name( + 'new_value', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=31), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=31), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=12), + 'counter', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=20), + Add(), + Constant( + 1, + lineno=17, + col_offset=24, + end_lineno=17, + end_col_offset=25), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=25), + For( + Name( + 'cell', + Store(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=16), + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=24), + '_watchers', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=34), + [ + Expr( + Call( + Attribute( + Name( + 'cell', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=16), + 'compute', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=24), + [], + [], + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=26), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=26)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=26)], + [ + Attribute( + Name( + 'value', + Load(), + lineno=14, + col_offset=5, + end_lineno=14, + end_col_offset=10), + 'setter', + Load(), + lineno=14, + col_offset=5, + end_lineno=14, + end_col_offset=17)], + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=19, + end_col_offset=26), + ClassDef( + 'InputCell', + [ + Name( + 'Cell', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20)], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + arg( + 'initial_value', + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=13), + [], + [], + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=15), + '__init__', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=24), + [], + [], + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=26), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=12), + '_value', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=19)], + Name( + 'initial_value', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=35), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=35)], + [], + lineno=23, + col_offset=4, + end_lineno=25, + end_col_offset=35)], + [], + lineno=22, + col_offset=0, + end_lineno=25, + end_col_offset=35), + ClassDef( + 'ComputeCell', + [ + Name( + 'Cell', + Load(), + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=22)], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=21), + arg( + 'inputs', + lineno=29, + col_offset=23, + end_lineno=29, + end_col_offset=29), + arg( + 'compute_function', + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=47)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=13), + [], + [], + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=15), + '__init__', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=24), + [], + [], + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=26), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=12), + 'inputs', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=19)], + Name( + 'inputs', + Load(), + lineno=31, + col_offset=22, + end_lineno=31, + end_col_offset=28), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'func', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=17)], + Name( + 'compute_function', + Load(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=36), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=12), + 'callbacks', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=22)], + Call( + Name( + 'set', + Load(), + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=28), + [], + [], + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=30), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=30), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'compute', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=20), + [], + [], + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=22), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=22), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=12), + '_register_inputs', + Load(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=29), + [], + [], + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=31), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=31)], + [], + lineno=29, + col_offset=4, + end_lineno=35, + end_col_offset=31), + FunctionDef( + '_register_inputs', + arguments( + [], + [ + arg( + 'self', + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'inp', + Store(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=15), + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=19, + end_lineno=38, + end_col_offset=23), + 'inputs', + Load(), + lineno=38, + col_offset=19, + end_lineno=38, + end_col_offset=30), + [ + Expr( + Call( + Attribute( + Name( + 'inp', + Load(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=15), + 'add_watcher', + Load(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=27), + [ + Name( + 'self', + Load(), + lineno=39, + col_offset=28, + end_lineno=39, + end_col_offset=32)], + [], + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=33), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=33)], + [], + lineno=38, + col_offset=8, + end_lineno=39, + end_col_offset=33)], + [], + lineno=37, + col_offset=4, + end_lineno=39, + end_col_offset=33), + FunctionDef( + 'compute', + arguments( + [], + [ + arg( + 'self', + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=14), + [ + SetComp( + Attribute( + Name( + 'inp', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=19), + 'counter', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=27), + [ + comprehension( + Name( + 'inp', + Store(), + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=35), + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=39, + end_lineno=43, + end_col_offset=43), + 'inputs', + Load(), + lineno=43, + col_offset=39, + end_lineno=43, + end_col_offset=50), + [], + 0)], + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=51)], + [], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=52), + [ + Gt()], + [ + Constant( + 1, + lineno=43, + col_offset=55, + end_lineno=43, + end_col_offset=56)], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=56), + [ + Return( + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=18)], + [], + lineno=43, + col_offset=8, + end_lineno=44, + end_col_offset=18), + Assign( + [ + Name( + 'new_val', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=15)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=22), + 'func', + Load(), + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=27), + [ + ListComp( + Attribute( + Name( + 'inp', + Load(), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=32), + 'value', + Load(), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=38), + [ + comprehension( + Name( + 'inp', + Store(), + lineno=45, + col_offset=43, + end_lineno=45, + end_col_offset=46), + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=50, + end_lineno=45, + end_col_offset=54), + 'inputs', + Load(), + lineno=45, + col_offset=50, + end_lineno=45, + end_col_offset=61), + [], + 0)], + lineno=45, + col_offset=28, + end_lineno=45, + end_col_offset=62)], + [], + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=63), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=63), + If( + Compare( + Name( + 'new_val', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=18), + [ + NotEq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=26), + '_value', + Load(), + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=33)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=33), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=16), + 'value', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=22)], + Name( + 'new_val', + Load(), + lineno=47, + col_offset=25, + end_lineno=47, + end_col_offset=32), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=32), + For( + Name( + 'cb', + Store(), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=18), + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=26), + 'callbacks', + Load(), + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=36), + [ + Expr( + Call( + Name( + 'cb', + Load(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=18), + [ + Name( + 'new_val', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=26)], + [], + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=27), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=27)], + [], + lineno=48, + col_offset=12, + end_lineno=49, + end_col_offset=27)], + [], + lineno=46, + col_offset=8, + end_lineno=49, + end_col_offset=27)], + [], + lineno=41, + col_offset=4, + end_lineno=49, + end_col_offset=27), + FunctionDef( + 'add_callback', + arguments( + [], + [ + arg( + 'self', + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=25), + arg( + 'callback', + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=12), + 'callbacks', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=22), + 'add', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=26), + [ + Name( + 'callback', + Load(), + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=35)], + [], + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=36), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=36)], + [], + lineno=51, + col_offset=4, + end_lineno=52, + end_col_offset=36), + FunctionDef( + 'remove_callback', + arguments( + [], + [ + arg( + 'self', + lineno=54, + col_offset=24, + end_lineno=54, + end_col_offset=28), + arg( + 'callback', + lineno=54, + col_offset=30, + end_lineno=54, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'callback', + Load(), + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=19), + [ + In()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=23, + end_lineno=55, + end_col_offset=27), + 'callbacks', + Load(), + lineno=55, + col_offset=23, + end_lineno=55, + end_col_offset=37)], + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=37), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=16), + 'callbacks', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=26), + 'remove', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=33), + [ + Name( + 'callback', + Load(), + lineno=56, + col_offset=34, + end_lineno=56, + end_col_offset=42)], + [], + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=43), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=43)], + [], + lineno=55, + col_offset=8, + end_lineno=56, + end_col_offset=43)], + [], + lineno=54, + col_offset=4, + end_lineno=56, + end_col_offset=43)], + [], + lineno=28, + col_offset=0, + end_lineno=56, + end_col_offset=43)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=22)], + List( + [], + Load(), + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=19)], + Constant( + None, + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=26), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=20)], + Constant( + 0, + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=24), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=24)], + [], + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=24), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=24), + arg( + 'placeholder_6', + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_2', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22), + 'append', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=29), + [ + Name( + 'placeholder_6', + Load(), + lineno=8, + col_offset=30, + end_lineno=8, + end_col_offset=34)], + [], + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=35), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=35)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=35), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=19), + 'placeholder_3', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=26), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=26)], + [ + Name( + 'property', + Load(), + lineno=10, + col_offset=5, + end_lineno=10, + end_col_offset=13)], + lineno=11, + col_offset=4, + end_lineno=12, + end_col_offset=26), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=18), + arg( + 'placeholder_8', + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=19)], + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=31), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=31), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=20), + Add(), + Constant( + 1, + lineno=17, + col_offset=24, + end_lineno=17, + end_col_offset=25), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=25), + For( + Name( + 'placeholder_6', + Store(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=16), + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=34), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=16), + 'compute', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=24), + [], + [], + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=26), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=26)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=26)], + [ + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=5, + end_lineno=14, + end_col_offset=10), + 'setter', + Load(), + lineno=14, + col_offset=5, + end_lineno=14, + end_col_offset=17)], + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=19, + end_col_offset=26), + ClassDef( + 'placeholder_9', + [ + Name( + 'placeholder_0', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=20)], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=21), + arg( + 'placeholder_10', + lineno=23, + col_offset=23, + end_lineno=23, + end_col_offset=36)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=13), + [], + [], + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=15), + 'placeholder_1', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=24), + [], + [], + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=26), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=19)], + Name( + 'placeholder_10', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=35), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=35)], + [], + lineno=23, + col_offset=4, + end_lineno=25, + end_col_offset=35)], + [], + lineno=22, + col_offset=0, + end_lineno=25, + end_col_offset=35), + ClassDef( + 'placeholder_11', + [ + Name( + 'placeholder_0', + Load(), + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=22)], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=29, + col_offset=17, + end_lineno=29, + end_col_offset=21), + arg( + 'placeholder_12', + lineno=29, + col_offset=23, + end_lineno=29, + end_col_offset=29), + arg( + 'placeholder_13', + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=47)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Call( + Name( + 'super', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=13), + [], + [], + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=15), + 'placeholder_1', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=24), + [], + [], + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=26), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=12), + 'placeholder_12', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=19)], + Name( + 'placeholder_12', + Load(), + lineno=31, + col_offset=22, + end_lineno=31, + end_col_offset=28), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=28), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'placeholder_14', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=17)], + Name( + 'placeholder_13', + Load(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=36), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=12), + 'placeholder_15', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=22)], + Call( + Name( + 'set', + Load(), + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=28), + [], + [], + lineno=33, + col_offset=25, + end_lineno=33, + end_col_offset=30), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=30), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'compute', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=20), + [], + [], + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=22), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=22), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=12), + '_register_inputs', + Load(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=29), + [], + [], + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=31), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=31)], + [], + lineno=29, + col_offset=4, + end_lineno=35, + end_col_offset=31), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'self', + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_17', + Store(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=15), + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=19, + end_lineno=38, + end_col_offset=23), + 'placeholder_12', + Load(), + lineno=38, + col_offset=19, + end_lineno=38, + end_col_offset=30), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=15), + 'placeholder_5', + Load(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=27), + [ + Name( + 'self', + Load(), + lineno=39, + col_offset=28, + end_lineno=39, + end_col_offset=32)], + [], + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=33), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=33)], + [], + lineno=38, + col_offset=8, + end_lineno=39, + end_col_offset=33)], + [], + lineno=37, + col_offset=4, + end_lineno=39, + end_col_offset=33), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'self', + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=14), + [ + SetComp( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=19), + 'placeholder_4', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=27), + [ + comprehension( + Name( + 'placeholder_17', + Store(), + lineno=43, + col_offset=32, + end_lineno=43, + end_col_offset=35), + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=39, + end_lineno=43, + end_col_offset=43), + 'placeholder_12', + Load(), + lineno=43, + col_offset=39, + end_lineno=43, + end_col_offset=50), + [], + 0)], + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=51)], + [], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=52), + [ + Gt()], + [ + Constant( + 1, + lineno=43, + col_offset=55, + end_lineno=43, + end_col_offset=56)], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=56), + [ + Return( + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=18)], + [], + lineno=43, + col_offset=8, + end_lineno=44, + end_col_offset=18), + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=15)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=22), + 'placeholder_14', + Load(), + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=27), + [ + ListComp( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=32), + 'placeholder_7', + Load(), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=38), + [ + comprehension( + Name( + 'placeholder_17', + Store(), + lineno=45, + col_offset=43, + end_lineno=45, + end_col_offset=46), + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=50, + end_lineno=45, + end_col_offset=54), + 'placeholder_12', + Load(), + lineno=45, + col_offset=50, + end_lineno=45, + end_col_offset=61), + [], + 0)], + lineno=45, + col_offset=28, + end_lineno=45, + end_col_offset=62)], + [], + lineno=45, + col_offset=18, + end_lineno=45, + end_col_offset=63), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=63), + If( + Compare( + Name( + 'placeholder_19', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=18), + [ + NotEq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=26), + 'placeholder_3', + Load(), + lineno=46, + col_offset=22, + end_lineno=46, + end_col_offset=33)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=33), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=16), + 'placeholder_7', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=22)], + Name( + 'placeholder_19', + Load(), + lineno=47, + col_offset=25, + end_lineno=47, + end_col_offset=32), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=32), + For( + Name( + 'placeholder_20', + Store(), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=18), + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=26), + 'placeholder_15', + Load(), + lineno=48, + col_offset=22, + end_lineno=48, + end_col_offset=36), + [ + Expr( + Call( + Name( + 'placeholder_20', + Load(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=18), + [ + Name( + 'placeholder_19', + Load(), + lineno=49, + col_offset=19, + end_lineno=49, + end_col_offset=26)], + [], + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=27), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=27)], + [], + lineno=48, + col_offset=12, + end_lineno=49, + end_col_offset=27)], + [], + lineno=46, + col_offset=8, + end_lineno=49, + end_col_offset=27)], + [], + lineno=41, + col_offset=4, + end_lineno=49, + end_col_offset=27), + FunctionDef( + 'placeholder_21', + arguments( + [], + [ + arg( + 'self', + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=25), + arg( + 'placeholder_22', + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=35)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=12), + 'placeholder_15', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=22), + 'add', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=26), + [ + Name( + 'placeholder_22', + Load(), + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=35)], + [], + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=36), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=36)], + [], + lineno=51, + col_offset=4, + end_lineno=52, + end_col_offset=36), + FunctionDef( + 'placeholder_23', + arguments( + [], + [ + arg( + 'self', + lineno=54, + col_offset=24, + end_lineno=54, + end_col_offset=28), + arg( + 'placeholder_22', + lineno=54, + col_offset=30, + end_lineno=54, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_22', + Load(), + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=19), + [ + In()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=23, + end_lineno=55, + end_col_offset=27), + 'placeholder_15', + Load(), + lineno=55, + col_offset=23, + end_lineno=55, + end_col_offset=37)], + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=37), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=16), + 'placeholder_15', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=26), + 'remove', + Load(), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=33), + [ + Name( + 'placeholder_22', + Load(), + lineno=56, + col_offset=34, + end_lineno=56, + end_col_offset=42)], + [], + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=43), + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=43)], + [], + lineno=55, + col_offset=8, + end_lineno=56, + end_col_offset=43)], + [], + lineno=54, + col_offset=4, + end_lineno=56, + end_col_offset=43)], + [], + lineno=28, + col_offset=0, + end_lineno=56, + end_col_offset=43)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-react/representation.txt b/test/practice-react/representation.txt new file mode 100644 index 0000000..4183bb4 --- /dev/null +++ b/test/practice-react/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_2', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=22)], List([], Load(), lineno=3, col_offset=25, end_lineno=3, end_col_offset=27), lineno=3, col_offset=8, end_lineno=3, end_col_offset=27), Assign([Attribute(Name('self', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=12), 'placeholder_3', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=19)], Constant(None, lineno=4, col_offset=22, end_lineno=4, end_col_offset=26), lineno=4, col_offset=8, end_lineno=4, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=12), 'placeholder_4', Store(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=20)], Constant(0, lineno=5, col_offset=23, end_lineno=5, end_col_offset=24), lineno=5, col_offset=8, end_lineno=5, end_col_offset=24)], [], lineno=2, col_offset=4, end_lineno=5, end_col_offset=24), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=7, col_offset=20, end_lineno=7, end_col_offset=24), arg('placeholder_6', lineno=7, col_offset=26, end_lineno=7, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_2', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=22), 'append', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=29), [Name('placeholder_6', Load(), lineno=8, col_offset=30, end_lineno=8, end_col_offset=34)], [], lineno=8, col_offset=8, end_lineno=8, end_col_offset=35), lineno=8, col_offset=8, end_lineno=8, end_col_offset=35)], [], lineno=7, col_offset=4, end_lineno=8, end_col_offset=35), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=11, col_offset=14, end_lineno=11, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=19), 'placeholder_3', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=26), lineno=12, col_offset=8, end_lineno=12, end_col_offset=26)], [Name('property', Load(), lineno=10, col_offset=5, end_lineno=10, end_col_offset=13)], lineno=11, col_offset=4, end_lineno=12, end_col_offset=26), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=15, col_offset=14, end_lineno=15, end_col_offset=18), arg('placeholder_8', lineno=15, col_offset=20, end_lineno=15, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=12), 'placeholder_3', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=19)], Name('placeholder_8', Load(), lineno=16, col_offset=22, end_lineno=16, end_col_offset=31), lineno=16, col_offset=8, end_lineno=16, end_col_offset=31), AugAssign(Attribute(Name('self', Load(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=12), 'placeholder_4', Store(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=20), Add(), Constant(1, lineno=17, col_offset=24, end_lineno=17, end_col_offset=25), lineno=17, col_offset=8, end_lineno=17, end_col_offset=25), For(Name('placeholder_6', Store(), lineno=18, col_offset=12, end_lineno=18, end_col_offset=16), Attribute(Name('self', Load(), lineno=18, col_offset=20, end_lineno=18, end_col_offset=24), 'placeholder_2', Load(), lineno=18, col_offset=20, end_lineno=18, end_col_offset=34), [Expr(Call(Attribute(Name('placeholder_6', Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=16), 'compute', Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=24), [], [], lineno=19, col_offset=12, end_lineno=19, end_col_offset=26), lineno=19, col_offset=12, end_lineno=19, end_col_offset=26)], [], lineno=18, col_offset=8, end_lineno=19, end_col_offset=26)], [Attribute(Name('placeholder_7', Load(), lineno=14, col_offset=5, end_lineno=14, end_col_offset=10), 'setter', Load(), lineno=14, col_offset=5, end_lineno=14, end_col_offset=17)], lineno=15, col_offset=4, end_lineno=19, end_col_offset=26)], [], lineno=1, col_offset=0, end_lineno=19, end_col_offset=26), ClassDef('placeholder_9', [Name('placeholder_0', Load(), lineno=22, col_offset=16, end_lineno=22, end_col_offset=20)], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=23, col_offset=17, end_lineno=23, end_col_offset=21), arg('placeholder_10', lineno=23, col_offset=23, end_lineno=23, end_col_offset=36)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Call(Name('super', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=13), [], [], lineno=24, col_offset=8, end_lineno=24, end_col_offset=15), 'placeholder_1', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=24), [], [], lineno=24, col_offset=8, end_lineno=24, end_col_offset=26), lineno=24, col_offset=8, end_lineno=24, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=12), 'placeholder_3', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=19)], Name('placeholder_10', Load(), lineno=25, col_offset=22, end_lineno=25, end_col_offset=35), lineno=25, col_offset=8, end_lineno=25, end_col_offset=35)], [], lineno=23, col_offset=4, end_lineno=25, end_col_offset=35)], [], lineno=22, col_offset=0, end_lineno=25, end_col_offset=35), ClassDef('placeholder_11', [Name('placeholder_0', Load(), lineno=28, col_offset=18, end_lineno=28, end_col_offset=22)], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=29, col_offset=17, end_lineno=29, end_col_offset=21), arg('placeholder_12', lineno=29, col_offset=23, end_lineno=29, end_col_offset=29), arg('placeholder_13', lineno=29, col_offset=31, end_lineno=29, end_col_offset=47)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Call(Name('super', Load(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=13), [], [], lineno=30, col_offset=8, end_lineno=30, end_col_offset=15), 'placeholder_1', Load(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=24), [], [], lineno=30, col_offset=8, end_lineno=30, end_col_offset=26), lineno=30, col_offset=8, end_lineno=30, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=12), 'placeholder_12', Store(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=19)], Name('placeholder_12', Load(), lineno=31, col_offset=22, end_lineno=31, end_col_offset=28), lineno=31, col_offset=8, end_lineno=31, end_col_offset=28), Assign([Attribute(Name('self', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=12), 'placeholder_14', Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=17)], Name('placeholder_13', Load(), lineno=32, col_offset=20, end_lineno=32, end_col_offset=36), lineno=32, col_offset=8, end_lineno=32, end_col_offset=36), Assign([Attribute(Name('self', Load(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=12), 'placeholder_15', Store(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=22)], Call(Name('set', Load(), lineno=33, col_offset=25, end_lineno=33, end_col_offset=28), [], [], lineno=33, col_offset=25, end_lineno=33, end_col_offset=30), lineno=33, col_offset=8, end_lineno=33, end_col_offset=30), Expr(Call(Attribute(Name('self', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=12), 'compute', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=20), [], [], lineno=34, col_offset=8, end_lineno=34, end_col_offset=22), lineno=34, col_offset=8, end_lineno=34, end_col_offset=22), Expr(Call(Attribute(Name('self', Load(), lineno=35, col_offset=8, end_lineno=35, end_col_offset=12), '_register_inputs', Load(), lineno=35, col_offset=8, end_lineno=35, end_col_offset=29), [], [], lineno=35, col_offset=8, end_lineno=35, end_col_offset=31), lineno=35, col_offset=8, end_lineno=35, end_col_offset=31)], [], lineno=29, col_offset=4, end_lineno=35, end_col_offset=31), FunctionDef('placeholder_16', arguments([], [arg('self', lineno=37, col_offset=25, end_lineno=37, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_17', Store(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=15), Attribute(Name('self', Load(), lineno=38, col_offset=19, end_lineno=38, end_col_offset=23), 'placeholder_12', Load(), lineno=38, col_offset=19, end_lineno=38, end_col_offset=30), [Expr(Call(Attribute(Name('placeholder_17', Load(), lineno=39, col_offset=12, end_lineno=39, end_col_offset=15), 'placeholder_5', Load(), lineno=39, col_offset=12, end_lineno=39, end_col_offset=27), [Name('self', Load(), lineno=39, col_offset=28, end_lineno=39, end_col_offset=32)], [], lineno=39, col_offset=12, end_lineno=39, end_col_offset=33), lineno=39, col_offset=12, end_lineno=39, end_col_offset=33)], [], lineno=38, col_offset=8, end_lineno=39, end_col_offset=33)], [], lineno=37, col_offset=4, end_lineno=39, end_col_offset=33), FunctionDef('placeholder_18', arguments([], [arg('self', lineno=41, col_offset=16, end_lineno=41, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=14), [SetComp(Attribute(Name('placeholder_17', Load(), lineno=43, col_offset=16, end_lineno=43, end_col_offset=19), 'placeholder_4', Load(), lineno=43, col_offset=16, end_lineno=43, end_col_offset=27), [comprehension(Name('placeholder_17', Store(), lineno=43, col_offset=32, end_lineno=43, end_col_offset=35), Attribute(Name('self', Load(), lineno=43, col_offset=39, end_lineno=43, end_col_offset=43), 'placeholder_12', Load(), lineno=43, col_offset=39, end_lineno=43, end_col_offset=50), [], 0)], lineno=43, col_offset=15, end_lineno=43, end_col_offset=51)], [], lineno=43, col_offset=11, end_lineno=43, end_col_offset=52), [Gt()], [Constant(1, lineno=43, col_offset=55, end_lineno=43, end_col_offset=56)], lineno=43, col_offset=11, end_lineno=43, end_col_offset=56), [Return(lineno=44, col_offset=12, end_lineno=44, end_col_offset=18)], [], lineno=43, col_offset=8, end_lineno=44, end_col_offset=18), Assign([Name('placeholder_19', Store(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=15)], Call(Attribute(Name('self', Load(), lineno=45, col_offset=18, end_lineno=45, end_col_offset=22), 'placeholder_14', Load(), lineno=45, col_offset=18, end_lineno=45, end_col_offset=27), [ListComp(Attribute(Name('placeholder_17', Load(), lineno=45, col_offset=29, end_lineno=45, end_col_offset=32), 'placeholder_7', Load(), lineno=45, col_offset=29, end_lineno=45, end_col_offset=38), [comprehension(Name('placeholder_17', Store(), lineno=45, col_offset=43, end_lineno=45, end_col_offset=46), Attribute(Name('self', Load(), lineno=45, col_offset=50, end_lineno=45, end_col_offset=54), 'placeholder_12', Load(), lineno=45, col_offset=50, end_lineno=45, end_col_offset=61), [], 0)], lineno=45, col_offset=28, end_lineno=45, end_col_offset=62)], [], lineno=45, col_offset=18, end_lineno=45, end_col_offset=63), lineno=45, col_offset=8, end_lineno=45, end_col_offset=63), If(Compare(Name('placeholder_19', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=18), [NotEq()], [Attribute(Name('self', Load(), lineno=46, col_offset=22, end_lineno=46, end_col_offset=26), 'placeholder_3', Load(), lineno=46, col_offset=22, end_lineno=46, end_col_offset=33)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=33), [Assign([Attribute(Name('self', Load(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=16), 'placeholder_7', Store(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=22)], Name('placeholder_19', Load(), lineno=47, col_offset=25, end_lineno=47, end_col_offset=32), lineno=47, col_offset=12, end_lineno=47, end_col_offset=32), For(Name('placeholder_20', Store(), lineno=48, col_offset=16, end_lineno=48, end_col_offset=18), Attribute(Name('self', Load(), lineno=48, col_offset=22, end_lineno=48, end_col_offset=26), 'placeholder_15', Load(), lineno=48, col_offset=22, end_lineno=48, end_col_offset=36), [Expr(Call(Name('placeholder_20', Load(), lineno=49, col_offset=16, end_lineno=49, end_col_offset=18), [Name('placeholder_19', Load(), lineno=49, col_offset=19, end_lineno=49, end_col_offset=26)], [], lineno=49, col_offset=16, end_lineno=49, end_col_offset=27), lineno=49, col_offset=16, end_lineno=49, end_col_offset=27)], [], lineno=48, col_offset=12, end_lineno=49, end_col_offset=27)], [], lineno=46, col_offset=8, end_lineno=49, end_col_offset=27)], [], lineno=41, col_offset=4, end_lineno=49, end_col_offset=27), FunctionDef('placeholder_21', arguments([], [arg('self', lineno=51, col_offset=21, end_lineno=51, end_col_offset=25), arg('placeholder_22', lineno=51, col_offset=27, end_lineno=51, end_col_offset=35)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=12), 'placeholder_15', Load(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=22), 'add', Load(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=26), [Name('placeholder_22', Load(), lineno=52, col_offset=27, end_lineno=52, end_col_offset=35)], [], lineno=52, col_offset=8, end_lineno=52, end_col_offset=36), lineno=52, col_offset=8, end_lineno=52, end_col_offset=36)], [], lineno=51, col_offset=4, end_lineno=52, end_col_offset=36), FunctionDef('placeholder_23', arguments([], [arg('self', lineno=54, col_offset=24, end_lineno=54, end_col_offset=28), arg('placeholder_22', lineno=54, col_offset=30, end_lineno=54, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_22', Load(), lineno=55, col_offset=11, end_lineno=55, end_col_offset=19), [In()], [Attribute(Name('self', Load(), lineno=55, col_offset=23, end_lineno=55, end_col_offset=27), 'placeholder_15', Load(), lineno=55, col_offset=23, end_lineno=55, end_col_offset=37)], lineno=55, col_offset=11, end_lineno=55, end_col_offset=37), [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=56, col_offset=12, end_lineno=56, end_col_offset=16), 'placeholder_15', Load(), lineno=56, col_offset=12, end_lineno=56, end_col_offset=26), 'remove', Load(), lineno=56, col_offset=12, end_lineno=56, end_col_offset=33), [Name('placeholder_22', Load(), lineno=56, col_offset=34, end_lineno=56, end_col_offset=42)], [], lineno=56, col_offset=12, end_lineno=56, end_col_offset=43), lineno=56, col_offset=12, end_lineno=56, end_col_offset=43)], [], lineno=55, col_offset=8, end_lineno=56, end_col_offset=43)], [], lineno=54, col_offset=4, end_lineno=56, end_col_offset=43)], [], lineno=28, col_offset=0, end_lineno=56, end_col_offset=43)], []) \ No newline at end of file diff --git a/test/practice-rectangles/.meta/config.json b/test/practice-rectangles/.meta/config.json new file mode 100644 index 0000000..4010f7d --- /dev/null +++ b/test/practice-rectangles/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [], + "contributors": [ + "aboutroots", + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "dvermd", + "ikhadykin", + "N-Parsons", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "rectangles.py" + ], + "test": [ + "rectangles_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Count the rectangles in an ASCII diagram." +} diff --git a/test/practice-rectangles/mapping.json b/test/practice-rectangles/mapping.json new file mode 100644 index 0000000..b04935f --- /dev/null +++ b/test/practice-rectangles/mapping.json @@ -0,0 +1,37 @@ +{ + "placeholder_0": "Corners", + "placeholder_1": "__init__", + "placeholder_2": "idx", + "placeholder_3": "jdx", + "placeholder_4": "__str__", + "placeholder_5": "same_line", + "placeholder_6": "index", + "placeholder_7": "list_obj", + "placeholder_8": "corner", + "placeholder_9": "same_col", + "placeholder_10": "search_corners", + "placeholder_11": "item", + "placeholder_12": "element", + "placeholder_13": "possible_rect", + "placeholder_14": "quartet", + "placeholder_15": "mid_x", + "placeholder_16": "mid_y", + "placeholder_17": "centroid", + "placeholder_18": "dx", + "placeholder_19": "dy", + "placeholder_20": "path", + "placeholder_21": "corner1", + "placeholder_22": "corner2", + "placeholder_23": "validate_rect", + "placeholder_24": "rectangle", + "placeholder_25": "_", + "placeholder_26": "line", + "placeholder_27": "column", + "placeholder_28": "rectangles", + "placeholder_29": "strings", + "placeholder_30": "rectangle_total", + "placeholder_31": "corners", + "placeholder_32": "quartets", + "placeholder_33": "r", + "placeholder_34": "paths" +} \ No newline at end of file diff --git a/test/practice-rectangles/rectangles.py b/test/practice-rectangles/rectangles.py new file mode 100644 index 0000000..fe66572 --- /dev/null +++ b/test/practice-rectangles/rectangles.py @@ -0,0 +1,111 @@ +import itertools + + +class Corners: + def __init__(self, idx, jdx): + # i, j are position of corner + self.idx = idx + self.jdx = jdx + + def __str__(self): + return '[' + str(self.idx) + ', ' + str(self.jdx) + ']' + + +# return corner on the same line +def same_line(index, list_obj): + for corner in list_obj: + if corner.idx == index: + return corner + return None + + +# return corner on the same column +def same_col(index, list_obj): + for corner in list_obj: + if corner.jdx == index: + return corner + return None + + +def search_corners(list_obj): + + return [Corners(item, element) for item in range(len(list_obj)) + for element in range(len(list_obj[item])) + if list_obj[item][element] == '+'] + + +# validate that 4 points form a rectangle by +# comparing distance to centroid of the rectangle for all corners +def possible_rect(quartet): + mid_x = 0 + mid_y = 0 + + for centroid in quartet: + mid_x = mid_x + centroid.idx / 4.0 + mid_y = mid_y + centroid.jdx / 4.0 + + # reference distance using first corner + dx = abs(quartet[0].idx - mid_x) + dy = abs(quartet[0].jdx - mid_y) + + # Check all the same distance from centroid are equals + for idx in range(1, len(quartet)): + if abs(quartet[idx].idx - mid_x) != dx or abs(quartet[idx].jdx - mid_y) != dy: + return False + return True + + +# validate path between two corners +def path(corner1, corner2, item): + if corner1.idx == corner2.idx: + for jdx in range(min(corner1.jdx + 1, corner2.jdx + 1), + max(corner1.jdx, corner2.jdx)): + if item[corner1.idx][jdx] != '-' and item[corner1.idx][jdx] != '+': + return False + return True + + elif corner1.jdx == corner2.jdx: + for idx in range(min(corner1.idx + 1, corner2.idx + 1), + max(corner1.idx, corner2.idx)): + if item[idx][corner1.jdx] != '|' and item[idx][corner1.jdx] != '+': + return False + return True + return None + + +# validate path of rectangle +def validate_rect(rectangle, item): + # validate connection at every corner + # with neighbours on the same line and col + for idx, _ in enumerate(rectangle): + line = same_line(rectangle[idx].idx, rectangle[0:idx] + rectangle[idx + 1:]) + column = same_col(rectangle[idx].jdx, rectangle[0:idx] + rectangle[idx + 1:]) + + if not path(rectangle[idx], line, item) or not path(rectangle[idx], column, item): + return False + + return True + + +# count number of rectangles inside ASCII in input lines +def rectangles(strings=''): + rectangle_total = 0 + # test empty str + if not strings: + return rectangle_total + + corners = search_corners(strings) + + # no corners in str + if not corners: + return rectangle_total + + # all combinations of 4 corners + quartets = list(itertools.combinations(corners, r=4)) + paths = (quartet for quartet in quartets if possible_rect(quartet)) + + # validate paths + for idx in paths: + if validate_rect(idx, strings): + rectangle_total += 1 + return rectangle_total diff --git a/test/practice-rectangles/representation.json b/test/practice-rectangles/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-rectangles/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-rectangles/representation.out b/test/practice-rectangles/representation.out new file mode 100644 index 0000000..afee252 --- /dev/null +++ b/test/practice-rectangles/representation.out @@ -0,0 +1,5573 @@ +## BEGIN NORMALIZED CODE ## +import itertools + + +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 + + def placeholder_4(self): + return "[" + str(self.placeholder_2) + ", " + str(self.placeholder_3) + "]" + + +def placeholder_5(placeholder_6, placeholder_7): + for placeholder_8 in placeholder_7: + if placeholder_8.placeholder_2 == placeholder_6: + return placeholder_8 + return None + + +def placeholder_9(placeholder_6, placeholder_7): + for placeholder_8 in placeholder_7: + if placeholder_8.placeholder_3 == placeholder_6: + return placeholder_8 + return None + + +def placeholder_10(placeholder_7): + return [ + placeholder_0(placeholder_11, placeholder_12) + for placeholder_11 in range(len(placeholder_7)) + for placeholder_12 in range(len(placeholder_7[placeholder_11])) + if placeholder_7[placeholder_11][placeholder_12] == "+" + ] + + +def placeholder_13(placeholder_14): + placeholder_15 = 0 + placeholder_16 = 0 + for placeholder_17 in placeholder_14: + placeholder_15 = placeholder_15 + placeholder_17.placeholder_2 / 4.0 + placeholder_16 = placeholder_16 + placeholder_17.placeholder_3 / 4.0 + placeholder_18 = abs(placeholder_14[0].placeholder_2 - placeholder_15) + placeholder_19 = abs(placeholder_14[0].placeholder_3 - placeholder_16) + for placeholder_2 in range(1, len(placeholder_14)): + if ( + abs(placeholder_14[placeholder_2].placeholder_2 - placeholder_15) + != placeholder_18 + or abs(placeholder_14[placeholder_2].placeholder_3 - placeholder_16) + != placeholder_19 + ): + return False + return True + + +def placeholder_20(placeholder_21, placeholder_22, placeholder_11): + if placeholder_21.placeholder_2 == placeholder_22.placeholder_2: + for placeholder_3 in range( + min(placeholder_21.placeholder_3 + 1, placeholder_22.placeholder_3 + 1), + max(placeholder_21.placeholder_3, placeholder_22.placeholder_3), + ): + if ( + placeholder_11[placeholder_21.placeholder_2][placeholder_3] != "-" + and placeholder_11[placeholder_21.placeholder_2][placeholder_3] != "+" + ): + return False + return True + elif placeholder_21.placeholder_3 == placeholder_22.placeholder_3: + for placeholder_2 in range( + min(placeholder_21.placeholder_2 + 1, placeholder_22.placeholder_2 + 1), + max(placeholder_21.placeholder_2, placeholder_22.placeholder_2), + ): + if ( + placeholder_11[placeholder_2][placeholder_21.placeholder_3] != "|" + and placeholder_11[placeholder_2][placeholder_21.placeholder_3] != "+" + ): + return False + return True + return None + + +def placeholder_23(placeholder_24, placeholder_11): + for placeholder_2, placeholder_25 in enumerate(placeholder_24): + placeholder_26 = placeholder_5( + placeholder_24[placeholder_2].placeholder_2, + placeholder_24[0:placeholder_2] + placeholder_24[placeholder_2 + 1 :], + ) + placeholder_27 = placeholder_9( + placeholder_24[placeholder_2].placeholder_3, + placeholder_24[0:placeholder_2] + placeholder_24[placeholder_2 + 1 :], + ) + if not placeholder_20( + placeholder_24[placeholder_2], placeholder_26, placeholder_11 + ) or not placeholder_20( + placeholder_24[placeholder_2], placeholder_27, placeholder_11 + ): + return False + return True + + +def placeholder_28(placeholder_29=""): + placeholder_30 = 0 + if not placeholder_29: + return placeholder_30 + placeholder_31 = placeholder_10(placeholder_29) + if not placeholder_31: + return placeholder_30 + placeholder_32 = list(itertools.combinations(placeholder_31, placeholder_33=4)) + placeholder_34 = ( + placeholder_14 + for placeholder_14 in placeholder_32 + if placeholder_13(placeholder_14) + ) + for placeholder_2 in placeholder_34: + if placeholder_23(placeholder_2, placeholder_29): + placeholder_30 += 1 + return placeholder_30 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'itertools', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=16)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16), + ClassDef( + 'Corners', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'idx', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=26), + arg( + 'jdx', + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'idx', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=16)], + Name( + 'idx', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=22), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'jdx', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=16)], + Name( + 'jdx', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=22), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + [], + lineno=5, + col_offset=4, + end_lineno=8, + end_col_offset=22), + FunctionDef( + '__str__', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + BinOp( + BinOp( + Constant( + '[', + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=18), + Add(), + Call( + Name( + 'str', + Load(), + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=24), + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=29), + 'idx', + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=33)], + [], + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=34), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=34), + Add(), + Constant( + ', ', + lineno=11, + col_offset=37, + end_lineno=11, + end_col_offset=41), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=41), + Add(), + Call( + Name( + 'str', + Load(), + lineno=11, + col_offset=44, + end_lineno=11, + end_col_offset=47), + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=48, + end_lineno=11, + end_col_offset=52), + 'jdx', + Load(), + lineno=11, + col_offset=48, + end_lineno=11, + end_col_offset=56)], + [], + lineno=11, + col_offset=44, + end_lineno=11, + end_col_offset=57), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=57), + Add(), + Constant( + ']', + lineno=11, + col_offset=60, + end_lineno=11, + end_col_offset=63), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=63), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=63)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=63)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=63), + FunctionDef( + 'same_line', + arguments( + [], + [ + arg( + 'index', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=19), + arg( + 'list_obj', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'corner', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=14), + Name( + 'list_obj', + Load(), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=26), + [ + If( + Compare( + Attribute( + Name( + 'corner', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=17), + 'idx', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=21), + [ + Eq()], + [ + Name( + 'index', + Load(), + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=30)], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=30), + [ + Return( + Name( + 'corner', + Load(), + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=25), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=25)], + [], + lineno=17, + col_offset=8, + end_lineno=18, + end_col_offset=25)], + [], + lineno=16, + col_offset=4, + end_lineno=18, + end_col_offset=25), + Return( + Constant( + None, + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=15), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=15)], + [], + lineno=15, + col_offset=0, + end_lineno=19, + end_col_offset=15), + FunctionDef( + 'same_col', + arguments( + [], + [ + arg( + 'index', + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=18), + arg( + 'list_obj', + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'corner', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=14), + Name( + 'list_obj', + Load(), + lineno=24, + col_offset=18, + end_lineno=24, + end_col_offset=26), + [ + If( + Compare( + Attribute( + Name( + 'corner', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=17), + 'jdx', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=21), + [ + Eq()], + [ + Name( + 'index', + Load(), + lineno=25, + col_offset=25, + end_lineno=25, + end_col_offset=30)], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=30), + [ + Return( + Name( + 'corner', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=25), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=25)], + [], + lineno=25, + col_offset=8, + end_lineno=26, + end_col_offset=25)], + [], + lineno=24, + col_offset=4, + end_lineno=26, + end_col_offset=25), + Return( + Constant( + None, + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=15), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=15)], + [], + lineno=23, + col_offset=0, + end_lineno=27, + end_col_offset=15), + FunctionDef( + 'search_corners', + arguments( + [], + [ + arg( + 'list_obj', + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'Corners', + Load(), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=19), + [ + Name( + 'item', + Load(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=24), + Name( + 'element', + Load(), + lineno=32, + col_offset=26, + end_lineno=32, + end_col_offset=33)], + [], + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=34), + [ + comprehension( + Name( + 'item', + Store(), + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=43), + Call( + Name( + 'range', + Load(), + lineno=32, + col_offset=47, + end_lineno=32, + end_col_offset=52), + [ + Call( + Name( + 'len', + Load(), + lineno=32, + col_offset=53, + end_lineno=32, + end_col_offset=56), + [ + Name( + 'list_obj', + Load(), + lineno=32, + col_offset=57, + end_lineno=32, + end_col_offset=65)], + [], + lineno=32, + col_offset=53, + end_lineno=32, + end_col_offset=66)], + [], + lineno=32, + col_offset=47, + end_lineno=32, + end_col_offset=67), + [], + 0), + comprehension( + Name( + 'element', + Store(), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=23), + Call( + Name( + 'range', + Load(), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=32), + [ + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=33, + end_lineno=33, + end_col_offset=36), + [ + Subscript( + Name( + 'list_obj', + Load(), + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=45), + Name( + 'item', + Load(), + lineno=33, + col_offset=46, + end_lineno=33, + end_col_offset=50), + Load(), + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=51)], + [], + lineno=33, + col_offset=33, + end_lineno=33, + end_col_offset=52)], + [], + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=53), + [ + Compare( + Subscript( + Subscript( + Name( + 'list_obj', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=23), + Name( + 'item', + Load(), + lineno=34, + col_offset=24, + end_lineno=34, + end_col_offset=28), + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=29), + Name( + 'element', + Load(), + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=37), + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=38), + [ + Eq()], + [ + Constant( + '+', + lineno=34, + col_offset=42, + end_lineno=34, + end_col_offset=45)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=45)], + 0)], + lineno=32, + col_offset=11, + end_lineno=34, + end_col_offset=46), + lineno=32, + col_offset=4, + end_lineno=34, + end_col_offset=46)], + [], + lineno=30, + col_offset=0, + end_lineno=34, + end_col_offset=46), + FunctionDef( + 'possible_rect', + arguments( + [], + [ + arg( + 'quartet', + lineno=39, + col_offset=18, + end_lineno=39, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'mid_x', + Store(), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=9)], + Constant( + 0, + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=13), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=13), + Assign( + [ + Name( + 'mid_y', + Store(), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=9)], + Constant( + 0, + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=13), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=13), + For( + Name( + 'centroid', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=16), + Name( + 'quartet', + Load(), + lineno=43, + col_offset=20, + end_lineno=43, + end_col_offset=27), + [ + Assign( + [ + Name( + 'mid_x', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=13)], + BinOp( + Name( + 'mid_x', + Load(), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=21), + Add(), + BinOp( + Attribute( + Name( + 'centroid', + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=32), + 'idx', + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=36), + Div(), + Constant( + 4.0, + lineno=44, + col_offset=39, + end_lineno=44, + end_col_offset=42), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=42), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=42), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=42), + Assign( + [ + Name( + 'mid_y', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=13)], + BinOp( + Name( + 'mid_y', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=21), + Add(), + BinOp( + Attribute( + Name( + 'centroid', + Load(), + lineno=45, + col_offset=24, + end_lineno=45, + end_col_offset=32), + 'jdx', + Load(), + lineno=45, + col_offset=24, + end_lineno=45, + end_col_offset=36), + Div(), + Constant( + 4.0, + lineno=45, + col_offset=39, + end_lineno=45, + end_col_offset=42), + lineno=45, + col_offset=24, + end_lineno=45, + end_col_offset=42), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=42), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=42)], + [], + lineno=43, + col_offset=4, + end_lineno=45, + end_col_offset=42), + Assign( + [ + Name( + 'dx', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=6)], + Call( + Name( + 'abs', + Load(), + lineno=48, + col_offset=9, + end_lineno=48, + end_col_offset=12), + [ + BinOp( + Attribute( + Subscript( + Name( + 'quartet', + Load(), + lineno=48, + col_offset=13, + end_lineno=48, + end_col_offset=20), + Constant( + 0, + lineno=48, + col_offset=21, + end_lineno=48, + end_col_offset=22), + Load(), + lineno=48, + col_offset=13, + end_lineno=48, + end_col_offset=23), + 'idx', + Load(), + lineno=48, + col_offset=13, + end_lineno=48, + end_col_offset=27), + Sub(), + Name( + 'mid_x', + Load(), + lineno=48, + col_offset=30, + end_lineno=48, + end_col_offset=35), + lineno=48, + col_offset=13, + end_lineno=48, + end_col_offset=35)], + [], + lineno=48, + col_offset=9, + end_lineno=48, + end_col_offset=36), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=36), + Assign( + [ + Name( + 'dy', + Store(), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=6)], + Call( + Name( + 'abs', + Load(), + lineno=49, + col_offset=9, + end_lineno=49, + end_col_offset=12), + [ + BinOp( + Attribute( + Subscript( + Name( + 'quartet', + Load(), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=20), + Constant( + 0, + lineno=49, + col_offset=21, + end_lineno=49, + end_col_offset=22), + Load(), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=23), + 'jdx', + Load(), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=27), + Sub(), + Name( + 'mid_y', + Load(), + lineno=49, + col_offset=30, + end_lineno=49, + end_col_offset=35), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=35)], + [], + lineno=49, + col_offset=9, + end_lineno=49, + end_col_offset=36), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=36), + For( + Name( + 'idx', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=20), + [ + Constant( + 1, + lineno=52, + col_offset=21, + end_lineno=52, + end_col_offset=22), + Call( + Name( + 'len', + Load(), + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=27), + [ + Name( + 'quartet', + Load(), + lineno=52, + col_offset=28, + end_lineno=52, + end_col_offset=35)], + [], + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=36)], + [], + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=37), + [ + If( + BoolOp( + Or(), + [ + Compare( + Call( + Name( + 'abs', + Load(), + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=14), + [ + BinOp( + Attribute( + Subscript( + Name( + 'quartet', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=22), + Name( + 'idx', + Load(), + lineno=53, + col_offset=23, + end_lineno=53, + end_col_offset=26), + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=27), + 'idx', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=31), + Sub(), + Name( + 'mid_x', + Load(), + lineno=53, + col_offset=34, + end_lineno=53, + end_col_offset=39), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=39)], + [], + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=40), + [ + NotEq()], + [ + Name( + 'dx', + Load(), + lineno=53, + col_offset=44, + end_lineno=53, + end_col_offset=46)], + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=46), + Compare( + Call( + Name( + 'abs', + Load(), + lineno=53, + col_offset=50, + end_lineno=53, + end_col_offset=53), + [ + BinOp( + Attribute( + Subscript( + Name( + 'quartet', + Load(), + lineno=53, + col_offset=54, + end_lineno=53, + end_col_offset=61), + Name( + 'idx', + Load(), + lineno=53, + col_offset=62, + end_lineno=53, + end_col_offset=65), + Load(), + lineno=53, + col_offset=54, + end_lineno=53, + end_col_offset=66), + 'jdx', + Load(), + lineno=53, + col_offset=54, + end_lineno=53, + end_col_offset=70), + Sub(), + Name( + 'mid_y', + Load(), + lineno=53, + col_offset=73, + end_lineno=53, + end_col_offset=78), + lineno=53, + col_offset=54, + end_lineno=53, + end_col_offset=78)], + [], + lineno=53, + col_offset=50, + end_lineno=53, + end_col_offset=79), + [ + NotEq()], + [ + Name( + 'dy', + Load(), + lineno=53, + col_offset=83, + end_lineno=53, + end_col_offset=85)], + lineno=53, + col_offset=50, + end_lineno=53, + end_col_offset=85)], + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=85), + [ + Return( + Constant( + False, + lineno=54, + col_offset=19, + end_lineno=54, + end_col_offset=24), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=24)], + [], + lineno=53, + col_offset=8, + end_lineno=54, + end_col_offset=24)], + [], + lineno=52, + col_offset=4, + end_lineno=54, + end_col_offset=24), + Return( + Constant( + True, + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=15), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=15)], + [], + lineno=39, + col_offset=0, + end_lineno=55, + end_col_offset=15), + FunctionDef( + 'path', + arguments( + [], + [ + arg( + 'corner1', + lineno=59, + col_offset=9, + end_lineno=59, + end_col_offset=16), + arg( + 'corner2', + lineno=59, + col_offset=18, + end_lineno=59, + end_col_offset=25), + arg( + 'item', + lineno=59, + col_offset=27, + end_lineno=59, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'corner1', + Load(), + lineno=60, + col_offset=7, + end_lineno=60, + end_col_offset=14), + 'idx', + Load(), + lineno=60, + col_offset=7, + end_lineno=60, + end_col_offset=18), + [ + Eq()], + [ + Attribute( + Name( + 'corner2', + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=29), + 'idx', + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=33)], + lineno=60, + col_offset=7, + end_lineno=60, + end_col_offset=33), + [ + For( + Name( + 'jdx', + Store(), + lineno=61, + col_offset=12, + end_lineno=61, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=61, + col_offset=19, + end_lineno=61, + end_col_offset=24), + [ + Call( + Name( + 'min', + Load(), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=28), + [ + BinOp( + Attribute( + Name( + 'corner1', + Load(), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=36), + 'jdx', + Load(), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=61, + col_offset=43, + end_lineno=61, + end_col_offset=44), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=44), + BinOp( + Attribute( + Name( + 'corner2', + Load(), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=53), + 'jdx', + Load(), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=57), + Add(), + Constant( + 1, + lineno=61, + col_offset=60, + end_lineno=61, + end_col_offset=61), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=61)], + [], + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=62), + Call( + Name( + 'max', + Load(), + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=26), + [ + Attribute( + Name( + 'corner1', + Load(), + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=34), + 'jdx', + Load(), + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=38), + Attribute( + Name( + 'corner2', + Load(), + lineno=62, + col_offset=40, + end_lineno=62, + end_col_offset=47), + 'jdx', + Load(), + lineno=62, + col_offset=40, + end_lineno=62, + end_col_offset=51)], + [], + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=52)], + [], + lineno=61, + col_offset=19, + end_lineno=62, + end_col_offset=53), + [ + If( + BoolOp( + And(), + [ + Compare( + Subscript( + Subscript( + Name( + 'item', + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=19), + Attribute( + Name( + 'corner1', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=27), + 'idx', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=31), + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=32), + Name( + 'jdx', + Load(), + lineno=63, + col_offset=33, + end_lineno=63, + end_col_offset=36), + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=37), + [ + NotEq()], + [ + Constant( + '-', + lineno=63, + col_offset=41, + end_lineno=63, + end_col_offset=44)], + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=44), + Compare( + Subscript( + Subscript( + Name( + 'item', + Load(), + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=53), + Attribute( + Name( + 'corner1', + Load(), + lineno=63, + col_offset=54, + end_lineno=63, + end_col_offset=61), + 'idx', + Load(), + lineno=63, + col_offset=54, + end_lineno=63, + end_col_offset=65), + Load(), + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=66), + Name( + 'jdx', + Load(), + lineno=63, + col_offset=67, + end_lineno=63, + end_col_offset=70), + Load(), + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=71), + [ + NotEq()], + [ + Constant( + '+', + lineno=63, + col_offset=75, + end_lineno=63, + end_col_offset=78)], + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=78)], + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=78), + [ + Return( + Constant( + False, + lineno=64, + col_offset=23, + end_lineno=64, + end_col_offset=28), + lineno=64, + col_offset=16, + end_lineno=64, + end_col_offset=28)], + [], + lineno=63, + col_offset=12, + end_lineno=64, + end_col_offset=28)], + [], + lineno=61, + col_offset=8, + end_lineno=64, + end_col_offset=28), + Return( + Constant( + True, + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=19), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=19)], + [ + If( + Compare( + Attribute( + Name( + 'corner1', + Load(), + lineno=67, + col_offset=9, + end_lineno=67, + end_col_offset=16), + 'jdx', + Load(), + lineno=67, + col_offset=9, + end_lineno=67, + end_col_offset=20), + [ + Eq()], + [ + Attribute( + Name( + 'corner2', + Load(), + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=31), + 'jdx', + Load(), + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=35)], + lineno=67, + col_offset=9, + end_lineno=67, + end_col_offset=35), + [ + For( + Name( + 'idx', + Store(), + lineno=68, + col_offset=12, + end_lineno=68, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=68, + col_offset=19, + end_lineno=68, + end_col_offset=24), + [ + Call( + Name( + 'min', + Load(), + lineno=68, + col_offset=25, + end_lineno=68, + end_col_offset=28), + [ + BinOp( + Attribute( + Name( + 'corner1', + Load(), + lineno=68, + col_offset=29, + end_lineno=68, + end_col_offset=36), + 'idx', + Load(), + lineno=68, + col_offset=29, + end_lineno=68, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=68, + col_offset=43, + end_lineno=68, + end_col_offset=44), + lineno=68, + col_offset=29, + end_lineno=68, + end_col_offset=44), + BinOp( + Attribute( + Name( + 'corner2', + Load(), + lineno=68, + col_offset=46, + end_lineno=68, + end_col_offset=53), + 'idx', + Load(), + lineno=68, + col_offset=46, + end_lineno=68, + end_col_offset=57), + Add(), + Constant( + 1, + lineno=68, + col_offset=60, + end_lineno=68, + end_col_offset=61), + lineno=68, + col_offset=46, + end_lineno=68, + end_col_offset=61)], + [], + lineno=68, + col_offset=25, + end_lineno=68, + end_col_offset=62), + Call( + Name( + 'max', + Load(), + lineno=69, + col_offset=23, + end_lineno=69, + end_col_offset=26), + [ + Attribute( + Name( + 'corner1', + Load(), + lineno=69, + col_offset=27, + end_lineno=69, + end_col_offset=34), + 'idx', + Load(), + lineno=69, + col_offset=27, + end_lineno=69, + end_col_offset=38), + Attribute( + Name( + 'corner2', + Load(), + lineno=69, + col_offset=40, + end_lineno=69, + end_col_offset=47), + 'idx', + Load(), + lineno=69, + col_offset=40, + end_lineno=69, + end_col_offset=51)], + [], + lineno=69, + col_offset=23, + end_lineno=69, + end_col_offset=52)], + [], + lineno=68, + col_offset=19, + end_lineno=69, + end_col_offset=53), + [ + If( + BoolOp( + And(), + [ + Compare( + Subscript( + Subscript( + Name( + 'item', + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=19), + Name( + 'idx', + Load(), + lineno=70, + col_offset=20, + end_lineno=70, + end_col_offset=23), + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=24), + Attribute( + Name( + 'corner1', + Load(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=32), + 'jdx', + Load(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=36), + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=37), + [ + NotEq()], + [ + Constant( + '|', + lineno=70, + col_offset=41, + end_lineno=70, + end_col_offset=44)], + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=44), + Compare( + Subscript( + Subscript( + Name( + 'item', + Load(), + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=53), + Name( + 'idx', + Load(), + lineno=70, + col_offset=54, + end_lineno=70, + end_col_offset=57), + Load(), + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=58), + Attribute( + Name( + 'corner1', + Load(), + lineno=70, + col_offset=59, + end_lineno=70, + end_col_offset=66), + 'jdx', + Load(), + lineno=70, + col_offset=59, + end_lineno=70, + end_col_offset=70), + Load(), + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=71), + [ + NotEq()], + [ + Constant( + '+', + lineno=70, + col_offset=75, + end_lineno=70, + end_col_offset=78)], + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=78)], + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=78), + [ + Return( + Constant( + False, + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=28), + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=28)], + [], + lineno=70, + col_offset=12, + end_lineno=71, + end_col_offset=28)], + [], + lineno=68, + col_offset=8, + end_lineno=71, + end_col_offset=28), + Return( + Constant( + True, + lineno=72, + col_offset=15, + end_lineno=72, + end_col_offset=19), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=19)], + [], + lineno=67, + col_offset=4, + end_lineno=72, + end_col_offset=19)], + lineno=60, + col_offset=4, + end_lineno=72, + end_col_offset=19), + Return( + Constant( + None, + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=15), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=15)], + [], + lineno=59, + col_offset=0, + end_lineno=73, + end_col_offset=15), + FunctionDef( + 'validate_rect', + arguments( + [], + [ + arg( + 'rectangle', + lineno=77, + col_offset=18, + end_lineno=77, + end_col_offset=27), + arg( + 'item', + lineno=77, + col_offset=29, + end_lineno=77, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=11), + Name( + '_', + Store(), + lineno=80, + col_offset=13, + end_lineno=80, + end_col_offset=14)], + Store(), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=14), + Call( + Name( + 'enumerate', + Load(), + lineno=80, + col_offset=18, + end_lineno=80, + end_col_offset=27), + [ + Name( + 'rectangle', + Load(), + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=37)], + [], + lineno=80, + col_offset=18, + end_lineno=80, + end_col_offset=38), + [ + Assign( + [ + Name( + 'line', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=12)], + Call( + Name( + 'same_line', + Load(), + lineno=81, + col_offset=15, + end_lineno=81, + end_col_offset=24), + [ + Attribute( + Subscript( + Name( + 'rectangle', + Load(), + lineno=81, + col_offset=25, + end_lineno=81, + end_col_offset=34), + Name( + 'idx', + Load(), + lineno=81, + col_offset=35, + end_lineno=81, + end_col_offset=38), + Load(), + lineno=81, + col_offset=25, + end_lineno=81, + end_col_offset=39), + 'idx', + Load(), + lineno=81, + col_offset=25, + end_lineno=81, + end_col_offset=43), + BinOp( + Subscript( + Name( + 'rectangle', + Load(), + lineno=81, + col_offset=45, + end_lineno=81, + end_col_offset=54), + Slice( + Constant( + 0, + lineno=81, + col_offset=55, + end_lineno=81, + end_col_offset=56), + Name( + 'idx', + Load(), + lineno=81, + col_offset=57, + end_lineno=81, + end_col_offset=60), + lineno=81, + col_offset=55, + end_lineno=81, + end_col_offset=60), + Load(), + lineno=81, + col_offset=45, + end_lineno=81, + end_col_offset=61), + Add(), + Subscript( + Name( + 'rectangle', + Load(), + lineno=81, + col_offset=64, + end_lineno=81, + end_col_offset=73), + Slice( + BinOp( + Name( + 'idx', + Load(), + lineno=81, + col_offset=74, + end_lineno=81, + end_col_offset=77), + Add(), + Constant( + 1, + lineno=81, + col_offset=80, + end_lineno=81, + end_col_offset=81), + lineno=81, + col_offset=74, + end_lineno=81, + end_col_offset=81), + lineno=81, + col_offset=74, + end_lineno=81, + end_col_offset=82), + Load(), + lineno=81, + col_offset=64, + end_lineno=81, + end_col_offset=83), + lineno=81, + col_offset=45, + end_lineno=81, + end_col_offset=83)], + [], + lineno=81, + col_offset=15, + end_lineno=81, + end_col_offset=84), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=84), + Assign( + [ + Name( + 'column', + Store(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=14)], + Call( + Name( + 'same_col', + Load(), + lineno=82, + col_offset=17, + end_lineno=82, + end_col_offset=25), + [ + Attribute( + Subscript( + Name( + 'rectangle', + Load(), + lineno=82, + col_offset=26, + end_lineno=82, + end_col_offset=35), + Name( + 'idx', + Load(), + lineno=82, + col_offset=36, + end_lineno=82, + end_col_offset=39), + Load(), + lineno=82, + col_offset=26, + end_lineno=82, + end_col_offset=40), + 'jdx', + Load(), + lineno=82, + col_offset=26, + end_lineno=82, + end_col_offset=44), + BinOp( + Subscript( + Name( + 'rectangle', + Load(), + lineno=82, + col_offset=46, + end_lineno=82, + end_col_offset=55), + Slice( + Constant( + 0, + lineno=82, + col_offset=56, + end_lineno=82, + end_col_offset=57), + Name( + 'idx', + Load(), + lineno=82, + col_offset=58, + end_lineno=82, + end_col_offset=61), + lineno=82, + col_offset=56, + end_lineno=82, + end_col_offset=61), + Load(), + lineno=82, + col_offset=46, + end_lineno=82, + end_col_offset=62), + Add(), + Subscript( + Name( + 'rectangle', + Load(), + lineno=82, + col_offset=65, + end_lineno=82, + end_col_offset=74), + Slice( + BinOp( + Name( + 'idx', + Load(), + lineno=82, + col_offset=75, + end_lineno=82, + end_col_offset=78), + Add(), + Constant( + 1, + lineno=82, + col_offset=81, + end_lineno=82, + end_col_offset=82), + lineno=82, + col_offset=75, + end_lineno=82, + end_col_offset=82), + lineno=82, + col_offset=75, + end_lineno=82, + end_col_offset=83), + Load(), + lineno=82, + col_offset=65, + end_lineno=82, + end_col_offset=84), + lineno=82, + col_offset=46, + end_lineno=82, + end_col_offset=84)], + [], + lineno=82, + col_offset=17, + end_lineno=82, + end_col_offset=85), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=85), + If( + BoolOp( + Or(), + [ + UnaryOp( + Not(), + Call( + Name( + 'path', + Load(), + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=19), + [ + Subscript( + Name( + 'rectangle', + Load(), + lineno=84, + col_offset=20, + end_lineno=84, + end_col_offset=29), + Name( + 'idx', + Load(), + lineno=84, + col_offset=30, + end_lineno=84, + end_col_offset=33), + Load(), + lineno=84, + col_offset=20, + end_lineno=84, + end_col_offset=34), + Name( + 'line', + Load(), + lineno=84, + col_offset=36, + end_lineno=84, + end_col_offset=40), + Name( + 'item', + Load(), + lineno=84, + col_offset=42, + end_lineno=84, + end_col_offset=46)], + [], + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=47), + lineno=84, + col_offset=11, + end_lineno=84, + end_col_offset=47), + UnaryOp( + Not(), + Call( + Name( + 'path', + Load(), + lineno=84, + col_offset=55, + end_lineno=84, + end_col_offset=59), + [ + Subscript( + Name( + 'rectangle', + Load(), + lineno=84, + col_offset=60, + end_lineno=84, + end_col_offset=69), + Name( + 'idx', + Load(), + lineno=84, + col_offset=70, + end_lineno=84, + end_col_offset=73), + Load(), + lineno=84, + col_offset=60, + end_lineno=84, + end_col_offset=74), + Name( + 'column', + Load(), + lineno=84, + col_offset=76, + end_lineno=84, + end_col_offset=82), + Name( + 'item', + Load(), + lineno=84, + col_offset=84, + end_lineno=84, + end_col_offset=88)], + [], + lineno=84, + col_offset=55, + end_lineno=84, + end_col_offset=89), + lineno=84, + col_offset=51, + end_lineno=84, + end_col_offset=89)], + lineno=84, + col_offset=11, + end_lineno=84, + end_col_offset=89), + [ + Return( + Constant( + False, + lineno=85, + col_offset=19, + end_lineno=85, + end_col_offset=24), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=24)], + [], + lineno=84, + col_offset=8, + end_lineno=85, + end_col_offset=24)], + [], + lineno=80, + col_offset=4, + end_lineno=85, + end_col_offset=24), + Return( + Constant( + True, + lineno=87, + col_offset=11, + end_lineno=87, + end_col_offset=15), + lineno=87, + col_offset=4, + end_lineno=87, + end_col_offset=15)], + [], + lineno=77, + col_offset=0, + end_lineno=87, + end_col_offset=15), + FunctionDef( + 'rectangles', + arguments( + [], + [ + arg( + 'strings', + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + '', + lineno=91, + col_offset=23, + end_lineno=91, + end_col_offset=25)]), + [ + Assign( + [ + Name( + 'rectangle_total', + Store(), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=19)], + Constant( + 0, + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=23), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=23), + If( + UnaryOp( + Not(), + Name( + 'strings', + Load(), + lineno=94, + col_offset=11, + end_lineno=94, + end_col_offset=18), + lineno=94, + col_offset=7, + end_lineno=94, + end_col_offset=18), + [ + Return( + Name( + 'rectangle_total', + Load(), + lineno=95, + col_offset=15, + end_lineno=95, + end_col_offset=30), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=30)], + [], + lineno=94, + col_offset=4, + end_lineno=95, + end_col_offset=30), + Assign( + [ + Name( + 'corners', + Store(), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=11)], + Call( + Name( + 'search_corners', + Load(), + lineno=97, + col_offset=14, + end_lineno=97, + end_col_offset=28), + [ + Name( + 'strings', + Load(), + lineno=97, + col_offset=29, + end_lineno=97, + end_col_offset=36)], + [], + lineno=97, + col_offset=14, + end_lineno=97, + end_col_offset=37), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=37), + If( + UnaryOp( + Not(), + Name( + 'corners', + Load(), + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=18), + lineno=100, + col_offset=7, + end_lineno=100, + end_col_offset=18), + [ + Return( + Name( + 'rectangle_total', + Load(), + lineno=101, + col_offset=15, + end_lineno=101, + end_col_offset=30), + lineno=101, + col_offset=8, + end_lineno=101, + end_col_offset=30)], + [], + lineno=100, + col_offset=4, + end_lineno=101, + end_col_offset=30), + Assign( + [ + Name( + 'quartets', + Store(), + lineno=104, + col_offset=4, + end_lineno=104, + end_col_offset=12)], + Call( + Name( + 'list', + Load(), + lineno=104, + col_offset=15, + end_lineno=104, + end_col_offset=19), + [ + Call( + Attribute( + Name( + 'itertools', + Load(), + lineno=104, + col_offset=20, + end_lineno=104, + end_col_offset=29), + 'combinations', + Load(), + lineno=104, + col_offset=20, + end_lineno=104, + end_col_offset=42), + [ + Name( + 'corners', + Load(), + lineno=104, + col_offset=43, + end_lineno=104, + end_col_offset=50)], + [ + keyword( + 'r', + Constant( + 4, + lineno=104, + col_offset=54, + end_lineno=104, + end_col_offset=55), + lineno=104, + col_offset=52, + end_lineno=104, + end_col_offset=55)], + lineno=104, + col_offset=20, + end_lineno=104, + end_col_offset=56)], + [], + lineno=104, + col_offset=15, + end_lineno=104, + end_col_offset=57), + lineno=104, + col_offset=4, + end_lineno=104, + end_col_offset=57), + Assign( + [ + Name( + 'paths', + Store(), + lineno=105, + col_offset=4, + end_lineno=105, + end_col_offset=9)], + GeneratorExp( + Name( + 'quartet', + Load(), + lineno=105, + col_offset=13, + end_lineno=105, + end_col_offset=20), + [ + comprehension( + Name( + 'quartet', + Store(), + lineno=105, + col_offset=25, + end_lineno=105, + end_col_offset=32), + Name( + 'quartets', + Load(), + lineno=105, + col_offset=36, + end_lineno=105, + end_col_offset=44), + [ + Call( + Name( + 'possible_rect', + Load(), + lineno=105, + col_offset=48, + end_lineno=105, + end_col_offset=61), + [ + Name( + 'quartet', + Load(), + lineno=105, + col_offset=62, + end_lineno=105, + end_col_offset=69)], + [], + lineno=105, + col_offset=48, + end_lineno=105, + end_col_offset=70)], + 0)], + lineno=105, + col_offset=12, + end_lineno=105, + end_col_offset=71), + lineno=105, + col_offset=4, + end_lineno=105, + end_col_offset=71), + For( + Name( + 'idx', + Store(), + lineno=108, + col_offset=8, + end_lineno=108, + end_col_offset=11), + Name( + 'paths', + Load(), + lineno=108, + col_offset=15, + end_lineno=108, + end_col_offset=20), + [ + If( + Call( + Name( + 'validate_rect', + Load(), + lineno=109, + col_offset=11, + end_lineno=109, + end_col_offset=24), + [ + Name( + 'idx', + Load(), + lineno=109, + col_offset=25, + end_lineno=109, + end_col_offset=28), + Name( + 'strings', + Load(), + lineno=109, + col_offset=30, + end_lineno=109, + end_col_offset=37)], + [], + lineno=109, + col_offset=11, + end_lineno=109, + end_col_offset=38), + [ + AugAssign( + Name( + 'rectangle_total', + Store(), + lineno=110, + col_offset=12, + end_lineno=110, + end_col_offset=27), + Add(), + Constant( + 1, + lineno=110, + col_offset=31, + end_lineno=110, + end_col_offset=32), + lineno=110, + col_offset=12, + end_lineno=110, + end_col_offset=32)], + [], + lineno=109, + col_offset=8, + end_lineno=110, + end_col_offset=32)], + [], + lineno=108, + col_offset=4, + end_lineno=110, + end_col_offset=32), + Return( + Name( + 'rectangle_total', + Load(), + lineno=111, + col_offset=11, + end_lineno=111, + end_col_offset=26), + lineno=111, + col_offset=4, + end_lineno=111, + end_col_offset=26)], + [], + lineno=91, + col_offset=0, + end_lineno=111, + end_col_offset=26)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'itertools', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=16)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=26), + arg( + 'placeholder_3', + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=16)], + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=19, + end_lineno=7, + end_col_offset=22), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=22), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=16)], + Name( + 'placeholder_3', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=22), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + [], + lineno=5, + col_offset=4, + end_lineno=8, + end_col_offset=22), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + BinOp( + BinOp( + Constant( + '[', + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=18), + Add(), + Call( + Name( + 'str', + Load(), + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=24), + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=29), + 'placeholder_2', + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=33)], + [], + lineno=11, + col_offset=21, + end_lineno=11, + end_col_offset=34), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=34), + Add(), + Constant( + ', ', + lineno=11, + col_offset=37, + end_lineno=11, + end_col_offset=41), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=41), + Add(), + Call( + Name( + 'str', + Load(), + lineno=11, + col_offset=44, + end_lineno=11, + end_col_offset=47), + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=48, + end_lineno=11, + end_col_offset=52), + 'placeholder_3', + Load(), + lineno=11, + col_offset=48, + end_lineno=11, + end_col_offset=56)], + [], + lineno=11, + col_offset=44, + end_lineno=11, + end_col_offset=57), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=57), + Add(), + Constant( + ']', + lineno=11, + col_offset=60, + end_lineno=11, + end_col_offset=63), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=63), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=63)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=63)], + [], + lineno=4, + col_offset=0, + end_lineno=11, + end_col_offset=63), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=19), + arg( + 'placeholder_7', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_8', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=14), + Name( + 'placeholder_7', + Load(), + lineno=16, + col_offset=18, + end_lineno=16, + end_col_offset=26), + [ + If( + Compare( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=17), + 'placeholder_2', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=21), + [ + Eq()], + [ + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=30)], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=30), + [ + Return( + Name( + 'placeholder_8', + Load(), + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=25), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=25)], + [], + lineno=17, + col_offset=8, + end_lineno=18, + end_col_offset=25)], + [], + lineno=16, + col_offset=4, + end_lineno=18, + end_col_offset=25), + Return( + Constant( + None, + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=15), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=15)], + [], + lineno=15, + col_offset=0, + end_lineno=19, + end_col_offset=15), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=23, + col_offset=13, + end_lineno=23, + end_col_offset=18), + arg( + 'placeholder_7', + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_8', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=14), + Name( + 'placeholder_7', + Load(), + lineno=24, + col_offset=18, + end_lineno=24, + end_col_offset=26), + [ + If( + Compare( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=17), + 'placeholder_3', + Load(), + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=21), + [ + Eq()], + [ + Name( + 'placeholder_6', + Load(), + lineno=25, + col_offset=25, + end_lineno=25, + end_col_offset=30)], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=30), + [ + Return( + Name( + 'placeholder_8', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=25), + lineno=26, + col_offset=12, + end_lineno=26, + end_col_offset=25)], + [], + lineno=25, + col_offset=8, + end_lineno=26, + end_col_offset=25)], + [], + lineno=24, + col_offset=4, + end_lineno=26, + end_col_offset=25), + Return( + Constant( + None, + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=15), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=15)], + [], + lineno=23, + col_offset=0, + end_lineno=27, + end_col_offset=15), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=19), + [ + Name( + 'placeholder_11', + Load(), + lineno=32, + col_offset=20, + end_lineno=32, + end_col_offset=24), + Name( + 'placeholder_12', + Load(), + lineno=32, + col_offset=26, + end_lineno=32, + end_col_offset=33)], + [], + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=34), + [ + comprehension( + Name( + 'placeholder_11', + Store(), + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=43), + Call( + Name( + 'range', + Load(), + lineno=32, + col_offset=47, + end_lineno=32, + end_col_offset=52), + [ + Call( + Name( + 'len', + Load(), + lineno=32, + col_offset=53, + end_lineno=32, + end_col_offset=56), + [ + Name( + 'placeholder_7', + Load(), + lineno=32, + col_offset=57, + end_lineno=32, + end_col_offset=65)], + [], + lineno=32, + col_offset=53, + end_lineno=32, + end_col_offset=66)], + [], + lineno=32, + col_offset=47, + end_lineno=32, + end_col_offset=67), + [], + 0), + comprehension( + Name( + 'placeholder_12', + Store(), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=23), + Call( + Name( + 'range', + Load(), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=32), + [ + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=33, + end_lineno=33, + end_col_offset=36), + [ + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=45), + Name( + 'placeholder_11', + Load(), + lineno=33, + col_offset=46, + end_lineno=33, + end_col_offset=50), + Load(), + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=51)], + [], + lineno=33, + col_offset=33, + end_lineno=33, + end_col_offset=52)], + [], + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=53), + [ + Compare( + Subscript( + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=23), + Name( + 'placeholder_11', + Load(), + lineno=34, + col_offset=24, + end_lineno=34, + end_col_offset=28), + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=29), + Name( + 'placeholder_12', + Load(), + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=37), + Load(), + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=38), + [ + Eq()], + [ + Constant( + '+', + lineno=34, + col_offset=42, + end_lineno=34, + end_col_offset=45)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=45)], + 0)], + lineno=32, + col_offset=11, + end_lineno=34, + end_col_offset=46), + lineno=32, + col_offset=4, + end_lineno=34, + end_col_offset=46)], + [], + lineno=30, + col_offset=0, + end_lineno=34, + end_col_offset=46), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=39, + col_offset=18, + end_lineno=39, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=9)], + Constant( + 0, + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=13), + lineno=40, + col_offset=4, + end_lineno=40, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=9)], + Constant( + 0, + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=13), + lineno=41, + col_offset=4, + end_lineno=41, + end_col_offset=13), + For( + Name( + 'placeholder_17', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=16), + Name( + 'placeholder_14', + Load(), + lineno=43, + col_offset=20, + end_lineno=43, + end_col_offset=27), + [ + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=13)], + BinOp( + Name( + 'placeholder_15', + Load(), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=21), + Add(), + BinOp( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=32), + 'placeholder_2', + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=36), + Div(), + Constant( + 4.0, + lineno=44, + col_offset=39, + end_lineno=44, + end_col_offset=42), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=42), + lineno=44, + col_offset=16, + end_lineno=44, + end_col_offset=42), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=13)], + BinOp( + Name( + 'placeholder_16', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=21), + Add(), + BinOp( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=45, + col_offset=24, + end_lineno=45, + end_col_offset=32), + 'placeholder_3', + Load(), + lineno=45, + col_offset=24, + end_lineno=45, + end_col_offset=36), + Div(), + Constant( + 4.0, + lineno=45, + col_offset=39, + end_lineno=45, + end_col_offset=42), + lineno=45, + col_offset=24, + end_lineno=45, + end_col_offset=42), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=42), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=42)], + [], + lineno=43, + col_offset=4, + end_lineno=45, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=6)], + Call( + Name( + 'abs', + Load(), + lineno=48, + col_offset=9, + end_lineno=48, + end_col_offset=12), + [ + BinOp( + Attribute( + Subscript( + Name( + 'placeholder_14', + Load(), + lineno=48, + col_offset=13, + end_lineno=48, + end_col_offset=20), + Constant( + 0, + lineno=48, + col_offset=21, + end_lineno=48, + end_col_offset=22), + Load(), + lineno=48, + col_offset=13, + end_lineno=48, + end_col_offset=23), + 'placeholder_2', + Load(), + lineno=48, + col_offset=13, + end_lineno=48, + end_col_offset=27), + Sub(), + Name( + 'placeholder_15', + Load(), + lineno=48, + col_offset=30, + end_lineno=48, + end_col_offset=35), + lineno=48, + col_offset=13, + end_lineno=48, + end_col_offset=35)], + [], + lineno=48, + col_offset=9, + end_lineno=48, + end_col_offset=36), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=36), + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=6)], + Call( + Name( + 'abs', + Load(), + lineno=49, + col_offset=9, + end_lineno=49, + end_col_offset=12), + [ + BinOp( + Attribute( + Subscript( + Name( + 'placeholder_14', + Load(), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=20), + Constant( + 0, + lineno=49, + col_offset=21, + end_lineno=49, + end_col_offset=22), + Load(), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=23), + 'placeholder_3', + Load(), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=27), + Sub(), + Name( + 'placeholder_16', + Load(), + lineno=49, + col_offset=30, + end_lineno=49, + end_col_offset=35), + lineno=49, + col_offset=13, + end_lineno=49, + end_col_offset=35)], + [], + lineno=49, + col_offset=9, + end_lineno=49, + end_col_offset=36), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=36), + For( + Name( + 'placeholder_2', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=20), + [ + Constant( + 1, + lineno=52, + col_offset=21, + end_lineno=52, + end_col_offset=22), + Call( + Name( + 'len', + Load(), + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=27), + [ + Name( + 'placeholder_14', + Load(), + lineno=52, + col_offset=28, + end_lineno=52, + end_col_offset=35)], + [], + lineno=52, + col_offset=24, + end_lineno=52, + end_col_offset=36)], + [], + lineno=52, + col_offset=15, + end_lineno=52, + end_col_offset=37), + [ + If( + BoolOp( + Or(), + [ + Compare( + Call( + Name( + 'abs', + Load(), + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=14), + [ + BinOp( + Attribute( + Subscript( + Name( + 'placeholder_14', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=22), + Name( + 'placeholder_2', + Load(), + lineno=53, + col_offset=23, + end_lineno=53, + end_col_offset=26), + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=27), + 'placeholder_2', + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=31), + Sub(), + Name( + 'placeholder_15', + Load(), + lineno=53, + col_offset=34, + end_lineno=53, + end_col_offset=39), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=39)], + [], + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=40), + [ + NotEq()], + [ + Name( + 'placeholder_18', + Load(), + lineno=53, + col_offset=44, + end_lineno=53, + end_col_offset=46)], + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=46), + Compare( + Call( + Name( + 'abs', + Load(), + lineno=53, + col_offset=50, + end_lineno=53, + end_col_offset=53), + [ + BinOp( + Attribute( + Subscript( + Name( + 'placeholder_14', + Load(), + lineno=53, + col_offset=54, + end_lineno=53, + end_col_offset=61), + Name( + 'placeholder_2', + Load(), + lineno=53, + col_offset=62, + end_lineno=53, + end_col_offset=65), + Load(), + lineno=53, + col_offset=54, + end_lineno=53, + end_col_offset=66), + 'placeholder_3', + Load(), + lineno=53, + col_offset=54, + end_lineno=53, + end_col_offset=70), + Sub(), + Name( + 'placeholder_16', + Load(), + lineno=53, + col_offset=73, + end_lineno=53, + end_col_offset=78), + lineno=53, + col_offset=54, + end_lineno=53, + end_col_offset=78)], + [], + lineno=53, + col_offset=50, + end_lineno=53, + end_col_offset=79), + [ + NotEq()], + [ + Name( + 'placeholder_19', + Load(), + lineno=53, + col_offset=83, + end_lineno=53, + end_col_offset=85)], + lineno=53, + col_offset=50, + end_lineno=53, + end_col_offset=85)], + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=85), + [ + Return( + Constant( + False, + lineno=54, + col_offset=19, + end_lineno=54, + end_col_offset=24), + lineno=54, + col_offset=12, + end_lineno=54, + end_col_offset=24)], + [], + lineno=53, + col_offset=8, + end_lineno=54, + end_col_offset=24)], + [], + lineno=52, + col_offset=4, + end_lineno=54, + end_col_offset=24), + Return( + Constant( + True, + lineno=55, + col_offset=11, + end_lineno=55, + end_col_offset=15), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=15)], + [], + lineno=39, + col_offset=0, + end_lineno=55, + end_col_offset=15), + FunctionDef( + 'placeholder_20', + arguments( + [], + [ + arg( + 'placeholder_21', + lineno=59, + col_offset=9, + end_lineno=59, + end_col_offset=16), + arg( + 'placeholder_22', + lineno=59, + col_offset=18, + end_lineno=59, + end_col_offset=25), + arg( + 'placeholder_11', + lineno=59, + col_offset=27, + end_lineno=59, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=60, + col_offset=7, + end_lineno=60, + end_col_offset=14), + 'placeholder_2', + Load(), + lineno=60, + col_offset=7, + end_lineno=60, + end_col_offset=18), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=29), + 'placeholder_2', + Load(), + lineno=60, + col_offset=22, + end_lineno=60, + end_col_offset=33)], + lineno=60, + col_offset=7, + end_lineno=60, + end_col_offset=33), + [ + For( + Name( + 'placeholder_3', + Store(), + lineno=61, + col_offset=12, + end_lineno=61, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=61, + col_offset=19, + end_lineno=61, + end_col_offset=24), + [ + Call( + Name( + 'min', + Load(), + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=28), + [ + BinOp( + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=36), + 'placeholder_3', + Load(), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=61, + col_offset=43, + end_lineno=61, + end_col_offset=44), + lineno=61, + col_offset=29, + end_lineno=61, + end_col_offset=44), + BinOp( + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=53), + 'placeholder_3', + Load(), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=57), + Add(), + Constant( + 1, + lineno=61, + col_offset=60, + end_lineno=61, + end_col_offset=61), + lineno=61, + col_offset=46, + end_lineno=61, + end_col_offset=61)], + [], + lineno=61, + col_offset=25, + end_lineno=61, + end_col_offset=62), + Call( + Name( + 'max', + Load(), + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=26), + [ + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=34), + 'placeholder_3', + Load(), + lineno=62, + col_offset=27, + end_lineno=62, + end_col_offset=38), + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=62, + col_offset=40, + end_lineno=62, + end_col_offset=47), + 'placeholder_3', + Load(), + lineno=62, + col_offset=40, + end_lineno=62, + end_col_offset=51)], + [], + lineno=62, + col_offset=23, + end_lineno=62, + end_col_offset=52)], + [], + lineno=61, + col_offset=19, + end_lineno=62, + end_col_offset=53), + [ + If( + BoolOp( + And(), + [ + Compare( + Subscript( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=19), + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=27), + 'placeholder_2', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=31), + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=32), + Name( + 'placeholder_3', + Load(), + lineno=63, + col_offset=33, + end_lineno=63, + end_col_offset=36), + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=37), + [ + NotEq()], + [ + Constant( + '-', + lineno=63, + col_offset=41, + end_lineno=63, + end_col_offset=44)], + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=44), + Compare( + Subscript( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=53), + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=63, + col_offset=54, + end_lineno=63, + end_col_offset=61), + 'placeholder_2', + Load(), + lineno=63, + col_offset=54, + end_lineno=63, + end_col_offset=65), + Load(), + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=66), + Name( + 'placeholder_3', + Load(), + lineno=63, + col_offset=67, + end_lineno=63, + end_col_offset=70), + Load(), + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=71), + [ + NotEq()], + [ + Constant( + '+', + lineno=63, + col_offset=75, + end_lineno=63, + end_col_offset=78)], + lineno=63, + col_offset=49, + end_lineno=63, + end_col_offset=78)], + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=78), + [ + Return( + Constant( + False, + lineno=64, + col_offset=23, + end_lineno=64, + end_col_offset=28), + lineno=64, + col_offset=16, + end_lineno=64, + end_col_offset=28)], + [], + lineno=63, + col_offset=12, + end_lineno=64, + end_col_offset=28)], + [], + lineno=61, + col_offset=8, + end_lineno=64, + end_col_offset=28), + Return( + Constant( + True, + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=19), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=19)], + [ + If( + Compare( + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=67, + col_offset=9, + end_lineno=67, + end_col_offset=16), + 'placeholder_3', + Load(), + lineno=67, + col_offset=9, + end_lineno=67, + end_col_offset=20), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=31), + 'placeholder_3', + Load(), + lineno=67, + col_offset=24, + end_lineno=67, + end_col_offset=35)], + lineno=67, + col_offset=9, + end_lineno=67, + end_col_offset=35), + [ + For( + Name( + 'placeholder_2', + Store(), + lineno=68, + col_offset=12, + end_lineno=68, + end_col_offset=15), + Call( + Name( + 'range', + Load(), + lineno=68, + col_offset=19, + end_lineno=68, + end_col_offset=24), + [ + Call( + Name( + 'min', + Load(), + lineno=68, + col_offset=25, + end_lineno=68, + end_col_offset=28), + [ + BinOp( + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=68, + col_offset=29, + end_lineno=68, + end_col_offset=36), + 'placeholder_2', + Load(), + lineno=68, + col_offset=29, + end_lineno=68, + end_col_offset=40), + Add(), + Constant( + 1, + lineno=68, + col_offset=43, + end_lineno=68, + end_col_offset=44), + lineno=68, + col_offset=29, + end_lineno=68, + end_col_offset=44), + BinOp( + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=68, + col_offset=46, + end_lineno=68, + end_col_offset=53), + 'placeholder_2', + Load(), + lineno=68, + col_offset=46, + end_lineno=68, + end_col_offset=57), + Add(), + Constant( + 1, + lineno=68, + col_offset=60, + end_lineno=68, + end_col_offset=61), + lineno=68, + col_offset=46, + end_lineno=68, + end_col_offset=61)], + [], + lineno=68, + col_offset=25, + end_lineno=68, + end_col_offset=62), + Call( + Name( + 'max', + Load(), + lineno=69, + col_offset=23, + end_lineno=69, + end_col_offset=26), + [ + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=69, + col_offset=27, + end_lineno=69, + end_col_offset=34), + 'placeholder_2', + Load(), + lineno=69, + col_offset=27, + end_lineno=69, + end_col_offset=38), + Attribute( + Name( + 'placeholder_22', + Load(), + lineno=69, + col_offset=40, + end_lineno=69, + end_col_offset=47), + 'placeholder_2', + Load(), + lineno=69, + col_offset=40, + end_lineno=69, + end_col_offset=51)], + [], + lineno=69, + col_offset=23, + end_lineno=69, + end_col_offset=52)], + [], + lineno=68, + col_offset=19, + end_lineno=69, + end_col_offset=53), + [ + If( + BoolOp( + And(), + [ + Compare( + Subscript( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=19), + Name( + 'placeholder_2', + Load(), + lineno=70, + col_offset=20, + end_lineno=70, + end_col_offset=23), + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=24), + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=32), + 'placeholder_3', + Load(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=36), + Load(), + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=37), + [ + NotEq()], + [ + Constant( + '|', + lineno=70, + col_offset=41, + end_lineno=70, + end_col_offset=44)], + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=44), + Compare( + Subscript( + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=53), + Name( + 'placeholder_2', + Load(), + lineno=70, + col_offset=54, + end_lineno=70, + end_col_offset=57), + Load(), + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=58), + Attribute( + Name( + 'placeholder_21', + Load(), + lineno=70, + col_offset=59, + end_lineno=70, + end_col_offset=66), + 'placeholder_3', + Load(), + lineno=70, + col_offset=59, + end_lineno=70, + end_col_offset=70), + Load(), + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=71), + [ + NotEq()], + [ + Constant( + '+', + lineno=70, + col_offset=75, + end_lineno=70, + end_col_offset=78)], + lineno=70, + col_offset=49, + end_lineno=70, + end_col_offset=78)], + lineno=70, + col_offset=15, + end_lineno=70, + end_col_offset=78), + [ + Return( + Constant( + False, + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=28), + lineno=71, + col_offset=16, + end_lineno=71, + end_col_offset=28)], + [], + lineno=70, + col_offset=12, + end_lineno=71, + end_col_offset=28)], + [], + lineno=68, + col_offset=8, + end_lineno=71, + end_col_offset=28), + Return( + Constant( + True, + lineno=72, + col_offset=15, + end_lineno=72, + end_col_offset=19), + lineno=72, + col_offset=8, + end_lineno=72, + end_col_offset=19)], + [], + lineno=67, + col_offset=4, + end_lineno=72, + end_col_offset=19)], + lineno=60, + col_offset=4, + end_lineno=72, + end_col_offset=19), + Return( + Constant( + None, + lineno=73, + col_offset=11, + end_lineno=73, + end_col_offset=15), + lineno=73, + col_offset=4, + end_lineno=73, + end_col_offset=15)], + [], + lineno=59, + col_offset=0, + end_lineno=73, + end_col_offset=15), + FunctionDef( + 'placeholder_23', + arguments( + [], + [ + arg( + 'placeholder_24', + lineno=77, + col_offset=18, + end_lineno=77, + end_col_offset=27), + arg( + 'placeholder_11', + lineno=77, + col_offset=29, + end_lineno=77, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Tuple( + [ + Name( + 'placeholder_2', + Store(), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=11), + Name( + 'placeholder_25', + Store(), + lineno=80, + col_offset=13, + end_lineno=80, + end_col_offset=14)], + Store(), + lineno=80, + col_offset=8, + end_lineno=80, + end_col_offset=14), + Call( + Name( + 'enumerate', + Load(), + lineno=80, + col_offset=18, + end_lineno=80, + end_col_offset=27), + [ + Name( + 'placeholder_24', + Load(), + lineno=80, + col_offset=28, + end_lineno=80, + end_col_offset=37)], + [], + lineno=80, + col_offset=18, + end_lineno=80, + end_col_offset=38), + [ + Assign( + [ + Name( + 'placeholder_26', + Store(), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=12)], + Call( + Name( + 'placeholder_5', + Load(), + lineno=81, + col_offset=15, + end_lineno=81, + end_col_offset=24), + [ + Attribute( + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=81, + col_offset=25, + end_lineno=81, + end_col_offset=34), + Name( + 'placeholder_2', + Load(), + lineno=81, + col_offset=35, + end_lineno=81, + end_col_offset=38), + Load(), + lineno=81, + col_offset=25, + end_lineno=81, + end_col_offset=39), + 'placeholder_2', + Load(), + lineno=81, + col_offset=25, + end_lineno=81, + end_col_offset=43), + BinOp( + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=81, + col_offset=45, + end_lineno=81, + end_col_offset=54), + Slice( + Constant( + 0, + lineno=81, + col_offset=55, + end_lineno=81, + end_col_offset=56), + Name( + 'placeholder_2', + Load(), + lineno=81, + col_offset=57, + end_lineno=81, + end_col_offset=60), + lineno=81, + col_offset=55, + end_lineno=81, + end_col_offset=60), + Load(), + lineno=81, + col_offset=45, + end_lineno=81, + end_col_offset=61), + Add(), + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=81, + col_offset=64, + end_lineno=81, + end_col_offset=73), + Slice( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=81, + col_offset=74, + end_lineno=81, + end_col_offset=77), + Add(), + Constant( + 1, + lineno=81, + col_offset=80, + end_lineno=81, + end_col_offset=81), + lineno=81, + col_offset=74, + end_lineno=81, + end_col_offset=81), + lineno=81, + col_offset=74, + end_lineno=81, + end_col_offset=82), + Load(), + lineno=81, + col_offset=64, + end_lineno=81, + end_col_offset=83), + lineno=81, + col_offset=45, + end_lineno=81, + end_col_offset=83)], + [], + lineno=81, + col_offset=15, + end_lineno=81, + end_col_offset=84), + lineno=81, + col_offset=8, + end_lineno=81, + end_col_offset=84), + Assign( + [ + Name( + 'placeholder_27', + Store(), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=14)], + Call( + Name( + 'placeholder_9', + Load(), + lineno=82, + col_offset=17, + end_lineno=82, + end_col_offset=25), + [ + Attribute( + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=82, + col_offset=26, + end_lineno=82, + end_col_offset=35), + Name( + 'placeholder_2', + Load(), + lineno=82, + col_offset=36, + end_lineno=82, + end_col_offset=39), + Load(), + lineno=82, + col_offset=26, + end_lineno=82, + end_col_offset=40), + 'placeholder_3', + Load(), + lineno=82, + col_offset=26, + end_lineno=82, + end_col_offset=44), + BinOp( + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=82, + col_offset=46, + end_lineno=82, + end_col_offset=55), + Slice( + Constant( + 0, + lineno=82, + col_offset=56, + end_lineno=82, + end_col_offset=57), + Name( + 'placeholder_2', + Load(), + lineno=82, + col_offset=58, + end_lineno=82, + end_col_offset=61), + lineno=82, + col_offset=56, + end_lineno=82, + end_col_offset=61), + Load(), + lineno=82, + col_offset=46, + end_lineno=82, + end_col_offset=62), + Add(), + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=82, + col_offset=65, + end_lineno=82, + end_col_offset=74), + Slice( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=82, + col_offset=75, + end_lineno=82, + end_col_offset=78), + Add(), + Constant( + 1, + lineno=82, + col_offset=81, + end_lineno=82, + end_col_offset=82), + lineno=82, + col_offset=75, + end_lineno=82, + end_col_offset=82), + lineno=82, + col_offset=75, + end_lineno=82, + end_col_offset=83), + Load(), + lineno=82, + col_offset=65, + end_lineno=82, + end_col_offset=84), + lineno=82, + col_offset=46, + end_lineno=82, + end_col_offset=84)], + [], + lineno=82, + col_offset=17, + end_lineno=82, + end_col_offset=85), + lineno=82, + col_offset=8, + end_lineno=82, + end_col_offset=85), + If( + BoolOp( + Or(), + [ + UnaryOp( + Not(), + Call( + Name( + 'placeholder_20', + Load(), + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=19), + [ + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=84, + col_offset=20, + end_lineno=84, + end_col_offset=29), + Name( + 'placeholder_2', + Load(), + lineno=84, + col_offset=30, + end_lineno=84, + end_col_offset=33), + Load(), + lineno=84, + col_offset=20, + end_lineno=84, + end_col_offset=34), + Name( + 'placeholder_26', + Load(), + lineno=84, + col_offset=36, + end_lineno=84, + end_col_offset=40), + Name( + 'placeholder_11', + Load(), + lineno=84, + col_offset=42, + end_lineno=84, + end_col_offset=46)], + [], + lineno=84, + col_offset=15, + end_lineno=84, + end_col_offset=47), + lineno=84, + col_offset=11, + end_lineno=84, + end_col_offset=47), + UnaryOp( + Not(), + Call( + Name( + 'placeholder_20', + Load(), + lineno=84, + col_offset=55, + end_lineno=84, + end_col_offset=59), + [ + Subscript( + Name( + 'placeholder_24', + Load(), + lineno=84, + col_offset=60, + end_lineno=84, + end_col_offset=69), + Name( + 'placeholder_2', + Load(), + lineno=84, + col_offset=70, + end_lineno=84, + end_col_offset=73), + Load(), + lineno=84, + col_offset=60, + end_lineno=84, + end_col_offset=74), + Name( + 'placeholder_27', + Load(), + lineno=84, + col_offset=76, + end_lineno=84, + end_col_offset=82), + Name( + 'placeholder_11', + Load(), + lineno=84, + col_offset=84, + end_lineno=84, + end_col_offset=88)], + [], + lineno=84, + col_offset=55, + end_lineno=84, + end_col_offset=89), + lineno=84, + col_offset=51, + end_lineno=84, + end_col_offset=89)], + lineno=84, + col_offset=11, + end_lineno=84, + end_col_offset=89), + [ + Return( + Constant( + False, + lineno=85, + col_offset=19, + end_lineno=85, + end_col_offset=24), + lineno=85, + col_offset=12, + end_lineno=85, + end_col_offset=24)], + [], + lineno=84, + col_offset=8, + end_lineno=85, + end_col_offset=24)], + [], + lineno=80, + col_offset=4, + end_lineno=85, + end_col_offset=24), + Return( + Constant( + True, + lineno=87, + col_offset=11, + end_lineno=87, + end_col_offset=15), + lineno=87, + col_offset=4, + end_lineno=87, + end_col_offset=15)], + [], + lineno=77, + col_offset=0, + end_lineno=87, + end_col_offset=15), + FunctionDef( + 'placeholder_28', + arguments( + [], + [ + arg( + 'placeholder_29', + lineno=91, + col_offset=15, + end_lineno=91, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + '', + lineno=91, + col_offset=23, + end_lineno=91, + end_col_offset=25)]), + [ + Assign( + [ + Name( + 'placeholder_30', + Store(), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=19)], + Constant( + 0, + lineno=92, + col_offset=22, + end_lineno=92, + end_col_offset=23), + lineno=92, + col_offset=4, + end_lineno=92, + end_col_offset=23), + If( + UnaryOp( + Not(), + Name( + 'placeholder_29', + Load(), + lineno=94, + col_offset=11, + end_lineno=94, + end_col_offset=18), + lineno=94, + col_offset=7, + end_lineno=94, + end_col_offset=18), + [ + Return( + Name( + 'placeholder_30', + Load(), + lineno=95, + col_offset=15, + end_lineno=95, + end_col_offset=30), + lineno=95, + col_offset=8, + end_lineno=95, + end_col_offset=30)], + [], + lineno=94, + col_offset=4, + end_lineno=95, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_31', + Store(), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=11)], + Call( + Name( + 'placeholder_10', + Load(), + lineno=97, + col_offset=14, + end_lineno=97, + end_col_offset=28), + [ + Name( + 'placeholder_29', + Load(), + lineno=97, + col_offset=29, + end_lineno=97, + end_col_offset=36)], + [], + lineno=97, + col_offset=14, + end_lineno=97, + end_col_offset=37), + lineno=97, + col_offset=4, + end_lineno=97, + end_col_offset=37), + If( + UnaryOp( + Not(), + Name( + 'placeholder_31', + Load(), + lineno=100, + col_offset=11, + end_lineno=100, + end_col_offset=18), + lineno=100, + col_offset=7, + end_lineno=100, + end_col_offset=18), + [ + Return( + Name( + 'placeholder_30', + Load(), + lineno=101, + col_offset=15, + end_lineno=101, + end_col_offset=30), + lineno=101, + col_offset=8, + end_lineno=101, + end_col_offset=30)], + [], + lineno=100, + col_offset=4, + end_lineno=101, + end_col_offset=30), + Assign( + [ + Name( + 'placeholder_32', + Store(), + lineno=104, + col_offset=4, + end_lineno=104, + end_col_offset=12)], + Call( + Name( + 'list', + Load(), + lineno=104, + col_offset=15, + end_lineno=104, + end_col_offset=19), + [ + Call( + Attribute( + Name( + 'itertools', + Load(), + lineno=104, + col_offset=20, + end_lineno=104, + end_col_offset=29), + 'combinations', + Load(), + lineno=104, + col_offset=20, + end_lineno=104, + end_col_offset=42), + [ + Name( + 'placeholder_31', + Load(), + lineno=104, + col_offset=43, + end_lineno=104, + end_col_offset=50)], + [ + keyword( + 'placeholder_33', + Constant( + 4, + lineno=104, + col_offset=54, + end_lineno=104, + end_col_offset=55), + lineno=104, + col_offset=52, + end_lineno=104, + end_col_offset=55)], + lineno=104, + col_offset=20, + end_lineno=104, + end_col_offset=56)], + [], + lineno=104, + col_offset=15, + end_lineno=104, + end_col_offset=57), + lineno=104, + col_offset=4, + end_lineno=104, + end_col_offset=57), + Assign( + [ + Name( + 'placeholder_34', + Store(), + lineno=105, + col_offset=4, + end_lineno=105, + end_col_offset=9)], + GeneratorExp( + Name( + 'placeholder_14', + Load(), + lineno=105, + col_offset=13, + end_lineno=105, + end_col_offset=20), + [ + comprehension( + Name( + 'placeholder_14', + Store(), + lineno=105, + col_offset=25, + end_lineno=105, + end_col_offset=32), + Name( + 'placeholder_32', + Load(), + lineno=105, + col_offset=36, + end_lineno=105, + end_col_offset=44), + [ + Call( + Name( + 'placeholder_13', + Load(), + lineno=105, + col_offset=48, + end_lineno=105, + end_col_offset=61), + [ + Name( + 'placeholder_14', + Load(), + lineno=105, + col_offset=62, + end_lineno=105, + end_col_offset=69)], + [], + lineno=105, + col_offset=48, + end_lineno=105, + end_col_offset=70)], + 0)], + lineno=105, + col_offset=12, + end_lineno=105, + end_col_offset=71), + lineno=105, + col_offset=4, + end_lineno=105, + end_col_offset=71), + For( + Name( + 'placeholder_2', + Store(), + lineno=108, + col_offset=8, + end_lineno=108, + end_col_offset=11), + Name( + 'placeholder_34', + Load(), + lineno=108, + col_offset=15, + end_lineno=108, + end_col_offset=20), + [ + If( + Call( + Name( + 'placeholder_23', + Load(), + lineno=109, + col_offset=11, + end_lineno=109, + end_col_offset=24), + [ + Name( + 'placeholder_2', + Load(), + lineno=109, + col_offset=25, + end_lineno=109, + end_col_offset=28), + Name( + 'placeholder_29', + Load(), + lineno=109, + col_offset=30, + end_lineno=109, + end_col_offset=37)], + [], + lineno=109, + col_offset=11, + end_lineno=109, + end_col_offset=38), + [ + AugAssign( + Name( + 'placeholder_30', + Store(), + lineno=110, + col_offset=12, + end_lineno=110, + end_col_offset=27), + Add(), + Constant( + 1, + lineno=110, + col_offset=31, + end_lineno=110, + end_col_offset=32), + lineno=110, + col_offset=12, + end_lineno=110, + end_col_offset=32)], + [], + lineno=109, + col_offset=8, + end_lineno=110, + end_col_offset=32)], + [], + lineno=108, + col_offset=4, + end_lineno=110, + end_col_offset=32), + Return( + Name( + 'placeholder_30', + Load(), + lineno=111, + col_offset=11, + end_lineno=111, + end_col_offset=26), + lineno=111, + col_offset=4, + end_lineno=111, + end_col_offset=26)], + [], + lineno=91, + col_offset=0, + end_lineno=111, + end_col_offset=26)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-rectangles/representation.txt b/test/practice-rectangles/representation.txt new file mode 100644 index 0000000..b09a189 --- /dev/null +++ b/test/practice-rectangles/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('itertools', lineno=1, col_offset=7, end_lineno=1, end_col_offset=16)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=16), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21), arg('placeholder_2', lineno=5, col_offset=23, end_lineno=5, end_col_offset=26), arg('placeholder_3', lineno=5, col_offset=28, end_lineno=5, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_2', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=16)], Name('placeholder_2', Load(), lineno=7, col_offset=19, end_lineno=7, end_col_offset=22), lineno=7, col_offset=8, end_lineno=7, end_col_offset=22), Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_3', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=16)], Name('placeholder_3', Load(), lineno=8, col_offset=19, end_lineno=8, end_col_offset=22), lineno=8, col_offset=8, end_lineno=8, end_col_offset=22)], [], lineno=5, col_offset=4, end_lineno=8, end_col_offset=22), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=10, col_offset=16, end_lineno=10, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(BinOp(BinOp(BinOp(Constant('[', lineno=11, col_offset=15, end_lineno=11, end_col_offset=18), Add(), Call(Name('str', Load(), lineno=11, col_offset=21, end_lineno=11, end_col_offset=24), [Attribute(Name('self', Load(), lineno=11, col_offset=25, end_lineno=11, end_col_offset=29), 'placeholder_2', Load(), lineno=11, col_offset=25, end_lineno=11, end_col_offset=33)], [], lineno=11, col_offset=21, end_lineno=11, end_col_offset=34), lineno=11, col_offset=15, end_lineno=11, end_col_offset=34), Add(), Constant(', ', lineno=11, col_offset=37, end_lineno=11, end_col_offset=41), lineno=11, col_offset=15, end_lineno=11, end_col_offset=41), Add(), Call(Name('str', Load(), lineno=11, col_offset=44, end_lineno=11, end_col_offset=47), [Attribute(Name('self', Load(), lineno=11, col_offset=48, end_lineno=11, end_col_offset=52), 'placeholder_3', Load(), lineno=11, col_offset=48, end_lineno=11, end_col_offset=56)], [], lineno=11, col_offset=44, end_lineno=11, end_col_offset=57), lineno=11, col_offset=15, end_lineno=11, end_col_offset=57), Add(), Constant(']', lineno=11, col_offset=60, end_lineno=11, end_col_offset=63), lineno=11, col_offset=15, end_lineno=11, end_col_offset=63), lineno=11, col_offset=8, end_lineno=11, end_col_offset=63)], [], lineno=10, col_offset=4, end_lineno=11, end_col_offset=63)], [], lineno=4, col_offset=0, end_lineno=11, end_col_offset=63), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=15, col_offset=14, end_lineno=15, end_col_offset=19), arg('placeholder_7', lineno=15, col_offset=21, end_lineno=15, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_8', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=14), Name('placeholder_7', Load(), lineno=16, col_offset=18, end_lineno=16, end_col_offset=26), [If(Compare(Attribute(Name('placeholder_8', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=17), 'placeholder_2', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=21), [Eq()], [Name('placeholder_6', Load(), lineno=17, col_offset=25, end_lineno=17, end_col_offset=30)], lineno=17, col_offset=11, end_lineno=17, end_col_offset=30), [Return(Name('placeholder_8', Load(), lineno=18, col_offset=19, end_lineno=18, end_col_offset=25), lineno=18, col_offset=12, end_lineno=18, end_col_offset=25)], [], lineno=17, col_offset=8, end_lineno=18, end_col_offset=25)], [], lineno=16, col_offset=4, end_lineno=18, end_col_offset=25), Return(Constant(None, lineno=19, col_offset=11, end_lineno=19, end_col_offset=15), lineno=19, col_offset=4, end_lineno=19, end_col_offset=15)], [], lineno=15, col_offset=0, end_lineno=19, end_col_offset=15), FunctionDef('placeholder_9', arguments([], [arg('placeholder_6', lineno=23, col_offset=13, end_lineno=23, end_col_offset=18), arg('placeholder_7', lineno=23, col_offset=20, end_lineno=23, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_8', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=14), Name('placeholder_7', Load(), lineno=24, col_offset=18, end_lineno=24, end_col_offset=26), [If(Compare(Attribute(Name('placeholder_8', Load(), lineno=25, col_offset=11, end_lineno=25, end_col_offset=17), 'placeholder_3', Load(), lineno=25, col_offset=11, end_lineno=25, end_col_offset=21), [Eq()], [Name('placeholder_6', Load(), lineno=25, col_offset=25, end_lineno=25, end_col_offset=30)], lineno=25, col_offset=11, end_lineno=25, end_col_offset=30), [Return(Name('placeholder_8', Load(), lineno=26, col_offset=19, end_lineno=26, end_col_offset=25), lineno=26, col_offset=12, end_lineno=26, end_col_offset=25)], [], lineno=25, col_offset=8, end_lineno=26, end_col_offset=25)], [], lineno=24, col_offset=4, end_lineno=26, end_col_offset=25), Return(Constant(None, lineno=27, col_offset=11, end_lineno=27, end_col_offset=15), lineno=27, col_offset=4, end_lineno=27, end_col_offset=15)], [], lineno=23, col_offset=0, end_lineno=27, end_col_offset=15), FunctionDef('placeholder_10', arguments([], [arg('placeholder_7', lineno=30, col_offset=19, end_lineno=30, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Call(Name('placeholder_0', Load(), lineno=32, col_offset=12, end_lineno=32, end_col_offset=19), [Name('placeholder_11', Load(), lineno=32, col_offset=20, end_lineno=32, end_col_offset=24), Name('placeholder_12', Load(), lineno=32, col_offset=26, end_lineno=32, end_col_offset=33)], [], lineno=32, col_offset=12, end_lineno=32, end_col_offset=34), [comprehension(Name('placeholder_11', Store(), lineno=32, col_offset=39, end_lineno=32, end_col_offset=43), Call(Name('range', Load(), lineno=32, col_offset=47, end_lineno=32, end_col_offset=52), [Call(Name('len', Load(), lineno=32, col_offset=53, end_lineno=32, end_col_offset=56), [Name('placeholder_7', Load(), lineno=32, col_offset=57, end_lineno=32, end_col_offset=65)], [], lineno=32, col_offset=53, end_lineno=32, end_col_offset=66)], [], lineno=32, col_offset=47, end_lineno=32, end_col_offset=67), [], 0), comprehension(Name('placeholder_12', Store(), lineno=33, col_offset=16, end_lineno=33, end_col_offset=23), Call(Name('range', Load(), lineno=33, col_offset=27, end_lineno=33, end_col_offset=32), [Call(Name('len', Load(), lineno=33, col_offset=33, end_lineno=33, end_col_offset=36), [Subscript(Name('placeholder_7', Load(), lineno=33, col_offset=37, end_lineno=33, end_col_offset=45), Name('placeholder_11', Load(), lineno=33, col_offset=46, end_lineno=33, end_col_offset=50), Load(), lineno=33, col_offset=37, end_lineno=33, end_col_offset=51)], [], lineno=33, col_offset=33, end_lineno=33, end_col_offset=52)], [], lineno=33, col_offset=27, end_lineno=33, end_col_offset=53), [Compare(Subscript(Subscript(Name('placeholder_7', Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=23), Name('placeholder_11', Load(), lineno=34, col_offset=24, end_lineno=34, end_col_offset=28), Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=29), Name('placeholder_12', Load(), lineno=34, col_offset=30, end_lineno=34, end_col_offset=37), Load(), lineno=34, col_offset=15, end_lineno=34, end_col_offset=38), [Eq()], [Constant('+', lineno=34, col_offset=42, end_lineno=34, end_col_offset=45)], lineno=34, col_offset=15, end_lineno=34, end_col_offset=45)], 0)], lineno=32, col_offset=11, end_lineno=34, end_col_offset=46), lineno=32, col_offset=4, end_lineno=34, end_col_offset=46)], [], lineno=30, col_offset=0, end_lineno=34, end_col_offset=46), FunctionDef('placeholder_13', arguments([], [arg('placeholder_14', lineno=39, col_offset=18, end_lineno=39, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_15', Store(), lineno=40, col_offset=4, end_lineno=40, end_col_offset=9)], Constant(0, lineno=40, col_offset=12, end_lineno=40, end_col_offset=13), lineno=40, col_offset=4, end_lineno=40, end_col_offset=13), Assign([Name('placeholder_16', Store(), lineno=41, col_offset=4, end_lineno=41, end_col_offset=9)], Constant(0, lineno=41, col_offset=12, end_lineno=41, end_col_offset=13), lineno=41, col_offset=4, end_lineno=41, end_col_offset=13), For(Name('placeholder_17', Store(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=16), Name('placeholder_14', Load(), lineno=43, col_offset=20, end_lineno=43, end_col_offset=27), [Assign([Name('placeholder_15', Store(), lineno=44, col_offset=8, end_lineno=44, end_col_offset=13)], BinOp(Name('placeholder_15', Load(), lineno=44, col_offset=16, end_lineno=44, end_col_offset=21), Add(), BinOp(Attribute(Name('placeholder_17', Load(), lineno=44, col_offset=24, end_lineno=44, end_col_offset=32), 'placeholder_2', Load(), lineno=44, col_offset=24, end_lineno=44, end_col_offset=36), Div(), Constant(4.0, lineno=44, col_offset=39, end_lineno=44, end_col_offset=42), lineno=44, col_offset=24, end_lineno=44, end_col_offset=42), lineno=44, col_offset=16, end_lineno=44, end_col_offset=42), lineno=44, col_offset=8, end_lineno=44, end_col_offset=42), Assign([Name('placeholder_16', Store(), lineno=45, col_offset=8, end_lineno=45, end_col_offset=13)], BinOp(Name('placeholder_16', Load(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=21), Add(), BinOp(Attribute(Name('placeholder_17', Load(), lineno=45, col_offset=24, end_lineno=45, end_col_offset=32), 'placeholder_3', Load(), lineno=45, col_offset=24, end_lineno=45, end_col_offset=36), Div(), Constant(4.0, lineno=45, col_offset=39, end_lineno=45, end_col_offset=42), lineno=45, col_offset=24, end_lineno=45, end_col_offset=42), lineno=45, col_offset=16, end_lineno=45, end_col_offset=42), lineno=45, col_offset=8, end_lineno=45, end_col_offset=42)], [], lineno=43, col_offset=4, end_lineno=45, end_col_offset=42), Assign([Name('placeholder_18', Store(), lineno=48, col_offset=4, end_lineno=48, end_col_offset=6)], Call(Name('abs', Load(), lineno=48, col_offset=9, end_lineno=48, end_col_offset=12), [BinOp(Attribute(Subscript(Name('placeholder_14', Load(), lineno=48, col_offset=13, end_lineno=48, end_col_offset=20), Constant(0, lineno=48, col_offset=21, end_lineno=48, end_col_offset=22), Load(), lineno=48, col_offset=13, end_lineno=48, end_col_offset=23), 'placeholder_2', Load(), lineno=48, col_offset=13, end_lineno=48, end_col_offset=27), Sub(), Name('placeholder_15', Load(), lineno=48, col_offset=30, end_lineno=48, end_col_offset=35), lineno=48, col_offset=13, end_lineno=48, end_col_offset=35)], [], lineno=48, col_offset=9, end_lineno=48, end_col_offset=36), lineno=48, col_offset=4, end_lineno=48, end_col_offset=36), Assign([Name('placeholder_19', Store(), lineno=49, col_offset=4, end_lineno=49, end_col_offset=6)], Call(Name('abs', Load(), lineno=49, col_offset=9, end_lineno=49, end_col_offset=12), [BinOp(Attribute(Subscript(Name('placeholder_14', Load(), lineno=49, col_offset=13, end_lineno=49, end_col_offset=20), Constant(0, lineno=49, col_offset=21, end_lineno=49, end_col_offset=22), Load(), lineno=49, col_offset=13, end_lineno=49, end_col_offset=23), 'placeholder_3', Load(), lineno=49, col_offset=13, end_lineno=49, end_col_offset=27), Sub(), Name('placeholder_16', Load(), lineno=49, col_offset=30, end_lineno=49, end_col_offset=35), lineno=49, col_offset=13, end_lineno=49, end_col_offset=35)], [], lineno=49, col_offset=9, end_lineno=49, end_col_offset=36), lineno=49, col_offset=4, end_lineno=49, end_col_offset=36), For(Name('placeholder_2', Store(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=11), Call(Name('range', Load(), lineno=52, col_offset=15, end_lineno=52, end_col_offset=20), [Constant(1, lineno=52, col_offset=21, end_lineno=52, end_col_offset=22), Call(Name('len', Load(), lineno=52, col_offset=24, end_lineno=52, end_col_offset=27), [Name('placeholder_14', Load(), lineno=52, col_offset=28, end_lineno=52, end_col_offset=35)], [], lineno=52, col_offset=24, end_lineno=52, end_col_offset=36)], [], lineno=52, col_offset=15, end_lineno=52, end_col_offset=37), [If(BoolOp(Or(), [Compare(Call(Name('abs', Load(), lineno=53, col_offset=11, end_lineno=53, end_col_offset=14), [BinOp(Attribute(Subscript(Name('placeholder_14', Load(), lineno=53, col_offset=15, end_lineno=53, end_col_offset=22), Name('placeholder_2', Load(), lineno=53, col_offset=23, end_lineno=53, end_col_offset=26), Load(), lineno=53, col_offset=15, end_lineno=53, end_col_offset=27), 'placeholder_2', Load(), lineno=53, col_offset=15, end_lineno=53, end_col_offset=31), Sub(), Name('placeholder_15', Load(), lineno=53, col_offset=34, end_lineno=53, end_col_offset=39), lineno=53, col_offset=15, end_lineno=53, end_col_offset=39)], [], lineno=53, col_offset=11, end_lineno=53, end_col_offset=40), [NotEq()], [Name('placeholder_18', Load(), lineno=53, col_offset=44, end_lineno=53, end_col_offset=46)], lineno=53, col_offset=11, end_lineno=53, end_col_offset=46), Compare(Call(Name('abs', Load(), lineno=53, col_offset=50, end_lineno=53, end_col_offset=53), [BinOp(Attribute(Subscript(Name('placeholder_14', Load(), lineno=53, col_offset=54, end_lineno=53, end_col_offset=61), Name('placeholder_2', Load(), lineno=53, col_offset=62, end_lineno=53, end_col_offset=65), Load(), lineno=53, col_offset=54, end_lineno=53, end_col_offset=66), 'placeholder_3', Load(), lineno=53, col_offset=54, end_lineno=53, end_col_offset=70), Sub(), Name('placeholder_16', Load(), lineno=53, col_offset=73, end_lineno=53, end_col_offset=78), lineno=53, col_offset=54, end_lineno=53, end_col_offset=78)], [], lineno=53, col_offset=50, end_lineno=53, end_col_offset=79), [NotEq()], [Name('placeholder_19', Load(), lineno=53, col_offset=83, end_lineno=53, end_col_offset=85)], lineno=53, col_offset=50, end_lineno=53, end_col_offset=85)], lineno=53, col_offset=11, end_lineno=53, end_col_offset=85), [Return(Constant(False, lineno=54, col_offset=19, end_lineno=54, end_col_offset=24), lineno=54, col_offset=12, end_lineno=54, end_col_offset=24)], [], lineno=53, col_offset=8, end_lineno=54, end_col_offset=24)], [], lineno=52, col_offset=4, end_lineno=54, end_col_offset=24), Return(Constant(True, lineno=55, col_offset=11, end_lineno=55, end_col_offset=15), lineno=55, col_offset=4, end_lineno=55, end_col_offset=15)], [], lineno=39, col_offset=0, end_lineno=55, end_col_offset=15), FunctionDef('placeholder_20', arguments([], [arg('placeholder_21', lineno=59, col_offset=9, end_lineno=59, end_col_offset=16), arg('placeholder_22', lineno=59, col_offset=18, end_lineno=59, end_col_offset=25), arg('placeholder_11', lineno=59, col_offset=27, end_lineno=59, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('placeholder_21', Load(), lineno=60, col_offset=7, end_lineno=60, end_col_offset=14), 'placeholder_2', Load(), lineno=60, col_offset=7, end_lineno=60, end_col_offset=18), [Eq()], [Attribute(Name('placeholder_22', Load(), lineno=60, col_offset=22, end_lineno=60, end_col_offset=29), 'placeholder_2', Load(), lineno=60, col_offset=22, end_lineno=60, end_col_offset=33)], lineno=60, col_offset=7, end_lineno=60, end_col_offset=33), [For(Name('placeholder_3', Store(), lineno=61, col_offset=12, end_lineno=61, end_col_offset=15), Call(Name('range', Load(), lineno=61, col_offset=19, end_lineno=61, end_col_offset=24), [Call(Name('min', Load(), lineno=61, col_offset=25, end_lineno=61, end_col_offset=28), [BinOp(Attribute(Name('placeholder_21', Load(), lineno=61, col_offset=29, end_lineno=61, end_col_offset=36), 'placeholder_3', Load(), lineno=61, col_offset=29, end_lineno=61, end_col_offset=40), Add(), Constant(1, lineno=61, col_offset=43, end_lineno=61, end_col_offset=44), lineno=61, col_offset=29, end_lineno=61, end_col_offset=44), BinOp(Attribute(Name('placeholder_22', Load(), lineno=61, col_offset=46, end_lineno=61, end_col_offset=53), 'placeholder_3', Load(), lineno=61, col_offset=46, end_lineno=61, end_col_offset=57), Add(), Constant(1, lineno=61, col_offset=60, end_lineno=61, end_col_offset=61), lineno=61, col_offset=46, end_lineno=61, end_col_offset=61)], [], lineno=61, col_offset=25, end_lineno=61, end_col_offset=62), Call(Name('max', Load(), lineno=62, col_offset=23, end_lineno=62, end_col_offset=26), [Attribute(Name('placeholder_21', Load(), lineno=62, col_offset=27, end_lineno=62, end_col_offset=34), 'placeholder_3', Load(), lineno=62, col_offset=27, end_lineno=62, end_col_offset=38), Attribute(Name('placeholder_22', Load(), lineno=62, col_offset=40, end_lineno=62, end_col_offset=47), 'placeholder_3', Load(), lineno=62, col_offset=40, end_lineno=62, end_col_offset=51)], [], lineno=62, col_offset=23, end_lineno=62, end_col_offset=52)], [], lineno=61, col_offset=19, end_lineno=62, end_col_offset=53), [If(BoolOp(And(), [Compare(Subscript(Subscript(Name('placeholder_11', Load(), lineno=63, col_offset=15, end_lineno=63, end_col_offset=19), Attribute(Name('placeholder_21', Load(), lineno=63, col_offset=20, end_lineno=63, end_col_offset=27), 'placeholder_2', Load(), lineno=63, col_offset=20, end_lineno=63, end_col_offset=31), Load(), lineno=63, col_offset=15, end_lineno=63, end_col_offset=32), Name('placeholder_3', Load(), lineno=63, col_offset=33, end_lineno=63, end_col_offset=36), Load(), lineno=63, col_offset=15, end_lineno=63, end_col_offset=37), [NotEq()], [Constant('-', lineno=63, col_offset=41, end_lineno=63, end_col_offset=44)], lineno=63, col_offset=15, end_lineno=63, end_col_offset=44), Compare(Subscript(Subscript(Name('placeholder_11', Load(), lineno=63, col_offset=49, end_lineno=63, end_col_offset=53), Attribute(Name('placeholder_21', Load(), lineno=63, col_offset=54, end_lineno=63, end_col_offset=61), 'placeholder_2', Load(), lineno=63, col_offset=54, end_lineno=63, end_col_offset=65), Load(), lineno=63, col_offset=49, end_lineno=63, end_col_offset=66), Name('placeholder_3', Load(), lineno=63, col_offset=67, end_lineno=63, end_col_offset=70), Load(), lineno=63, col_offset=49, end_lineno=63, end_col_offset=71), [NotEq()], [Constant('+', lineno=63, col_offset=75, end_lineno=63, end_col_offset=78)], lineno=63, col_offset=49, end_lineno=63, end_col_offset=78)], lineno=63, col_offset=15, end_lineno=63, end_col_offset=78), [Return(Constant(False, lineno=64, col_offset=23, end_lineno=64, end_col_offset=28), lineno=64, col_offset=16, end_lineno=64, end_col_offset=28)], [], lineno=63, col_offset=12, end_lineno=64, end_col_offset=28)], [], lineno=61, col_offset=8, end_lineno=64, end_col_offset=28), Return(Constant(True, lineno=65, col_offset=15, end_lineno=65, end_col_offset=19), lineno=65, col_offset=8, end_lineno=65, end_col_offset=19)], [If(Compare(Attribute(Name('placeholder_21', Load(), lineno=67, col_offset=9, end_lineno=67, end_col_offset=16), 'placeholder_3', Load(), lineno=67, col_offset=9, end_lineno=67, end_col_offset=20), [Eq()], [Attribute(Name('placeholder_22', Load(), lineno=67, col_offset=24, end_lineno=67, end_col_offset=31), 'placeholder_3', Load(), lineno=67, col_offset=24, end_lineno=67, end_col_offset=35)], lineno=67, col_offset=9, end_lineno=67, end_col_offset=35), [For(Name('placeholder_2', Store(), lineno=68, col_offset=12, end_lineno=68, end_col_offset=15), Call(Name('range', Load(), lineno=68, col_offset=19, end_lineno=68, end_col_offset=24), [Call(Name('min', Load(), lineno=68, col_offset=25, end_lineno=68, end_col_offset=28), [BinOp(Attribute(Name('placeholder_21', Load(), lineno=68, col_offset=29, end_lineno=68, end_col_offset=36), 'placeholder_2', Load(), lineno=68, col_offset=29, end_lineno=68, end_col_offset=40), Add(), Constant(1, lineno=68, col_offset=43, end_lineno=68, end_col_offset=44), lineno=68, col_offset=29, end_lineno=68, end_col_offset=44), BinOp(Attribute(Name('placeholder_22', Load(), lineno=68, col_offset=46, end_lineno=68, end_col_offset=53), 'placeholder_2', Load(), lineno=68, col_offset=46, end_lineno=68, end_col_offset=57), Add(), Constant(1, lineno=68, col_offset=60, end_lineno=68, end_col_offset=61), lineno=68, col_offset=46, end_lineno=68, end_col_offset=61)], [], lineno=68, col_offset=25, end_lineno=68, end_col_offset=62), Call(Name('max', Load(), lineno=69, col_offset=23, end_lineno=69, end_col_offset=26), [Attribute(Name('placeholder_21', Load(), lineno=69, col_offset=27, end_lineno=69, end_col_offset=34), 'placeholder_2', Load(), lineno=69, col_offset=27, end_lineno=69, end_col_offset=38), Attribute(Name('placeholder_22', Load(), lineno=69, col_offset=40, end_lineno=69, end_col_offset=47), 'placeholder_2', Load(), lineno=69, col_offset=40, end_lineno=69, end_col_offset=51)], [], lineno=69, col_offset=23, end_lineno=69, end_col_offset=52)], [], lineno=68, col_offset=19, end_lineno=69, end_col_offset=53), [If(BoolOp(And(), [Compare(Subscript(Subscript(Name('placeholder_11', Load(), lineno=70, col_offset=15, end_lineno=70, end_col_offset=19), Name('placeholder_2', Load(), lineno=70, col_offset=20, end_lineno=70, end_col_offset=23), Load(), lineno=70, col_offset=15, end_lineno=70, end_col_offset=24), Attribute(Name('placeholder_21', Load(), lineno=70, col_offset=25, end_lineno=70, end_col_offset=32), 'placeholder_3', Load(), lineno=70, col_offset=25, end_lineno=70, end_col_offset=36), Load(), lineno=70, col_offset=15, end_lineno=70, end_col_offset=37), [NotEq()], [Constant('|', lineno=70, col_offset=41, end_lineno=70, end_col_offset=44)], lineno=70, col_offset=15, end_lineno=70, end_col_offset=44), Compare(Subscript(Subscript(Name('placeholder_11', Load(), lineno=70, col_offset=49, end_lineno=70, end_col_offset=53), Name('placeholder_2', Load(), lineno=70, col_offset=54, end_lineno=70, end_col_offset=57), Load(), lineno=70, col_offset=49, end_lineno=70, end_col_offset=58), Attribute(Name('placeholder_21', Load(), lineno=70, col_offset=59, end_lineno=70, end_col_offset=66), 'placeholder_3', Load(), lineno=70, col_offset=59, end_lineno=70, end_col_offset=70), Load(), lineno=70, col_offset=49, end_lineno=70, end_col_offset=71), [NotEq()], [Constant('+', lineno=70, col_offset=75, end_lineno=70, end_col_offset=78)], lineno=70, col_offset=49, end_lineno=70, end_col_offset=78)], lineno=70, col_offset=15, end_lineno=70, end_col_offset=78), [Return(Constant(False, lineno=71, col_offset=23, end_lineno=71, end_col_offset=28), lineno=71, col_offset=16, end_lineno=71, end_col_offset=28)], [], lineno=70, col_offset=12, end_lineno=71, end_col_offset=28)], [], lineno=68, col_offset=8, end_lineno=71, end_col_offset=28), Return(Constant(True, lineno=72, col_offset=15, end_lineno=72, end_col_offset=19), lineno=72, col_offset=8, end_lineno=72, end_col_offset=19)], [], lineno=67, col_offset=4, end_lineno=72, end_col_offset=19)], lineno=60, col_offset=4, end_lineno=72, end_col_offset=19), Return(Constant(None, lineno=73, col_offset=11, end_lineno=73, end_col_offset=15), lineno=73, col_offset=4, end_lineno=73, end_col_offset=15)], [], lineno=59, col_offset=0, end_lineno=73, end_col_offset=15), FunctionDef('placeholder_23', arguments([], [arg('placeholder_24', lineno=77, col_offset=18, end_lineno=77, end_col_offset=27), arg('placeholder_11', lineno=77, col_offset=29, end_lineno=77, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Tuple([Name('placeholder_2', Store(), lineno=80, col_offset=8, end_lineno=80, end_col_offset=11), Name('placeholder_25', Store(), lineno=80, col_offset=13, end_lineno=80, end_col_offset=14)], Store(), lineno=80, col_offset=8, end_lineno=80, end_col_offset=14), Call(Name('enumerate', Load(), lineno=80, col_offset=18, end_lineno=80, end_col_offset=27), [Name('placeholder_24', Load(), lineno=80, col_offset=28, end_lineno=80, end_col_offset=37)], [], lineno=80, col_offset=18, end_lineno=80, end_col_offset=38), [Assign([Name('placeholder_26', Store(), lineno=81, col_offset=8, end_lineno=81, end_col_offset=12)], Call(Name('placeholder_5', Load(), lineno=81, col_offset=15, end_lineno=81, end_col_offset=24), [Attribute(Subscript(Name('placeholder_24', Load(), lineno=81, col_offset=25, end_lineno=81, end_col_offset=34), Name('placeholder_2', Load(), lineno=81, col_offset=35, end_lineno=81, end_col_offset=38), Load(), lineno=81, col_offset=25, end_lineno=81, end_col_offset=39), 'placeholder_2', Load(), lineno=81, col_offset=25, end_lineno=81, end_col_offset=43), BinOp(Subscript(Name('placeholder_24', Load(), lineno=81, col_offset=45, end_lineno=81, end_col_offset=54), Slice(Constant(0, lineno=81, col_offset=55, end_lineno=81, end_col_offset=56), Name('placeholder_2', Load(), lineno=81, col_offset=57, end_lineno=81, end_col_offset=60), lineno=81, col_offset=55, end_lineno=81, end_col_offset=60), Load(), lineno=81, col_offset=45, end_lineno=81, end_col_offset=61), Add(), Subscript(Name('placeholder_24', Load(), lineno=81, col_offset=64, end_lineno=81, end_col_offset=73), Slice(BinOp(Name('placeholder_2', Load(), lineno=81, col_offset=74, end_lineno=81, end_col_offset=77), Add(), Constant(1, lineno=81, col_offset=80, end_lineno=81, end_col_offset=81), lineno=81, col_offset=74, end_lineno=81, end_col_offset=81), lineno=81, col_offset=74, end_lineno=81, end_col_offset=82), Load(), lineno=81, col_offset=64, end_lineno=81, end_col_offset=83), lineno=81, col_offset=45, end_lineno=81, end_col_offset=83)], [], lineno=81, col_offset=15, end_lineno=81, end_col_offset=84), lineno=81, col_offset=8, end_lineno=81, end_col_offset=84), Assign([Name('placeholder_27', Store(), lineno=82, col_offset=8, end_lineno=82, end_col_offset=14)], Call(Name('placeholder_9', Load(), lineno=82, col_offset=17, end_lineno=82, end_col_offset=25), [Attribute(Subscript(Name('placeholder_24', Load(), lineno=82, col_offset=26, end_lineno=82, end_col_offset=35), Name('placeholder_2', Load(), lineno=82, col_offset=36, end_lineno=82, end_col_offset=39), Load(), lineno=82, col_offset=26, end_lineno=82, end_col_offset=40), 'placeholder_3', Load(), lineno=82, col_offset=26, end_lineno=82, end_col_offset=44), BinOp(Subscript(Name('placeholder_24', Load(), lineno=82, col_offset=46, end_lineno=82, end_col_offset=55), Slice(Constant(0, lineno=82, col_offset=56, end_lineno=82, end_col_offset=57), Name('placeholder_2', Load(), lineno=82, col_offset=58, end_lineno=82, end_col_offset=61), lineno=82, col_offset=56, end_lineno=82, end_col_offset=61), Load(), lineno=82, col_offset=46, end_lineno=82, end_col_offset=62), Add(), Subscript(Name('placeholder_24', Load(), lineno=82, col_offset=65, end_lineno=82, end_col_offset=74), Slice(BinOp(Name('placeholder_2', Load(), lineno=82, col_offset=75, end_lineno=82, end_col_offset=78), Add(), Constant(1, lineno=82, col_offset=81, end_lineno=82, end_col_offset=82), lineno=82, col_offset=75, end_lineno=82, end_col_offset=82), lineno=82, col_offset=75, end_lineno=82, end_col_offset=83), Load(), lineno=82, col_offset=65, end_lineno=82, end_col_offset=84), lineno=82, col_offset=46, end_lineno=82, end_col_offset=84)], [], lineno=82, col_offset=17, end_lineno=82, end_col_offset=85), lineno=82, col_offset=8, end_lineno=82, end_col_offset=85), If(BoolOp(Or(), [UnaryOp(Not(), Call(Name('placeholder_20', Load(), lineno=84, col_offset=15, end_lineno=84, end_col_offset=19), [Subscript(Name('placeholder_24', Load(), lineno=84, col_offset=20, end_lineno=84, end_col_offset=29), Name('placeholder_2', Load(), lineno=84, col_offset=30, end_lineno=84, end_col_offset=33), Load(), lineno=84, col_offset=20, end_lineno=84, end_col_offset=34), Name('placeholder_26', Load(), lineno=84, col_offset=36, end_lineno=84, end_col_offset=40), Name('placeholder_11', Load(), lineno=84, col_offset=42, end_lineno=84, end_col_offset=46)], [], lineno=84, col_offset=15, end_lineno=84, end_col_offset=47), lineno=84, col_offset=11, end_lineno=84, end_col_offset=47), UnaryOp(Not(), Call(Name('placeholder_20', Load(), lineno=84, col_offset=55, end_lineno=84, end_col_offset=59), [Subscript(Name('placeholder_24', Load(), lineno=84, col_offset=60, end_lineno=84, end_col_offset=69), Name('placeholder_2', Load(), lineno=84, col_offset=70, end_lineno=84, end_col_offset=73), Load(), lineno=84, col_offset=60, end_lineno=84, end_col_offset=74), Name('placeholder_27', Load(), lineno=84, col_offset=76, end_lineno=84, end_col_offset=82), Name('placeholder_11', Load(), lineno=84, col_offset=84, end_lineno=84, end_col_offset=88)], [], lineno=84, col_offset=55, end_lineno=84, end_col_offset=89), lineno=84, col_offset=51, end_lineno=84, end_col_offset=89)], lineno=84, col_offset=11, end_lineno=84, end_col_offset=89), [Return(Constant(False, lineno=85, col_offset=19, end_lineno=85, end_col_offset=24), lineno=85, col_offset=12, end_lineno=85, end_col_offset=24)], [], lineno=84, col_offset=8, end_lineno=85, end_col_offset=24)], [], lineno=80, col_offset=4, end_lineno=85, end_col_offset=24), Return(Constant(True, lineno=87, col_offset=11, end_lineno=87, end_col_offset=15), lineno=87, col_offset=4, end_lineno=87, end_col_offset=15)], [], lineno=77, col_offset=0, end_lineno=87, end_col_offset=15), FunctionDef('placeholder_28', arguments([], [arg('placeholder_29', lineno=91, col_offset=15, end_lineno=91, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[Constant('', lineno=91, col_offset=23, end_lineno=91, end_col_offset=25)]), [Assign([Name('placeholder_30', Store(), lineno=92, col_offset=4, end_lineno=92, end_col_offset=19)], Constant(0, lineno=92, col_offset=22, end_lineno=92, end_col_offset=23), lineno=92, col_offset=4, end_lineno=92, end_col_offset=23), If(UnaryOp(Not(), Name('placeholder_29', Load(), lineno=94, col_offset=11, end_lineno=94, end_col_offset=18), lineno=94, col_offset=7, end_lineno=94, end_col_offset=18), [Return(Name('placeholder_30', Load(), lineno=95, col_offset=15, end_lineno=95, end_col_offset=30), lineno=95, col_offset=8, end_lineno=95, end_col_offset=30)], [], lineno=94, col_offset=4, end_lineno=95, end_col_offset=30), Assign([Name('placeholder_31', Store(), lineno=97, col_offset=4, end_lineno=97, end_col_offset=11)], Call(Name('placeholder_10', Load(), lineno=97, col_offset=14, end_lineno=97, end_col_offset=28), [Name('placeholder_29', Load(), lineno=97, col_offset=29, end_lineno=97, end_col_offset=36)], [], lineno=97, col_offset=14, end_lineno=97, end_col_offset=37), lineno=97, col_offset=4, end_lineno=97, end_col_offset=37), If(UnaryOp(Not(), Name('placeholder_31', Load(), lineno=100, col_offset=11, end_lineno=100, end_col_offset=18), lineno=100, col_offset=7, end_lineno=100, end_col_offset=18), [Return(Name('placeholder_30', Load(), lineno=101, col_offset=15, end_lineno=101, end_col_offset=30), lineno=101, col_offset=8, end_lineno=101, end_col_offset=30)], [], lineno=100, col_offset=4, end_lineno=101, end_col_offset=30), Assign([Name('placeholder_32', Store(), lineno=104, col_offset=4, end_lineno=104, end_col_offset=12)], Call(Name('list', Load(), lineno=104, col_offset=15, end_lineno=104, end_col_offset=19), [Call(Attribute(Name('itertools', Load(), lineno=104, col_offset=20, end_lineno=104, end_col_offset=29), 'combinations', Load(), lineno=104, col_offset=20, end_lineno=104, end_col_offset=42), [Name('placeholder_31', Load(), lineno=104, col_offset=43, end_lineno=104, end_col_offset=50)], [keyword('placeholder_33', Constant(4, lineno=104, col_offset=54, end_lineno=104, end_col_offset=55), lineno=104, col_offset=52, end_lineno=104, end_col_offset=55)], lineno=104, col_offset=20, end_lineno=104, end_col_offset=56)], [], lineno=104, col_offset=15, end_lineno=104, end_col_offset=57), lineno=104, col_offset=4, end_lineno=104, end_col_offset=57), Assign([Name('placeholder_34', Store(), lineno=105, col_offset=4, end_lineno=105, end_col_offset=9)], GeneratorExp(Name('placeholder_14', Load(), lineno=105, col_offset=13, end_lineno=105, end_col_offset=20), [comprehension(Name('placeholder_14', Store(), lineno=105, col_offset=25, end_lineno=105, end_col_offset=32), Name('placeholder_32', Load(), lineno=105, col_offset=36, end_lineno=105, end_col_offset=44), [Call(Name('placeholder_13', Load(), lineno=105, col_offset=48, end_lineno=105, end_col_offset=61), [Name('placeholder_14', Load(), lineno=105, col_offset=62, end_lineno=105, end_col_offset=69)], [], lineno=105, col_offset=48, end_lineno=105, end_col_offset=70)], 0)], lineno=105, col_offset=12, end_lineno=105, end_col_offset=71), lineno=105, col_offset=4, end_lineno=105, end_col_offset=71), For(Name('placeholder_2', Store(), lineno=108, col_offset=8, end_lineno=108, end_col_offset=11), Name('placeholder_34', Load(), lineno=108, col_offset=15, end_lineno=108, end_col_offset=20), [If(Call(Name('placeholder_23', Load(), lineno=109, col_offset=11, end_lineno=109, end_col_offset=24), [Name('placeholder_2', Load(), lineno=109, col_offset=25, end_lineno=109, end_col_offset=28), Name('placeholder_29', Load(), lineno=109, col_offset=30, end_lineno=109, end_col_offset=37)], [], lineno=109, col_offset=11, end_lineno=109, end_col_offset=38), [AugAssign(Name('placeholder_30', Store(), lineno=110, col_offset=12, end_lineno=110, end_col_offset=27), Add(), Constant(1, lineno=110, col_offset=31, end_lineno=110, end_col_offset=32), lineno=110, col_offset=12, end_lineno=110, end_col_offset=32)], [], lineno=109, col_offset=8, end_lineno=110, end_col_offset=32)], [], lineno=108, col_offset=4, end_lineno=110, end_col_offset=32), Return(Name('placeholder_30', Load(), lineno=111, col_offset=11, end_lineno=111, end_col_offset=26), lineno=111, col_offset=4, end_lineno=111, end_col_offset=26)], [], lineno=91, col_offset=0, end_lineno=111, end_col_offset=26)], []) \ No newline at end of file diff --git a/test/practice-resistor-color-duo/.meta/config.json b/test/practice-resistor-color-duo/.meta/config.json new file mode 100644 index 0000000..f8177d2 --- /dev/null +++ b/test/practice-resistor-color-duo/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "ee7" + ], + "contributors": [ + "alirezaghey", + "BethanyG", + "cmccandless", + "Dog", + "xitanggg", + "yawpitch" + ], + "files": { + "solution": [ + "resistor_color_duo.py" + ], + "test": [ + "resistor_color_duo_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Convert color codes, as used on resistors, to a numeric value.", + "source": "Maud de Vries, Erik Schierboom", + "source_url": "https://github.com/exercism/problem-specifications/issues/1464" +} diff --git a/test/practice-resistor-color-duo/mapping.json b/test/practice-resistor-color-duo/mapping.json new file mode 100644 index 0000000..184f251 --- /dev/null +++ b/test/practice-resistor-color-duo/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "COLORS", + "placeholder_1": "value", + "placeholder_2": "colors" +} \ No newline at end of file diff --git a/test/practice-resistor-color-duo/representation.json b/test/practice-resistor-color-duo/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-resistor-color-duo/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-resistor-color-duo/representation.out b/test/practice-resistor-color-duo/representation.out new file mode 100644 index 0000000..d4f9991 --- /dev/null +++ b/test/practice-resistor-color-duo/representation.out @@ -0,0 +1,439 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = [ + "black", + "brown", + "red", + "orange", + "yellow", + "green", + "blue", + "violet", + "grey", + "white", +] + + +def placeholder_1(placeholder_2): + return 10 * placeholder_0.index(placeholder_2[0]) + placeholder_0.index( + placeholder_2[1] + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'COLORS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + List( + [ + Constant( + 'black', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11), + Constant( + 'brown', + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11), + Constant( + 'red', + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=9), + Constant( + 'orange', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12), + Constant( + 'yellow', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=12), + Constant( + 'green', + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11), + Constant( + 'blue', + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10), + Constant( + 'violet', + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=12), + Constant( + 'grey', + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=10), + Constant( + 'white', + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=11)], + Load(), + lineno=1, + col_offset=9, + end_lineno=12, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=1), + FunctionDef( + 'value', + arguments( + [], + [ + arg( + 'colors', + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + Constant( + 10, + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=13), + Mult(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=22), + 'index', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=28), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=16, + col_offset=29, + end_lineno=16, + end_col_offset=35), + Constant( + 0, + lineno=16, + col_offset=36, + end_lineno=16, + end_col_offset=37), + Load(), + lineno=16, + col_offset=29, + end_lineno=16, + end_col_offset=38)], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=39), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=39), + Add(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=16, + col_offset=42, + end_lineno=16, + end_col_offset=48), + 'index', + Load(), + lineno=16, + col_offset=42, + end_lineno=16, + end_col_offset=54), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=16, + col_offset=55, + end_lineno=16, + end_col_offset=61), + Constant( + 1, + lineno=16, + col_offset=62, + end_lineno=16, + end_col_offset=63), + Load(), + lineno=16, + col_offset=55, + end_lineno=16, + end_col_offset=64)], + [], + lineno=16, + col_offset=42, + end_lineno=16, + end_col_offset=65), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=65), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=65)], + [], + lineno=15, + col_offset=0, + end_lineno=16, + end_col_offset=65)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + List( + [ + Constant( + 'black', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11), + Constant( + 'brown', + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11), + Constant( + 'red', + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=9), + Constant( + 'orange', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12), + Constant( + 'yellow', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=12), + Constant( + 'green', + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11), + Constant( + 'blue', + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10), + Constant( + 'violet', + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=12), + Constant( + 'grey', + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=10), + Constant( + 'white', + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=11)], + Load(), + lineno=1, + col_offset=9, + end_lineno=12, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=1), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + Constant( + 10, + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=13), + Mult(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=22), + 'index', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=28), + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=29, + end_lineno=16, + end_col_offset=35), + Constant( + 0, + lineno=16, + col_offset=36, + end_lineno=16, + end_col_offset=37), + Load(), + lineno=16, + col_offset=29, + end_lineno=16, + end_col_offset=38)], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=39), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=39), + Add(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=42, + end_lineno=16, + end_col_offset=48), + 'index', + Load(), + lineno=16, + col_offset=42, + end_lineno=16, + end_col_offset=54), + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=55, + end_lineno=16, + end_col_offset=61), + Constant( + 1, + lineno=16, + col_offset=62, + end_lineno=16, + end_col_offset=63), + Load(), + lineno=16, + col_offset=55, + end_lineno=16, + end_col_offset=64)], + [], + lineno=16, + col_offset=42, + end_lineno=16, + end_col_offset=65), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=65), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=65)], + [], + lineno=15, + col_offset=0, + end_lineno=16, + end_col_offset=65)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-resistor-color-duo/representation.txt b/test/practice-resistor-color-duo/representation.txt new file mode 100644 index 0000000..e77dc14 --- /dev/null +++ b/test/practice-resistor-color-duo/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=6)], List([Constant('black', lineno=2, col_offset=4, end_lineno=2, end_col_offset=11), Constant('brown', lineno=3, col_offset=4, end_lineno=3, end_col_offset=11), Constant('red', lineno=4, col_offset=4, end_lineno=4, end_col_offset=9), Constant('orange', lineno=5, col_offset=4, end_lineno=5, end_col_offset=12), Constant('yellow', lineno=6, col_offset=4, end_lineno=6, end_col_offset=12), Constant('green', lineno=7, col_offset=4, end_lineno=7, end_col_offset=11), Constant('blue', lineno=8, col_offset=4, end_lineno=8, end_col_offset=10), Constant('violet', lineno=9, col_offset=4, end_lineno=9, end_col_offset=12), Constant('grey', lineno=10, col_offset=4, end_lineno=10, end_col_offset=10), Constant('white', lineno=11, col_offset=4, end_lineno=11, end_col_offset=11)], Load(), lineno=1, col_offset=9, end_lineno=12, end_col_offset=1), lineno=1, col_offset=0, end_lineno=12, end_col_offset=1), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=15, col_offset=10, end_lineno=15, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(BinOp(Constant(10, lineno=16, col_offset=11, end_lineno=16, end_col_offset=13), Mult(), Call(Attribute(Name('placeholder_0', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=22), 'index', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=28), [Subscript(Name('placeholder_2', Load(), lineno=16, col_offset=29, end_lineno=16, end_col_offset=35), Constant(0, lineno=16, col_offset=36, end_lineno=16, end_col_offset=37), Load(), lineno=16, col_offset=29, end_lineno=16, end_col_offset=38)], [], lineno=16, col_offset=16, end_lineno=16, end_col_offset=39), lineno=16, col_offset=11, end_lineno=16, end_col_offset=39), Add(), Call(Attribute(Name('placeholder_0', Load(), lineno=16, col_offset=42, end_lineno=16, end_col_offset=48), 'index', Load(), lineno=16, col_offset=42, end_lineno=16, end_col_offset=54), [Subscript(Name('placeholder_2', Load(), lineno=16, col_offset=55, end_lineno=16, end_col_offset=61), Constant(1, lineno=16, col_offset=62, end_lineno=16, end_col_offset=63), Load(), lineno=16, col_offset=55, end_lineno=16, end_col_offset=64)], [], lineno=16, col_offset=42, end_lineno=16, end_col_offset=65), lineno=16, col_offset=11, end_lineno=16, end_col_offset=65), lineno=16, col_offset=4, end_lineno=16, end_col_offset=65)], [], lineno=15, col_offset=0, end_lineno=16, end_col_offset=65)], []) \ No newline at end of file diff --git a/test/practice-resistor-color-duo/resistor_color_duo.py b/test/practice-resistor-color-duo/resistor_color_duo.py new file mode 100644 index 0000000..0f12859 --- /dev/null +++ b/test/practice-resistor-color-duo/resistor_color_duo.py @@ -0,0 +1,16 @@ +COLORS = [ + 'black', + 'brown', + 'red', + 'orange', + 'yellow', + 'green', + 'blue', + 'violet', + 'grey', + 'white' +] + + +def value(colors): + return 10 * COLORS.index(colors[0]) + COLORS.index(colors[1]) diff --git a/test/practice-resistor-color-expert/.meta/config.json b/test/practice-resistor-color-expert/.meta/config.json new file mode 100644 index 0000000..edf50b4 --- /dev/null +++ b/test/practice-resistor-color-expert/.meta/config.json @@ -0,0 +1,20 @@ +{ + "authors": [ + "meatball133", + "bethanyg" + ], + "files": { + "solution": [ + "resistor_color_expert.py" + ], + "test": [ + "resistor_color_expert_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Convert color codes as used on resistors with different bands to a human-readable label.", + "source": "Based on earlier resistor color exercises made by Erik Schierboom and Maud de Vries", + "source_url": "https://github.com/exercism/problem-specifications/issues/1464" +} diff --git a/test/practice-resistor-color-expert/mapping.json b/test/practice-resistor-color-expert/mapping.json new file mode 100644 index 0000000..7b6f987 --- /dev/null +++ b/test/practice-resistor-color-expert/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "COLORS", + "placeholder_1": "COLORS_TOLERANCE", + "placeholder_2": "resistor_label", + "placeholder_3": "colors", + "placeholder_4": "value", + "placeholder_5": "unit", + "placeholder_6": "color_code", + "placeholder_7": "color" +} \ No newline at end of file diff --git a/test/practice-resistor-color-expert/representation.json b/test/practice-resistor-color-expert/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-resistor-color-expert/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-resistor-color-expert/representation.out b/test/practice-resistor-color-expert/representation.out new file mode 100644 index 0000000..9859a73 --- /dev/null +++ b/test/practice-resistor-color-expert/representation.out @@ -0,0 +1,2733 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = [ + "black", + "brown", + "red", + "orange", + "yellow", + "green", + "blue", + "violet", + "grey", + "white", +] +placeholder_1 = { + "brown": 1, + "red": 2, + "green": 0.5, + "blue": 0.25, + "violet": 0.1, + "grey": 0.05, + "gold": 5, + "silver": 10, +} + + +def placeholder_2(placeholder_3): + if len(placeholder_3) == 1: + return f"0 ohms" + elif len(placeholder_3) == 4: + placeholder_4 = 10 * placeholder_0.index( + placeholder_3[0] + ) + placeholder_0.index(placeholder_3[1]) + placeholder_4 *= 10 ** placeholder_0.index(placeholder_3[2]) + placeholder_4, placeholder_5 = color_code(placeholder_4) + placeholder_4 = ( + int(placeholder_4) if placeholder_4.is_integer() else placeholder_4 + ) + return f"{placeholder_4} {placeholder_5} ±{placeholder_1[placeholder_3[3]]}%" + else: + placeholder_4 = ( + 100 * placeholder_0.index(placeholder_3[0]) + + 10 * placeholder_0.index(placeholder_3[1]) + + placeholder_0.index(placeholder_3[2]) + ) + placeholder_4 *= 10 ** placeholder_0.index(placeholder_3[3]) + placeholder_4, placeholder_5 = color_code(placeholder_4) + placeholder_4 = ( + int(placeholder_4) if placeholder_4.is_integer() else placeholder_4 + ) + return f"{placeholder_4} {placeholder_5} ±{placeholder_1[placeholder_3[4]]}%" + + +def placeholder_6(placeholder_7): + if placeholder_7 < 1000: + return (placeholder_7 / 1, "ohms") + elif placeholder_7 < 1000000: + return (placeholder_7 / 1000, "kiloohms") + else: + return (placeholder_7 / 1000000, "megaohms") + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'COLORS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + List( + [ + Constant( + 'black', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11), + Constant( + 'brown', + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11), + Constant( + 'red', + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=9), + Constant( + 'orange', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12), + Constant( + 'yellow', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=12), + Constant( + 'green', + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11), + Constant( + 'blue', + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10), + Constant( + 'violet', + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=12), + Constant( + 'grey', + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=10), + Constant( + 'white', + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=11)], + Load(), + lineno=1, + col_offset=9, + end_lineno=12, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=1), + Assign( + [ + Name( + 'COLORS_TOLERANCE', + Store(), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=16)], + Dict( + [ + Constant( + 'brown', + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=11), + Constant( + 'red', + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=9), + Constant( + 'green', + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=11), + Constant( + 'blue', + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=10), + Constant( + 'violet', + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=12), + Constant( + 'grey', + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=10), + Constant( + 'gold', + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=10), + Constant( + 'silver', + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=12)], + [ + Constant( + 1, + lineno=15, + col_offset=13, + end_lineno=15, + end_col_offset=14), + Constant( + 2, + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=12), + Constant( + 0.5, + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=16), + Constant( + 0.25, + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=16), + Constant( + 0.1, + lineno=19, + col_offset=14, + end_lineno=19, + end_col_offset=17), + Constant( + 0.05, + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=16), + Constant( + 5, + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=13), + Constant( + 10, + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=16)], + lineno=14, + col_offset=19, + end_lineno=23, + end_col_offset=1), + lineno=14, + col_offset=0, + end_lineno=23, + end_col_offset=1), + FunctionDef( + 'resistor_label', + arguments( + [], + [ + arg( + 'colors', + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=27, + col_offset=7, + end_lineno=27, + end_col_offset=10), + [ + Name( + 'colors', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=17)], + [], + lineno=27, + col_offset=7, + end_lineno=27, + end_col_offset=18), + [ + Eq()], + [ + Constant( + 1, + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=23)], + lineno=27, + col_offset=7, + end_lineno=27, + end_col_offset=23), + [ + Return( + JoinedStr( + [ + Constant( + '0 ohms', + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=24)], + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=24), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=24)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=29, + col_offset=9, + end_lineno=29, + end_col_offset=12), + [ + Name( + 'colors', + Load(), + lineno=29, + col_offset=13, + end_lineno=29, + end_col_offset=19)], + [], + lineno=29, + col_offset=9, + end_lineno=29, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 4, + lineno=29, + col_offset=24, + end_lineno=29, + end_col_offset=25)], + lineno=29, + col_offset=9, + end_lineno=29, + end_col_offset=25), + [ + Assign( + [ + Name( + 'value', + Store(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=13)], + BinOp( + BinOp( + Constant( + 10, + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=18), + Mult(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=30, + col_offset=21, + end_lineno=30, + end_col_offset=27), + 'index', + Load(), + lineno=30, + col_offset=21, + end_lineno=30, + end_col_offset=33), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=40), + Constant( + 0, + lineno=30, + col_offset=41, + end_lineno=30, + end_col_offset=42), + Load(), + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=43)], + [], + lineno=30, + col_offset=21, + end_lineno=30, + end_col_offset=44), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=44), + Add(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=53), + 'index', + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=59), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=30, + col_offset=60, + end_lineno=30, + end_col_offset=66), + Constant( + 1, + lineno=30, + col_offset=67, + end_lineno=30, + end_col_offset=68), + Load(), + lineno=30, + col_offset=60, + end_lineno=30, + end_col_offset=69)], + [], + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=70), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=70), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=70), + AugAssign( + Name( + 'value', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=13), + Mult(), + BinOp( + Constant( + 10, + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=19), + Pow(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=29), + 'index', + Load(), + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=35), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=31, + col_offset=36, + end_lineno=31, + end_col_offset=42), + Constant( + 2, + lineno=31, + col_offset=43, + end_lineno=31, + end_col_offset=44), + Load(), + lineno=31, + col_offset=36, + end_lineno=31, + end_col_offset=45)], + [], + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=46), + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=46), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=46), + Assign( + [ + Tuple( + [ + Name( + 'value', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=13), + Name( + 'unit', + Store(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=19)], + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=19)], + Call( + Name( + 'color_code', + Load(), + lineno=32, + col_offset=22, + end_lineno=32, + end_col_offset=32), + [ + Name( + 'value', + Load(), + lineno=32, + col_offset=33, + end_lineno=32, + end_col_offset=38)], + [], + lineno=32, + col_offset=22, + end_lineno=32, + end_col_offset=39), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=39), + Assign( + [ + Name( + 'value', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=13)], + IfExp( + Call( + Attribute( + Name( + 'value', + Load(), + lineno=33, + col_offset=30, + end_lineno=33, + end_col_offset=35), + 'is_integer', + Load(), + lineno=33, + col_offset=30, + end_lineno=33, + end_col_offset=46), + [], + [], + lineno=33, + col_offset=30, + end_lineno=33, + end_col_offset=48), + Call( + Name( + 'int', + Load(), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=19), + [ + Name( + 'value', + Load(), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=25)], + [], + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=26), + Name( + 'value', + Load(), + lineno=33, + col_offset=54, + end_lineno=33, + end_col_offset=59), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=59), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=59), + Return( + JoinedStr( + [ + FormattedValue( + Name( + 'value', + Load(), + lineno=34, + col_offset=18, + end_lineno=34, + end_col_offset=23), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + Constant( + ' ', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + FormattedValue( + Name( + 'unit', + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=30), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + Constant( + ' ±', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + FormattedValue( + Subscript( + Name( + 'COLORS_TOLERANCE', + Load(), + lineno=34, + col_offset=35, + end_lineno=34, + end_col_offset=51), + Subscript( + Name( + 'colors', + Load(), + lineno=34, + col_offset=52, + end_lineno=34, + end_col_offset=58), + Constant( + 3, + lineno=34, + col_offset=59, + end_lineno=34, + end_col_offset=60), + Load(), + lineno=34, + col_offset=52, + end_lineno=34, + end_col_offset=61), + Load(), + lineno=34, + col_offset=35, + end_lineno=34, + end_col_offset=62), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + Constant( + '%', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=65)], + [ + Assign( + [ + Name( + 'value', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=13)], + BinOp( + BinOp( + BinOp( + Constant( + 100, + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=19), + Mult(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=28), + 'index', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=34), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=36, + col_offset=35, + end_lineno=36, + end_col_offset=41), + Constant( + 0, + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=43), + Load(), + lineno=36, + col_offset=35, + end_lineno=36, + end_col_offset=44)], + [], + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=45), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=45), + Add(), + BinOp( + Constant( + 10, + lineno=36, + col_offset=48, + end_lineno=36, + end_col_offset=50), + Mult(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=36, + col_offset=53, + end_lineno=36, + end_col_offset=59), + 'index', + Load(), + lineno=36, + col_offset=53, + end_lineno=36, + end_col_offset=65), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=36, + col_offset=66, + end_lineno=36, + end_col_offset=72), + Constant( + 1, + lineno=36, + col_offset=73, + end_lineno=36, + end_col_offset=74), + Load(), + lineno=36, + col_offset=66, + end_lineno=36, + end_col_offset=75)], + [], + lineno=36, + col_offset=53, + end_lineno=36, + end_col_offset=76), + lineno=36, + col_offset=48, + end_lineno=36, + end_col_offset=76), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=76), + Add(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=36, + col_offset=79, + end_lineno=36, + end_col_offset=85), + 'index', + Load(), + lineno=36, + col_offset=79, + end_lineno=36, + end_col_offset=91), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=36, + col_offset=92, + end_lineno=36, + end_col_offset=98), + Constant( + 2, + lineno=36, + col_offset=99, + end_lineno=36, + end_col_offset=100), + Load(), + lineno=36, + col_offset=92, + end_lineno=36, + end_col_offset=101)], + [], + lineno=36, + col_offset=79, + end_lineno=36, + end_col_offset=102), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=102), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=102), + AugAssign( + Name( + 'value', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=13), + Mult(), + BinOp( + Constant( + 10, + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=19), + Pow(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=37, + col_offset=23, + end_lineno=37, + end_col_offset=29), + 'index', + Load(), + lineno=37, + col_offset=23, + end_lineno=37, + end_col_offset=35), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=42), + Constant( + 3, + lineno=37, + col_offset=43, + end_lineno=37, + end_col_offset=44), + Load(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=45)], + [], + lineno=37, + col_offset=23, + end_lineno=37, + end_col_offset=46), + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=46), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=46), + Assign( + [ + Tuple( + [ + Name( + 'value', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=13), + Name( + 'unit', + Store(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=19)], + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=19)], + Call( + Name( + 'color_code', + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=32), + [ + Name( + 'value', + Load(), + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=38)], + [], + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=39), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=39), + Assign( + [ + Name( + 'value', + Store(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=13)], + IfExp( + Call( + Attribute( + Name( + 'value', + Load(), + lineno=39, + col_offset=30, + end_lineno=39, + end_col_offset=35), + 'is_integer', + Load(), + lineno=39, + col_offset=30, + end_lineno=39, + end_col_offset=46), + [], + [], + lineno=39, + col_offset=30, + end_lineno=39, + end_col_offset=48), + Call( + Name( + 'int', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=19), + [ + Name( + 'value', + Load(), + lineno=39, + col_offset=20, + end_lineno=39, + end_col_offset=25)], + [], + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=26), + Name( + 'value', + Load(), + lineno=39, + col_offset=54, + end_lineno=39, + end_col_offset=59), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=59), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=59), + Return( + JoinedStr( + [ + FormattedValue( + Name( + 'value', + Load(), + lineno=40, + col_offset=18, + end_lineno=40, + end_col_offset=23), + -1, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + Constant( + ' ', + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + FormattedValue( + Name( + 'unit', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=30), + -1, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + Constant( + ' ±', + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + FormattedValue( + Subscript( + Name( + 'COLORS_TOLERANCE', + Load(), + lineno=40, + col_offset=35, + end_lineno=40, + end_col_offset=51), + Subscript( + Name( + 'colors', + Load(), + lineno=40, + col_offset=52, + end_lineno=40, + end_col_offset=58), + Constant( + 4, + lineno=40, + col_offset=59, + end_lineno=40, + end_col_offset=60), + Load(), + lineno=40, + col_offset=52, + end_lineno=40, + end_col_offset=61), + Load(), + lineno=40, + col_offset=35, + end_lineno=40, + end_col_offset=62), + -1, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + Constant( + '%', + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65)], + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=65)], + lineno=29, + col_offset=4, + end_lineno=40, + end_col_offset=65)], + lineno=27, + col_offset=4, + end_lineno=40, + end_col_offset=65)], + [], + lineno=26, + col_offset=0, + end_lineno=40, + end_col_offset=65), + FunctionDef( + 'color_code', + arguments( + [], + [ + arg( + 'color', + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'color', + Load(), + lineno=44, + col_offset=7, + end_lineno=44, + end_col_offset=12), + [ + Lt()], + [ + Constant( + 1000, + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=19)], + lineno=44, + col_offset=7, + end_lineno=44, + end_col_offset=19), + [ + Return( + Tuple( + [ + BinOp( + Name( + 'color', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=20), + Div(), + Constant( + 1, + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=24), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=24), + Constant( + 'ohms', + lineno=45, + col_offset=26, + end_lineno=45, + end_col_offset=32)], + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=32), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=32)], + [ + If( + Compare( + Name( + 'color', + Load(), + lineno=46, + col_offset=9, + end_lineno=46, + end_col_offset=14), + [ + Lt()], + [ + Constant( + 1000000, + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=24)], + lineno=46, + col_offset=9, + end_lineno=46, + end_col_offset=24), + [ + Return( + Tuple( + [ + BinOp( + Name( + 'color', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=20), + Div(), + Constant( + 1000, + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=27), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=27), + Constant( + 'kiloohms', + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=39)], + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=39), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=39)], + [ + Return( + Tuple( + [ + BinOp( + Name( + 'color', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=20), + Div(), + Constant( + 1000000, + lineno=49, + col_offset=23, + end_lineno=49, + end_col_offset=30), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=30), + Constant( + 'megaohms', + lineno=49, + col_offset=32, + end_lineno=49, + end_col_offset=42)], + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=42), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=42)], + lineno=46, + col_offset=4, + end_lineno=49, + end_col_offset=42)], + lineno=44, + col_offset=4, + end_lineno=49, + end_col_offset=42)], + [], + lineno=43, + col_offset=0, + end_lineno=49, + end_col_offset=42)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + List( + [ + Constant( + 'black', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11), + Constant( + 'brown', + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11), + Constant( + 'red', + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=9), + Constant( + 'orange', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12), + Constant( + 'yellow', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=12), + Constant( + 'green', + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11), + Constant( + 'blue', + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10), + Constant( + 'violet', + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=12), + Constant( + 'grey', + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=10), + Constant( + 'white', + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=11)], + Load(), + lineno=1, + col_offset=9, + end_lineno=12, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=1), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=16)], + Dict( + [ + Constant( + 'brown', + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=11), + Constant( + 'red', + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=9), + Constant( + 'green', + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=11), + Constant( + 'blue', + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=10), + Constant( + 'violet', + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=12), + Constant( + 'grey', + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=10), + Constant( + 'gold', + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=10), + Constant( + 'silver', + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=12)], + [ + Constant( + 1, + lineno=15, + col_offset=13, + end_lineno=15, + end_col_offset=14), + Constant( + 2, + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=12), + Constant( + 0.5, + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=16), + Constant( + 0.25, + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=16), + Constant( + 0.1, + lineno=19, + col_offset=14, + end_lineno=19, + end_col_offset=17), + Constant( + 0.05, + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=16), + Constant( + 5, + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=13), + Constant( + 10, + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=16)], + lineno=14, + col_offset=19, + end_lineno=23, + end_col_offset=1), + lineno=14, + col_offset=0, + end_lineno=23, + end_col_offset=1), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=27, + col_offset=7, + end_lineno=27, + end_col_offset=10), + [ + Name( + 'placeholder_3', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=17)], + [], + lineno=27, + col_offset=7, + end_lineno=27, + end_col_offset=18), + [ + Eq()], + [ + Constant( + 1, + lineno=27, + col_offset=22, + end_lineno=27, + end_col_offset=23)], + lineno=27, + col_offset=7, + end_lineno=27, + end_col_offset=23), + [ + Return( + JoinedStr( + [ + Constant( + '0 ohms', + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=24)], + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=24), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=24)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=29, + col_offset=9, + end_lineno=29, + end_col_offset=12), + [ + Name( + 'placeholder_3', + Load(), + lineno=29, + col_offset=13, + end_lineno=29, + end_col_offset=19)], + [], + lineno=29, + col_offset=9, + end_lineno=29, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 4, + lineno=29, + col_offset=24, + end_lineno=29, + end_col_offset=25)], + lineno=29, + col_offset=9, + end_lineno=29, + end_col_offset=25), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=13)], + BinOp( + BinOp( + Constant( + 10, + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=18), + Mult(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=30, + col_offset=21, + end_lineno=30, + end_col_offset=27), + 'index', + Load(), + lineno=30, + col_offset=21, + end_lineno=30, + end_col_offset=33), + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=40), + Constant( + 0, + lineno=30, + col_offset=41, + end_lineno=30, + end_col_offset=42), + Load(), + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=43)], + [], + lineno=30, + col_offset=21, + end_lineno=30, + end_col_offset=44), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=44), + Add(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=53), + 'index', + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=59), + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=30, + col_offset=60, + end_lineno=30, + end_col_offset=66), + Constant( + 1, + lineno=30, + col_offset=67, + end_lineno=30, + end_col_offset=68), + Load(), + lineno=30, + col_offset=60, + end_lineno=30, + end_col_offset=69)], + [], + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=70), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=70), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=70), + AugAssign( + Name( + 'placeholder_4', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=13), + Mult(), + BinOp( + Constant( + 10, + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=19), + Pow(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=29), + 'index', + Load(), + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=35), + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=31, + col_offset=36, + end_lineno=31, + end_col_offset=42), + Constant( + 2, + lineno=31, + col_offset=43, + end_lineno=31, + end_col_offset=44), + Load(), + lineno=31, + col_offset=36, + end_lineno=31, + end_col_offset=45)], + [], + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=46), + lineno=31, + col_offset=17, + end_lineno=31, + end_col_offset=46), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=46), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_4', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=13), + Name( + 'placeholder_5', + Store(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=19)], + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=19)], + Call( + Name( + 'color_code', + Load(), + lineno=32, + col_offset=22, + end_lineno=32, + end_col_offset=32), + [ + Name( + 'placeholder_4', + Load(), + lineno=32, + col_offset=33, + end_lineno=32, + end_col_offset=38)], + [], + lineno=32, + col_offset=22, + end_lineno=32, + end_col_offset=39), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=13)], + IfExp( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=33, + col_offset=30, + end_lineno=33, + end_col_offset=35), + 'is_integer', + Load(), + lineno=33, + col_offset=30, + end_lineno=33, + end_col_offset=46), + [], + [], + lineno=33, + col_offset=30, + end_lineno=33, + end_col_offset=48), + Call( + Name( + 'int', + Load(), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=19), + [ + Name( + 'placeholder_4', + Load(), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=25)], + [], + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=26), + Name( + 'placeholder_4', + Load(), + lineno=33, + col_offset=54, + end_lineno=33, + end_col_offset=59), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=59), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=59), + Return( + JoinedStr( + [ + FormattedValue( + Name( + 'placeholder_4', + Load(), + lineno=34, + col_offset=18, + end_lineno=34, + end_col_offset=23), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + Constant( + ' ', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + FormattedValue( + Name( + 'placeholder_5', + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=30), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + Constant( + ' ±', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + FormattedValue( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=34, + col_offset=35, + end_lineno=34, + end_col_offset=51), + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=34, + col_offset=52, + end_lineno=34, + end_col_offset=58), + Constant( + 3, + lineno=34, + col_offset=59, + end_lineno=34, + end_col_offset=60), + Load(), + lineno=34, + col_offset=52, + end_lineno=34, + end_col_offset=61), + Load(), + lineno=34, + col_offset=35, + end_lineno=34, + end_col_offset=62), + -1, + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + Constant( + '%', + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65)], + lineno=34, + col_offset=15, + end_lineno=34, + end_col_offset=65), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=65)], + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=13)], + BinOp( + BinOp( + BinOp( + Constant( + 100, + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=19), + Mult(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=28), + 'index', + Load(), + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=34), + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=36, + col_offset=35, + end_lineno=36, + end_col_offset=41), + Constant( + 0, + lineno=36, + col_offset=42, + end_lineno=36, + end_col_offset=43), + Load(), + lineno=36, + col_offset=35, + end_lineno=36, + end_col_offset=44)], + [], + lineno=36, + col_offset=22, + end_lineno=36, + end_col_offset=45), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=45), + Add(), + BinOp( + Constant( + 10, + lineno=36, + col_offset=48, + end_lineno=36, + end_col_offset=50), + Mult(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=36, + col_offset=53, + end_lineno=36, + end_col_offset=59), + 'index', + Load(), + lineno=36, + col_offset=53, + end_lineno=36, + end_col_offset=65), + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=36, + col_offset=66, + end_lineno=36, + end_col_offset=72), + Constant( + 1, + lineno=36, + col_offset=73, + end_lineno=36, + end_col_offset=74), + Load(), + lineno=36, + col_offset=66, + end_lineno=36, + end_col_offset=75)], + [], + lineno=36, + col_offset=53, + end_lineno=36, + end_col_offset=76), + lineno=36, + col_offset=48, + end_lineno=36, + end_col_offset=76), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=76), + Add(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=36, + col_offset=79, + end_lineno=36, + end_col_offset=85), + 'index', + Load(), + lineno=36, + col_offset=79, + end_lineno=36, + end_col_offset=91), + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=36, + col_offset=92, + end_lineno=36, + end_col_offset=98), + Constant( + 2, + lineno=36, + col_offset=99, + end_lineno=36, + end_col_offset=100), + Load(), + lineno=36, + col_offset=92, + end_lineno=36, + end_col_offset=101)], + [], + lineno=36, + col_offset=79, + end_lineno=36, + end_col_offset=102), + lineno=36, + col_offset=16, + end_lineno=36, + end_col_offset=102), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=102), + AugAssign( + Name( + 'placeholder_4', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=13), + Mult(), + BinOp( + Constant( + 10, + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=19), + Pow(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=37, + col_offset=23, + end_lineno=37, + end_col_offset=29), + 'index', + Load(), + lineno=37, + col_offset=23, + end_lineno=37, + end_col_offset=35), + [ + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=42), + Constant( + 3, + lineno=37, + col_offset=43, + end_lineno=37, + end_col_offset=44), + Load(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=45)], + [], + lineno=37, + col_offset=23, + end_lineno=37, + end_col_offset=46), + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=46), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=46), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_4', + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=13), + Name( + 'placeholder_5', + Store(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=19)], + Store(), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=19)], + Call( + Name( + 'color_code', + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=32), + [ + Name( + 'placeholder_4', + Load(), + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=38)], + [], + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=39), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=13)], + IfExp( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=39, + col_offset=30, + end_lineno=39, + end_col_offset=35), + 'is_integer', + Load(), + lineno=39, + col_offset=30, + end_lineno=39, + end_col_offset=46), + [], + [], + lineno=39, + col_offset=30, + end_lineno=39, + end_col_offset=48), + Call( + Name( + 'int', + Load(), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=19), + [ + Name( + 'placeholder_4', + Load(), + lineno=39, + col_offset=20, + end_lineno=39, + end_col_offset=25)], + [], + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=26), + Name( + 'placeholder_4', + Load(), + lineno=39, + col_offset=54, + end_lineno=39, + end_col_offset=59), + lineno=39, + col_offset=16, + end_lineno=39, + end_col_offset=59), + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=59), + Return( + JoinedStr( + [ + FormattedValue( + Name( + 'placeholder_4', + Load(), + lineno=40, + col_offset=18, + end_lineno=40, + end_col_offset=23), + -1, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + Constant( + ' ', + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + FormattedValue( + Name( + 'placeholder_5', + Load(), + lineno=40, + col_offset=26, + end_lineno=40, + end_col_offset=30), + -1, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + Constant( + ' ±', + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + FormattedValue( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=40, + col_offset=35, + end_lineno=40, + end_col_offset=51), + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=40, + col_offset=52, + end_lineno=40, + end_col_offset=58), + Constant( + 4, + lineno=40, + col_offset=59, + end_lineno=40, + end_col_offset=60), + Load(), + lineno=40, + col_offset=52, + end_lineno=40, + end_col_offset=61), + Load(), + lineno=40, + col_offset=35, + end_lineno=40, + end_col_offset=62), + -1, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + Constant( + '%', + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65)], + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=65), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=65)], + lineno=29, + col_offset=4, + end_lineno=40, + end_col_offset=65)], + lineno=27, + col_offset=4, + end_lineno=40, + end_col_offset=65)], + [], + lineno=26, + col_offset=0, + end_lineno=40, + end_col_offset=65), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=44, + col_offset=7, + end_lineno=44, + end_col_offset=12), + [ + Lt()], + [ + Constant( + 1000, + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=19)], + lineno=44, + col_offset=7, + end_lineno=44, + end_col_offset=19), + [ + Return( + Tuple( + [ + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=20), + Div(), + Constant( + 1, + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=24), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=24), + Constant( + 'ohms', + lineno=45, + col_offset=26, + end_lineno=45, + end_col_offset=32)], + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=32), + lineno=45, + col_offset=8, + end_lineno=45, + end_col_offset=32)], + [ + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=46, + col_offset=9, + end_lineno=46, + end_col_offset=14), + [ + Lt()], + [ + Constant( + 1000000, + lineno=46, + col_offset=17, + end_lineno=46, + end_col_offset=24)], + lineno=46, + col_offset=9, + end_lineno=46, + end_col_offset=24), + [ + Return( + Tuple( + [ + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=20), + Div(), + Constant( + 1000, + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=27), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=27), + Constant( + 'kiloohms', + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=39)], + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=39), + lineno=47, + col_offset=8, + end_lineno=47, + end_col_offset=39)], + [ + Return( + Tuple( + [ + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=20), + Div(), + Constant( + 1000000, + lineno=49, + col_offset=23, + end_lineno=49, + end_col_offset=30), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=30), + Constant( + 'megaohms', + lineno=49, + col_offset=32, + end_lineno=49, + end_col_offset=42)], + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=42), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=42)], + lineno=46, + col_offset=4, + end_lineno=49, + end_col_offset=42)], + lineno=44, + col_offset=4, + end_lineno=49, + end_col_offset=42)], + [], + lineno=43, + col_offset=0, + end_lineno=49, + end_col_offset=42)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-resistor-color-expert/representation.txt b/test/practice-resistor-color-expert/representation.txt new file mode 100644 index 0000000..da78a7a --- /dev/null +++ b/test/practice-resistor-color-expert/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=6)], List([Constant('black', lineno=2, col_offset=4, end_lineno=2, end_col_offset=11), Constant('brown', lineno=3, col_offset=4, end_lineno=3, end_col_offset=11), Constant('red', lineno=4, col_offset=4, end_lineno=4, end_col_offset=9), Constant('orange', lineno=5, col_offset=4, end_lineno=5, end_col_offset=12), Constant('yellow', lineno=6, col_offset=4, end_lineno=6, end_col_offset=12), Constant('green', lineno=7, col_offset=4, end_lineno=7, end_col_offset=11), Constant('blue', lineno=8, col_offset=4, end_lineno=8, end_col_offset=10), Constant('violet', lineno=9, col_offset=4, end_lineno=9, end_col_offset=12), Constant('grey', lineno=10, col_offset=4, end_lineno=10, end_col_offset=10), Constant('white', lineno=11, col_offset=4, end_lineno=11, end_col_offset=11)], Load(), lineno=1, col_offset=9, end_lineno=12, end_col_offset=1), lineno=1, col_offset=0, end_lineno=12, end_col_offset=1), Assign([Name('placeholder_1', Store(), lineno=14, col_offset=0, end_lineno=14, end_col_offset=16)], Dict([Constant('brown', lineno=15, col_offset=4, end_lineno=15, end_col_offset=11), Constant('red', lineno=16, col_offset=4, end_lineno=16, end_col_offset=9), Constant('green', lineno=17, col_offset=4, end_lineno=17, end_col_offset=11), Constant('blue', lineno=18, col_offset=4, end_lineno=18, end_col_offset=10), Constant('violet', lineno=19, col_offset=4, end_lineno=19, end_col_offset=12), Constant('grey', lineno=20, col_offset=4, end_lineno=20, end_col_offset=10), Constant('gold', lineno=21, col_offset=4, end_lineno=21, end_col_offset=10), Constant('silver', lineno=22, col_offset=4, end_lineno=22, end_col_offset=12)], [Constant(1, lineno=15, col_offset=13, end_lineno=15, end_col_offset=14), Constant(2, lineno=16, col_offset=11, end_lineno=16, end_col_offset=12), Constant(0.5, lineno=17, col_offset=13, end_lineno=17, end_col_offset=16), Constant(0.25, lineno=18, col_offset=12, end_lineno=18, end_col_offset=16), Constant(0.1, lineno=19, col_offset=14, end_lineno=19, end_col_offset=17), Constant(0.05, lineno=20, col_offset=12, end_lineno=20, end_col_offset=16), Constant(5, lineno=21, col_offset=12, end_lineno=21, end_col_offset=13), Constant(10, lineno=22, col_offset=14, end_lineno=22, end_col_offset=16)], lineno=14, col_offset=19, end_lineno=23, end_col_offset=1), lineno=14, col_offset=0, end_lineno=23, end_col_offset=1), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=26, col_offset=19, end_lineno=26, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=27, col_offset=7, end_lineno=27, end_col_offset=10), [Name('placeholder_3', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=17)], [], lineno=27, col_offset=7, end_lineno=27, end_col_offset=18), [Eq()], [Constant(1, lineno=27, col_offset=22, end_lineno=27, end_col_offset=23)], lineno=27, col_offset=7, end_lineno=27, end_col_offset=23), [Return(JoinedStr([Constant('0 ohms', lineno=28, col_offset=15, end_lineno=28, end_col_offset=24)], lineno=28, col_offset=15, end_lineno=28, end_col_offset=24), lineno=28, col_offset=8, end_lineno=28, end_col_offset=24)], [If(Compare(Call(Name('len', Load(), lineno=29, col_offset=9, end_lineno=29, end_col_offset=12), [Name('placeholder_3', Load(), lineno=29, col_offset=13, end_lineno=29, end_col_offset=19)], [], lineno=29, col_offset=9, end_lineno=29, end_col_offset=20), [Eq()], [Constant(4, lineno=29, col_offset=24, end_lineno=29, end_col_offset=25)], lineno=29, col_offset=9, end_lineno=29, end_col_offset=25), [Assign([Name('placeholder_4', Store(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=13)], BinOp(BinOp(Constant(10, lineno=30, col_offset=16, end_lineno=30, end_col_offset=18), Mult(), Call(Attribute(Name('placeholder_0', Load(), lineno=30, col_offset=21, end_lineno=30, end_col_offset=27), 'index', Load(), lineno=30, col_offset=21, end_lineno=30, end_col_offset=33), [Subscript(Name('placeholder_3', Load(), lineno=30, col_offset=34, end_lineno=30, end_col_offset=40), Constant(0, lineno=30, col_offset=41, end_lineno=30, end_col_offset=42), Load(), lineno=30, col_offset=34, end_lineno=30, end_col_offset=43)], [], lineno=30, col_offset=21, end_lineno=30, end_col_offset=44), lineno=30, col_offset=16, end_lineno=30, end_col_offset=44), Add(), Call(Attribute(Name('placeholder_0', Load(), lineno=30, col_offset=47, end_lineno=30, end_col_offset=53), 'index', Load(), lineno=30, col_offset=47, end_lineno=30, end_col_offset=59), [Subscript(Name('placeholder_3', Load(), lineno=30, col_offset=60, end_lineno=30, end_col_offset=66), Constant(1, lineno=30, col_offset=67, end_lineno=30, end_col_offset=68), Load(), lineno=30, col_offset=60, end_lineno=30, end_col_offset=69)], [], lineno=30, col_offset=47, end_lineno=30, end_col_offset=70), lineno=30, col_offset=16, end_lineno=30, end_col_offset=70), lineno=30, col_offset=8, end_lineno=30, end_col_offset=70), AugAssign(Name('placeholder_4', Store(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=13), Mult(), BinOp(Constant(10, lineno=31, col_offset=17, end_lineno=31, end_col_offset=19), Pow(), Call(Attribute(Name('placeholder_0', Load(), lineno=31, col_offset=23, end_lineno=31, end_col_offset=29), 'index', Load(), lineno=31, col_offset=23, end_lineno=31, end_col_offset=35), [Subscript(Name('placeholder_3', Load(), lineno=31, col_offset=36, end_lineno=31, end_col_offset=42), Constant(2, lineno=31, col_offset=43, end_lineno=31, end_col_offset=44), Load(), lineno=31, col_offset=36, end_lineno=31, end_col_offset=45)], [], lineno=31, col_offset=23, end_lineno=31, end_col_offset=46), lineno=31, col_offset=17, end_lineno=31, end_col_offset=46), lineno=31, col_offset=8, end_lineno=31, end_col_offset=46), Assign([Tuple([Name('placeholder_4', Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=13), Name('placeholder_5', Store(), lineno=32, col_offset=15, end_lineno=32, end_col_offset=19)], Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=19)], Call(Name('color_code', Load(), lineno=32, col_offset=22, end_lineno=32, end_col_offset=32), [Name('placeholder_4', Load(), lineno=32, col_offset=33, end_lineno=32, end_col_offset=38)], [], lineno=32, col_offset=22, end_lineno=32, end_col_offset=39), lineno=32, col_offset=8, end_lineno=32, end_col_offset=39), Assign([Name('placeholder_4', Store(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=13)], IfExp(Call(Attribute(Name('placeholder_4', Load(), lineno=33, col_offset=30, end_lineno=33, end_col_offset=35), 'is_integer', Load(), lineno=33, col_offset=30, end_lineno=33, end_col_offset=46), [], [], lineno=33, col_offset=30, end_lineno=33, end_col_offset=48), Call(Name('int', Load(), lineno=33, col_offset=16, end_lineno=33, end_col_offset=19), [Name('placeholder_4', Load(), lineno=33, col_offset=20, end_lineno=33, end_col_offset=25)], [], lineno=33, col_offset=16, end_lineno=33, end_col_offset=26), Name('placeholder_4', Load(), lineno=33, col_offset=54, end_lineno=33, end_col_offset=59), lineno=33, col_offset=16, end_lineno=33, end_col_offset=59), lineno=33, col_offset=8, end_lineno=33, end_col_offset=59), Return(JoinedStr([FormattedValue(Name('placeholder_4', Load(), lineno=34, col_offset=18, end_lineno=34, end_col_offset=23), -1, lineno=34, col_offset=15, end_lineno=34, end_col_offset=65), Constant(' ', lineno=34, col_offset=15, end_lineno=34, end_col_offset=65), FormattedValue(Name('placeholder_5', Load(), lineno=34, col_offset=26, end_lineno=34, end_col_offset=30), -1, lineno=34, col_offset=15, end_lineno=34, end_col_offset=65), Constant(' ±', lineno=34, col_offset=15, end_lineno=34, end_col_offset=65), FormattedValue(Subscript(Name('placeholder_1', Load(), lineno=34, col_offset=35, end_lineno=34, end_col_offset=51), Subscript(Name('placeholder_3', Load(), lineno=34, col_offset=52, end_lineno=34, end_col_offset=58), Constant(3, lineno=34, col_offset=59, end_lineno=34, end_col_offset=60), Load(), lineno=34, col_offset=52, end_lineno=34, end_col_offset=61), Load(), lineno=34, col_offset=35, end_lineno=34, end_col_offset=62), -1, lineno=34, col_offset=15, end_lineno=34, end_col_offset=65), Constant('%', lineno=34, col_offset=15, end_lineno=34, end_col_offset=65)], lineno=34, col_offset=15, end_lineno=34, end_col_offset=65), lineno=34, col_offset=8, end_lineno=34, end_col_offset=65)], [Assign([Name('placeholder_4', Store(), lineno=36, col_offset=8, end_lineno=36, end_col_offset=13)], BinOp(BinOp(BinOp(Constant(100, lineno=36, col_offset=16, end_lineno=36, end_col_offset=19), Mult(), Call(Attribute(Name('placeholder_0', Load(), lineno=36, col_offset=22, end_lineno=36, end_col_offset=28), 'index', Load(), lineno=36, col_offset=22, end_lineno=36, end_col_offset=34), [Subscript(Name('placeholder_3', Load(), lineno=36, col_offset=35, end_lineno=36, end_col_offset=41), Constant(0, lineno=36, col_offset=42, end_lineno=36, end_col_offset=43), Load(), lineno=36, col_offset=35, end_lineno=36, end_col_offset=44)], [], lineno=36, col_offset=22, end_lineno=36, end_col_offset=45), lineno=36, col_offset=16, end_lineno=36, end_col_offset=45), Add(), BinOp(Constant(10, lineno=36, col_offset=48, end_lineno=36, end_col_offset=50), Mult(), Call(Attribute(Name('placeholder_0', Load(), lineno=36, col_offset=53, end_lineno=36, end_col_offset=59), 'index', Load(), lineno=36, col_offset=53, end_lineno=36, end_col_offset=65), [Subscript(Name('placeholder_3', Load(), lineno=36, col_offset=66, end_lineno=36, end_col_offset=72), Constant(1, lineno=36, col_offset=73, end_lineno=36, end_col_offset=74), Load(), lineno=36, col_offset=66, end_lineno=36, end_col_offset=75)], [], lineno=36, col_offset=53, end_lineno=36, end_col_offset=76), lineno=36, col_offset=48, end_lineno=36, end_col_offset=76), lineno=36, col_offset=16, end_lineno=36, end_col_offset=76), Add(), Call(Attribute(Name('placeholder_0', Load(), lineno=36, col_offset=79, end_lineno=36, end_col_offset=85), 'index', Load(), lineno=36, col_offset=79, end_lineno=36, end_col_offset=91), [Subscript(Name('placeholder_3', Load(), lineno=36, col_offset=92, end_lineno=36, end_col_offset=98), Constant(2, lineno=36, col_offset=99, end_lineno=36, end_col_offset=100), Load(), lineno=36, col_offset=92, end_lineno=36, end_col_offset=101)], [], lineno=36, col_offset=79, end_lineno=36, end_col_offset=102), lineno=36, col_offset=16, end_lineno=36, end_col_offset=102), lineno=36, col_offset=8, end_lineno=36, end_col_offset=102), AugAssign(Name('placeholder_4', Store(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=13), Mult(), BinOp(Constant(10, lineno=37, col_offset=17, end_lineno=37, end_col_offset=19), Pow(), Call(Attribute(Name('placeholder_0', Load(), lineno=37, col_offset=23, end_lineno=37, end_col_offset=29), 'index', Load(), lineno=37, col_offset=23, end_lineno=37, end_col_offset=35), [Subscript(Name('placeholder_3', Load(), lineno=37, col_offset=36, end_lineno=37, end_col_offset=42), Constant(3, lineno=37, col_offset=43, end_lineno=37, end_col_offset=44), Load(), lineno=37, col_offset=36, end_lineno=37, end_col_offset=45)], [], lineno=37, col_offset=23, end_lineno=37, end_col_offset=46), lineno=37, col_offset=17, end_lineno=37, end_col_offset=46), lineno=37, col_offset=8, end_lineno=37, end_col_offset=46), Assign([Tuple([Name('placeholder_4', Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=13), Name('placeholder_5', Store(), lineno=38, col_offset=15, end_lineno=38, end_col_offset=19)], Store(), lineno=38, col_offset=8, end_lineno=38, end_col_offset=19)], Call(Name('color_code', Load(), lineno=38, col_offset=22, end_lineno=38, end_col_offset=32), [Name('placeholder_4', Load(), lineno=38, col_offset=33, end_lineno=38, end_col_offset=38)], [], lineno=38, col_offset=22, end_lineno=38, end_col_offset=39), lineno=38, col_offset=8, end_lineno=38, end_col_offset=39), Assign([Name('placeholder_4', Store(), lineno=39, col_offset=8, end_lineno=39, end_col_offset=13)], IfExp(Call(Attribute(Name('placeholder_4', Load(), lineno=39, col_offset=30, end_lineno=39, end_col_offset=35), 'is_integer', Load(), lineno=39, col_offset=30, end_lineno=39, end_col_offset=46), [], [], lineno=39, col_offset=30, end_lineno=39, end_col_offset=48), Call(Name('int', Load(), lineno=39, col_offset=16, end_lineno=39, end_col_offset=19), [Name('placeholder_4', Load(), lineno=39, col_offset=20, end_lineno=39, end_col_offset=25)], [], lineno=39, col_offset=16, end_lineno=39, end_col_offset=26), Name('placeholder_4', Load(), lineno=39, col_offset=54, end_lineno=39, end_col_offset=59), lineno=39, col_offset=16, end_lineno=39, end_col_offset=59), lineno=39, col_offset=8, end_lineno=39, end_col_offset=59), Return(JoinedStr([FormattedValue(Name('placeholder_4', Load(), lineno=40, col_offset=18, end_lineno=40, end_col_offset=23), -1, lineno=40, col_offset=15, end_lineno=40, end_col_offset=65), Constant(' ', lineno=40, col_offset=15, end_lineno=40, end_col_offset=65), FormattedValue(Name('placeholder_5', Load(), lineno=40, col_offset=26, end_lineno=40, end_col_offset=30), -1, lineno=40, col_offset=15, end_lineno=40, end_col_offset=65), Constant(' ±', lineno=40, col_offset=15, end_lineno=40, end_col_offset=65), FormattedValue(Subscript(Name('placeholder_1', Load(), lineno=40, col_offset=35, end_lineno=40, end_col_offset=51), Subscript(Name('placeholder_3', Load(), lineno=40, col_offset=52, end_lineno=40, end_col_offset=58), Constant(4, lineno=40, col_offset=59, end_lineno=40, end_col_offset=60), Load(), lineno=40, col_offset=52, end_lineno=40, end_col_offset=61), Load(), lineno=40, col_offset=35, end_lineno=40, end_col_offset=62), -1, lineno=40, col_offset=15, end_lineno=40, end_col_offset=65), Constant('%', lineno=40, col_offset=15, end_lineno=40, end_col_offset=65)], lineno=40, col_offset=15, end_lineno=40, end_col_offset=65), lineno=40, col_offset=8, end_lineno=40, end_col_offset=65)], lineno=29, col_offset=4, end_lineno=40, end_col_offset=65)], lineno=27, col_offset=4, end_lineno=40, end_col_offset=65)], [], lineno=26, col_offset=0, end_lineno=40, end_col_offset=65), FunctionDef('placeholder_6', arguments([], [arg('placeholder_7', lineno=43, col_offset=15, end_lineno=43, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_7', Load(), lineno=44, col_offset=7, end_lineno=44, end_col_offset=12), [Lt()], [Constant(1000, lineno=44, col_offset=15, end_lineno=44, end_col_offset=19)], lineno=44, col_offset=7, end_lineno=44, end_col_offset=19), [Return(Tuple([BinOp(Name('placeholder_7', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=20), Div(), Constant(1, lineno=45, col_offset=23, end_lineno=45, end_col_offset=24), lineno=45, col_offset=15, end_lineno=45, end_col_offset=24), Constant('ohms', lineno=45, col_offset=26, end_lineno=45, end_col_offset=32)], Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=32), lineno=45, col_offset=8, end_lineno=45, end_col_offset=32)], [If(Compare(Name('placeholder_7', Load(), lineno=46, col_offset=9, end_lineno=46, end_col_offset=14), [Lt()], [Constant(1000000, lineno=46, col_offset=17, end_lineno=46, end_col_offset=24)], lineno=46, col_offset=9, end_lineno=46, end_col_offset=24), [Return(Tuple([BinOp(Name('placeholder_7', Load(), lineno=47, col_offset=15, end_lineno=47, end_col_offset=20), Div(), Constant(1000, lineno=47, col_offset=23, end_lineno=47, end_col_offset=27), lineno=47, col_offset=15, end_lineno=47, end_col_offset=27), Constant('kiloohms', lineno=47, col_offset=29, end_lineno=47, end_col_offset=39)], Load(), lineno=47, col_offset=15, end_lineno=47, end_col_offset=39), lineno=47, col_offset=8, end_lineno=47, end_col_offset=39)], [Return(Tuple([BinOp(Name('placeholder_7', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=20), Div(), Constant(1000000, lineno=49, col_offset=23, end_lineno=49, end_col_offset=30), lineno=49, col_offset=15, end_lineno=49, end_col_offset=30), Constant('megaohms', lineno=49, col_offset=32, end_lineno=49, end_col_offset=42)], Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=42), lineno=49, col_offset=8, end_lineno=49, end_col_offset=42)], lineno=46, col_offset=4, end_lineno=49, end_col_offset=42)], lineno=44, col_offset=4, end_lineno=49, end_col_offset=42)], [], lineno=43, col_offset=0, end_lineno=49, end_col_offset=42)], []) \ No newline at end of file diff --git a/test/practice-resistor-color-expert/resistor_color_expert.py b/test/practice-resistor-color-expert/resistor_color_expert.py new file mode 100644 index 0000000..0fd6e42 --- /dev/null +++ b/test/practice-resistor-color-expert/resistor_color_expert.py @@ -0,0 +1,49 @@ +COLORS = [ + 'black', + 'brown', + 'red', + 'orange', + 'yellow', + 'green', + 'blue', + 'violet', + 'grey', + 'white' +] + +COLORS_TOLERANCE = { + 'brown': 1, + 'red': 2, + 'green': 0.5, + 'blue': 0.25, + 'violet': 0.1, + 'grey': 0.05, + 'gold': 5, + 'silver': 10 +} + + +def resistor_label(colors): + if len(colors) == 1: + return f'0 ohms' + elif len(colors) == 4: + value = 10 * COLORS.index(colors[0]) + COLORS.index(colors[1]) + value *= 10 ** COLORS.index(colors[2]) + value, unit = color_code(value) + value = int(value) if value.is_integer() else value + return f'{value} {unit} ±{COLORS_TOLERANCE[colors[3]]}%' + else: + value = 100 * COLORS.index(colors[0]) + 10 * COLORS.index(colors[1]) + COLORS.index(colors[2]) + value *= 10 ** COLORS.index(colors[3]) + value, unit = color_code(value) + value = int(value) if value.is_integer() else value + return f'{value} {unit} ±{COLORS_TOLERANCE[colors[4]]}%' + + +def color_code(color): + if color < 1000: + return color / 1, 'ohms' + elif color < 1000000: + return color / 1000, 'kiloohms' + else: + return color / 1000000, 'megaohms' \ No newline at end of file diff --git a/test/practice-resistor-color-trio/.meta/config.json b/test/practice-resistor-color-trio/.meta/config.json new file mode 100644 index 0000000..68dad4c --- /dev/null +++ b/test/practice-resistor-color-trio/.meta/config.json @@ -0,0 +1,20 @@ +{ + "authors": [ + "meatball133", + "bethanyg" + ], + "files": { + "solution": [ + "resistor_color_trio.py" + ], + "test": [ + "resistor_color_trio_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Convert color codes, as used on resistors, to a human-readable label.", + "source": "Maud de Vries, Erik Schierboom", + "source_url": "https://github.com/exercism/problem-specifications/issues/1549" +} diff --git a/test/practice-resistor-color-trio/mapping.json b/test/practice-resistor-color-trio/mapping.json new file mode 100644 index 0000000..2482c84 --- /dev/null +++ b/test/practice-resistor-color-trio/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "COLORS", + "placeholder_1": "label", + "placeholder_2": "colors", + "placeholder_3": "value", + "placeholder_4": "unit" +} \ No newline at end of file diff --git a/test/practice-resistor-color-trio/representation.json b/test/practice-resistor-color-trio/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-resistor-color-trio/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-resistor-color-trio/representation.out b/test/practice-resistor-color-trio/representation.out new file mode 100644 index 0000000..95bb20c --- /dev/null +++ b/test/practice-resistor-color-trio/representation.out @@ -0,0 +1,1585 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = [ + "black", + "brown", + "red", + "orange", + "yellow", + "green", + "blue", + "violet", + "grey", + "white", +] + + +def placeholder_1(placeholder_2): + placeholder_3 = 10 * placeholder_0.index(placeholder_2[0]) + placeholder_0.index( + placeholder_2[1] + ) + placeholder_3 *= 10 ** placeholder_0.index(placeholder_2[2]) + placeholder_1 = str(placeholder_3) + if len(placeholder_1) < 4: + placeholder_4 = "ohms" + elif len(placeholder_1) < 7: + placeholder_1 = str(placeholder_3 // 1000) + placeholder_4 = "kiloohms" + elif len(placeholder_1) <= 8: + placeholder_1 = str(placeholder_3 // 1000000) + placeholder_4 = "megaohms" + elif len(placeholder_1) >= 9: + placeholder_1 = str(placeholder_3 // 1000000000) + placeholder_4 = "gigaohms" + return ( + f"{(placeholder_3 if placeholder_3 < 1000 else placeholder_1)} {placeholder_4}" + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'COLORS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + List( + [ + Constant( + 'black', + lineno=2, + col_offset=8, + end_lineno=2, + end_col_offset=15), + Constant( + 'brown', + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=15), + Constant( + 'red', + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=13), + Constant( + 'orange', + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=16), + Constant( + 'yellow', + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=16), + Constant( + 'green', + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=15), + Constant( + 'blue', + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=14), + Constant( + 'violet', + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=16), + Constant( + 'grey', + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14), + Constant( + 'white', + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=15)], + Load(), + lineno=1, + col_offset=9, + end_lineno=12, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=1), + FunctionDef( + 'label', + arguments( + [], + [ + arg( + 'colors', + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'value', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=9)], + BinOp( + BinOp( + Constant( + 10, + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=14), + Mult(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=16, + col_offset=17, + end_lineno=16, + end_col_offset=23), + 'index', + Load(), + lineno=16, + col_offset=17, + end_lineno=16, + end_col_offset=29), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=36), + Constant( + 0, + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=38), + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=39)], + [], + lineno=16, + col_offset=17, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=40), + Add(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=49), + 'index', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=55), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=62), + Constant( + 1, + lineno=16, + col_offset=63, + end_lineno=16, + end_col_offset=64), + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=65)], + [], + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=66), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=66), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=66), + AugAssign( + Name( + 'value', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=9), + Mult(), + BinOp( + Constant( + 10, + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=15), + Pow(), + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=25), + 'index', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=31), + [ + Subscript( + Name( + 'colors', + Load(), + lineno=17, + col_offset=32, + end_lineno=17, + end_col_offset=38), + Constant( + 2, + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=40), + Load(), + lineno=17, + col_offset=32, + end_lineno=17, + end_col_offset=41)], + [], + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=42), + Assign( + [ + Name( + 'label', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=9)], + Call( + Name( + 'str', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=15), + [ + Name( + 'value', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=21)], + [], + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=22), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=22), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=10), + [ + Name( + 'label', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=16)], + [], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=17), + [ + Lt()], + [ + Constant( + 4, + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=21)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=21), + [ + Assign( + [ + Name( + 'unit', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12)], + Constant( + 'ohms', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=21), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=21)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=12), + [ + Name( + 'label', + Load(), + lineno=22, + col_offset=13, + end_lineno=22, + end_col_offset=18)], + [], + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=19), + [ + Lt()], + [ + Constant( + 7, + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=23)], + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=23), + [ + Assign( + [ + Name( + 'label', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=13)], + Call( + Name( + 'str', + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=19), + [ + BinOp( + Name( + 'value', + Load(), + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=25), + FloorDiv(), + Constant( + 1000, + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=31), + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=31)], + [], + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=32), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=32), + Assign( + [ + Name( + 'unit', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12)], + Constant( + 'kiloohms', + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=25), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=25)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=9, + end_lineno=25, + end_col_offset=12), + [ + Name( + 'label', + Load(), + lineno=25, + col_offset=13, + end_lineno=25, + end_col_offset=18)], + [], + lineno=25, + col_offset=9, + end_lineno=25, + end_col_offset=19), + [ + LtE()], + [ + Constant( + 8, + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=24)], + lineno=25, + col_offset=9, + end_lineno=25, + end_col_offset=24), + [ + Assign( + [ + Name( + 'label', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=13)], + Call( + Name( + 'str', + Load(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=19), + [ + BinOp( + Name( + 'value', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=25), + FloorDiv(), + Constant( + 1000000, + lineno=26, + col_offset=27, + end_lineno=26, + end_col_offset=34), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=34)], + [], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=35), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=35), + Assign( + [ + Name( + 'unit', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=12)], + Constant( + 'megaohms', + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=25), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=25)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=28, + col_offset=9, + end_lineno=28, + end_col_offset=12), + [ + Name( + 'label', + Load(), + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=18)], + [], + lineno=28, + col_offset=9, + end_lineno=28, + end_col_offset=19), + [ + GtE()], + [ + Constant( + 9, + lineno=28, + col_offset=23, + end_lineno=28, + end_col_offset=24)], + lineno=28, + col_offset=9, + end_lineno=28, + end_col_offset=24), + [ + Assign( + [ + Name( + 'label', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=13)], + Call( + Name( + 'str', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=19), + [ + BinOp( + Name( + 'value', + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=25), + FloorDiv(), + Constant( + 1000000000, + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=37), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=37)], + [], + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=38), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=38), + Assign( + [ + Name( + 'unit', + Store(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=12)], + Constant( + 'gigaohms', + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=25), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=25)], + [], + lineno=28, + col_offset=4, + end_lineno=30, + end_col_offset=25)], + lineno=25, + col_offset=4, + end_lineno=30, + end_col_offset=25)], + lineno=22, + col_offset=4, + end_lineno=30, + end_col_offset=25)], + lineno=20, + col_offset=4, + end_lineno=30, + end_col_offset=25), + Return( + JoinedStr( + [ + FormattedValue( + IfExp( + Compare( + Name( + 'value', + Load(), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=28), + [ + Lt()], + [ + Constant( + 1000, + lineno=32, + col_offset=31, + end_lineno=32, + end_col_offset=35)], + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=35), + Name( + 'value', + Load(), + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=19), + Name( + 'label', + Load(), + lineno=32, + col_offset=41, + end_lineno=32, + end_col_offset=46), + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=46), + -1, + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=55), + Constant( + ' ', + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=55), + FormattedValue( + Name( + 'unit', + Load(), + lineno=32, + col_offset=49, + end_lineno=32, + end_col_offset=53), + -1, + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=55)], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=55), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=55)], + [], + lineno=15, + col_offset=0, + end_lineno=32, + end_col_offset=55)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + List( + [ + Constant( + 'black', + lineno=2, + col_offset=8, + end_lineno=2, + end_col_offset=15), + Constant( + 'brown', + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=15), + Constant( + 'red', + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=13), + Constant( + 'orange', + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=16), + Constant( + 'yellow', + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=16), + Constant( + 'green', + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=15), + Constant( + 'blue', + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=14), + Constant( + 'violet', + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=16), + Constant( + 'grey', + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=14), + Constant( + 'white', + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=15)], + Load(), + lineno=1, + col_offset=9, + end_lineno=12, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=1), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=15, + col_offset=10, + end_lineno=15, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=9)], + BinOp( + BinOp( + Constant( + 10, + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=14), + Mult(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=17, + end_lineno=16, + end_col_offset=23), + 'index', + Load(), + lineno=16, + col_offset=17, + end_lineno=16, + end_col_offset=29), + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=36), + Constant( + 0, + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=38), + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=39)], + [], + lineno=16, + col_offset=17, + end_lineno=16, + end_col_offset=40), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=40), + Add(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=49), + 'index', + Load(), + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=55), + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=62), + Constant( + 1, + lineno=16, + col_offset=63, + end_lineno=16, + end_col_offset=64), + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=65)], + [], + lineno=16, + col_offset=43, + end_lineno=16, + end_col_offset=66), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=66), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=66), + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=9), + Mult(), + BinOp( + Constant( + 10, + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=15), + Pow(), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=25), + 'index', + Load(), + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=31), + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=17, + col_offset=32, + end_lineno=17, + end_col_offset=38), + Constant( + 2, + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=40), + Load(), + lineno=17, + col_offset=32, + end_lineno=17, + end_col_offset=41)], + [], + lineno=17, + col_offset=19, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=9)], + Call( + Name( + 'str', + Load(), + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=15), + [ + Name( + 'placeholder_3', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=21)], + [], + lineno=18, + col_offset=12, + end_lineno=18, + end_col_offset=22), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=22), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=10), + [ + Name( + 'placeholder_1', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=16)], + [], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=17), + [ + Lt()], + [ + Constant( + 4, + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=21)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=21), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12)], + Constant( + 'ohms', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=21), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=21)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=12), + [ + Name( + 'placeholder_1', + Load(), + lineno=22, + col_offset=13, + end_lineno=22, + end_col_offset=18)], + [], + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=19), + [ + Lt()], + [ + Constant( + 7, + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=23)], + lineno=22, + col_offset=9, + end_lineno=22, + end_col_offset=23), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=13)], + Call( + Name( + 'str', + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=19), + [ + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=25), + FloorDiv(), + Constant( + 1000, + lineno=23, + col_offset=27, + end_lineno=23, + end_col_offset=31), + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=31)], + [], + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=32), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12)], + Constant( + 'kiloohms', + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=25), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=25)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=25, + col_offset=9, + end_lineno=25, + end_col_offset=12), + [ + Name( + 'placeholder_1', + Load(), + lineno=25, + col_offset=13, + end_lineno=25, + end_col_offset=18)], + [], + lineno=25, + col_offset=9, + end_lineno=25, + end_col_offset=19), + [ + LtE()], + [ + Constant( + 8, + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=24)], + lineno=25, + col_offset=9, + end_lineno=25, + end_col_offset=24), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=13)], + Call( + Name( + 'str', + Load(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=19), + [ + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=25), + FloorDiv(), + Constant( + 1000000, + lineno=26, + col_offset=27, + end_lineno=26, + end_col_offset=34), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=34)], + [], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=35), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=35), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=12)], + Constant( + 'megaohms', + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=25), + lineno=27, + col_offset=8, + end_lineno=27, + end_col_offset=25)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=28, + col_offset=9, + end_lineno=28, + end_col_offset=12), + [ + Name( + 'placeholder_1', + Load(), + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=18)], + [], + lineno=28, + col_offset=9, + end_lineno=28, + end_col_offset=19), + [ + GtE()], + [ + Constant( + 9, + lineno=28, + col_offset=23, + end_lineno=28, + end_col_offset=24)], + lineno=28, + col_offset=9, + end_lineno=28, + end_col_offset=24), + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=13)], + Call( + Name( + 'str', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=19), + [ + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=25), + FloorDiv(), + Constant( + 1000000000, + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=37), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=37)], + [], + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=38), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=38), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=12)], + Constant( + 'gigaohms', + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=25), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=25)], + [], + lineno=28, + col_offset=4, + end_lineno=30, + end_col_offset=25)], + lineno=25, + col_offset=4, + end_lineno=30, + end_col_offset=25)], + lineno=22, + col_offset=4, + end_lineno=30, + end_col_offset=25)], + lineno=20, + col_offset=4, + end_lineno=30, + end_col_offset=25), + Return( + JoinedStr( + [ + FormattedValue( + IfExp( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=28), + [ + Lt()], + [ + Constant( + 1000, + lineno=32, + col_offset=31, + end_lineno=32, + end_col_offset=35)], + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=35), + Name( + 'placeholder_3', + Load(), + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=19), + Name( + 'placeholder_1', + Load(), + lineno=32, + col_offset=41, + end_lineno=32, + end_col_offset=46), + lineno=32, + col_offset=14, + end_lineno=32, + end_col_offset=46), + -1, + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=55), + Constant( + ' ', + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=55), + FormattedValue( + Name( + 'placeholder_4', + Load(), + lineno=32, + col_offset=49, + end_lineno=32, + end_col_offset=53), + -1, + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=55)], + lineno=32, + col_offset=11, + end_lineno=32, + end_col_offset=55), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=55)], + [], + lineno=15, + col_offset=0, + end_lineno=32, + end_col_offset=55)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-resistor-color-trio/representation.txt b/test/practice-resistor-color-trio/representation.txt new file mode 100644 index 0000000..cd04027 --- /dev/null +++ b/test/practice-resistor-color-trio/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=6)], List([Constant('black', lineno=2, col_offset=8, end_lineno=2, end_col_offset=15), Constant('brown', lineno=3, col_offset=8, end_lineno=3, end_col_offset=15), Constant('red', lineno=4, col_offset=8, end_lineno=4, end_col_offset=13), Constant('orange', lineno=5, col_offset=8, end_lineno=5, end_col_offset=16), Constant('yellow', lineno=6, col_offset=8, end_lineno=6, end_col_offset=16), Constant('green', lineno=7, col_offset=8, end_lineno=7, end_col_offset=15), Constant('blue', lineno=8, col_offset=8, end_lineno=8, end_col_offset=14), Constant('violet', lineno=9, col_offset=8, end_lineno=9, end_col_offset=16), Constant('grey', lineno=10, col_offset=8, end_lineno=10, end_col_offset=14), Constant('white', lineno=11, col_offset=8, end_lineno=11, end_col_offset=15)], Load(), lineno=1, col_offset=9, end_lineno=12, end_col_offset=1), lineno=1, col_offset=0, end_lineno=12, end_col_offset=1), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=15, col_offset=10, end_lineno=15, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=16, col_offset=4, end_lineno=16, end_col_offset=9)], BinOp(BinOp(Constant(10, lineno=16, col_offset=12, end_lineno=16, end_col_offset=14), Mult(), Call(Attribute(Name('placeholder_0', Load(), lineno=16, col_offset=17, end_lineno=16, end_col_offset=23), 'index', Load(), lineno=16, col_offset=17, end_lineno=16, end_col_offset=29), [Subscript(Name('placeholder_2', Load(), lineno=16, col_offset=30, end_lineno=16, end_col_offset=36), Constant(0, lineno=16, col_offset=37, end_lineno=16, end_col_offset=38), Load(), lineno=16, col_offset=30, end_lineno=16, end_col_offset=39)], [], lineno=16, col_offset=17, end_lineno=16, end_col_offset=40), lineno=16, col_offset=12, end_lineno=16, end_col_offset=40), Add(), Call(Attribute(Name('placeholder_0', Load(), lineno=16, col_offset=43, end_lineno=16, end_col_offset=49), 'index', Load(), lineno=16, col_offset=43, end_lineno=16, end_col_offset=55), [Subscript(Name('placeholder_2', Load(), lineno=16, col_offset=56, end_lineno=16, end_col_offset=62), Constant(1, lineno=16, col_offset=63, end_lineno=16, end_col_offset=64), Load(), lineno=16, col_offset=56, end_lineno=16, end_col_offset=65)], [], lineno=16, col_offset=43, end_lineno=16, end_col_offset=66), lineno=16, col_offset=12, end_lineno=16, end_col_offset=66), lineno=16, col_offset=4, end_lineno=16, end_col_offset=66), AugAssign(Name('placeholder_3', Store(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=9), Mult(), BinOp(Constant(10, lineno=17, col_offset=13, end_lineno=17, end_col_offset=15), Pow(), Call(Attribute(Name('placeholder_0', Load(), lineno=17, col_offset=19, end_lineno=17, end_col_offset=25), 'index', Load(), lineno=17, col_offset=19, end_lineno=17, end_col_offset=31), [Subscript(Name('placeholder_2', Load(), lineno=17, col_offset=32, end_lineno=17, end_col_offset=38), Constant(2, lineno=17, col_offset=39, end_lineno=17, end_col_offset=40), Load(), lineno=17, col_offset=32, end_lineno=17, end_col_offset=41)], [], lineno=17, col_offset=19, end_lineno=17, end_col_offset=42), lineno=17, col_offset=13, end_lineno=17, end_col_offset=42), lineno=17, col_offset=4, end_lineno=17, end_col_offset=42), Assign([Name('placeholder_1', Store(), lineno=18, col_offset=4, end_lineno=18, end_col_offset=9)], Call(Name('str', Load(), lineno=18, col_offset=12, end_lineno=18, end_col_offset=15), [Name('placeholder_3', Load(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=21)], [], lineno=18, col_offset=12, end_lineno=18, end_col_offset=22), lineno=18, col_offset=4, end_lineno=18, end_col_offset=22), If(Compare(Call(Name('len', Load(), lineno=20, col_offset=7, end_lineno=20, end_col_offset=10), [Name('placeholder_1', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=16)], [], lineno=20, col_offset=7, end_lineno=20, end_col_offset=17), [Lt()], [Constant(4, lineno=20, col_offset=20, end_lineno=20, end_col_offset=21)], lineno=20, col_offset=7, end_lineno=20, end_col_offset=21), [Assign([Name('placeholder_4', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=12)], Constant('ohms', lineno=21, col_offset=15, end_lineno=21, end_col_offset=21), lineno=21, col_offset=8, end_lineno=21, end_col_offset=21)], [If(Compare(Call(Name('len', Load(), lineno=22, col_offset=9, end_lineno=22, end_col_offset=12), [Name('placeholder_1', Load(), lineno=22, col_offset=13, end_lineno=22, end_col_offset=18)], [], lineno=22, col_offset=9, end_lineno=22, end_col_offset=19), [Lt()], [Constant(7, lineno=22, col_offset=22, end_lineno=22, end_col_offset=23)], lineno=22, col_offset=9, end_lineno=22, end_col_offset=23), [Assign([Name('placeholder_1', Store(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=13)], Call(Name('str', Load(), lineno=23, col_offset=16, end_lineno=23, end_col_offset=19), [BinOp(Name('placeholder_3', Load(), lineno=23, col_offset=20, end_lineno=23, end_col_offset=25), FloorDiv(), Constant(1000, lineno=23, col_offset=27, end_lineno=23, end_col_offset=31), lineno=23, col_offset=20, end_lineno=23, end_col_offset=31)], [], lineno=23, col_offset=16, end_lineno=23, end_col_offset=32), lineno=23, col_offset=8, end_lineno=23, end_col_offset=32), Assign([Name('placeholder_4', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=12)], Constant('kiloohms', lineno=24, col_offset=15, end_lineno=24, end_col_offset=25), lineno=24, col_offset=8, end_lineno=24, end_col_offset=25)], [If(Compare(Call(Name('len', Load(), lineno=25, col_offset=9, end_lineno=25, end_col_offset=12), [Name('placeholder_1', Load(), lineno=25, col_offset=13, end_lineno=25, end_col_offset=18)], [], lineno=25, col_offset=9, end_lineno=25, end_col_offset=19), [LtE()], [Constant(8, lineno=25, col_offset=23, end_lineno=25, end_col_offset=24)], lineno=25, col_offset=9, end_lineno=25, end_col_offset=24), [Assign([Name('placeholder_1', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=13)], Call(Name('str', Load(), lineno=26, col_offset=16, end_lineno=26, end_col_offset=19), [BinOp(Name('placeholder_3', Load(), lineno=26, col_offset=20, end_lineno=26, end_col_offset=25), FloorDiv(), Constant(1000000, lineno=26, col_offset=27, end_lineno=26, end_col_offset=34), lineno=26, col_offset=20, end_lineno=26, end_col_offset=34)], [], lineno=26, col_offset=16, end_lineno=26, end_col_offset=35), lineno=26, col_offset=8, end_lineno=26, end_col_offset=35), Assign([Name('placeholder_4', Store(), lineno=27, col_offset=8, end_lineno=27, end_col_offset=12)], Constant('megaohms', lineno=27, col_offset=15, end_lineno=27, end_col_offset=25), lineno=27, col_offset=8, end_lineno=27, end_col_offset=25)], [If(Compare(Call(Name('len', Load(), lineno=28, col_offset=9, end_lineno=28, end_col_offset=12), [Name('placeholder_1', Load(), lineno=28, col_offset=13, end_lineno=28, end_col_offset=18)], [], lineno=28, col_offset=9, end_lineno=28, end_col_offset=19), [GtE()], [Constant(9, lineno=28, col_offset=23, end_lineno=28, end_col_offset=24)], lineno=28, col_offset=9, end_lineno=28, end_col_offset=24), [Assign([Name('placeholder_1', Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=13)], Call(Name('str', Load(), lineno=29, col_offset=16, end_lineno=29, end_col_offset=19), [BinOp(Name('placeholder_3', Load(), lineno=29, col_offset=20, end_lineno=29, end_col_offset=25), FloorDiv(), Constant(1000000000, lineno=29, col_offset=27, end_lineno=29, end_col_offset=37), lineno=29, col_offset=20, end_lineno=29, end_col_offset=37)], [], lineno=29, col_offset=16, end_lineno=29, end_col_offset=38), lineno=29, col_offset=8, end_lineno=29, end_col_offset=38), Assign([Name('placeholder_4', Store(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=12)], Constant('gigaohms', lineno=30, col_offset=15, end_lineno=30, end_col_offset=25), lineno=30, col_offset=8, end_lineno=30, end_col_offset=25)], [], lineno=28, col_offset=4, end_lineno=30, end_col_offset=25)], lineno=25, col_offset=4, end_lineno=30, end_col_offset=25)], lineno=22, col_offset=4, end_lineno=30, end_col_offset=25)], lineno=20, col_offset=4, end_lineno=30, end_col_offset=25), Return(JoinedStr([FormattedValue(IfExp(Compare(Name('placeholder_3', Load(), lineno=32, col_offset=23, end_lineno=32, end_col_offset=28), [Lt()], [Constant(1000, lineno=32, col_offset=31, end_lineno=32, end_col_offset=35)], lineno=32, col_offset=23, end_lineno=32, end_col_offset=35), Name('placeholder_3', Load(), lineno=32, col_offset=14, end_lineno=32, end_col_offset=19), Name('placeholder_1', Load(), lineno=32, col_offset=41, end_lineno=32, end_col_offset=46), lineno=32, col_offset=14, end_lineno=32, end_col_offset=46), -1, lineno=32, col_offset=11, end_lineno=32, end_col_offset=55), Constant(' ', lineno=32, col_offset=11, end_lineno=32, end_col_offset=55), FormattedValue(Name('placeholder_4', Load(), lineno=32, col_offset=49, end_lineno=32, end_col_offset=53), -1, lineno=32, col_offset=11, end_lineno=32, end_col_offset=55)], lineno=32, col_offset=11, end_lineno=32, end_col_offset=55), lineno=32, col_offset=4, end_lineno=32, end_col_offset=55)], [], lineno=15, col_offset=0, end_lineno=32, end_col_offset=55)], []) \ No newline at end of file diff --git a/test/practice-resistor-color-trio/resistor_color_trio.py b/test/practice-resistor-color-trio/resistor_color_trio.py new file mode 100644 index 0000000..6955459 --- /dev/null +++ b/test/practice-resistor-color-trio/resistor_color_trio.py @@ -0,0 +1,32 @@ +COLORS = [ + 'black', + 'brown', + 'red', + 'orange', + 'yellow', + 'green', + 'blue', + 'violet', + 'grey', + 'white' +] + + +def label(colors): + value = 10 * COLORS.index(colors[0]) + COLORS.index(colors[1]) + value *= 10 ** COLORS.index(colors[2]) + label = str(value) + + if len(label) < 4 : + unit = 'ohms' + elif len(label) < 7: + label = str(value//1000) + unit = 'kiloohms' + elif len(label) <= 8 : + label = str(value//1000000) + unit = 'megaohms' + elif len(label) >= 9: + label = str(value//1000000000) + unit = 'gigaohms' + + return f'{value if value < 1000 else label} {unit}' diff --git a/test/practice-resistor-color/.meta/config.json b/test/practice-resistor-color/.meta/config.json new file mode 100644 index 0000000..08c69e1 --- /dev/null +++ b/test/practice-resistor-color/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "gabriel376" + ], + "contributors": [ + "cmccandless", + "Dog", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "resistor_color.py" + ], + "test": [ + "resistor_color_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Convert a resistor band's color to its numeric representation.", + "source": "Maud de Vries, Erik Schierboom", + "source_url": "https://github.com/exercism/problem-specifications/issues/1458" +} diff --git a/test/practice-resistor-color/mapping.json b/test/practice-resistor-color/mapping.json new file mode 100644 index 0000000..5f95a2f --- /dev/null +++ b/test/practice-resistor-color/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "COLORS", + "placeholder_1": "color_code", + "placeholder_2": "color", + "placeholder_3": "colors" +} \ No newline at end of file diff --git a/test/practice-resistor-color/representation.json b/test/practice-resistor-color/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-resistor-color/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-resistor-color/representation.out b/test/practice-resistor-color/representation.out new file mode 100644 index 0000000..eb295d5 --- /dev/null +++ b/test/practice-resistor-color/representation.out @@ -0,0 +1,353 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = [ + "black", + "brown", + "red", + "orange", + "yellow", + "green", + "blue", + "violet", + "grey", + "white", +] + + +def placeholder_1(placeholder_2): + return placeholder_0.index(placeholder_2) + + +def placeholder_3(): + return placeholder_0 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'COLORS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + List( + [ + Constant( + 'black', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11), + Constant( + 'brown', + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11), + Constant( + 'red', + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=9), + Constant( + 'orange', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12), + Constant( + 'yellow', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=12), + Constant( + 'green', + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11), + Constant( + 'blue', + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10), + Constant( + 'violet', + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=12), + Constant( + 'grey', + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=10), + Constant( + 'white', + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=11)], + Load(), + lineno=1, + col_offset=9, + end_lineno=12, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=1), + FunctionDef( + 'color_code', + arguments( + [], + [ + arg( + 'color', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'COLORS', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + 'index', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=23), + [ + Name( + 'color', + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=29)], + [], + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=30), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=30)], + [], + lineno=15, + col_offset=0, + end_lineno=16, + end_col_offset=30), + FunctionDef( + 'colors', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'COLORS', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=17), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=17)], + [], + lineno=19, + col_offset=0, + end_lineno=20, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + List( + [ + Constant( + 'black', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=11), + Constant( + 'brown', + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11), + Constant( + 'red', + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=9), + Constant( + 'orange', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12), + Constant( + 'yellow', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=12), + Constant( + 'green', + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11), + Constant( + 'blue', + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=10), + Constant( + 'violet', + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=12), + Constant( + 'grey', + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=10), + Constant( + 'white', + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=11)], + Load(), + lineno=1, + col_offset=9, + end_lineno=12, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=1), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + 'index', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=23), + [ + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=29)], + [], + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=30), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=30)], + [], + lineno=15, + col_offset=0, + end_lineno=16, + end_col_offset=30), + FunctionDef( + 'placeholder_3', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'placeholder_0', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=17), + lineno=20, + col_offset=4, + end_lineno=20, + end_col_offset=17)], + [], + lineno=19, + col_offset=0, + end_lineno=20, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-resistor-color/representation.txt b/test/practice-resistor-color/representation.txt new file mode 100644 index 0000000..e3a4f0a --- /dev/null +++ b/test/practice-resistor-color/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=6)], List([Constant('black', lineno=2, col_offset=4, end_lineno=2, end_col_offset=11), Constant('brown', lineno=3, col_offset=4, end_lineno=3, end_col_offset=11), Constant('red', lineno=4, col_offset=4, end_lineno=4, end_col_offset=9), Constant('orange', lineno=5, col_offset=4, end_lineno=5, end_col_offset=12), Constant('yellow', lineno=6, col_offset=4, end_lineno=6, end_col_offset=12), Constant('green', lineno=7, col_offset=4, end_lineno=7, end_col_offset=11), Constant('blue', lineno=8, col_offset=4, end_lineno=8, end_col_offset=10), Constant('violet', lineno=9, col_offset=4, end_lineno=9, end_col_offset=12), Constant('grey', lineno=10, col_offset=4, end_lineno=10, end_col_offset=10), Constant('white', lineno=11, col_offset=4, end_lineno=11, end_col_offset=11)], Load(), lineno=1, col_offset=9, end_lineno=12, end_col_offset=1), lineno=1, col_offset=0, end_lineno=12, end_col_offset=1), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=15, col_offset=15, end_lineno=15, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_0', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=17), 'index', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=23), [Name('placeholder_2', Load(), lineno=16, col_offset=24, end_lineno=16, end_col_offset=29)], [], lineno=16, col_offset=11, end_lineno=16, end_col_offset=30), lineno=16, col_offset=4, end_lineno=16, end_col_offset=30)], [], lineno=15, col_offset=0, end_lineno=16, end_col_offset=30), FunctionDef('placeholder_3', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Name('placeholder_0', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=17), lineno=20, col_offset=4, end_lineno=20, end_col_offset=17)], [], lineno=19, col_offset=0, end_lineno=20, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-resistor-color/resistor_color.py b/test/practice-resistor-color/resistor_color.py new file mode 100644 index 0000000..83c67f4 --- /dev/null +++ b/test/practice-resistor-color/resistor_color.py @@ -0,0 +1,20 @@ +COLORS = [ + 'black', + 'brown', + 'red', + 'orange', + 'yellow', + 'green', + 'blue', + 'violet', + 'grey', + 'white' +] + + +def color_code(color): + return COLORS.index(color) + + +def colors(): + return COLORS diff --git a/test/practice-rest-api/.meta/config.json b/test/practice-rest-api/.meta/config.json new file mode 100644 index 0000000..889bf78 --- /dev/null +++ b/test/practice-rest-api/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "AnAccountForReportingBugs", + "BethanyG", + "Dog", + "omer-g", + "rpalo", + "tqa236", + "vgerak", + "yawpitch" + ], + "files": { + "solution": [ + "rest_api.py" + ], + "test": [ + "rest_api_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement a RESTful API for tracking IOUs." +} diff --git a/test/practice-rest-api/mapping.json b/test/practice-rest-api/mapping.json new file mode 100644 index 0000000..fe72473 --- /dev/null +++ b/test/practice-rest-api/mapping.json @@ -0,0 +1,25 @@ +{ + "placeholder_0": "RestAPI", + "placeholder_1": "__init__", + "placeholder_2": "database", + "placeholder_3": "update", + "placeholder_4": "user", + "placeholder_5": "owed_by", + "placeholder_6": "owes", + "placeholder_7": "debtor", + "placeholder_8": "diff", + "placeholder_9": "get", + "placeholder_10": "url", + "placeholder_11": "payload", + "placeholder_12": "post", + "placeholder_13": "result", + "placeholder_14": "name", + "placeholder_15": "users", + "placeholder_16": "idx", + "placeholder_17": "new_user", + "placeholder_18": "lender_name", + "placeholder_19": "borrower_name", + "placeholder_20": "amount", + "placeholder_21": "lender", + "placeholder_22": "borrower" +} \ No newline at end of file diff --git a/test/practice-rest-api/representation.json b/test/practice-rest-api/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-rest-api/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-rest-api/representation.out b/test/practice-rest-api/representation.out new file mode 100644 index 0000000..d271cac --- /dev/null +++ b/test/practice-rest-api/representation.out @@ -0,0 +1,4828 @@ +## BEGIN NORMALIZED CODE ## +import json + + +class placeholder_0: + def placeholder_1(self, placeholder_2=None): + self.placeholder_2 = placeholder_2 or {"users": []} + + def placeholder_3(self): + for placeholder_4 in self.placeholder_2["users"]: + placeholder_5 = placeholder_4["owed_by"] + placeholder_6 = placeholder_4["owes"] + for placeholder_7 in list(placeholder_5.keys()): + if placeholder_7 in placeholder_6: + placeholder_8 = 0 + if placeholder_7 in placeholder_6: + placeholder_8 = placeholder_6[placeholder_7] + del placeholder_6[placeholder_7] + if placeholder_7 in placeholder_5: + placeholder_8 -= placeholder_5[placeholder_7] + del placeholder_5[placeholder_7] + if placeholder_8 > 0: + placeholder_6[placeholder_7] = placeholder_8 + elif placeholder_8 < 0: + placeholder_5[placeholder_7] = -placeholder_8 + placeholder_4["balance"] = sum(placeholder_5.values()) - sum( + placeholder_6.values() + ) + + def placeholder_9(self, placeholder_10, placeholder_11=None): + if placeholder_11 is not None: + placeholder_11 = json.loads(placeholder_11) + if placeholder_10 == "/users": + if placeholder_11 is None: + return json.dumps(self.placeholder_2) + else: + return json.dumps( + { + "users": [ + placeholder_4 + for placeholder_4 in self.placeholder_2["users"] + if placeholder_4["name"] in placeholder_11["users"] + ] + } + ) + return None + + def placeholder_12(self, placeholder_10, placeholder_11=None): + placeholder_13 = None + if placeholder_11 is not None: + placeholder_11 = json.loads(placeholder_11) + if placeholder_10 == "/add": + if placeholder_11 is not None: + placeholder_14 = placeholder_11["user"] + placeholder_15 = self.placeholder_2["users"] + placeholder_4 = None + for placeholder_16 in placeholder_15: + if placeholder_16["name"] == placeholder_14: + placeholder_4 = placeholder_16 + break + if placeholder_4 is None: + placeholder_17 = { + "name": placeholder_14, + "owes": {}, + "owed_by": {}, + "balance": 0, + } + placeholder_15.append(placeholder_17) + self.placeholder_3() + placeholder_13 = json.dumps(placeholder_17) + elif placeholder_10 == "/iou": + if placeholder_11 is not None: + placeholder_18 = placeholder_11["lender"] + placeholder_19 = placeholder_11["borrower"] + placeholder_20 = placeholder_11["amount"] + placeholder_21 = placeholder_22 = None + for placeholder_4 in self.placeholder_2["users"]: + if placeholder_4["name"] == placeholder_18: + placeholder_21 = placeholder_4 + elif placeholder_4["name"] == placeholder_19: + placeholder_22 = placeholder_4 + if placeholder_21 is not None and placeholder_22 is not None: + placeholder_21["owed_by"].setdefault(placeholder_19, 0) + placeholder_21["owed_by"][placeholder_19] += placeholder_20 + placeholder_22["owes"].setdefault(placeholder_18, 0) + placeholder_22["owes"][placeholder_18] += placeholder_20 + self.placeholder_3() + placeholder_13 = self.placeholder_9( + "/users", + json.dumps({"users": [placeholder_18, placeholder_19]}), + ) + return placeholder_13 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'json', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + ClassDef( + 'RestAPI', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'database', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=36)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'database', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=21)], + BoolOp( + Or(), + [ + Name( + 'database', + Load(), + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=32), + Dict( + [ + Constant( + 'users', + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=44)], + [ + List( + [], + Load(), + lineno=6, + col_offset=46, + end_lineno=6, + end_col_offset=48)], + lineno=6, + col_offset=36, + end_lineno=6, + end_col_offset=49)], + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=49), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=49)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=49), + FunctionDef( + 'update', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'user', + Store(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=16), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=24), + 'database', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=33), + Constant( + 'users', + lineno=9, + col_offset=34, + end_lineno=9, + end_col_offset=41), + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=42), + [ + Assign( + [ + Name( + 'owed_by', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=19)], + Subscript( + Name( + 'user', + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=26), + Constant( + 'owed_by', + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=36), + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=37), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=37), + Assign( + [ + Name( + 'owes', + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=16)], + Subscript( + Name( + 'user', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=23), + Constant( + 'owes', + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=30), + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=31), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=31), + For( + Name( + 'debtor', + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=22), + Call( + Name( + 'list', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=30), + [ + Call( + Attribute( + Name( + 'owed_by', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=38), + 'keys', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=43), + [], + [], + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=45)], + [], + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=46), + [ + If( + Compare( + Name( + 'debtor', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=25), + [ + In()], + [ + Name( + 'owes', + Load(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=33)], + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=33), + [ + Assign( + [ + Name( + 'diff', + Store(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=24)], + Constant( + 0, + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=28), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=28), + If( + Compare( + Name( + 'debtor', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=29), + [ + In()], + [ + Name( + 'owes', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=37)], + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=37), + [ + Assign( + [ + Name( + 'diff', + Store(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=28)], + Subscript( + Name( + 'owes', + Load(), + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=35), + Name( + 'debtor', + Load(), + lineno=16, + col_offset=36, + end_lineno=16, + end_col_offset=42), + Load(), + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=43), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=43), + Delete( + [ + Subscript( + Name( + 'owes', + Load(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=32), + Name( + 'debtor', + Load(), + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=39), + Del(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=40)], + lineno=17, + col_offset=24, + end_lineno=17, + end_col_offset=40)], + [], + lineno=15, + col_offset=20, + end_lineno=17, + end_col_offset=40), + If( + Compare( + Name( + 'debtor', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=29), + [ + In()], + [ + Name( + 'owed_by', + Load(), + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=40)], + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=40), + [ + AugAssign( + Name( + 'diff', + Store(), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=28), + Sub(), + Subscript( + Name( + 'owed_by', + Load(), + lineno=19, + col_offset=32, + end_lineno=19, + end_col_offset=39), + Name( + 'debtor', + Load(), + lineno=19, + col_offset=40, + end_lineno=19, + end_col_offset=46), + Load(), + lineno=19, + col_offset=32, + end_lineno=19, + end_col_offset=47), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=47), + Delete( + [ + Subscript( + Name( + 'owed_by', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=35), + Name( + 'debtor', + Load(), + lineno=20, + col_offset=36, + end_lineno=20, + end_col_offset=42), + Del(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=43)], + lineno=20, + col_offset=24, + end_lineno=20, + end_col_offset=43)], + [], + lineno=18, + col_offset=20, + end_lineno=20, + end_col_offset=43), + If( + Compare( + Name( + 'diff', + Load(), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=27), + [ + Gt()], + [ + Constant( + 0, + lineno=21, + col_offset=30, + end_lineno=21, + end_col_offset=31)], + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=31), + [ + Assign( + [ + Subscript( + Name( + 'owes', + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=28), + Name( + 'debtor', + Load(), + lineno=22, + col_offset=29, + end_lineno=22, + end_col_offset=35), + Store(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=36)], + Name( + 'diff', + Load(), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=43), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=43)], + [ + If( + Compare( + Name( + 'diff', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=29), + [ + Lt()], + [ + Constant( + 0, + lineno=23, + col_offset=32, + end_lineno=23, + end_col_offset=33)], + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=33), + [ + Assign( + [ + Subscript( + Name( + 'owed_by', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=31), + Name( + 'debtor', + Load(), + lineno=24, + col_offset=32, + end_lineno=24, + end_col_offset=38), + Store(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=39)], + UnaryOp( + USub(), + Name( + 'diff', + Load(), + lineno=24, + col_offset=43, + end_lineno=24, + end_col_offset=47), + lineno=24, + col_offset=42, + end_lineno=24, + end_col_offset=47), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=47)], + [], + lineno=23, + col_offset=20, + end_lineno=24, + end_col_offset=47)], + lineno=21, + col_offset=20, + end_lineno=24, + end_col_offset=47)], + [], + lineno=13, + col_offset=16, + end_lineno=24, + end_col_offset=47)], + [], + lineno=12, + col_offset=12, + end_lineno=24, + end_col_offset=47), + Assign( + [ + Subscript( + Name( + 'user', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=16), + Constant( + 'balance', + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=26), + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=27)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=25, + col_offset=30, + end_lineno=25, + end_col_offset=33), + [ + Call( + Attribute( + Name( + 'owed_by', + Load(), + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=41), + 'values', + Load(), + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=48), + [], + [], + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=50)], + [], + lineno=25, + col_offset=30, + end_lineno=25, + end_col_offset=51), + Sub(), + Call( + Name( + 'sum', + Load(), + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=57), + [ + Call( + Attribute( + Name( + 'owes', + Load(), + lineno=25, + col_offset=58, + end_lineno=25, + end_col_offset=62), + 'values', + Load(), + lineno=25, + col_offset=58, + end_lineno=25, + end_col_offset=69), + [], + [], + lineno=25, + col_offset=58, + end_lineno=25, + end_col_offset=71)], + [], + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=72), + lineno=25, + col_offset=30, + end_lineno=25, + end_col_offset=72), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=72)], + [], + lineno=9, + col_offset=8, + end_lineno=25, + end_col_offset=72)], + [], + lineno=8, + col_offset=4, + end_lineno=25, + end_col_offset=72), + FunctionDef( + 'get', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16), + arg( + 'url', + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=21), + arg( + 'payload', + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=27, + col_offset=31, + end_lineno=27, + end_col_offset=35)]), + [ + If( + Compare( + Name( + 'payload', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=18), + [ + IsNot()], + [ + Constant( + None, + lineno=28, + col_offset=26, + end_lineno=28, + end_col_offset=30)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=30), + [ + Assign( + [ + Name( + 'payload', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=19)], + Call( + Attribute( + Name( + 'json', + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=26), + 'loads', + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=32), + [ + Name( + 'payload', + Load(), + lineno=29, + col_offset=33, + end_lineno=29, + end_col_offset=40)], + [], + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=41), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=41)], + [], + lineno=28, + col_offset=8, + end_lineno=29, + end_col_offset=41), + If( + Compare( + Name( + 'url', + Load(), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=14), + [ + Eq()], + [ + Constant( + '/users', + lineno=30, + col_offset=18, + end_lineno=30, + end_col_offset=26)], + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=26), + [ + If( + Compare( + Name( + 'payload', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=22), + [ + Is()], + [ + Constant( + None, + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=30)], + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=30), + [ + Return( + Call( + Attribute( + Name( + 'json', + Load(), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=27), + 'dumps', + Load(), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=33), + [ + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=34, + end_lineno=32, + end_col_offset=38), + 'database', + Load(), + lineno=32, + col_offset=34, + end_lineno=32, + end_col_offset=47)], + [], + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=48), + lineno=32, + col_offset=16, + end_lineno=32, + end_col_offset=48)], + [ + Return( + Call( + Attribute( + Name( + 'json', + Load(), + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=27), + 'dumps', + Load(), + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=33), + [ + Dict( + [ + Constant( + 'users', + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=27)], + [ + ListComp( + Name( + 'user', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=28), + [ + comprehension( + Name( + 'user', + Store(), + lineno=36, + col_offset=33, + end_lineno=36, + end_col_offset=37), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=45), + 'database', + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=54), + Constant( + 'users', + lineno=36, + col_offset=55, + end_lineno=36, + end_col_offset=62), + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=63), + [ + Compare( + Subscript( + Name( + 'user', + Load(), + lineno=37, + col_offset=27, + end_lineno=37, + end_col_offset=31), + Constant( + 'name', + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=38), + Load(), + lineno=37, + col_offset=27, + end_lineno=37, + end_col_offset=39), + [ + In()], + [ + Subscript( + Name( + 'payload', + Load(), + lineno=37, + col_offset=43, + end_lineno=37, + end_col_offset=50), + Constant( + 'users', + lineno=37, + col_offset=51, + end_lineno=37, + end_col_offset=58), + Load(), + lineno=37, + col_offset=43, + end_lineno=37, + end_col_offset=59)], + lineno=37, + col_offset=27, + end_lineno=37, + end_col_offset=59)], + 0)], + lineno=35, + col_offset=29, + end_lineno=38, + end_col_offset=21)], + lineno=34, + col_offset=34, + end_lineno=39, + end_col_offset=17)], + [], + lineno=34, + col_offset=23, + end_lineno=39, + end_col_offset=18), + lineno=34, + col_offset=16, + end_lineno=39, + end_col_offset=18)], + lineno=31, + col_offset=12, + end_lineno=39, + end_col_offset=18)], + [], + lineno=30, + col_offset=8, + end_lineno=39, + end_col_offset=18), + Return( + Constant( + None, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=19), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=19)], + [], + lineno=27, + col_offset=4, + end_lineno=40, + end_col_offset=19), + FunctionDef( + 'post', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=17), + arg( + 'url', + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=22), + arg( + 'payload', + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=42, + col_offset=32, + end_lineno=42, + end_col_offset=36)]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=14)], + Constant( + None, + lineno=43, + col_offset=17, + end_lineno=43, + end_col_offset=21), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=21), + If( + Compare( + Name( + 'payload', + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=18), + [ + IsNot()], + [ + Constant( + None, + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=30)], + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=30), + [ + Assign( + [ + Name( + 'payload', + Store(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=19)], + Call( + Attribute( + Name( + 'json', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=26), + 'loads', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=32), + [ + Name( + 'payload', + Load(), + lineno=45, + col_offset=33, + end_lineno=45, + end_col_offset=40)], + [], + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=41), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=41)], + [], + lineno=44, + col_offset=8, + end_lineno=45, + end_col_offset=41), + If( + Compare( + Name( + 'url', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=14), + [ + Eq()], + [ + Constant( + '/add', + lineno=46, + col_offset=18, + end_lineno=46, + end_col_offset=24)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=24), + [ + If( + Compare( + Name( + 'payload', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=22), + [ + IsNot()], + [ + Constant( + None, + lineno=47, + col_offset=30, + end_lineno=47, + end_col_offset=34)], + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=34), + [ + Assign( + [ + Name( + 'name', + Store(), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=20)], + Subscript( + Name( + 'payload', + Load(), + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=30), + Constant( + 'user', + lineno=48, + col_offset=31, + end_lineno=48, + end_col_offset=37), + Load(), + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=38), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=38), + Assign( + [ + Name( + 'users', + Store(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=21)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=28), + 'database', + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=37), + Constant( + 'users', + lineno=49, + col_offset=38, + end_lineno=49, + end_col_offset=45), + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=46), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=46), + Assign( + [ + Name( + 'user', + Store(), + lineno=50, + col_offset=16, + end_lineno=50, + end_col_offset=20)], + Constant( + None, + lineno=50, + col_offset=23, + end_lineno=50, + end_col_offset=27), + lineno=50, + col_offset=16, + end_lineno=50, + end_col_offset=27), + For( + Name( + 'idx', + Store(), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=23), + Name( + 'users', + Load(), + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=32), + [ + If( + Compare( + Subscript( + Name( + 'idx', + Load(), + lineno=52, + col_offset=23, + end_lineno=52, + end_col_offset=26), + Constant( + 'name', + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=33), + Load(), + lineno=52, + col_offset=23, + end_lineno=52, + end_col_offset=34), + [ + Eq()], + [ + Name( + 'name', + Load(), + lineno=52, + col_offset=38, + end_lineno=52, + end_col_offset=42)], + lineno=52, + col_offset=23, + end_lineno=52, + end_col_offset=42), + [ + Assign( + [ + Name( + 'user', + Store(), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=28)], + Name( + 'idx', + Load(), + lineno=53, + col_offset=31, + end_lineno=53, + end_col_offset=34), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=34), + Break( + lineno=54, + col_offset=24, + end_lineno=54, + end_col_offset=29)], + [], + lineno=52, + col_offset=20, + end_lineno=54, + end_col_offset=29)], + [], + lineno=51, + col_offset=16, + end_lineno=54, + end_col_offset=29), + If( + Compare( + Name( + 'user', + Load(), + lineno=55, + col_offset=19, + end_lineno=55, + end_col_offset=23), + [ + Is()], + [ + Constant( + None, + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=31)], + lineno=55, + col_offset=19, + end_lineno=55, + end_col_offset=31), + [ + Assign( + [ + Name( + 'new_user', + Store(), + lineno=56, + col_offset=20, + end_lineno=56, + end_col_offset=28)], + Dict( + [ + Constant( + 'name', + lineno=57, + col_offset=24, + end_lineno=57, + end_col_offset=30), + Constant( + 'owes', + lineno=58, + col_offset=24, + end_lineno=58, + end_col_offset=30), + Constant( + 'owed_by', + lineno=59, + col_offset=24, + end_lineno=59, + end_col_offset=33), + Constant( + 'balance', + lineno=60, + col_offset=24, + end_lineno=60, + end_col_offset=33)], + [ + Name( + 'name', + Load(), + lineno=57, + col_offset=32, + end_lineno=57, + end_col_offset=36), + Dict( + [], + [], + lineno=58, + col_offset=32, + end_lineno=58, + end_col_offset=34), + Dict( + [], + [], + lineno=59, + col_offset=35, + end_lineno=59, + end_col_offset=37), + Constant( + 0, + lineno=60, + col_offset=35, + end_lineno=60, + end_col_offset=36)], + lineno=56, + col_offset=31, + end_lineno=61, + end_col_offset=21), + lineno=56, + col_offset=20, + end_lineno=61, + end_col_offset=21), + Expr( + Call( + Attribute( + Name( + 'users', + Load(), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=25), + 'append', + Load(), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=32), + [ + Name( + 'new_user', + Load(), + lineno=62, + col_offset=33, + end_lineno=62, + end_col_offset=41)], + [], + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=42), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=42), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=24), + 'update', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=31), + [], + [], + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=33), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=33), + Assign( + [ + Name( + 'result', + Store(), + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=26)], + Call( + Attribute( + Name( + 'json', + Load(), + lineno=64, + col_offset=29, + end_lineno=64, + end_col_offset=33), + 'dumps', + Load(), + lineno=64, + col_offset=29, + end_lineno=64, + end_col_offset=39), + [ + Name( + 'new_user', + Load(), + lineno=64, + col_offset=40, + end_lineno=64, + end_col_offset=48)], + [], + lineno=64, + col_offset=29, + end_lineno=64, + end_col_offset=49), + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=49)], + [], + lineno=55, + col_offset=16, + end_lineno=64, + end_col_offset=49)], + [], + lineno=47, + col_offset=12, + end_lineno=64, + end_col_offset=49)], + [ + If( + Compare( + Name( + 'url', + Load(), + lineno=65, + col_offset=13, + end_lineno=65, + end_col_offset=16), + [ + Eq()], + [ + Constant( + '/iou', + lineno=65, + col_offset=20, + end_lineno=65, + end_col_offset=26)], + lineno=65, + col_offset=13, + end_lineno=65, + end_col_offset=26), + [ + If( + Compare( + Name( + 'payload', + Load(), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=22), + [ + IsNot()], + [ + Constant( + None, + lineno=66, + col_offset=30, + end_lineno=66, + end_col_offset=34)], + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=34), + [ + Assign( + [ + Name( + 'lender_name', + Store(), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=27)], + Subscript( + Name( + 'payload', + Load(), + lineno=67, + col_offset=30, + end_lineno=67, + end_col_offset=37), + Constant( + 'lender', + lineno=67, + col_offset=38, + end_lineno=67, + end_col_offset=46), + Load(), + lineno=67, + col_offset=30, + end_lineno=67, + end_col_offset=47), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=47), + Assign( + [ + Name( + 'borrower_name', + Store(), + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=29)], + Subscript( + Name( + 'payload', + Load(), + lineno=68, + col_offset=32, + end_lineno=68, + end_col_offset=39), + Constant( + 'borrower', + lineno=68, + col_offset=40, + end_lineno=68, + end_col_offset=50), + Load(), + lineno=68, + col_offset=32, + end_lineno=68, + end_col_offset=51), + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=51), + Assign( + [ + Name( + 'amount', + Store(), + lineno=69, + col_offset=16, + end_lineno=69, + end_col_offset=22)], + Subscript( + Name( + 'payload', + Load(), + lineno=69, + col_offset=25, + end_lineno=69, + end_col_offset=32), + Constant( + 'amount', + lineno=69, + col_offset=33, + end_lineno=69, + end_col_offset=41), + Load(), + lineno=69, + col_offset=25, + end_lineno=69, + end_col_offset=42), + lineno=69, + col_offset=16, + end_lineno=69, + end_col_offset=42), + Assign( + [ + Name( + 'lender', + Store(), + lineno=70, + col_offset=16, + end_lineno=70, + end_col_offset=22), + Name( + 'borrower', + Store(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=33)], + Constant( + None, + lineno=70, + col_offset=36, + end_lineno=70, + end_col_offset=40), + lineno=70, + col_offset=16, + end_lineno=70, + end_col_offset=40), + For( + Name( + 'user', + Store(), + lineno=71, + col_offset=20, + end_lineno=71, + end_col_offset=24), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=71, + col_offset=28, + end_lineno=71, + end_col_offset=32), + 'database', + Load(), + lineno=71, + col_offset=28, + end_lineno=71, + end_col_offset=41), + Constant( + 'users', + lineno=71, + col_offset=42, + end_lineno=71, + end_col_offset=49), + Load(), + lineno=71, + col_offset=28, + end_lineno=71, + end_col_offset=50), + [ + If( + Compare( + Subscript( + Name( + 'user', + Load(), + lineno=72, + col_offset=23, + end_lineno=72, + end_col_offset=27), + Constant( + 'name', + lineno=72, + col_offset=28, + end_lineno=72, + end_col_offset=34), + Load(), + lineno=72, + col_offset=23, + end_lineno=72, + end_col_offset=35), + [ + Eq()], + [ + Name( + 'lender_name', + Load(), + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=50)], + lineno=72, + col_offset=23, + end_lineno=72, + end_col_offset=50), + [ + Assign( + [ + Name( + 'lender', + Store(), + lineno=73, + col_offset=24, + end_lineno=73, + end_col_offset=30)], + Name( + 'user', + Load(), + lineno=73, + col_offset=33, + end_lineno=73, + end_col_offset=37), + lineno=73, + col_offset=24, + end_lineno=73, + end_col_offset=37)], + [ + If( + Compare( + Subscript( + Name( + 'user', + Load(), + lineno=74, + col_offset=25, + end_lineno=74, + end_col_offset=29), + Constant( + 'name', + lineno=74, + col_offset=30, + end_lineno=74, + end_col_offset=36), + Load(), + lineno=74, + col_offset=25, + end_lineno=74, + end_col_offset=37), + [ + Eq()], + [ + Name( + 'borrower_name', + Load(), + lineno=74, + col_offset=41, + end_lineno=74, + end_col_offset=54)], + lineno=74, + col_offset=25, + end_lineno=74, + end_col_offset=54), + [ + Assign( + [ + Name( + 'borrower', + Store(), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=32)], + Name( + 'user', + Load(), + lineno=75, + col_offset=35, + end_lineno=75, + end_col_offset=39), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=39)], + [], + lineno=74, + col_offset=20, + end_lineno=75, + end_col_offset=39)], + lineno=72, + col_offset=20, + end_lineno=75, + end_col_offset=39)], + [], + lineno=71, + col_offset=16, + end_lineno=75, + end_col_offset=39), + If( + BoolOp( + And(), + [ + Compare( + Name( + 'lender', + Load(), + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=25), + [ + IsNot()], + [ + Constant( + None, + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=37)], + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=37), + Compare( + Name( + 'borrower', + Load(), + lineno=76, + col_offset=42, + end_lineno=76, + end_col_offset=50), + [ + IsNot()], + [ + Constant( + None, + lineno=76, + col_offset=58, + end_lineno=76, + end_col_offset=62)], + lineno=76, + col_offset=42, + end_lineno=76, + end_col_offset=62)], + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=62), + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'lender', + Load(), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=26), + Constant( + 'owed_by', + lineno=77, + col_offset=27, + end_lineno=77, + end_col_offset=36), + Load(), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=37), + 'setdefault', + Load(), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=48), + [ + Name( + 'borrower_name', + Load(), + lineno=77, + col_offset=49, + end_lineno=77, + end_col_offset=62), + Constant( + 0, + lineno=77, + col_offset=64, + end_lineno=77, + end_col_offset=65)], + [], + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=66), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=66), + AugAssign( + Subscript( + Subscript( + Name( + 'lender', + Load(), + lineno=78, + col_offset=20, + end_lineno=78, + end_col_offset=26), + Constant( + 'owed_by', + lineno=78, + col_offset=27, + end_lineno=78, + end_col_offset=36), + Load(), + lineno=78, + col_offset=20, + end_lineno=78, + end_col_offset=37), + Name( + 'borrower_name', + Load(), + lineno=78, + col_offset=38, + end_lineno=78, + end_col_offset=51), + Store(), + lineno=78, + col_offset=20, + end_lineno=78, + end_col_offset=52), + Add(), + Name( + 'amount', + Load(), + lineno=78, + col_offset=56, + end_lineno=78, + end_col_offset=62), + lineno=78, + col_offset=20, + end_lineno=78, + end_col_offset=62), + Expr( + Call( + Attribute( + Subscript( + Name( + 'borrower', + Load(), + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=28), + Constant( + 'owes', + lineno=79, + col_offset=29, + end_lineno=79, + end_col_offset=35), + Load(), + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=36), + 'setdefault', + Load(), + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=47), + [ + Name( + 'lender_name', + Load(), + lineno=79, + col_offset=48, + end_lineno=79, + end_col_offset=59), + Constant( + 0, + lineno=79, + col_offset=61, + end_lineno=79, + end_col_offset=62)], + [], + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=63), + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=63), + AugAssign( + Subscript( + Subscript( + Name( + 'borrower', + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=28), + Constant( + 'owes', + lineno=80, + col_offset=29, + end_lineno=80, + end_col_offset=35), + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=36), + Name( + 'lender_name', + Load(), + lineno=80, + col_offset=37, + end_lineno=80, + end_col_offset=48), + Store(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=49), + Add(), + Name( + 'amount', + Load(), + lineno=80, + col_offset=53, + end_lineno=80, + end_col_offset=59), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=59), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=81, + col_offset=20, + end_lineno=81, + end_col_offset=24), + 'update', + Load(), + lineno=81, + col_offset=20, + end_lineno=81, + end_col_offset=31), + [], + [], + lineno=81, + col_offset=20, + end_lineno=81, + end_col_offset=33), + lineno=81, + col_offset=20, + end_lineno=81, + end_col_offset=33), + Assign( + [ + Name( + 'result', + Store(), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=26)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=82, + col_offset=29, + end_lineno=82, + end_col_offset=33), + 'get', + Load(), + lineno=82, + col_offset=29, + end_lineno=82, + end_col_offset=37), + [ + Constant( + '/users', + lineno=83, + col_offset=24, + end_lineno=83, + end_col_offset=32), + Call( + Attribute( + Name( + 'json', + Load(), + lineno=84, + col_offset=24, + end_lineno=84, + end_col_offset=28), + 'dumps', + Load(), + lineno=84, + col_offset=24, + end_lineno=84, + end_col_offset=34), + [ + Dict( + [ + Constant( + 'users', + lineno=84, + col_offset=36, + end_lineno=84, + end_col_offset=43)], + [ + List( + [ + Name( + 'lender_name', + Load(), + lineno=84, + col_offset=46, + end_lineno=84, + end_col_offset=57), + Name( + 'borrower_name', + Load(), + lineno=84, + col_offset=59, + end_lineno=84, + end_col_offset=72)], + Load(), + lineno=84, + col_offset=45, + end_lineno=84, + end_col_offset=73)], + lineno=84, + col_offset=35, + end_lineno=84, + end_col_offset=74)], + [], + lineno=84, + col_offset=24, + end_lineno=84, + end_col_offset=75)], + [], + lineno=82, + col_offset=29, + end_lineno=85, + end_col_offset=21), + lineno=82, + col_offset=20, + end_lineno=85, + end_col_offset=21)], + [], + lineno=76, + col_offset=16, + end_lineno=85, + end_col_offset=21)], + [], + lineno=66, + col_offset=12, + end_lineno=85, + end_col_offset=21)], + [], + lineno=65, + col_offset=8, + end_lineno=85, + end_col_offset=21)], + lineno=46, + col_offset=8, + end_lineno=85, + end_col_offset=21), + Return( + Name( + 'result', + Load(), + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=21), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=21)], + [], + lineno=42, + col_offset=4, + end_lineno=86, + end_col_offset=21)], + [], + lineno=4, + col_offset=0, + end_lineno=86, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'json', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=5, + col_offset=32, + end_lineno=5, + end_col_offset=36)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=21)], + BoolOp( + Or(), + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=32), + Dict( + [ + Constant( + 'users', + lineno=6, + col_offset=37, + end_lineno=6, + end_col_offset=44)], + [ + List( + [], + Load(), + lineno=6, + col_offset=46, + end_lineno=6, + end_col_offset=48)], + lineno=6, + col_offset=36, + end_lineno=6, + end_col_offset=49)], + lineno=6, + col_offset=24, + end_lineno=6, + end_col_offset=49), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=49)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=49), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'self', + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + For( + Name( + 'placeholder_4', + Store(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=16), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=33), + Constant( + 'users', + lineno=9, + col_offset=34, + end_lineno=9, + end_col_offset=41), + Load(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=42), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=19)], + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=26), + Constant( + 'owed_by', + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=36), + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=37), + lineno=10, + col_offset=12, + end_lineno=10, + end_col_offset=37), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=16)], + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=23), + Constant( + 'owes', + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=30), + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=31), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=31), + For( + Name( + 'placeholder_7', + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=22), + Call( + Name( + 'list', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=30), + [ + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=38), + 'keys', + Load(), + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=43), + [], + [], + lineno=12, + col_offset=31, + end_lineno=12, + end_col_offset=45)], + [], + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=46), + [ + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=25), + [ + In()], + [ + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=33)], + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=33), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=24)], + Constant( + 0, + lineno=14, + col_offset=27, + end_lineno=14, + end_col_offset=28), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=28), + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=29), + [ + In()], + [ + Name( + 'placeholder_6', + Load(), + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=37)], + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=37), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=28)], + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=35), + Name( + 'placeholder_7', + Load(), + lineno=16, + col_offset=36, + end_lineno=16, + end_col_offset=42), + Load(), + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=43), + lineno=16, + col_offset=24, + end_lineno=16, + end_col_offset=43), + Delete( + [ + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=32), + Name( + 'placeholder_7', + Load(), + lineno=17, + col_offset=33, + end_lineno=17, + end_col_offset=39), + Del(), + lineno=17, + col_offset=28, + end_lineno=17, + end_col_offset=40)], + lineno=17, + col_offset=24, + end_lineno=17, + end_col_offset=40)], + [], + lineno=15, + col_offset=20, + end_lineno=17, + end_col_offset=40), + If( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=29), + [ + In()], + [ + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=40)], + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=40), + [ + AugAssign( + Name( + 'placeholder_8', + Store(), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=28), + Sub(), + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=19, + col_offset=32, + end_lineno=19, + end_col_offset=39), + Name( + 'placeholder_7', + Load(), + lineno=19, + col_offset=40, + end_lineno=19, + end_col_offset=46), + Load(), + lineno=19, + col_offset=32, + end_lineno=19, + end_col_offset=47), + lineno=19, + col_offset=24, + end_lineno=19, + end_col_offset=47), + Delete( + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=35), + Name( + 'placeholder_7', + Load(), + lineno=20, + col_offset=36, + end_lineno=20, + end_col_offset=42), + Del(), + lineno=20, + col_offset=28, + end_lineno=20, + end_col_offset=43)], + lineno=20, + col_offset=24, + end_lineno=20, + end_col_offset=43)], + [], + lineno=18, + col_offset=20, + end_lineno=20, + end_col_offset=43), + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=27), + [ + Gt()], + [ + Constant( + 0, + lineno=21, + col_offset=30, + end_lineno=21, + end_col_offset=31)], + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=31), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=28), + Name( + 'placeholder_7', + Load(), + lineno=22, + col_offset=29, + end_lineno=22, + end_col_offset=35), + Store(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=36)], + Name( + 'placeholder_8', + Load(), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=43), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=43)], + [ + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=29), + [ + Lt()], + [ + Constant( + 0, + lineno=23, + col_offset=32, + end_lineno=23, + end_col_offset=33)], + lineno=23, + col_offset=25, + end_lineno=23, + end_col_offset=33), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=31), + Name( + 'placeholder_7', + Load(), + lineno=24, + col_offset=32, + end_lineno=24, + end_col_offset=38), + Store(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=39)], + UnaryOp( + USub(), + Name( + 'placeholder_8', + Load(), + lineno=24, + col_offset=43, + end_lineno=24, + end_col_offset=47), + lineno=24, + col_offset=42, + end_lineno=24, + end_col_offset=47), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=47)], + [], + lineno=23, + col_offset=20, + end_lineno=24, + end_col_offset=47)], + lineno=21, + col_offset=20, + end_lineno=24, + end_col_offset=47)], + [], + lineno=13, + col_offset=16, + end_lineno=24, + end_col_offset=47)], + [], + lineno=12, + col_offset=12, + end_lineno=24, + end_col_offset=47), + Assign( + [ + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=16), + Constant( + 'balance', + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=26), + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=27)], + BinOp( + Call( + Name( + 'sum', + Load(), + lineno=25, + col_offset=30, + end_lineno=25, + end_col_offset=33), + [ + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=41), + 'values', + Load(), + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=48), + [], + [], + lineno=25, + col_offset=34, + end_lineno=25, + end_col_offset=50)], + [], + lineno=25, + col_offset=30, + end_lineno=25, + end_col_offset=51), + Sub(), + Call( + Name( + 'sum', + Load(), + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=57), + [ + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=25, + col_offset=58, + end_lineno=25, + end_col_offset=62), + 'values', + Load(), + lineno=25, + col_offset=58, + end_lineno=25, + end_col_offset=69), + [], + [], + lineno=25, + col_offset=58, + end_lineno=25, + end_col_offset=71)], + [], + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=72), + lineno=25, + col_offset=30, + end_lineno=25, + end_col_offset=72), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=72)], + [], + lineno=9, + col_offset=8, + end_lineno=25, + end_col_offset=72)], + [], + lineno=8, + col_offset=4, + end_lineno=25, + end_col_offset=72), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16), + arg( + 'placeholder_10', + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=21), + arg( + 'placeholder_11', + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=27, + col_offset=31, + end_lineno=27, + end_col_offset=35)]), + [ + If( + Compare( + Name( + 'placeholder_11', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=18), + [ + IsNot()], + [ + Constant( + None, + lineno=28, + col_offset=26, + end_lineno=28, + end_col_offset=30)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=30), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=19)], + Call( + Attribute( + Name( + 'json', + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=26), + 'loads', + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=32), + [ + Name( + 'placeholder_11', + Load(), + lineno=29, + col_offset=33, + end_lineno=29, + end_col_offset=40)], + [], + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=41), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=41)], + [], + lineno=28, + col_offset=8, + end_lineno=29, + end_col_offset=41), + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=14), + [ + Eq()], + [ + Constant( + '/users', + lineno=30, + col_offset=18, + end_lineno=30, + end_col_offset=26)], + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=26), + [ + If( + Compare( + Name( + 'placeholder_11', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=22), + [ + Is()], + [ + Constant( + None, + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=30)], + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=30), + [ + Return( + Call( + Attribute( + Name( + 'json', + Load(), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=27), + 'dumps', + Load(), + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=33), + [ + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=34, + end_lineno=32, + end_col_offset=38), + 'placeholder_2', + Load(), + lineno=32, + col_offset=34, + end_lineno=32, + end_col_offset=47)], + [], + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=48), + lineno=32, + col_offset=16, + end_lineno=32, + end_col_offset=48)], + [ + Return( + Call( + Attribute( + Name( + 'json', + Load(), + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=27), + 'dumps', + Load(), + lineno=34, + col_offset=23, + end_lineno=34, + end_col_offset=33), + [ + Dict( + [ + Constant( + 'users', + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=27)], + [ + ListComp( + Name( + 'placeholder_4', + Load(), + lineno=36, + col_offset=24, + end_lineno=36, + end_col_offset=28), + [ + comprehension( + Name( + 'placeholder_4', + Store(), + lineno=36, + col_offset=33, + end_lineno=36, + end_col_offset=37), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=45), + 'placeholder_2', + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=54), + Constant( + 'users', + lineno=36, + col_offset=55, + end_lineno=36, + end_col_offset=62), + Load(), + lineno=36, + col_offset=41, + end_lineno=36, + end_col_offset=63), + [ + Compare( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=37, + col_offset=27, + end_lineno=37, + end_col_offset=31), + Constant( + 'name', + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=38), + Load(), + lineno=37, + col_offset=27, + end_lineno=37, + end_col_offset=39), + [ + In()], + [ + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=37, + col_offset=43, + end_lineno=37, + end_col_offset=50), + Constant( + 'users', + lineno=37, + col_offset=51, + end_lineno=37, + end_col_offset=58), + Load(), + lineno=37, + col_offset=43, + end_lineno=37, + end_col_offset=59)], + lineno=37, + col_offset=27, + end_lineno=37, + end_col_offset=59)], + 0)], + lineno=35, + col_offset=29, + end_lineno=38, + end_col_offset=21)], + lineno=34, + col_offset=34, + end_lineno=39, + end_col_offset=17)], + [], + lineno=34, + col_offset=23, + end_lineno=39, + end_col_offset=18), + lineno=34, + col_offset=16, + end_lineno=39, + end_col_offset=18)], + lineno=31, + col_offset=12, + end_lineno=39, + end_col_offset=18)], + [], + lineno=30, + col_offset=8, + end_lineno=39, + end_col_offset=18), + Return( + Constant( + None, + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=19), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=19)], + [], + lineno=27, + col_offset=4, + end_lineno=40, + end_col_offset=19), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=17), + arg( + 'placeholder_10', + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=22), + arg( + 'placeholder_11', + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=42, + col_offset=32, + end_lineno=42, + end_col_offset=36)]), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=14)], + Constant( + None, + lineno=43, + col_offset=17, + end_lineno=43, + end_col_offset=21), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=21), + If( + Compare( + Name( + 'placeholder_11', + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=18), + [ + IsNot()], + [ + Constant( + None, + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=30)], + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=30), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=19)], + Call( + Attribute( + Name( + 'json', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=26), + 'loads', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=32), + [ + Name( + 'placeholder_11', + Load(), + lineno=45, + col_offset=33, + end_lineno=45, + end_col_offset=40)], + [], + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=41), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=41)], + [], + lineno=44, + col_offset=8, + end_lineno=45, + end_col_offset=41), + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=14), + [ + Eq()], + [ + Constant( + '/add', + lineno=46, + col_offset=18, + end_lineno=46, + end_col_offset=24)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=24), + [ + If( + Compare( + Name( + 'placeholder_11', + Load(), + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=22), + [ + IsNot()], + [ + Constant( + None, + lineno=47, + col_offset=30, + end_lineno=47, + end_col_offset=34)], + lineno=47, + col_offset=15, + end_lineno=47, + end_col_offset=34), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=20)], + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=30), + Constant( + 'user', + lineno=48, + col_offset=31, + end_lineno=48, + end_col_offset=37), + Load(), + lineno=48, + col_offset=23, + end_lineno=48, + end_col_offset=38), + lineno=48, + col_offset=16, + end_lineno=48, + end_col_offset=38), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=21)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=37), + Constant( + 'users', + lineno=49, + col_offset=38, + end_lineno=49, + end_col_offset=45), + Load(), + lineno=49, + col_offset=24, + end_lineno=49, + end_col_offset=46), + lineno=49, + col_offset=16, + end_lineno=49, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=50, + col_offset=16, + end_lineno=50, + end_col_offset=20)], + Constant( + None, + lineno=50, + col_offset=23, + end_lineno=50, + end_col_offset=27), + lineno=50, + col_offset=16, + end_lineno=50, + end_col_offset=27), + For( + Name( + 'placeholder_16', + Store(), + lineno=51, + col_offset=20, + end_lineno=51, + end_col_offset=23), + Name( + 'placeholder_15', + Load(), + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=32), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=52, + col_offset=23, + end_lineno=52, + end_col_offset=26), + Constant( + 'name', + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=33), + Load(), + lineno=52, + col_offset=23, + end_lineno=52, + end_col_offset=34), + [ + Eq()], + [ + Name( + 'placeholder_14', + Load(), + lineno=52, + col_offset=38, + end_lineno=52, + end_col_offset=42)], + lineno=52, + col_offset=23, + end_lineno=52, + end_col_offset=42), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=28)], + Name( + 'placeholder_16', + Load(), + lineno=53, + col_offset=31, + end_lineno=53, + end_col_offset=34), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=34), + Break( + lineno=54, + col_offset=24, + end_lineno=54, + end_col_offset=29)], + [], + lineno=52, + col_offset=20, + end_lineno=54, + end_col_offset=29)], + [], + lineno=51, + col_offset=16, + end_lineno=54, + end_col_offset=29), + If( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=55, + col_offset=19, + end_lineno=55, + end_col_offset=23), + [ + Is()], + [ + Constant( + None, + lineno=55, + col_offset=27, + end_lineno=55, + end_col_offset=31)], + lineno=55, + col_offset=19, + end_lineno=55, + end_col_offset=31), + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=56, + col_offset=20, + end_lineno=56, + end_col_offset=28)], + Dict( + [ + Constant( + 'name', + lineno=57, + col_offset=24, + end_lineno=57, + end_col_offset=30), + Constant( + 'owes', + lineno=58, + col_offset=24, + end_lineno=58, + end_col_offset=30), + Constant( + 'owed_by', + lineno=59, + col_offset=24, + end_lineno=59, + end_col_offset=33), + Constant( + 'balance', + lineno=60, + col_offset=24, + end_lineno=60, + end_col_offset=33)], + [ + Name( + 'placeholder_14', + Load(), + lineno=57, + col_offset=32, + end_lineno=57, + end_col_offset=36), + Dict( + [], + [], + lineno=58, + col_offset=32, + end_lineno=58, + end_col_offset=34), + Dict( + [], + [], + lineno=59, + col_offset=35, + end_lineno=59, + end_col_offset=37), + Constant( + 0, + lineno=60, + col_offset=35, + end_lineno=60, + end_col_offset=36)], + lineno=56, + col_offset=31, + end_lineno=61, + end_col_offset=21), + lineno=56, + col_offset=20, + end_lineno=61, + end_col_offset=21), + Expr( + Call( + Attribute( + Name( + 'placeholder_15', + Load(), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=25), + 'append', + Load(), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=32), + [ + Name( + 'placeholder_17', + Load(), + lineno=62, + col_offset=33, + end_lineno=62, + end_col_offset=41)], + [], + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=42), + lineno=62, + col_offset=20, + end_lineno=62, + end_col_offset=42), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=24), + 'placeholder_3', + Load(), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=31), + [], + [], + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=33), + lineno=63, + col_offset=20, + end_lineno=63, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=26)], + Call( + Attribute( + Name( + 'json', + Load(), + lineno=64, + col_offset=29, + end_lineno=64, + end_col_offset=33), + 'dumps', + Load(), + lineno=64, + col_offset=29, + end_lineno=64, + end_col_offset=39), + [ + Name( + 'placeholder_17', + Load(), + lineno=64, + col_offset=40, + end_lineno=64, + end_col_offset=48)], + [], + lineno=64, + col_offset=29, + end_lineno=64, + end_col_offset=49), + lineno=64, + col_offset=20, + end_lineno=64, + end_col_offset=49)], + [], + lineno=55, + col_offset=16, + end_lineno=64, + end_col_offset=49)], + [], + lineno=47, + col_offset=12, + end_lineno=64, + end_col_offset=49)], + [ + If( + Compare( + Name( + 'placeholder_10', + Load(), + lineno=65, + col_offset=13, + end_lineno=65, + end_col_offset=16), + [ + Eq()], + [ + Constant( + '/iou', + lineno=65, + col_offset=20, + end_lineno=65, + end_col_offset=26)], + lineno=65, + col_offset=13, + end_lineno=65, + end_col_offset=26), + [ + If( + Compare( + Name( + 'placeholder_11', + Load(), + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=22), + [ + IsNot()], + [ + Constant( + None, + lineno=66, + col_offset=30, + end_lineno=66, + end_col_offset=34)], + lineno=66, + col_offset=15, + end_lineno=66, + end_col_offset=34), + [ + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=27)], + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=67, + col_offset=30, + end_lineno=67, + end_col_offset=37), + Constant( + 'lender', + lineno=67, + col_offset=38, + end_lineno=67, + end_col_offset=46), + Load(), + lineno=67, + col_offset=30, + end_lineno=67, + end_col_offset=47), + lineno=67, + col_offset=16, + end_lineno=67, + end_col_offset=47), + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=29)], + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=68, + col_offset=32, + end_lineno=68, + end_col_offset=39), + Constant( + 'borrower', + lineno=68, + col_offset=40, + end_lineno=68, + end_col_offset=50), + Load(), + lineno=68, + col_offset=32, + end_lineno=68, + end_col_offset=51), + lineno=68, + col_offset=16, + end_lineno=68, + end_col_offset=51), + Assign( + [ + Name( + 'placeholder_20', + Store(), + lineno=69, + col_offset=16, + end_lineno=69, + end_col_offset=22)], + Subscript( + Name( + 'placeholder_11', + Load(), + lineno=69, + col_offset=25, + end_lineno=69, + end_col_offset=32), + Constant( + 'amount', + lineno=69, + col_offset=33, + end_lineno=69, + end_col_offset=41), + Load(), + lineno=69, + col_offset=25, + end_lineno=69, + end_col_offset=42), + lineno=69, + col_offset=16, + end_lineno=69, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=70, + col_offset=16, + end_lineno=70, + end_col_offset=22), + Name( + 'placeholder_22', + Store(), + lineno=70, + col_offset=25, + end_lineno=70, + end_col_offset=33)], + Constant( + None, + lineno=70, + col_offset=36, + end_lineno=70, + end_col_offset=40), + lineno=70, + col_offset=16, + end_lineno=70, + end_col_offset=40), + For( + Name( + 'placeholder_4', + Store(), + lineno=71, + col_offset=20, + end_lineno=71, + end_col_offset=24), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=71, + col_offset=28, + end_lineno=71, + end_col_offset=32), + 'placeholder_2', + Load(), + lineno=71, + col_offset=28, + end_lineno=71, + end_col_offset=41), + Constant( + 'users', + lineno=71, + col_offset=42, + end_lineno=71, + end_col_offset=49), + Load(), + lineno=71, + col_offset=28, + end_lineno=71, + end_col_offset=50), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=72, + col_offset=23, + end_lineno=72, + end_col_offset=27), + Constant( + 'name', + lineno=72, + col_offset=28, + end_lineno=72, + end_col_offset=34), + Load(), + lineno=72, + col_offset=23, + end_lineno=72, + end_col_offset=35), + [ + Eq()], + [ + Name( + 'placeholder_18', + Load(), + lineno=72, + col_offset=39, + end_lineno=72, + end_col_offset=50)], + lineno=72, + col_offset=23, + end_lineno=72, + end_col_offset=50), + [ + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=73, + col_offset=24, + end_lineno=73, + end_col_offset=30)], + Name( + 'placeholder_4', + Load(), + lineno=73, + col_offset=33, + end_lineno=73, + end_col_offset=37), + lineno=73, + col_offset=24, + end_lineno=73, + end_col_offset=37)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=74, + col_offset=25, + end_lineno=74, + end_col_offset=29), + Constant( + 'name', + lineno=74, + col_offset=30, + end_lineno=74, + end_col_offset=36), + Load(), + lineno=74, + col_offset=25, + end_lineno=74, + end_col_offset=37), + [ + Eq()], + [ + Name( + 'placeholder_19', + Load(), + lineno=74, + col_offset=41, + end_lineno=74, + end_col_offset=54)], + lineno=74, + col_offset=25, + end_lineno=74, + end_col_offset=54), + [ + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=32)], + Name( + 'placeholder_4', + Load(), + lineno=75, + col_offset=35, + end_lineno=75, + end_col_offset=39), + lineno=75, + col_offset=24, + end_lineno=75, + end_col_offset=39)], + [], + lineno=74, + col_offset=20, + end_lineno=75, + end_col_offset=39)], + lineno=72, + col_offset=20, + end_lineno=75, + end_col_offset=39)], + [], + lineno=71, + col_offset=16, + end_lineno=75, + end_col_offset=39), + If( + BoolOp( + And(), + [ + Compare( + Name( + 'placeholder_21', + Load(), + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=25), + [ + IsNot()], + [ + Constant( + None, + lineno=76, + col_offset=33, + end_lineno=76, + end_col_offset=37)], + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=37), + Compare( + Name( + 'placeholder_22', + Load(), + lineno=76, + col_offset=42, + end_lineno=76, + end_col_offset=50), + [ + IsNot()], + [ + Constant( + None, + lineno=76, + col_offset=58, + end_lineno=76, + end_col_offset=62)], + lineno=76, + col_offset=42, + end_lineno=76, + end_col_offset=62)], + lineno=76, + col_offset=19, + end_lineno=76, + end_col_offset=62), + [ + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_21', + Load(), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=26), + Constant( + 'owed_by', + lineno=77, + col_offset=27, + end_lineno=77, + end_col_offset=36), + Load(), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=37), + 'setdefault', + Load(), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=48), + [ + Name( + 'placeholder_19', + Load(), + lineno=77, + col_offset=49, + end_lineno=77, + end_col_offset=62), + Constant( + 0, + lineno=77, + col_offset=64, + end_lineno=77, + end_col_offset=65)], + [], + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=66), + lineno=77, + col_offset=20, + end_lineno=77, + end_col_offset=66), + AugAssign( + Subscript( + Subscript( + Name( + 'placeholder_21', + Load(), + lineno=78, + col_offset=20, + end_lineno=78, + end_col_offset=26), + Constant( + 'owed_by', + lineno=78, + col_offset=27, + end_lineno=78, + end_col_offset=36), + Load(), + lineno=78, + col_offset=20, + end_lineno=78, + end_col_offset=37), + Name( + 'placeholder_19', + Load(), + lineno=78, + col_offset=38, + end_lineno=78, + end_col_offset=51), + Store(), + lineno=78, + col_offset=20, + end_lineno=78, + end_col_offset=52), + Add(), + Name( + 'placeholder_20', + Load(), + lineno=78, + col_offset=56, + end_lineno=78, + end_col_offset=62), + lineno=78, + col_offset=20, + end_lineno=78, + end_col_offset=62), + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_22', + Load(), + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=28), + Constant( + 'owes', + lineno=79, + col_offset=29, + end_lineno=79, + end_col_offset=35), + Load(), + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=36), + 'setdefault', + Load(), + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=47), + [ + Name( + 'placeholder_18', + Load(), + lineno=79, + col_offset=48, + end_lineno=79, + end_col_offset=59), + Constant( + 0, + lineno=79, + col_offset=61, + end_lineno=79, + end_col_offset=62)], + [], + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=63), + lineno=79, + col_offset=20, + end_lineno=79, + end_col_offset=63), + AugAssign( + Subscript( + Subscript( + Name( + 'placeholder_22', + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=28), + Constant( + 'owes', + lineno=80, + col_offset=29, + end_lineno=80, + end_col_offset=35), + Load(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=36), + Name( + 'placeholder_18', + Load(), + lineno=80, + col_offset=37, + end_lineno=80, + end_col_offset=48), + Store(), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=49), + Add(), + Name( + 'placeholder_20', + Load(), + lineno=80, + col_offset=53, + end_lineno=80, + end_col_offset=59), + lineno=80, + col_offset=20, + end_lineno=80, + end_col_offset=59), + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=81, + col_offset=20, + end_lineno=81, + end_col_offset=24), + 'placeholder_3', + Load(), + lineno=81, + col_offset=20, + end_lineno=81, + end_col_offset=31), + [], + [], + lineno=81, + col_offset=20, + end_lineno=81, + end_col_offset=33), + lineno=81, + col_offset=20, + end_lineno=81, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=26)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=82, + col_offset=29, + end_lineno=82, + end_col_offset=33), + 'placeholder_9', + Load(), + lineno=82, + col_offset=29, + end_lineno=82, + end_col_offset=37), + [ + Constant( + '/users', + lineno=83, + col_offset=24, + end_lineno=83, + end_col_offset=32), + Call( + Attribute( + Name( + 'json', + Load(), + lineno=84, + col_offset=24, + end_lineno=84, + end_col_offset=28), + 'dumps', + Load(), + lineno=84, + col_offset=24, + end_lineno=84, + end_col_offset=34), + [ + Dict( + [ + Constant( + 'users', + lineno=84, + col_offset=36, + end_lineno=84, + end_col_offset=43)], + [ + List( + [ + Name( + 'placeholder_18', + Load(), + lineno=84, + col_offset=46, + end_lineno=84, + end_col_offset=57), + Name( + 'placeholder_19', + Load(), + lineno=84, + col_offset=59, + end_lineno=84, + end_col_offset=72)], + Load(), + lineno=84, + col_offset=45, + end_lineno=84, + end_col_offset=73)], + lineno=84, + col_offset=35, + end_lineno=84, + end_col_offset=74)], + [], + lineno=84, + col_offset=24, + end_lineno=84, + end_col_offset=75)], + [], + lineno=82, + col_offset=29, + end_lineno=85, + end_col_offset=21), + lineno=82, + col_offset=20, + end_lineno=85, + end_col_offset=21)], + [], + lineno=76, + col_offset=16, + end_lineno=85, + end_col_offset=21)], + [], + lineno=66, + col_offset=12, + end_lineno=85, + end_col_offset=21)], + [], + lineno=65, + col_offset=8, + end_lineno=85, + end_col_offset=21)], + lineno=46, + col_offset=8, + end_lineno=85, + end_col_offset=21), + Return( + Name( + 'placeholder_13', + Load(), + lineno=86, + col_offset=15, + end_lineno=86, + end_col_offset=21), + lineno=86, + col_offset=8, + end_lineno=86, + end_col_offset=21)], + [], + lineno=42, + col_offset=4, + end_lineno=86, + end_col_offset=21)], + [], + lineno=4, + col_offset=0, + end_lineno=86, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-rest-api/representation.txt b/test/practice-rest-api/representation.txt new file mode 100644 index 0000000..bcdc51f --- /dev/null +++ b/test/practice-rest-api/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('json', lineno=1, col_offset=7, end_lineno=1, end_col_offset=11)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=11), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21), arg('placeholder_2', lineno=5, col_offset=23, end_lineno=5, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=5, col_offset=32, end_lineno=5, end_col_offset=36)]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_2', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=21)], BoolOp(Or(), [Name('placeholder_2', Load(), lineno=6, col_offset=24, end_lineno=6, end_col_offset=32), Dict([Constant('users', lineno=6, col_offset=37, end_lineno=6, end_col_offset=44)], [List([], Load(), lineno=6, col_offset=46, end_lineno=6, end_col_offset=48)], lineno=6, col_offset=36, end_lineno=6, end_col_offset=49)], lineno=6, col_offset=24, end_lineno=6, end_col_offset=49), lineno=6, col_offset=8, end_lineno=6, end_col_offset=49)], [], lineno=5, col_offset=4, end_lineno=6, end_col_offset=49), FunctionDef('placeholder_3', arguments([], [arg('self', lineno=8, col_offset=15, end_lineno=8, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [For(Name('placeholder_4', Store(), lineno=9, col_offset=12, end_lineno=9, end_col_offset=16), Subscript(Attribute(Name('self', Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=24), 'placeholder_2', Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=33), Constant('users', lineno=9, col_offset=34, end_lineno=9, end_col_offset=41), Load(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=42), [Assign([Name('placeholder_5', Store(), lineno=10, col_offset=12, end_lineno=10, end_col_offset=19)], Subscript(Name('placeholder_4', Load(), lineno=10, col_offset=22, end_lineno=10, end_col_offset=26), Constant('owed_by', lineno=10, col_offset=27, end_lineno=10, end_col_offset=36), Load(), lineno=10, col_offset=22, end_lineno=10, end_col_offset=37), lineno=10, col_offset=12, end_lineno=10, end_col_offset=37), Assign([Name('placeholder_6', Store(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=16)], Subscript(Name('placeholder_4', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=23), Constant('owes', lineno=11, col_offset=24, end_lineno=11, end_col_offset=30), Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=31), lineno=11, col_offset=12, end_lineno=11, end_col_offset=31), For(Name('placeholder_7', Store(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=22), Call(Name('list', Load(), lineno=12, col_offset=26, end_lineno=12, end_col_offset=30), [Call(Attribute(Name('placeholder_5', Load(), lineno=12, col_offset=31, end_lineno=12, end_col_offset=38), 'keys', Load(), lineno=12, col_offset=31, end_lineno=12, end_col_offset=43), [], [], lineno=12, col_offset=31, end_lineno=12, end_col_offset=45)], [], lineno=12, col_offset=26, end_lineno=12, end_col_offset=46), [If(Compare(Name('placeholder_7', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=25), [In()], [Name('placeholder_6', Load(), lineno=13, col_offset=29, end_lineno=13, end_col_offset=33)], lineno=13, col_offset=19, end_lineno=13, end_col_offset=33), [Assign([Name('placeholder_8', Store(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=24)], Constant(0, lineno=14, col_offset=27, end_lineno=14, end_col_offset=28), lineno=14, col_offset=20, end_lineno=14, end_col_offset=28), If(Compare(Name('placeholder_7', Load(), lineno=15, col_offset=23, end_lineno=15, end_col_offset=29), [In()], [Name('placeholder_6', Load(), lineno=15, col_offset=33, end_lineno=15, end_col_offset=37)], lineno=15, col_offset=23, end_lineno=15, end_col_offset=37), [Assign([Name('placeholder_8', Store(), lineno=16, col_offset=24, end_lineno=16, end_col_offset=28)], Subscript(Name('placeholder_6', Load(), lineno=16, col_offset=31, end_lineno=16, end_col_offset=35), Name('placeholder_7', Load(), lineno=16, col_offset=36, end_lineno=16, end_col_offset=42), Load(), lineno=16, col_offset=31, end_lineno=16, end_col_offset=43), lineno=16, col_offset=24, end_lineno=16, end_col_offset=43), Delete([Subscript(Name('placeholder_6', Load(), lineno=17, col_offset=28, end_lineno=17, end_col_offset=32), Name('placeholder_7', Load(), lineno=17, col_offset=33, end_lineno=17, end_col_offset=39), Del(), lineno=17, col_offset=28, end_lineno=17, end_col_offset=40)], lineno=17, col_offset=24, end_lineno=17, end_col_offset=40)], [], lineno=15, col_offset=20, end_lineno=17, end_col_offset=40), If(Compare(Name('placeholder_7', Load(), lineno=18, col_offset=23, end_lineno=18, end_col_offset=29), [In()], [Name('placeholder_5', Load(), lineno=18, col_offset=33, end_lineno=18, end_col_offset=40)], lineno=18, col_offset=23, end_lineno=18, end_col_offset=40), [AugAssign(Name('placeholder_8', Store(), lineno=19, col_offset=24, end_lineno=19, end_col_offset=28), Sub(), Subscript(Name('placeholder_5', Load(), lineno=19, col_offset=32, end_lineno=19, end_col_offset=39), Name('placeholder_7', Load(), lineno=19, col_offset=40, end_lineno=19, end_col_offset=46), Load(), lineno=19, col_offset=32, end_lineno=19, end_col_offset=47), lineno=19, col_offset=24, end_lineno=19, end_col_offset=47), Delete([Subscript(Name('placeholder_5', Load(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=35), Name('placeholder_7', Load(), lineno=20, col_offset=36, end_lineno=20, end_col_offset=42), Del(), lineno=20, col_offset=28, end_lineno=20, end_col_offset=43)], lineno=20, col_offset=24, end_lineno=20, end_col_offset=43)], [], lineno=18, col_offset=20, end_lineno=20, end_col_offset=43), If(Compare(Name('placeholder_8', Load(), lineno=21, col_offset=23, end_lineno=21, end_col_offset=27), [Gt()], [Constant(0, lineno=21, col_offset=30, end_lineno=21, end_col_offset=31)], lineno=21, col_offset=23, end_lineno=21, end_col_offset=31), [Assign([Subscript(Name('placeholder_6', Load(), lineno=22, col_offset=24, end_lineno=22, end_col_offset=28), Name('placeholder_7', Load(), lineno=22, col_offset=29, end_lineno=22, end_col_offset=35), Store(), lineno=22, col_offset=24, end_lineno=22, end_col_offset=36)], Name('placeholder_8', Load(), lineno=22, col_offset=39, end_lineno=22, end_col_offset=43), lineno=22, col_offset=24, end_lineno=22, end_col_offset=43)], [If(Compare(Name('placeholder_8', Load(), lineno=23, col_offset=25, end_lineno=23, end_col_offset=29), [Lt()], [Constant(0, lineno=23, col_offset=32, end_lineno=23, end_col_offset=33)], lineno=23, col_offset=25, end_lineno=23, end_col_offset=33), [Assign([Subscript(Name('placeholder_5', Load(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=31), Name('placeholder_7', Load(), lineno=24, col_offset=32, end_lineno=24, end_col_offset=38), Store(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=39)], UnaryOp(USub(), Name('placeholder_8', Load(), lineno=24, col_offset=43, end_lineno=24, end_col_offset=47), lineno=24, col_offset=42, end_lineno=24, end_col_offset=47), lineno=24, col_offset=24, end_lineno=24, end_col_offset=47)], [], lineno=23, col_offset=20, end_lineno=24, end_col_offset=47)], lineno=21, col_offset=20, end_lineno=24, end_col_offset=47)], [], lineno=13, col_offset=16, end_lineno=24, end_col_offset=47)], [], lineno=12, col_offset=12, end_lineno=24, end_col_offset=47), Assign([Subscript(Name('placeholder_4', Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=16), Constant('balance', lineno=25, col_offset=17, end_lineno=25, end_col_offset=26), Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=27)], BinOp(Call(Name('sum', Load(), lineno=25, col_offset=30, end_lineno=25, end_col_offset=33), [Call(Attribute(Name('placeholder_5', Load(), lineno=25, col_offset=34, end_lineno=25, end_col_offset=41), 'values', Load(), lineno=25, col_offset=34, end_lineno=25, end_col_offset=48), [], [], lineno=25, col_offset=34, end_lineno=25, end_col_offset=50)], [], lineno=25, col_offset=30, end_lineno=25, end_col_offset=51), Sub(), Call(Name('sum', Load(), lineno=25, col_offset=54, end_lineno=25, end_col_offset=57), [Call(Attribute(Name('placeholder_6', Load(), lineno=25, col_offset=58, end_lineno=25, end_col_offset=62), 'values', Load(), lineno=25, col_offset=58, end_lineno=25, end_col_offset=69), [], [], lineno=25, col_offset=58, end_lineno=25, end_col_offset=71)], [], lineno=25, col_offset=54, end_lineno=25, end_col_offset=72), lineno=25, col_offset=30, end_lineno=25, end_col_offset=72), lineno=25, col_offset=12, end_lineno=25, end_col_offset=72)], [], lineno=9, col_offset=8, end_lineno=25, end_col_offset=72)], [], lineno=8, col_offset=4, end_lineno=25, end_col_offset=72), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=27, col_offset=12, end_lineno=27, end_col_offset=16), arg('placeholder_10', lineno=27, col_offset=18, end_lineno=27, end_col_offset=21), arg('placeholder_11', lineno=27, col_offset=23, end_lineno=27, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=27, col_offset=31, end_lineno=27, end_col_offset=35)]), [If(Compare(Name('placeholder_11', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=18), [IsNot()], [Constant(None, lineno=28, col_offset=26, end_lineno=28, end_col_offset=30)], lineno=28, col_offset=11, end_lineno=28, end_col_offset=30), [Assign([Name('placeholder_11', Store(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=19)], Call(Attribute(Name('json', Load(), lineno=29, col_offset=22, end_lineno=29, end_col_offset=26), 'loads', Load(), lineno=29, col_offset=22, end_lineno=29, end_col_offset=32), [Name('placeholder_11', Load(), lineno=29, col_offset=33, end_lineno=29, end_col_offset=40)], [], lineno=29, col_offset=22, end_lineno=29, end_col_offset=41), lineno=29, col_offset=12, end_lineno=29, end_col_offset=41)], [], lineno=28, col_offset=8, end_lineno=29, end_col_offset=41), If(Compare(Name('placeholder_10', Load(), lineno=30, col_offset=11, end_lineno=30, end_col_offset=14), [Eq()], [Constant('/users', lineno=30, col_offset=18, end_lineno=30, end_col_offset=26)], lineno=30, col_offset=11, end_lineno=30, end_col_offset=26), [If(Compare(Name('placeholder_11', Load(), lineno=31, col_offset=15, end_lineno=31, end_col_offset=22), [Is()], [Constant(None, lineno=31, col_offset=26, end_lineno=31, end_col_offset=30)], lineno=31, col_offset=15, end_lineno=31, end_col_offset=30), [Return(Call(Attribute(Name('json', Load(), lineno=32, col_offset=23, end_lineno=32, end_col_offset=27), 'dumps', Load(), lineno=32, col_offset=23, end_lineno=32, end_col_offset=33), [Attribute(Name('self', Load(), lineno=32, col_offset=34, end_lineno=32, end_col_offset=38), 'placeholder_2', Load(), lineno=32, col_offset=34, end_lineno=32, end_col_offset=47)], [], lineno=32, col_offset=23, end_lineno=32, end_col_offset=48), lineno=32, col_offset=16, end_lineno=32, end_col_offset=48)], [Return(Call(Attribute(Name('json', Load(), lineno=34, col_offset=23, end_lineno=34, end_col_offset=27), 'dumps', Load(), lineno=34, col_offset=23, end_lineno=34, end_col_offset=33), [Dict([Constant('users', lineno=35, col_offset=20, end_lineno=35, end_col_offset=27)], [ListComp(Name('placeholder_4', Load(), lineno=36, col_offset=24, end_lineno=36, end_col_offset=28), [comprehension(Name('placeholder_4', Store(), lineno=36, col_offset=33, end_lineno=36, end_col_offset=37), Subscript(Attribute(Name('self', Load(), lineno=36, col_offset=41, end_lineno=36, end_col_offset=45), 'placeholder_2', Load(), lineno=36, col_offset=41, end_lineno=36, end_col_offset=54), Constant('users', lineno=36, col_offset=55, end_lineno=36, end_col_offset=62), Load(), lineno=36, col_offset=41, end_lineno=36, end_col_offset=63), [Compare(Subscript(Name('placeholder_4', Load(), lineno=37, col_offset=27, end_lineno=37, end_col_offset=31), Constant('name', lineno=37, col_offset=32, end_lineno=37, end_col_offset=38), Load(), lineno=37, col_offset=27, end_lineno=37, end_col_offset=39), [In()], [Subscript(Name('placeholder_11', Load(), lineno=37, col_offset=43, end_lineno=37, end_col_offset=50), Constant('users', lineno=37, col_offset=51, end_lineno=37, end_col_offset=58), Load(), lineno=37, col_offset=43, end_lineno=37, end_col_offset=59)], lineno=37, col_offset=27, end_lineno=37, end_col_offset=59)], 0)], lineno=35, col_offset=29, end_lineno=38, end_col_offset=21)], lineno=34, col_offset=34, end_lineno=39, end_col_offset=17)], [], lineno=34, col_offset=23, end_lineno=39, end_col_offset=18), lineno=34, col_offset=16, end_lineno=39, end_col_offset=18)], lineno=31, col_offset=12, end_lineno=39, end_col_offset=18)], [], lineno=30, col_offset=8, end_lineno=39, end_col_offset=18), Return(Constant(None, lineno=40, col_offset=15, end_lineno=40, end_col_offset=19), lineno=40, col_offset=8, end_lineno=40, end_col_offset=19)], [], lineno=27, col_offset=4, end_lineno=40, end_col_offset=19), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=42, col_offset=13, end_lineno=42, end_col_offset=17), arg('placeholder_10', lineno=42, col_offset=19, end_lineno=42, end_col_offset=22), arg('placeholder_11', lineno=42, col_offset=24, end_lineno=42, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=42, col_offset=32, end_lineno=42, end_col_offset=36)]), [Assign([Name('placeholder_13', Store(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=14)], Constant(None, lineno=43, col_offset=17, end_lineno=43, end_col_offset=21), lineno=43, col_offset=8, end_lineno=43, end_col_offset=21), If(Compare(Name('placeholder_11', Load(), lineno=44, col_offset=11, end_lineno=44, end_col_offset=18), [IsNot()], [Constant(None, lineno=44, col_offset=26, end_lineno=44, end_col_offset=30)], lineno=44, col_offset=11, end_lineno=44, end_col_offset=30), [Assign([Name('placeholder_11', Store(), lineno=45, col_offset=12, end_lineno=45, end_col_offset=19)], Call(Attribute(Name('json', Load(), lineno=45, col_offset=22, end_lineno=45, end_col_offset=26), 'loads', Load(), lineno=45, col_offset=22, end_lineno=45, end_col_offset=32), [Name('placeholder_11', Load(), lineno=45, col_offset=33, end_lineno=45, end_col_offset=40)], [], lineno=45, col_offset=22, end_lineno=45, end_col_offset=41), lineno=45, col_offset=12, end_lineno=45, end_col_offset=41)], [], lineno=44, col_offset=8, end_lineno=45, end_col_offset=41), If(Compare(Name('placeholder_10', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=14), [Eq()], [Constant('/add', lineno=46, col_offset=18, end_lineno=46, end_col_offset=24)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=24), [If(Compare(Name('placeholder_11', Load(), lineno=47, col_offset=15, end_lineno=47, end_col_offset=22), [IsNot()], [Constant(None, lineno=47, col_offset=30, end_lineno=47, end_col_offset=34)], lineno=47, col_offset=15, end_lineno=47, end_col_offset=34), [Assign([Name('placeholder_14', Store(), lineno=48, col_offset=16, end_lineno=48, end_col_offset=20)], Subscript(Name('placeholder_11', Load(), lineno=48, col_offset=23, end_lineno=48, end_col_offset=30), Constant('user', lineno=48, col_offset=31, end_lineno=48, end_col_offset=37), Load(), lineno=48, col_offset=23, end_lineno=48, end_col_offset=38), lineno=48, col_offset=16, end_lineno=48, end_col_offset=38), Assign([Name('placeholder_15', Store(), lineno=49, col_offset=16, end_lineno=49, end_col_offset=21)], Subscript(Attribute(Name('self', Load(), lineno=49, col_offset=24, end_lineno=49, end_col_offset=28), 'placeholder_2', Load(), lineno=49, col_offset=24, end_lineno=49, end_col_offset=37), Constant('users', lineno=49, col_offset=38, end_lineno=49, end_col_offset=45), Load(), lineno=49, col_offset=24, end_lineno=49, end_col_offset=46), lineno=49, col_offset=16, end_lineno=49, end_col_offset=46), Assign([Name('placeholder_4', Store(), lineno=50, col_offset=16, end_lineno=50, end_col_offset=20)], Constant(None, lineno=50, col_offset=23, end_lineno=50, end_col_offset=27), lineno=50, col_offset=16, end_lineno=50, end_col_offset=27), For(Name('placeholder_16', Store(), lineno=51, col_offset=20, end_lineno=51, end_col_offset=23), Name('placeholder_15', Load(), lineno=51, col_offset=27, end_lineno=51, end_col_offset=32), [If(Compare(Subscript(Name('placeholder_16', Load(), lineno=52, col_offset=23, end_lineno=52, end_col_offset=26), Constant('name', lineno=52, col_offset=27, end_lineno=52, end_col_offset=33), Load(), lineno=52, col_offset=23, end_lineno=52, end_col_offset=34), [Eq()], [Name('placeholder_14', Load(), lineno=52, col_offset=38, end_lineno=52, end_col_offset=42)], lineno=52, col_offset=23, end_lineno=52, end_col_offset=42), [Assign([Name('placeholder_4', Store(), lineno=53, col_offset=24, end_lineno=53, end_col_offset=28)], Name('placeholder_16', Load(), lineno=53, col_offset=31, end_lineno=53, end_col_offset=34), lineno=53, col_offset=24, end_lineno=53, end_col_offset=34), Break(lineno=54, col_offset=24, end_lineno=54, end_col_offset=29)], [], lineno=52, col_offset=20, end_lineno=54, end_col_offset=29)], [], lineno=51, col_offset=16, end_lineno=54, end_col_offset=29), If(Compare(Name('placeholder_4', Load(), lineno=55, col_offset=19, end_lineno=55, end_col_offset=23), [Is()], [Constant(None, lineno=55, col_offset=27, end_lineno=55, end_col_offset=31)], lineno=55, col_offset=19, end_lineno=55, end_col_offset=31), [Assign([Name('placeholder_17', Store(), lineno=56, col_offset=20, end_lineno=56, end_col_offset=28)], Dict([Constant('name', lineno=57, col_offset=24, end_lineno=57, end_col_offset=30), Constant('owes', lineno=58, col_offset=24, end_lineno=58, end_col_offset=30), Constant('owed_by', lineno=59, col_offset=24, end_lineno=59, end_col_offset=33), Constant('balance', lineno=60, col_offset=24, end_lineno=60, end_col_offset=33)], [Name('placeholder_14', Load(), lineno=57, col_offset=32, end_lineno=57, end_col_offset=36), Dict([], [], lineno=58, col_offset=32, end_lineno=58, end_col_offset=34), Dict([], [], lineno=59, col_offset=35, end_lineno=59, end_col_offset=37), Constant(0, lineno=60, col_offset=35, end_lineno=60, end_col_offset=36)], lineno=56, col_offset=31, end_lineno=61, end_col_offset=21), lineno=56, col_offset=20, end_lineno=61, end_col_offset=21), Expr(Call(Attribute(Name('placeholder_15', Load(), lineno=62, col_offset=20, end_lineno=62, end_col_offset=25), 'append', Load(), lineno=62, col_offset=20, end_lineno=62, end_col_offset=32), [Name('placeholder_17', Load(), lineno=62, col_offset=33, end_lineno=62, end_col_offset=41)], [], lineno=62, col_offset=20, end_lineno=62, end_col_offset=42), lineno=62, col_offset=20, end_lineno=62, end_col_offset=42), Expr(Call(Attribute(Name('self', Load(), lineno=63, col_offset=20, end_lineno=63, end_col_offset=24), 'placeholder_3', Load(), lineno=63, col_offset=20, end_lineno=63, end_col_offset=31), [], [], lineno=63, col_offset=20, end_lineno=63, end_col_offset=33), lineno=63, col_offset=20, end_lineno=63, end_col_offset=33), Assign([Name('placeholder_13', Store(), lineno=64, col_offset=20, end_lineno=64, end_col_offset=26)], Call(Attribute(Name('json', Load(), lineno=64, col_offset=29, end_lineno=64, end_col_offset=33), 'dumps', Load(), lineno=64, col_offset=29, end_lineno=64, end_col_offset=39), [Name('placeholder_17', Load(), lineno=64, col_offset=40, end_lineno=64, end_col_offset=48)], [], lineno=64, col_offset=29, end_lineno=64, end_col_offset=49), lineno=64, col_offset=20, end_lineno=64, end_col_offset=49)], [], lineno=55, col_offset=16, end_lineno=64, end_col_offset=49)], [], lineno=47, col_offset=12, end_lineno=64, end_col_offset=49)], [If(Compare(Name('placeholder_10', Load(), lineno=65, col_offset=13, end_lineno=65, end_col_offset=16), [Eq()], [Constant('/iou', lineno=65, col_offset=20, end_lineno=65, end_col_offset=26)], lineno=65, col_offset=13, end_lineno=65, end_col_offset=26), [If(Compare(Name('placeholder_11', Load(), lineno=66, col_offset=15, end_lineno=66, end_col_offset=22), [IsNot()], [Constant(None, lineno=66, col_offset=30, end_lineno=66, end_col_offset=34)], lineno=66, col_offset=15, end_lineno=66, end_col_offset=34), [Assign([Name('placeholder_18', Store(), lineno=67, col_offset=16, end_lineno=67, end_col_offset=27)], Subscript(Name('placeholder_11', Load(), lineno=67, col_offset=30, end_lineno=67, end_col_offset=37), Constant('lender', lineno=67, col_offset=38, end_lineno=67, end_col_offset=46), Load(), lineno=67, col_offset=30, end_lineno=67, end_col_offset=47), lineno=67, col_offset=16, end_lineno=67, end_col_offset=47), Assign([Name('placeholder_19', Store(), lineno=68, col_offset=16, end_lineno=68, end_col_offset=29)], Subscript(Name('placeholder_11', Load(), lineno=68, col_offset=32, end_lineno=68, end_col_offset=39), Constant('borrower', lineno=68, col_offset=40, end_lineno=68, end_col_offset=50), Load(), lineno=68, col_offset=32, end_lineno=68, end_col_offset=51), lineno=68, col_offset=16, end_lineno=68, end_col_offset=51), Assign([Name('placeholder_20', Store(), lineno=69, col_offset=16, end_lineno=69, end_col_offset=22)], Subscript(Name('placeholder_11', Load(), lineno=69, col_offset=25, end_lineno=69, end_col_offset=32), Constant('amount', lineno=69, col_offset=33, end_lineno=69, end_col_offset=41), Load(), lineno=69, col_offset=25, end_lineno=69, end_col_offset=42), lineno=69, col_offset=16, end_lineno=69, end_col_offset=42), Assign([Name('placeholder_21', Store(), lineno=70, col_offset=16, end_lineno=70, end_col_offset=22), Name('placeholder_22', Store(), lineno=70, col_offset=25, end_lineno=70, end_col_offset=33)], Constant(None, lineno=70, col_offset=36, end_lineno=70, end_col_offset=40), lineno=70, col_offset=16, end_lineno=70, end_col_offset=40), For(Name('placeholder_4', Store(), lineno=71, col_offset=20, end_lineno=71, end_col_offset=24), Subscript(Attribute(Name('self', Load(), lineno=71, col_offset=28, end_lineno=71, end_col_offset=32), 'placeholder_2', Load(), lineno=71, col_offset=28, end_lineno=71, end_col_offset=41), Constant('users', lineno=71, col_offset=42, end_lineno=71, end_col_offset=49), Load(), lineno=71, col_offset=28, end_lineno=71, end_col_offset=50), [If(Compare(Subscript(Name('placeholder_4', Load(), lineno=72, col_offset=23, end_lineno=72, end_col_offset=27), Constant('name', lineno=72, col_offset=28, end_lineno=72, end_col_offset=34), Load(), lineno=72, col_offset=23, end_lineno=72, end_col_offset=35), [Eq()], [Name('placeholder_18', Load(), lineno=72, col_offset=39, end_lineno=72, end_col_offset=50)], lineno=72, col_offset=23, end_lineno=72, end_col_offset=50), [Assign([Name('placeholder_21', Store(), lineno=73, col_offset=24, end_lineno=73, end_col_offset=30)], Name('placeholder_4', Load(), lineno=73, col_offset=33, end_lineno=73, end_col_offset=37), lineno=73, col_offset=24, end_lineno=73, end_col_offset=37)], [If(Compare(Subscript(Name('placeholder_4', Load(), lineno=74, col_offset=25, end_lineno=74, end_col_offset=29), Constant('name', lineno=74, col_offset=30, end_lineno=74, end_col_offset=36), Load(), lineno=74, col_offset=25, end_lineno=74, end_col_offset=37), [Eq()], [Name('placeholder_19', Load(), lineno=74, col_offset=41, end_lineno=74, end_col_offset=54)], lineno=74, col_offset=25, end_lineno=74, end_col_offset=54), [Assign([Name('placeholder_22', Store(), lineno=75, col_offset=24, end_lineno=75, end_col_offset=32)], Name('placeholder_4', Load(), lineno=75, col_offset=35, end_lineno=75, end_col_offset=39), lineno=75, col_offset=24, end_lineno=75, end_col_offset=39)], [], lineno=74, col_offset=20, end_lineno=75, end_col_offset=39)], lineno=72, col_offset=20, end_lineno=75, end_col_offset=39)], [], lineno=71, col_offset=16, end_lineno=75, end_col_offset=39), If(BoolOp(And(), [Compare(Name('placeholder_21', Load(), lineno=76, col_offset=19, end_lineno=76, end_col_offset=25), [IsNot()], [Constant(None, lineno=76, col_offset=33, end_lineno=76, end_col_offset=37)], lineno=76, col_offset=19, end_lineno=76, end_col_offset=37), Compare(Name('placeholder_22', Load(), lineno=76, col_offset=42, end_lineno=76, end_col_offset=50), [IsNot()], [Constant(None, lineno=76, col_offset=58, end_lineno=76, end_col_offset=62)], lineno=76, col_offset=42, end_lineno=76, end_col_offset=62)], lineno=76, col_offset=19, end_lineno=76, end_col_offset=62), [Expr(Call(Attribute(Subscript(Name('placeholder_21', Load(), lineno=77, col_offset=20, end_lineno=77, end_col_offset=26), Constant('owed_by', lineno=77, col_offset=27, end_lineno=77, end_col_offset=36), Load(), lineno=77, col_offset=20, end_lineno=77, end_col_offset=37), 'setdefault', Load(), lineno=77, col_offset=20, end_lineno=77, end_col_offset=48), [Name('placeholder_19', Load(), lineno=77, col_offset=49, end_lineno=77, end_col_offset=62), Constant(0, lineno=77, col_offset=64, end_lineno=77, end_col_offset=65)], [], lineno=77, col_offset=20, end_lineno=77, end_col_offset=66), lineno=77, col_offset=20, end_lineno=77, end_col_offset=66), AugAssign(Subscript(Subscript(Name('placeholder_21', Load(), lineno=78, col_offset=20, end_lineno=78, end_col_offset=26), Constant('owed_by', lineno=78, col_offset=27, end_lineno=78, end_col_offset=36), Load(), lineno=78, col_offset=20, end_lineno=78, end_col_offset=37), Name('placeholder_19', Load(), lineno=78, col_offset=38, end_lineno=78, end_col_offset=51), Store(), lineno=78, col_offset=20, end_lineno=78, end_col_offset=52), Add(), Name('placeholder_20', Load(), lineno=78, col_offset=56, end_lineno=78, end_col_offset=62), lineno=78, col_offset=20, end_lineno=78, end_col_offset=62), Expr(Call(Attribute(Subscript(Name('placeholder_22', Load(), lineno=79, col_offset=20, end_lineno=79, end_col_offset=28), Constant('owes', lineno=79, col_offset=29, end_lineno=79, end_col_offset=35), Load(), lineno=79, col_offset=20, end_lineno=79, end_col_offset=36), 'setdefault', Load(), lineno=79, col_offset=20, end_lineno=79, end_col_offset=47), [Name('placeholder_18', Load(), lineno=79, col_offset=48, end_lineno=79, end_col_offset=59), Constant(0, lineno=79, col_offset=61, end_lineno=79, end_col_offset=62)], [], lineno=79, col_offset=20, end_lineno=79, end_col_offset=63), lineno=79, col_offset=20, end_lineno=79, end_col_offset=63), AugAssign(Subscript(Subscript(Name('placeholder_22', Load(), lineno=80, col_offset=20, end_lineno=80, end_col_offset=28), Constant('owes', lineno=80, col_offset=29, end_lineno=80, end_col_offset=35), Load(), lineno=80, col_offset=20, end_lineno=80, end_col_offset=36), Name('placeholder_18', Load(), lineno=80, col_offset=37, end_lineno=80, end_col_offset=48), Store(), lineno=80, col_offset=20, end_lineno=80, end_col_offset=49), Add(), Name('placeholder_20', Load(), lineno=80, col_offset=53, end_lineno=80, end_col_offset=59), lineno=80, col_offset=20, end_lineno=80, end_col_offset=59), Expr(Call(Attribute(Name('self', Load(), lineno=81, col_offset=20, end_lineno=81, end_col_offset=24), 'placeholder_3', Load(), lineno=81, col_offset=20, end_lineno=81, end_col_offset=31), [], [], lineno=81, col_offset=20, end_lineno=81, end_col_offset=33), lineno=81, col_offset=20, end_lineno=81, end_col_offset=33), Assign([Name('placeholder_13', Store(), lineno=82, col_offset=20, end_lineno=82, end_col_offset=26)], Call(Attribute(Name('self', Load(), lineno=82, col_offset=29, end_lineno=82, end_col_offset=33), 'placeholder_9', Load(), lineno=82, col_offset=29, end_lineno=82, end_col_offset=37), [Constant('/users', lineno=83, col_offset=24, end_lineno=83, end_col_offset=32), Call(Attribute(Name('json', Load(), lineno=84, col_offset=24, end_lineno=84, end_col_offset=28), 'dumps', Load(), lineno=84, col_offset=24, end_lineno=84, end_col_offset=34), [Dict([Constant('users', lineno=84, col_offset=36, end_lineno=84, end_col_offset=43)], [List([Name('placeholder_18', Load(), lineno=84, col_offset=46, end_lineno=84, end_col_offset=57), Name('placeholder_19', Load(), lineno=84, col_offset=59, end_lineno=84, end_col_offset=72)], Load(), lineno=84, col_offset=45, end_lineno=84, end_col_offset=73)], lineno=84, col_offset=35, end_lineno=84, end_col_offset=74)], [], lineno=84, col_offset=24, end_lineno=84, end_col_offset=75)], [], lineno=82, col_offset=29, end_lineno=85, end_col_offset=21), lineno=82, col_offset=20, end_lineno=85, end_col_offset=21)], [], lineno=76, col_offset=16, end_lineno=85, end_col_offset=21)], [], lineno=66, col_offset=12, end_lineno=85, end_col_offset=21)], [], lineno=65, col_offset=8, end_lineno=85, end_col_offset=21)], lineno=46, col_offset=8, end_lineno=85, end_col_offset=21), Return(Name('placeholder_13', Load(), lineno=86, col_offset=15, end_lineno=86, end_col_offset=21), lineno=86, col_offset=8, end_lineno=86, end_col_offset=21)], [], lineno=42, col_offset=4, end_lineno=86, end_col_offset=21)], [], lineno=4, col_offset=0, end_lineno=86, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-rest-api/rest_api.py b/test/practice-rest-api/rest_api.py new file mode 100644 index 0000000..46556ef --- /dev/null +++ b/test/practice-rest-api/rest_api.py @@ -0,0 +1,86 @@ +import json + + +class RestAPI: + def __init__(self, database=None): + self.database = database or {'users': []} + + def update(self): + for user in self.database['users']: + owed_by = user['owed_by'] + owes = user['owes'] + for debtor in list(owed_by.keys()): + if debtor in owes: + diff = 0 + if debtor in owes: + diff = owes[debtor] + del owes[debtor] + if debtor in owed_by: + diff -= owed_by[debtor] + del owed_by[debtor] + if diff > 0: + owes[debtor] = diff + elif diff < 0: + owed_by[debtor] = -diff + user['balance'] = sum(owed_by.values()) - sum(owes.values()) + + def get(self, url, payload=None): + if payload is not None: + payload = json.loads(payload) + if url == '/users': + if payload is None: + return json.dumps(self.database) + else: + return json.dumps({ + 'users': [ + user for user in self.database['users'] + if user['name'] in payload['users'] + ] + }) + return None + + def post(self, url, payload=None): + result = None + if payload is not None: + payload = json.loads(payload) + if url == '/add': + if payload is not None: + name = payload['user'] + users = self.database['users'] + user = None + for idx in users: + if idx['name'] == name: + user = idx + break + if user is None: + new_user = { + 'name': name, + 'owes': {}, + 'owed_by': {}, + 'balance': 0 + } + users.append(new_user) + self.update() + result = json.dumps(new_user) + elif url == '/iou': + if payload is not None: + lender_name = payload['lender'] + borrower_name = payload['borrower'] + amount = payload['amount'] + lender = borrower = None + for user in self.database['users']: + if user['name'] == lender_name: + lender = user + elif user['name'] == borrower_name: + borrower = user + if lender is not None and borrower is not None: + lender['owed_by'].setdefault(borrower_name, 0) + lender['owed_by'][borrower_name] += amount + borrower['owes'].setdefault(lender_name, 0) + borrower['owes'][lender_name] += amount + self.update() + result = self.get( + '/users', + json.dumps({'users': [lender_name, borrower_name]}) + ) + return result diff --git a/test/practice-reverse-string/.meta/config.json b/test/practice-reverse-string/.meta/config.json new file mode 100644 index 0000000..1df068a --- /dev/null +++ b/test/practice-reverse-string/.meta/config.json @@ -0,0 +1,28 @@ +{ + "authors": [ + "sjwarner-bp" + ], + "contributors": [ + "cmccandless", + "dmerejkowsky", + "Dog", + "flores-jacob", + "frerich", + "Grociu", + "tqa236" + ], + "files": { + "solution": [ + "reverse_string.py" + ], + "test": [ + "reverse_string_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Reverse a string.", + "source": "Introductory challenge to reverse an input string", + "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" +} diff --git a/test/practice-reverse-string/mapping.json b/test/practice-reverse-string/mapping.json new file mode 100644 index 0000000..f572f84 --- /dev/null +++ b/test/practice-reverse-string/mapping.json @@ -0,0 +1,4 @@ +{ + "placeholder_0": "reverse", + "placeholder_1": "text" +} \ No newline at end of file diff --git a/test/practice-reverse-string/representation.json b/test/practice-reverse-string/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-reverse-string/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-reverse-string/representation.out b/test/practice-reverse-string/representation.out new file mode 100644 index 0000000..e3c2ce3 --- /dev/null +++ b/test/practice-reverse-string/representation.out @@ -0,0 +1,139 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1=""): + return placeholder_1[::-1] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'reverse', + arguments( + [], + [ + arg( + 'text', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + '', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=19)]), + [ + Return( + Subscript( + Name( + 'text', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=15), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=16, + end_lineno=2, + end_col_offset=20), + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=21), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=21)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + '', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=19)]), + [ + Return( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=15), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=2, + col_offset=19, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=20), + lineno=2, + col_offset=16, + end_lineno=2, + end_col_offset=20), + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=21), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=21)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-reverse-string/representation.txt b/test/practice-reverse-string/representation.txt new file mode 100644 index 0000000..2a815f4 --- /dev/null +++ b/test/practice-reverse-string/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=12, end_lineno=1, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[Constant('', lineno=1, col_offset=17, end_lineno=1, end_col_offset=19)]), [Return(Subscript(Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=15), Slice(step=UnaryOp(USub(), Constant(1, lineno=2, col_offset=19, end_lineno=2, end_col_offset=20), lineno=2, col_offset=18, end_lineno=2, end_col_offset=20), lineno=2, col_offset=16, end_lineno=2, end_col_offset=20), Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=21), lineno=2, col_offset=4, end_lineno=2, end_col_offset=21)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-reverse-string/reverse_string.py b/test/practice-reverse-string/reverse_string.py new file mode 100644 index 0000000..c8b38d5 --- /dev/null +++ b/test/practice-reverse-string/reverse_string.py @@ -0,0 +1,2 @@ +def reverse(text=''): + return text[::-1] diff --git a/test/practice-rna-transcription/.meta/config.json b/test/practice-rna-transcription/.meta/config.json new file mode 100644 index 0000000..636aa7e --- /dev/null +++ b/test/practice-rna-transcription/.meta/config.json @@ -0,0 +1,38 @@ +{ + "authors": [ + "BrianHicks" + ], + "contributors": [ + "behrtam", + "cmccandless", + "davepeake", + "Dog", + "dvermd", + "hariesramdhani", + "ikhadykin", + "jamesmcm", + "kytrinyx", + "lowks", + "magnus-hogberg", + "N-Parsons", + "pheanex", + "sjakobi", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "rna_transcription.py" + ], + "test": [ + "rna_transcription_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a DNA strand, return its RNA Complement Transcription.", + "source": "Hyperphysics", + "source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html" +} diff --git a/test/practice-rna-transcription/mapping.json b/test/practice-rna-transcription/mapping.json new file mode 100644 index 0000000..596f9d8 --- /dev/null +++ b/test/practice-rna-transcription/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "DNA_TO_RNA", + "placeholder_1": "to_rna", + "placeholder_2": "dna_strand" +} \ No newline at end of file diff --git a/test/practice-rna-transcription/representation.json b/test/practice-rna-transcription/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-rna-transcription/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-rna-transcription/representation.out b/test/practice-rna-transcription/representation.out new file mode 100644 index 0000000..ae1ab43 --- /dev/null +++ b/test/practice-rna-transcription/representation.out @@ -0,0 +1,218 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = str.maketrans("AGCT", "UCGA") + + +def placeholder_1(placeholder_2): + return placeholder_2.translate(placeholder_0) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'DNA_TO_RNA', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=10)], + Call( + Attribute( + Name( + 'str', + Load(), + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=16), + 'maketrans', + Load(), + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=26), + [ + Constant( + 'AGCT', + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=33), + Constant( + 'UCGA', + lineno=1, + col_offset=35, + end_lineno=1, + end_col_offset=41)], + [], + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=42), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=42), + FunctionDef( + 'to_rna', + arguments( + [], + [ + arg( + 'dna_strand', + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'dna_strand', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=21), + 'translate', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=31), + [ + Name( + 'DNA_TO_RNA', + Load(), + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=42)], + [], + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=43), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=43)], + [], + lineno=3, + col_offset=0, + end_lineno=4, + end_col_offset=43)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=10)], + Call( + Attribute( + Name( + 'str', + Load(), + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=16), + 'maketrans', + Load(), + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=26), + [ + Constant( + 'AGCT', + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=33), + Constant( + 'UCGA', + lineno=1, + col_offset=35, + end_lineno=1, + end_col_offset=41)], + [], + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=42), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=42), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=21), + 'translate', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=31), + [ + Name( + 'placeholder_0', + Load(), + lineno=4, + col_offset=32, + end_lineno=4, + end_col_offset=42)], + [], + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=43), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=43)], + [], + lineno=3, + col_offset=0, + end_lineno=4, + end_col_offset=43)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-rna-transcription/representation.txt b/test/practice-rna-transcription/representation.txt new file mode 100644 index 0000000..4ea001d --- /dev/null +++ b/test/practice-rna-transcription/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=10)], Call(Attribute(Name('str', Load(), lineno=1, col_offset=13, end_lineno=1, end_col_offset=16), 'maketrans', Load(), lineno=1, col_offset=13, end_lineno=1, end_col_offset=26), [Constant('AGCT', lineno=1, col_offset=27, end_lineno=1, end_col_offset=33), Constant('UCGA', lineno=1, col_offset=35, end_lineno=1, end_col_offset=41)], [], lineno=1, col_offset=13, end_lineno=1, end_col_offset=42), lineno=1, col_offset=0, end_lineno=1, end_col_offset=42), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=3, col_offset=11, end_lineno=3, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('placeholder_2', Load(), lineno=4, col_offset=11, end_lineno=4, end_col_offset=21), 'translate', Load(), lineno=4, col_offset=11, end_lineno=4, end_col_offset=31), [Name('placeholder_0', Load(), lineno=4, col_offset=32, end_lineno=4, end_col_offset=42)], [], lineno=4, col_offset=11, end_lineno=4, end_col_offset=43), lineno=4, col_offset=4, end_lineno=4, end_col_offset=43)], [], lineno=3, col_offset=0, end_lineno=4, end_col_offset=43)], []) \ No newline at end of file diff --git a/test/practice-rna-transcription/rna_transcription.py b/test/practice-rna-transcription/rna_transcription.py new file mode 100644 index 0000000..61db942 --- /dev/null +++ b/test/practice-rna-transcription/rna_transcription.py @@ -0,0 +1,4 @@ +DNA_TO_RNA = str.maketrans("AGCT", "UCGA") + +def to_rna(dna_strand): + return dna_strand.translate(DNA_TO_RNA) diff --git a/test/practice-robot-name/.meta/config.json b/test/practice-robot-name/.meta/config.json new file mode 100644 index 0000000..648bc8e --- /dev/null +++ b/test/practice-robot-name/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [], + "contributors": [ + "ariso353", + "behrtam", + "cmccandless", + "Dog", + "kytrinyx", + "lowks", + "N-Parsons", + "pheanex", + "rootulp", + "sjakobi", + "tqa236", + "tstirrat15" + ], + "files": { + "solution": [ + "robot_name.py" + ], + "test": [ + "robot_name_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Manage robot factory settings.", + "source": "A debugging session with Paul Blackwell at gSchool." +} diff --git a/test/practice-robot-name/mapping.json b/test/practice-robot-name/mapping.json new file mode 100644 index 0000000..b5f099c --- /dev/null +++ b/test/practice-robot-name/mapping.json @@ -0,0 +1,14 @@ +{ + "placeholder_0": "ALPHABET", + "placeholder_1": "Robot", + "placeholder_2": "__init__", + "placeholder_3": "_name", + "placeholder_4": "_past_names", + "placeholder_5": "prefix", + "placeholder_6": "_", + "placeholder_7": "suffix", + "placeholder_8": "get_name", + "placeholder_9": "del_name", + "placeholder_10": "name", + "placeholder_11": "reset" +} \ No newline at end of file diff --git a/test/practice-robot-name/representation.json b/test/practice-robot-name/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-robot-name/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-robot-name/representation.out b/test/practice-robot-name/representation.out new file mode 100644 index 0000000..8d97d71 --- /dev/null +++ b/test/practice-robot-name/representation.out @@ -0,0 +1,1567 @@ +## BEGIN NORMALIZED CODE ## +import random + +placeholder_0 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + +class placeholder_1: + def placeholder_2(self): + self.placeholder_3 = None + self.placeholder_4 = set() + + def placeholder_5(self): + return "".join([random.choice(placeholder_0) for placeholder_6 in range(0, 2)]) + + def placeholder_7(self): + return "".join( + [str(random.choice(range(0, 10))) for placeholder_6 in range(0, 3)] + ) + + def placeholder_8(self): + if not self.placeholder_3: + while True: + self.placeholder_3 = self.placeholder_5() + self.placeholder_7() + if self.placeholder_3 not in self.placeholder_4: + self.placeholder_4.add(self.placeholder_3) + break + return self.placeholder_3 + + def placeholder_9(self): + self.placeholder_3 = None + + placeholder_10 = property(placeholder_8, None, placeholder_9) + + def placeholder_11(self): + del self.name + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'random', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=13)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=13), + Assign( + [ + Name( + 'ALPHABET', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=8)], + Constant( + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=39), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=39), + ClassDef( + 'Robot', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + '_name', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=18)], + Constant( + None, + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=25), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=25), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + '_past_names', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=24)], + Call( + Name( + 'set', + Load(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=30), + [], + [], + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=32), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=32)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=32), + FunctionDef( + 'prefix', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=17), + 'join', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=22), + [ + ListComp( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18), + 'choice', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=25), + [ + Name( + 'ALPHABET', + Load(), + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=34)], + [], + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=35), + [ + comprehension( + Name( + '_', + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=17), + Call( + Name( + 'range', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=26), + [ + Constant( + 0, + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=28), + Constant( + 2, + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=31)], + [], + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=32), + [], + 0)], + lineno=10, + col_offset=23, + end_lineno=13, + end_col_offset=9)], + [], + lineno=10, + col_offset=15, + end_lineno=13, + end_col_offset=10), + lineno=10, + col_offset=8, + end_lineno=13, + end_col_offset=10)], + [], + lineno=9, + col_offset=4, + end_lineno=13, + end_col_offset=10), + FunctionDef( + 'suffix', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '', + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=17), + 'join', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=22), + [ + ListComp( + Call( + Name( + 'str', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=15), + [ + Call( + Attribute( + Name( + 'random', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=22), + 'choice', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=29), + [ + Call( + Name( + 'range', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=35), + [ + Constant( + 0, + lineno=17, + col_offset=36, + end_lineno=17, + end_col_offset=37), + Constant( + 10, + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=41)], + [], + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=42)], + [], + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=43)], + [], + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=44), + [ + comprehension( + Name( + '_', + Store(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=17), + Call( + Name( + 'range', + Load(), + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=26), + [ + Constant( + 0, + lineno=18, + col_offset=27, + end_lineno=18, + end_col_offset=28), + Constant( + 3, + lineno=18, + col_offset=30, + end_lineno=18, + end_col_offset=31)], + [], + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=32), + [], + 0)], + lineno=16, + col_offset=23, + end_lineno=19, + end_col_offset=9)], + [], + lineno=16, + col_offset=15, + end_lineno=19, + end_col_offset=10), + lineno=16, + col_offset=8, + end_lineno=19, + end_col_offset=10)], + [], + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=10), + FunctionDef( + 'get_name', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=19), + '_name', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=25), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=25), + [ + While( + Constant( + True, + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=22), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=20), + '_name', + Store(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=26)], + BinOp( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=33), + 'prefix', + Load(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=40), + [], + [], + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=42), + Add(), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=45, + end_lineno=26, + end_col_offset=49), + 'suffix', + Load(), + lineno=26, + col_offset=45, + end_lineno=26, + end_col_offset=56), + [], + [], + lineno=26, + col_offset=45, + end_lineno=26, + end_col_offset=58), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=58), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=58), + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=23), + '_name', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=29), + [ + NotIn()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=37, + end_lineno=27, + end_col_offset=41), + '_past_names', + Load(), + lineno=27, + col_offset=37, + end_lineno=27, + end_col_offset=53)], + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=53), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=24), + '_past_names', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=36), + 'add', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=40), + [ + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=41, + end_lineno=28, + end_col_offset=45), + '_name', + Load(), + lineno=28, + col_offset=41, + end_lineno=28, + end_col_offset=51)], + [], + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=52), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=52), + Break( + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=25)], + [], + lineno=27, + col_offset=16, + end_lineno=29, + end_col_offset=25)], + [], + lineno=25, + col_offset=12, + end_lineno=29, + end_col_offset=25)], + [], + lineno=22, + col_offset=8, + end_lineno=29, + end_col_offset=25), + Return( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=19), + '_name', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=25), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=25)], + [], + lineno=21, + col_offset=4, + end_lineno=31, + end_col_offset=25), + FunctionDef( + 'del_name', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + '_name', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=18)], + Constant( + None, + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=25), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=25)], + [], + lineno=33, + col_offset=4, + end_lineno=34, + end_col_offset=25), + Assign( + [ + Name( + 'name', + Store(), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=8)], + Call( + Name( + 'property', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=19), + [ + Name( + 'get_name', + Load(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=28), + Constant( + None, + lineno=36, + col_offset=30, + end_lineno=36, + end_col_offset=34), + Name( + 'del_name', + Load(), + lineno=36, + col_offset=36, + end_lineno=36, + end_col_offset=44)], + [], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=45), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=45), + FunctionDef( + 'reset', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=14, + end_lineno=38, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Delete( + [ + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=16), + 'name', + Del(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=21)], + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=21)], + [], + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=21)], + [], + lineno=4, + col_offset=0, + end_lineno=39, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'random', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=13)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=8)], + Constant( + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=39), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=39), + ClassDef( + 'placeholder_1', + [], + [], + [ + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=18)], + Constant( + None, + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=25), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=25), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=24)], + Call( + Name( + 'set', + Load(), + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=30), + [], + [], + lineno=7, + col_offset=27, + end_lineno=7, + end_col_offset=32), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=32)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=32), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=17), + 'join', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=22), + [ + ListComp( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18), + 'choice', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=25), + [ + Name( + 'placeholder_0', + Load(), + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=34)], + [], + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=35), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=17), + Call( + Name( + 'range', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=26), + [ + Constant( + 0, + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=28), + Constant( + 2, + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=31)], + [], + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=32), + [], + 0)], + lineno=10, + col_offset=23, + end_lineno=13, + end_col_offset=9)], + [], + lineno=10, + col_offset=15, + end_lineno=13, + end_col_offset=10), + lineno=10, + col_offset=8, + end_lineno=13, + end_col_offset=10)], + [], + lineno=9, + col_offset=4, + end_lineno=13, + end_col_offset=10), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '', + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=17), + 'join', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=22), + [ + ListComp( + Call( + Name( + 'str', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=15), + [ + Call( + Attribute( + Name( + 'random', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=22), + 'choice', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=29), + [ + Call( + Name( + 'range', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=35), + [ + Constant( + 0, + lineno=17, + col_offset=36, + end_lineno=17, + end_col_offset=37), + Constant( + 10, + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=41)], + [], + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=42)], + [], + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=43)], + [], + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=44), + [ + comprehension( + Name( + 'placeholder_6', + Store(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=17), + Call( + Name( + 'range', + Load(), + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=26), + [ + Constant( + 0, + lineno=18, + col_offset=27, + end_lineno=18, + end_col_offset=28), + Constant( + 3, + lineno=18, + col_offset=30, + end_lineno=18, + end_col_offset=31)], + [], + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=32), + [], + 0)], + lineno=16, + col_offset=23, + end_lineno=19, + end_col_offset=9)], + [], + lineno=16, + col_offset=15, + end_lineno=19, + end_col_offset=10), + lineno=16, + col_offset=8, + end_lineno=19, + end_col_offset=10)], + [], + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=10), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=19), + 'placeholder_3', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=25), + lineno=22, + col_offset=11, + end_lineno=22, + end_col_offset=25), + [ + While( + Constant( + True, + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=22), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=20), + 'placeholder_3', + Store(), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=26)], + BinOp( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=33), + 'placeholder_5', + Load(), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=40), + [], + [], + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=42), + Add(), + Call( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=45, + end_lineno=26, + end_col_offset=49), + 'placeholder_7', + Load(), + lineno=26, + col_offset=45, + end_lineno=26, + end_col_offset=56), + [], + [], + lineno=26, + col_offset=45, + end_lineno=26, + end_col_offset=58), + lineno=26, + col_offset=29, + end_lineno=26, + end_col_offset=58), + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=58), + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=23), + 'placeholder_3', + Load(), + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=29), + [ + NotIn()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=37, + end_lineno=27, + end_col_offset=41), + 'placeholder_4', + Load(), + lineno=27, + col_offset=37, + end_lineno=27, + end_col_offset=53)], + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=53), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=24), + 'placeholder_4', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=36), + 'add', + Load(), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=40), + [ + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=41, + end_lineno=28, + end_col_offset=45), + 'placeholder_3', + Load(), + lineno=28, + col_offset=41, + end_lineno=28, + end_col_offset=51)], + [], + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=52), + lineno=28, + col_offset=20, + end_lineno=28, + end_col_offset=52), + Break( + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=25)], + [], + lineno=27, + col_offset=16, + end_lineno=29, + end_col_offset=25)], + [], + lineno=25, + col_offset=12, + end_lineno=29, + end_col_offset=25)], + [], + lineno=22, + col_offset=8, + end_lineno=29, + end_col_offset=25), + Return( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=19), + 'placeholder_3', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=25), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=25)], + [], + lineno=21, + col_offset=4, + end_lineno=31, + end_col_offset=25), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=18)], + Constant( + None, + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=25), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=25)], + [], + lineno=33, + col_offset=4, + end_lineno=34, + end_col_offset=25), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=8)], + Call( + Name( + 'property', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=19), + [ + Name( + 'placeholder_8', + Load(), + lineno=36, + col_offset=20, + end_lineno=36, + end_col_offset=28), + Constant( + None, + lineno=36, + col_offset=30, + end_lineno=36, + end_col_offset=34), + Name( + 'placeholder_9', + Load(), + lineno=36, + col_offset=36, + end_lineno=36, + end_col_offset=44)], + [], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=45), + lineno=36, + col_offset=4, + end_lineno=36, + end_col_offset=45), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=38, + col_offset=14, + end_lineno=38, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Delete( + [ + Attribute( + Name( + 'self', + Load(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=16), + 'name', + Del(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=21)], + lineno=39, + col_offset=8, + end_lineno=39, + end_col_offset=21)], + [], + lineno=38, + col_offset=4, + end_lineno=39, + end_col_offset=21)], + [], + lineno=4, + col_offset=0, + end_lineno=39, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-robot-name/representation.txt b/test/practice-robot-name/representation.txt new file mode 100644 index 0000000..3e00a4c --- /dev/null +++ b/test/practice-robot-name/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('random', lineno=1, col_offset=7, end_lineno=1, end_col_offset=13)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=13), Assign([Name('placeholder_0', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=8)], Constant('ABCDEFGHIJKLMNOPQRSTUVWXYZ', lineno=3, col_offset=11, end_lineno=3, end_col_offset=39), lineno=3, col_offset=0, end_lineno=3, end_col_offset=39), ClassDef('placeholder_1', [], [], [FunctionDef('placeholder_2', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_3', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=18)], Constant(None, lineno=6, col_offset=21, end_lineno=6, end_col_offset=25), lineno=6, col_offset=8, end_lineno=6, end_col_offset=25), Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_4', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=24)], Call(Name('set', Load(), lineno=7, col_offset=27, end_lineno=7, end_col_offset=30), [], [], lineno=7, col_offset=27, end_lineno=7, end_col_offset=32), lineno=7, col_offset=8, end_lineno=7, end_col_offset=32)], [], lineno=5, col_offset=4, end_lineno=7, end_col_offset=32), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=9, col_offset=15, end_lineno=9, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Constant('', lineno=10, col_offset=15, end_lineno=10, end_col_offset=17), 'join', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=22), [ListComp(Call(Attribute(Name('random', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=18), 'choice', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=25), [Name('placeholder_0', Load(), lineno=11, col_offset=26, end_lineno=11, end_col_offset=34)], [], lineno=11, col_offset=12, end_lineno=11, end_col_offset=35), [comprehension(Name('placeholder_6', Store(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=17), Call(Name('range', Load(), lineno=12, col_offset=21, end_lineno=12, end_col_offset=26), [Constant(0, lineno=12, col_offset=27, end_lineno=12, end_col_offset=28), Constant(2, lineno=12, col_offset=30, end_lineno=12, end_col_offset=31)], [], lineno=12, col_offset=21, end_lineno=12, end_col_offset=32), [], 0)], lineno=10, col_offset=23, end_lineno=13, end_col_offset=9)], [], lineno=10, col_offset=15, end_lineno=13, end_col_offset=10), lineno=10, col_offset=8, end_lineno=13, end_col_offset=10)], [], lineno=9, col_offset=4, end_lineno=13, end_col_offset=10), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=15, col_offset=15, end_lineno=15, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Constant('', lineno=16, col_offset=15, end_lineno=16, end_col_offset=17), 'join', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=22), [ListComp(Call(Name('str', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=15), [Call(Attribute(Name('random', Load(), lineno=17, col_offset=16, end_lineno=17, end_col_offset=22), 'choice', Load(), lineno=17, col_offset=16, end_lineno=17, end_col_offset=29), [Call(Name('range', Load(), lineno=17, col_offset=30, end_lineno=17, end_col_offset=35), [Constant(0, lineno=17, col_offset=36, end_lineno=17, end_col_offset=37), Constant(10, lineno=17, col_offset=39, end_lineno=17, end_col_offset=41)], [], lineno=17, col_offset=30, end_lineno=17, end_col_offset=42)], [], lineno=17, col_offset=16, end_lineno=17, end_col_offset=43)], [], lineno=17, col_offset=12, end_lineno=17, end_col_offset=44), [comprehension(Name('placeholder_6', Store(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=17), Call(Name('range', Load(), lineno=18, col_offset=21, end_lineno=18, end_col_offset=26), [Constant(0, lineno=18, col_offset=27, end_lineno=18, end_col_offset=28), Constant(3, lineno=18, col_offset=30, end_lineno=18, end_col_offset=31)], [], lineno=18, col_offset=21, end_lineno=18, end_col_offset=32), [], 0)], lineno=16, col_offset=23, end_lineno=19, end_col_offset=9)], [], lineno=16, col_offset=15, end_lineno=19, end_col_offset=10), lineno=16, col_offset=8, end_lineno=19, end_col_offset=10)], [], lineno=15, col_offset=4, end_lineno=19, end_col_offset=10), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=21, col_offset=17, end_lineno=21, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=22, col_offset=15, end_lineno=22, end_col_offset=19), 'placeholder_3', Load(), lineno=22, col_offset=15, end_lineno=22, end_col_offset=25), lineno=22, col_offset=11, end_lineno=22, end_col_offset=25), [While(Constant(True, lineno=25, col_offset=18, end_lineno=25, end_col_offset=22), [Assign([Attribute(Name('self', Load(), lineno=26, col_offset=16, end_lineno=26, end_col_offset=20), 'placeholder_3', Store(), lineno=26, col_offset=16, end_lineno=26, end_col_offset=26)], BinOp(Call(Attribute(Name('self', Load(), lineno=26, col_offset=29, end_lineno=26, end_col_offset=33), 'placeholder_5', Load(), lineno=26, col_offset=29, end_lineno=26, end_col_offset=40), [], [], lineno=26, col_offset=29, end_lineno=26, end_col_offset=42), Add(), Call(Attribute(Name('self', Load(), lineno=26, col_offset=45, end_lineno=26, end_col_offset=49), 'placeholder_7', Load(), lineno=26, col_offset=45, end_lineno=26, end_col_offset=56), [], [], lineno=26, col_offset=45, end_lineno=26, end_col_offset=58), lineno=26, col_offset=29, end_lineno=26, end_col_offset=58), lineno=26, col_offset=16, end_lineno=26, end_col_offset=58), If(Compare(Attribute(Name('self', Load(), lineno=27, col_offset=19, end_lineno=27, end_col_offset=23), 'placeholder_3', Load(), lineno=27, col_offset=19, end_lineno=27, end_col_offset=29), [NotIn()], [Attribute(Name('self', Load(), lineno=27, col_offset=37, end_lineno=27, end_col_offset=41), 'placeholder_4', Load(), lineno=27, col_offset=37, end_lineno=27, end_col_offset=53)], lineno=27, col_offset=19, end_lineno=27, end_col_offset=53), [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=28, col_offset=20, end_lineno=28, end_col_offset=24), 'placeholder_4', Load(), lineno=28, col_offset=20, end_lineno=28, end_col_offset=36), 'add', Load(), lineno=28, col_offset=20, end_lineno=28, end_col_offset=40), [Attribute(Name('self', Load(), lineno=28, col_offset=41, end_lineno=28, end_col_offset=45), 'placeholder_3', Load(), lineno=28, col_offset=41, end_lineno=28, end_col_offset=51)], [], lineno=28, col_offset=20, end_lineno=28, end_col_offset=52), lineno=28, col_offset=20, end_lineno=28, end_col_offset=52), Break(lineno=29, col_offset=20, end_lineno=29, end_col_offset=25)], [], lineno=27, col_offset=16, end_lineno=29, end_col_offset=25)], [], lineno=25, col_offset=12, end_lineno=29, end_col_offset=25)], [], lineno=22, col_offset=8, end_lineno=29, end_col_offset=25), Return(Attribute(Name('self', Load(), lineno=31, col_offset=15, end_lineno=31, end_col_offset=19), 'placeholder_3', Load(), lineno=31, col_offset=15, end_lineno=31, end_col_offset=25), lineno=31, col_offset=8, end_lineno=31, end_col_offset=25)], [], lineno=21, col_offset=4, end_lineno=31, end_col_offset=25), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=33, col_offset=17, end_lineno=33, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=12), 'placeholder_3', Store(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=18)], Constant(None, lineno=34, col_offset=21, end_lineno=34, end_col_offset=25), lineno=34, col_offset=8, end_lineno=34, end_col_offset=25)], [], lineno=33, col_offset=4, end_lineno=34, end_col_offset=25), Assign([Name('placeholder_10', Store(), lineno=36, col_offset=4, end_lineno=36, end_col_offset=8)], Call(Name('property', Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=19), [Name('placeholder_8', Load(), lineno=36, col_offset=20, end_lineno=36, end_col_offset=28), Constant(None, lineno=36, col_offset=30, end_lineno=36, end_col_offset=34), Name('placeholder_9', Load(), lineno=36, col_offset=36, end_lineno=36, end_col_offset=44)], [], lineno=36, col_offset=11, end_lineno=36, end_col_offset=45), lineno=36, col_offset=4, end_lineno=36, end_col_offset=45), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=38, col_offset=14, end_lineno=38, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Delete([Attribute(Name('self', Load(), lineno=39, col_offset=12, end_lineno=39, end_col_offset=16), 'name', Del(), lineno=39, col_offset=12, end_lineno=39, end_col_offset=21)], lineno=39, col_offset=8, end_lineno=39, end_col_offset=21)], [], lineno=38, col_offset=4, end_lineno=39, end_col_offset=21)], [], lineno=4, col_offset=0, end_lineno=39, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-robot-name/robot_name.py b/test/practice-robot-name/robot_name.py new file mode 100644 index 0000000..4051427 --- /dev/null +++ b/test/practice-robot-name/robot_name.py @@ -0,0 +1,39 @@ +import random + +ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +class Robot: + def __init__(self): + self._name = None + self._past_names = set() + + def prefix(self): + return ''.join([ + random.choice(ALPHABET) + for _ in range(0, 2) + ]) + + def suffix(self): + return ''.join([ + str(random.choice(range(0, 10))) + for _ in range(0, 3) + ]) + + def get_name(self): + if not self._name: + + # Collision detection + while True: + self._name = self.prefix() + self.suffix() + if self._name not in self._past_names: + self._past_names.add(self._name) + break + + return self._name + + def del_name(self): + self._name = None + + name = property(get_name, None, del_name) + + def reset(self): + del self.name diff --git a/test/practice-robot-simulator/.DS_Store b/test/practice-robot-simulator/.DS_Store new file mode 100644 index 0000000..c54942d Binary files /dev/null and b/test/practice-robot-simulator/.DS_Store differ diff --git a/test/practice-robot-simulator/.meta/config.json b/test/practice-robot-simulator/.meta/config.json new file mode 100644 index 0000000..aa08e31 --- /dev/null +++ b/test/practice-robot-simulator/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "cmccandless", + "denislooby", + "Dog", + "Galixxon", + "GKotfis", + "Grociu", + "JuliaKBremer", + "N-Parsons", + "parinporecha", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "robot_simulator.py" + ], + "test": [ + "robot_simulator_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Write a robot simulator.", + "source": "Inspired by an interview question at a famous company." +} diff --git a/test/practice-robot-simulator/mapping.json b/test/practice-robot-simulator/mapping.json new file mode 100644 index 0000000..78d60e6 --- /dev/null +++ b/test/practice-robot-simulator/mapping.json @@ -0,0 +1,23 @@ +{ + "placeholder_0": "NORTH", + "placeholder_1": "EAST", + "placeholder_2": "SOUTH", + "placeholder_3": "WEST", + "placeholder_4": "Compass", + "placeholder_5": "compass", + "placeholder_6": "__init__", + "placeholder_7": "direction", + "placeholder_8": "left", + "placeholder_9": "right", + "placeholder_10": "Robot", + "placeholder_11": "x_pos", + "placeholder_12": "y_pos", + "placeholder_13": "advance", + "placeholder_14": "turn_left", + "placeholder_15": "turn_right", + "placeholder_16": "move", + "placeholder_17": "commands", + "placeholder_18": "instructions", + "placeholder_19": "cmd", + "placeholder_20": "coordinates" +} \ No newline at end of file diff --git a/test/practice-robot-simulator/representation.json b/test/practice-robot-simulator/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-robot-simulator/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-robot-simulator/representation.out b/test/practice-robot-simulator/representation.out new file mode 100644 index 0000000..966541a --- /dev/null +++ b/test/practice-robot-simulator/representation.out @@ -0,0 +1,2486 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0, placeholder_1, placeholder_2, placeholder_3 = range(4) + + +class placeholder_4: + placeholder_5 = [placeholder_0, placeholder_1, placeholder_2, placeholder_3] + + def placeholder_6(self, placeholder_7=placeholder_0): + self.placeholder_7 = placeholder_7 + + def placeholder_8(self): + self.placeholder_7 = self.placeholder_5[self.placeholder_7 - 1] + + def placeholder_9(self): + self.placeholder_7 = self.placeholder_5[(self.placeholder_7 + 1) % 4] + + +class placeholder_10: + def placeholder_6( + self, placeholder_7=placeholder_0, placeholder_11=0, placeholder_12=0 + ): + self.placeholder_5 = placeholder_4(placeholder_7) + self.placeholder_11 = placeholder_11 + self.placeholder_12 = placeholder_12 + + def placeholder_13(self): + if self.placeholder_7 == placeholder_0: + self.placeholder_12 += 1 + elif self.placeholder_7 == placeholder_2: + self.placeholder_12 -= 1 + elif self.placeholder_7 == placeholder_1: + self.placeholder_11 += 1 + elif self.placeholder_7 == placeholder_3: + self.placeholder_11 -= 1 + + def placeholder_14(self): + self.placeholder_5.placeholder_8() + + def placeholder_15(self): + self.placeholder_5.placeholder_9() + + def placeholder_16(self, placeholder_17): + placeholder_18 = { + "A": self.placeholder_13, + "R": self.placeholder_15, + "L": self.placeholder_14, + } + for placeholder_19 in placeholder_17: + if placeholder_19 in placeholder_18: + placeholder_18[placeholder_19]() + + @property + def placeholder_7(self): + return self.placeholder_5.placeholder_7 + + @property + def placeholder_20(self): + return (self.placeholder_11, self.placeholder_12) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Tuple( + [ + Name( + 'NORTH', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=5), + Name( + 'EAST', + Store(), + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11), + Name( + 'SOUTH', + Store(), + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=18), + Name( + 'WEST', + Store(), + lineno=1, + col_offset=20, + end_lineno=1, + end_col_offset=24)], + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=24)], + Call( + Name( + 'range', + Load(), + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=32), + [ + Constant( + 4, + lineno=1, + col_offset=33, + end_lineno=1, + end_col_offset=34)], + [], + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=35), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=35), + ClassDef( + 'Compass', + [], + [], + [ + Assign( + [ + Name( + 'compass', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + List( + [ + Name( + 'NORTH', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=20), + Name( + 'EAST', + Load(), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=26), + Name( + 'SOUTH', + Load(), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=33), + Name( + 'WEST', + Load(), + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=39)], + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=40), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=40), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21), + arg( + 'direction', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Name( + 'NORTH', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=38)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'direction', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + Name( + 'direction', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=34), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=34)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=34), + FunctionDef( + 'left', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=13, + end_lineno=10, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'direction', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=22)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=29), + 'compass', + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=37), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=42), + 'direction', + Load(), + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=52), + Sub(), + Constant( + 1, + lineno=11, + col_offset=55, + end_lineno=11, + end_col_offset=56), + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=56), + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=57), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=57)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=57), + FunctionDef( + 'right', + arguments( + [], + [ + arg( + 'self', + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=12), + 'direction', + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=22)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=29), + 'compass', + Load(), + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=37), + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=43), + 'direction', + Load(), + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=53), + Add(), + Constant( + 1, + lineno=14, + col_offset=56, + end_lineno=14, + end_col_offset=57), + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=57), + Mod(), + Constant( + 4, + lineno=14, + col_offset=61, + end_lineno=14, + end_col_offset=62), + lineno=14, + col_offset=38, + end_lineno=14, + end_col_offset=62), + Load(), + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=63), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=63)], + [], + lineno=13, + col_offset=4, + end_lineno=14, + end_col_offset=63)], + [], + lineno=4, + col_offset=0, + end_lineno=14, + end_col_offset=63), + ClassDef( + 'Robot', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=17, + end_lineno=18, + end_col_offset=21), + arg( + 'direction', + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=32), + arg( + 'x_pos', + lineno=18, + col_offset=40, + end_lineno=18, + end_col_offset=45), + arg( + 'y_pos', + lineno=18, + col_offset=49, + end_lineno=18, + end_col_offset=54)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Name( + 'NORTH', + Load(), + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=38), + Constant( + 0, + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=47), + Constant( + 0, + lineno=18, + col_offset=55, + end_lineno=18, + end_col_offset=56)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=12), + 'compass', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=20)], + Call( + Name( + 'Compass', + Load(), + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=30), + [ + Name( + 'direction', + Load(), + lineno=19, + col_offset=31, + end_lineno=19, + end_col_offset=40)], + [], + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=41), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=41), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=12), + 'x_pos', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=18)], + Name( + 'x_pos', + Load(), + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=26), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12), + 'y_pos', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=18)], + Name( + 'y_pos', + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=26), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=26)], + [], + lineno=18, + col_offset=4, + end_lineno=21, + end_col_offset=26), + FunctionDef( + 'advance', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=15), + 'direction', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=25), + [ + Eq()], + [ + Name( + 'NORTH', + Load(), + lineno=24, + col_offset=29, + end_lineno=24, + end_col_offset=34)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=34), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=16), + 'y_pos', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=27), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=27)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=13, + end_lineno=26, + end_col_offset=17), + 'direction', + Load(), + lineno=26, + col_offset=13, + end_lineno=26, + end_col_offset=27), + [ + Eq()], + [ + Name( + 'SOUTH', + Load(), + lineno=26, + col_offset=31, + end_lineno=26, + end_col_offset=36)], + lineno=26, + col_offset=13, + end_lineno=26, + end_col_offset=36), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16), + 'y_pos', + Store(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=22), + Sub(), + Constant( + 1, + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=27), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=27)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=17), + 'direction', + Load(), + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=27), + [ + Eq()], + [ + Name( + 'EAST', + Load(), + lineno=28, + col_offset=31, + end_lineno=28, + end_col_offset=35)], + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=35), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=16), + 'x_pos', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=29, + col_offset=26, + end_lineno=29, + end_col_offset=27), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=27)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=17), + 'direction', + Load(), + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=27), + [ + Eq()], + [ + Name( + 'WEST', + Load(), + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=35)], + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=35), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=16), + 'x_pos', + Store(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=22), + Sub(), + Constant( + 1, + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=27), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=27)], + [], + lineno=30, + col_offset=8, + end_lineno=31, + end_col_offset=27)], + lineno=28, + col_offset=8, + end_lineno=31, + end_col_offset=27)], + lineno=26, + col_offset=8, + end_lineno=31, + end_col_offset=27)], + lineno=24, + col_offset=8, + end_lineno=31, + end_col_offset=27)], + [], + lineno=23, + col_offset=4, + end_lineno=31, + end_col_offset=27), + FunctionDef( + 'turn_left', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=18, + end_lineno=33, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'compass', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=20), + 'left', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=25), + [], + [], + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=27), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=27)], + [], + lineno=33, + col_offset=4, + end_lineno=34, + end_col_offset=27), + FunctionDef( + 'turn_right', + arguments( + [], + [ + arg( + 'self', + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=12), + 'compass', + Load(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=20), + 'right', + Load(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=26), + [], + [], + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=28), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=28)], + [], + lineno=36, + col_offset=4, + end_lineno=37, + end_col_offset=28), + FunctionDef( + 'move', + arguments( + [], + [ + arg( + 'self', + lineno=39, + col_offset=13, + end_lineno=39, + end_col_offset=17), + arg( + 'commands', + lineno=39, + col_offset=19, + end_lineno=39, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'instructions', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=20)], + Dict( + [ + Constant( + 'A', + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=27), + Constant( + 'R', + lineno=41, + col_offset=24, + end_lineno=41, + end_col_offset=27), + Constant( + 'L', + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=27)], + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=29, + end_lineno=40, + end_col_offset=33), + 'advance', + Load(), + lineno=40, + col_offset=29, + end_lineno=40, + end_col_offset=41), + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=33), + 'turn_right', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=44), + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=33), + 'turn_left', + Load(), + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=43)], + lineno=40, + col_offset=23, + end_lineno=42, + end_col_offset=44), + lineno=40, + col_offset=8, + end_lineno=42, + end_col_offset=44), + For( + Name( + 'cmd', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=15), + Name( + 'commands', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=27), + [ + If( + Compare( + Name( + 'cmd', + Load(), + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=18), + [ + In()], + [ + Name( + 'instructions', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=34)], + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=34), + [ + Expr( + Call( + Subscript( + Name( + 'instructions', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=28), + Name( + 'cmd', + Load(), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=32), + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=33), + [], + [], + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=35), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=35)], + [], + lineno=44, + col_offset=12, + end_lineno=45, + end_col_offset=35)], + [], + lineno=43, + col_offset=8, + end_lineno=45, + end_col_offset=35)], + [], + lineno=39, + col_offset=4, + end_lineno=45, + end_col_offset=35), + FunctionDef( + 'direction', + arguments( + [], + [ + arg( + 'self', + lineno=48, + col_offset=18, + end_lineno=48, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=19), + 'compass', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=27), + 'direction', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=37), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=37)], + [ + Name( + 'property', + Load(), + lineno=47, + col_offset=5, + end_lineno=47, + end_col_offset=13)], + lineno=48, + col_offset=4, + end_lineno=49, + end_col_offset=37), + FunctionDef( + 'coordinates', + arguments( + [], + [ + arg( + 'self', + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Tuple( + [ + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=20), + 'x_pos', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=26), + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=28, + end_lineno=53, + end_col_offset=32), + 'y_pos', + Load(), + lineno=53, + col_offset=28, + end_lineno=53, + end_col_offset=38)], + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=39), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=39)], + [ + Name( + 'property', + Load(), + lineno=51, + col_offset=5, + end_lineno=51, + end_col_offset=13)], + lineno=52, + col_offset=4, + end_lineno=53, + end_col_offset=39)], + [], + lineno=17, + col_offset=0, + end_lineno=53, + end_col_offset=39)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=5), + Name( + 'placeholder_1', + Store(), + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11), + Name( + 'placeholder_2', + Store(), + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=18), + Name( + 'placeholder_3', + Store(), + lineno=1, + col_offset=20, + end_lineno=1, + end_col_offset=24)], + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=24)], + Call( + Name( + 'range', + Load(), + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=32), + [ + Constant( + 4, + lineno=1, + col_offset=33, + end_lineno=1, + end_col_offset=34)], + [], + lineno=1, + col_offset=27, + end_lineno=1, + end_col_offset=35), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=35), + ClassDef( + 'placeholder_4', + [], + [], + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + List( + [ + Name( + 'placeholder_0', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=20), + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=26), + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=33), + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=39)], + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=40), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=40), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21), + arg( + 'placeholder_7', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Name( + 'placeholder_0', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=38)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + Name( + 'placeholder_7', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=34), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=34)], + [], + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=34), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=13, + end_lineno=10, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=22)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=29), + 'placeholder_5', + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=37), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=42), + 'placeholder_7', + Load(), + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=52), + Sub(), + Constant( + 1, + lineno=11, + col_offset=55, + end_lineno=11, + end_col_offset=56), + lineno=11, + col_offset=38, + end_lineno=11, + end_col_offset=56), + Load(), + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=57), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=57)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=57), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=22)], + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=29), + 'placeholder_5', + Load(), + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=37), + BinOp( + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=43), + 'placeholder_7', + Load(), + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=53), + Add(), + Constant( + 1, + lineno=14, + col_offset=56, + end_lineno=14, + end_col_offset=57), + lineno=14, + col_offset=39, + end_lineno=14, + end_col_offset=57), + Mod(), + Constant( + 4, + lineno=14, + col_offset=61, + end_lineno=14, + end_col_offset=62), + lineno=14, + col_offset=38, + end_lineno=14, + end_col_offset=62), + Load(), + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=63), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=63)], + [], + lineno=13, + col_offset=4, + end_lineno=14, + end_col_offset=63)], + [], + lineno=4, + col_offset=0, + end_lineno=14, + end_col_offset=63), + ClassDef( + 'placeholder_10', + [], + [], + [ + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=17, + end_lineno=18, + end_col_offset=21), + arg( + 'placeholder_7', + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=32), + arg( + 'placeholder_11', + lineno=18, + col_offset=40, + end_lineno=18, + end_col_offset=45), + arg( + 'placeholder_12', + lineno=18, + col_offset=49, + end_lineno=18, + end_col_offset=54)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Name( + 'placeholder_0', + Load(), + lineno=18, + col_offset=33, + end_lineno=18, + end_col_offset=38), + Constant( + 0, + lineno=18, + col_offset=46, + end_lineno=18, + end_col_offset=47), + Constant( + 0, + lineno=18, + col_offset=55, + end_lineno=18, + end_col_offset=56)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=12), + 'placeholder_5', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=20)], + Call( + Name( + 'placeholder_4', + Load(), + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=30), + [ + Name( + 'placeholder_7', + Load(), + lineno=19, + col_offset=31, + end_lineno=19, + end_col_offset=40)], + [], + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=41), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=41), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=12), + 'placeholder_11', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=18)], + Name( + 'placeholder_11', + Load(), + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=26), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=12), + 'placeholder_12', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=18)], + Name( + 'placeholder_12', + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=26), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=26)], + [], + lineno=18, + col_offset=4, + end_lineno=21, + end_col_offset=26), + FunctionDef( + 'placeholder_13', + arguments( + [], + [ + arg( + 'self', + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=15), + 'placeholder_7', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=25), + [ + Eq()], + [ + Name( + 'placeholder_0', + Load(), + lineno=24, + col_offset=29, + end_lineno=24, + end_col_offset=34)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=34), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=16), + 'placeholder_12', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=27), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=27)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=26, + col_offset=13, + end_lineno=26, + end_col_offset=17), + 'placeholder_7', + Load(), + lineno=26, + col_offset=13, + end_lineno=26, + end_col_offset=27), + [ + Eq()], + [ + Name( + 'placeholder_2', + Load(), + lineno=26, + col_offset=31, + end_lineno=26, + end_col_offset=36)], + lineno=26, + col_offset=13, + end_lineno=26, + end_col_offset=36), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=16), + 'placeholder_12', + Store(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=22), + Sub(), + Constant( + 1, + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=27), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=27)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=17), + 'placeholder_7', + Load(), + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=27), + [ + Eq()], + [ + Name( + 'placeholder_1', + Load(), + lineno=28, + col_offset=31, + end_lineno=28, + end_col_offset=35)], + lineno=28, + col_offset=13, + end_lineno=28, + end_col_offset=35), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=16), + 'placeholder_11', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=22), + Add(), + Constant( + 1, + lineno=29, + col_offset=26, + end_lineno=29, + end_col_offset=27), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=27)], + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=17), + 'placeholder_7', + Load(), + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=27), + [ + Eq()], + [ + Name( + 'placeholder_3', + Load(), + lineno=30, + col_offset=31, + end_lineno=30, + end_col_offset=35)], + lineno=30, + col_offset=13, + end_lineno=30, + end_col_offset=35), + [ + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=16), + 'placeholder_11', + Store(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=22), + Sub(), + Constant( + 1, + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=27), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=27)], + [], + lineno=30, + col_offset=8, + end_lineno=31, + end_col_offset=27)], + lineno=28, + col_offset=8, + end_lineno=31, + end_col_offset=27)], + lineno=26, + col_offset=8, + end_lineno=31, + end_col_offset=27)], + lineno=24, + col_offset=8, + end_lineno=31, + end_col_offset=27)], + [], + lineno=23, + col_offset=4, + end_lineno=31, + end_col_offset=27), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'self', + lineno=33, + col_offset=18, + end_lineno=33, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'placeholder_5', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=20), + 'placeholder_8', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=25), + [], + [], + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=27), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=27)], + [], + lineno=33, + col_offset=4, + end_lineno=34, + end_col_offset=27), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=12), + 'placeholder_5', + Load(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=20), + 'placeholder_9', + Load(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=26), + [], + [], + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=28), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=28)], + [], + lineno=36, + col_offset=4, + end_lineno=37, + end_col_offset=28), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'self', + lineno=39, + col_offset=13, + end_lineno=39, + end_col_offset=17), + arg( + 'placeholder_17', + lineno=39, + col_offset=19, + end_lineno=39, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=20)], + Dict( + [ + Constant( + 'A', + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=27), + Constant( + 'R', + lineno=41, + col_offset=24, + end_lineno=41, + end_col_offset=27), + Constant( + 'L', + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=27)], + [ + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=29, + end_lineno=40, + end_col_offset=33), + 'placeholder_13', + Load(), + lineno=40, + col_offset=29, + end_lineno=40, + end_col_offset=41), + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=33), + 'placeholder_15', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=44), + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=33), + 'placeholder_14', + Load(), + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=43)], + lineno=40, + col_offset=23, + end_lineno=42, + end_col_offset=44), + lineno=40, + col_offset=8, + end_lineno=42, + end_col_offset=44), + For( + Name( + 'placeholder_19', + Store(), + lineno=43, + col_offset=12, + end_lineno=43, + end_col_offset=15), + Name( + 'placeholder_17', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=27), + [ + If( + Compare( + Name( + 'placeholder_19', + Load(), + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=18), + [ + In()], + [ + Name( + 'placeholder_18', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=34)], + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=34), + [ + Expr( + Call( + Subscript( + Name( + 'placeholder_18', + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=28), + Name( + 'placeholder_19', + Load(), + lineno=45, + col_offset=29, + end_lineno=45, + end_col_offset=32), + Load(), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=33), + [], + [], + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=35), + lineno=45, + col_offset=16, + end_lineno=45, + end_col_offset=35)], + [], + lineno=44, + col_offset=12, + end_lineno=45, + end_col_offset=35)], + [], + lineno=43, + col_offset=8, + end_lineno=45, + end_col_offset=35)], + [], + lineno=39, + col_offset=4, + end_lineno=45, + end_col_offset=35), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=48, + col_offset=18, + end_lineno=48, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=19), + 'placeholder_5', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=27), + 'placeholder_7', + Load(), + lineno=49, + col_offset=15, + end_lineno=49, + end_col_offset=37), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=37)], + [ + Name( + 'property', + Load(), + lineno=47, + col_offset=5, + end_lineno=47, + end_col_offset=13)], + lineno=48, + col_offset=4, + end_lineno=49, + end_col_offset=37), + FunctionDef( + 'placeholder_20', + arguments( + [], + [ + arg( + 'self', + lineno=52, + col_offset=20, + end_lineno=52, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Tuple( + [ + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=20), + 'placeholder_11', + Load(), + lineno=53, + col_offset=16, + end_lineno=53, + end_col_offset=26), + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=28, + end_lineno=53, + end_col_offset=32), + 'placeholder_12', + Load(), + lineno=53, + col_offset=28, + end_lineno=53, + end_col_offset=38)], + Load(), + lineno=53, + col_offset=15, + end_lineno=53, + end_col_offset=39), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=39)], + [ + Name( + 'property', + Load(), + lineno=51, + col_offset=5, + end_lineno=51, + end_col_offset=13)], + lineno=52, + col_offset=4, + end_lineno=53, + end_col_offset=39)], + [], + lineno=17, + col_offset=0, + end_lineno=53, + end_col_offset=39)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-robot-simulator/representation.txt b/test/practice-robot-simulator/representation.txt new file mode 100644 index 0000000..f954a0b --- /dev/null +++ b/test/practice-robot-simulator/representation.txt @@ -0,0 +1 @@ +Module([Assign([Tuple([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=5), Name('placeholder_1', Store(), lineno=1, col_offset=7, end_lineno=1, end_col_offset=11), Name('placeholder_2', Store(), lineno=1, col_offset=13, end_lineno=1, end_col_offset=18), Name('placeholder_3', Store(), lineno=1, col_offset=20, end_lineno=1, end_col_offset=24)], Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=24)], Call(Name('range', Load(), lineno=1, col_offset=27, end_lineno=1, end_col_offset=32), [Constant(4, lineno=1, col_offset=33, end_lineno=1, end_col_offset=34)], [], lineno=1, col_offset=27, end_lineno=1, end_col_offset=35), lineno=1, col_offset=0, end_lineno=1, end_col_offset=35), ClassDef('placeholder_4', [], [], [Assign([Name('placeholder_5', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=11)], List([Name('placeholder_0', Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=20), Name('placeholder_1', Load(), lineno=5, col_offset=22, end_lineno=5, end_col_offset=26), Name('placeholder_2', Load(), lineno=5, col_offset=28, end_lineno=5, end_col_offset=33), Name('placeholder_3', Load(), lineno=5, col_offset=35, end_lineno=5, end_col_offset=39)], Load(), lineno=5, col_offset=14, end_lineno=5, end_col_offset=40), lineno=5, col_offset=4, end_lineno=5, end_col_offset=40), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=7, col_offset=17, end_lineno=7, end_col_offset=21), arg('placeholder_7', lineno=7, col_offset=23, end_lineno=7, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[Name('placeholder_0', Load(), lineno=7, col_offset=33, end_lineno=7, end_col_offset=38)]), [Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_7', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=22)], Name('placeholder_7', Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=34), lineno=8, col_offset=8, end_lineno=8, end_col_offset=34)], [], lineno=7, col_offset=4, end_lineno=8, end_col_offset=34), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=10, col_offset=13, end_lineno=10, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12), 'placeholder_7', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=22)], Subscript(Attribute(Name('self', Load(), lineno=11, col_offset=25, end_lineno=11, end_col_offset=29), 'placeholder_5', Load(), lineno=11, col_offset=25, end_lineno=11, end_col_offset=37), BinOp(Attribute(Name('self', Load(), lineno=11, col_offset=38, end_lineno=11, end_col_offset=42), 'placeholder_7', Load(), lineno=11, col_offset=38, end_lineno=11, end_col_offset=52), Sub(), Constant(1, lineno=11, col_offset=55, end_lineno=11, end_col_offset=56), lineno=11, col_offset=38, end_lineno=11, end_col_offset=56), Load(), lineno=11, col_offset=25, end_lineno=11, end_col_offset=57), lineno=11, col_offset=8, end_lineno=11, end_col_offset=57)], [], lineno=10, col_offset=4, end_lineno=11, end_col_offset=57), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=13, col_offset=14, end_lineno=13, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=12), 'placeholder_7', Store(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=22)], Subscript(Attribute(Name('self', Load(), lineno=14, col_offset=25, end_lineno=14, end_col_offset=29), 'placeholder_5', Load(), lineno=14, col_offset=25, end_lineno=14, end_col_offset=37), BinOp(BinOp(Attribute(Name('self', Load(), lineno=14, col_offset=39, end_lineno=14, end_col_offset=43), 'placeholder_7', Load(), lineno=14, col_offset=39, end_lineno=14, end_col_offset=53), Add(), Constant(1, lineno=14, col_offset=56, end_lineno=14, end_col_offset=57), lineno=14, col_offset=39, end_lineno=14, end_col_offset=57), Mod(), Constant(4, lineno=14, col_offset=61, end_lineno=14, end_col_offset=62), lineno=14, col_offset=38, end_lineno=14, end_col_offset=62), Load(), lineno=14, col_offset=25, end_lineno=14, end_col_offset=63), lineno=14, col_offset=8, end_lineno=14, end_col_offset=63)], [], lineno=13, col_offset=4, end_lineno=14, end_col_offset=63)], [], lineno=4, col_offset=0, end_lineno=14, end_col_offset=63), ClassDef('placeholder_10', [], [], [FunctionDef('placeholder_6', arguments([], [arg('self', lineno=18, col_offset=17, end_lineno=18, end_col_offset=21), arg('placeholder_7', lineno=18, col_offset=23, end_lineno=18, end_col_offset=32), arg('placeholder_11', lineno=18, col_offset=40, end_lineno=18, end_col_offset=45), arg('placeholder_12', lineno=18, col_offset=49, end_lineno=18, end_col_offset=54)], kwonlyargs=[], kw_defaults=[], defaults=[Name('placeholder_0', Load(), lineno=18, col_offset=33, end_lineno=18, end_col_offset=38), Constant(0, lineno=18, col_offset=46, end_lineno=18, end_col_offset=47), Constant(0, lineno=18, col_offset=55, end_lineno=18, end_col_offset=56)]), [Assign([Attribute(Name('self', Load(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=12), 'placeholder_5', Store(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=20)], Call(Name('placeholder_4', Load(), lineno=19, col_offset=23, end_lineno=19, end_col_offset=30), [Name('placeholder_7', Load(), lineno=19, col_offset=31, end_lineno=19, end_col_offset=40)], [], lineno=19, col_offset=23, end_lineno=19, end_col_offset=41), lineno=19, col_offset=8, end_lineno=19, end_col_offset=41), Assign([Attribute(Name('self', Load(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=12), 'placeholder_11', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=18)], Name('placeholder_11', Load(), lineno=20, col_offset=21, end_lineno=20, end_col_offset=26), lineno=20, col_offset=8, end_lineno=20, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=12), 'placeholder_12', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=18)], Name('placeholder_12', Load(), lineno=21, col_offset=21, end_lineno=21, end_col_offset=26), lineno=21, col_offset=8, end_lineno=21, end_col_offset=26)], [], lineno=18, col_offset=4, end_lineno=21, end_col_offset=26), FunctionDef('placeholder_13', arguments([], [arg('self', lineno=23, col_offset=16, end_lineno=23, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=15), 'placeholder_7', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=25), [Eq()], [Name('placeholder_0', Load(), lineno=24, col_offset=29, end_lineno=24, end_col_offset=34)], lineno=24, col_offset=11, end_lineno=24, end_col_offset=34), [AugAssign(Attribute(Name('self', Load(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=16), 'placeholder_12', Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=22), Add(), Constant(1, lineno=25, col_offset=26, end_lineno=25, end_col_offset=27), lineno=25, col_offset=12, end_lineno=25, end_col_offset=27)], [If(Compare(Attribute(Name('self', Load(), lineno=26, col_offset=13, end_lineno=26, end_col_offset=17), 'placeholder_7', Load(), lineno=26, col_offset=13, end_lineno=26, end_col_offset=27), [Eq()], [Name('placeholder_2', Load(), lineno=26, col_offset=31, end_lineno=26, end_col_offset=36)], lineno=26, col_offset=13, end_lineno=26, end_col_offset=36), [AugAssign(Attribute(Name('self', Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=16), 'placeholder_12', Store(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=22), Sub(), Constant(1, lineno=27, col_offset=26, end_lineno=27, end_col_offset=27), lineno=27, col_offset=12, end_lineno=27, end_col_offset=27)], [If(Compare(Attribute(Name('self', Load(), lineno=28, col_offset=13, end_lineno=28, end_col_offset=17), 'placeholder_7', Load(), lineno=28, col_offset=13, end_lineno=28, end_col_offset=27), [Eq()], [Name('placeholder_1', Load(), lineno=28, col_offset=31, end_lineno=28, end_col_offset=35)], lineno=28, col_offset=13, end_lineno=28, end_col_offset=35), [AugAssign(Attribute(Name('self', Load(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=16), 'placeholder_11', Store(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=22), Add(), Constant(1, lineno=29, col_offset=26, end_lineno=29, end_col_offset=27), lineno=29, col_offset=12, end_lineno=29, end_col_offset=27)], [If(Compare(Attribute(Name('self', Load(), lineno=30, col_offset=13, end_lineno=30, end_col_offset=17), 'placeholder_7', Load(), lineno=30, col_offset=13, end_lineno=30, end_col_offset=27), [Eq()], [Name('placeholder_3', Load(), lineno=30, col_offset=31, end_lineno=30, end_col_offset=35)], lineno=30, col_offset=13, end_lineno=30, end_col_offset=35), [AugAssign(Attribute(Name('self', Load(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=16), 'placeholder_11', Store(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=22), Sub(), Constant(1, lineno=31, col_offset=26, end_lineno=31, end_col_offset=27), lineno=31, col_offset=12, end_lineno=31, end_col_offset=27)], [], lineno=30, col_offset=8, end_lineno=31, end_col_offset=27)], lineno=28, col_offset=8, end_lineno=31, end_col_offset=27)], lineno=26, col_offset=8, end_lineno=31, end_col_offset=27)], lineno=24, col_offset=8, end_lineno=31, end_col_offset=27)], [], lineno=23, col_offset=4, end_lineno=31, end_col_offset=27), FunctionDef('placeholder_14', arguments([], [arg('self', lineno=33, col_offset=18, end_lineno=33, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=12), 'placeholder_5', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=20), 'placeholder_8', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=25), [], [], lineno=34, col_offset=8, end_lineno=34, end_col_offset=27), lineno=34, col_offset=8, end_lineno=34, end_col_offset=27)], [], lineno=33, col_offset=4, end_lineno=34, end_col_offset=27), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=36, col_offset=19, end_lineno=36, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Expr(Call(Attribute(Attribute(Name('self', Load(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=12), 'placeholder_5', Load(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=20), 'placeholder_9', Load(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=26), [], [], lineno=37, col_offset=8, end_lineno=37, end_col_offset=28), lineno=37, col_offset=8, end_lineno=37, end_col_offset=28)], [], lineno=36, col_offset=4, end_lineno=37, end_col_offset=28), FunctionDef('placeholder_16', arguments([], [arg('self', lineno=39, col_offset=13, end_lineno=39, end_col_offset=17), arg('placeholder_17', lineno=39, col_offset=19, end_lineno=39, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_18', Store(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=20)], Dict([Constant('A', lineno=40, col_offset=24, end_lineno=40, end_col_offset=27), Constant('R', lineno=41, col_offset=24, end_lineno=41, end_col_offset=27), Constant('L', lineno=42, col_offset=24, end_lineno=42, end_col_offset=27)], [Attribute(Name('self', Load(), lineno=40, col_offset=29, end_lineno=40, end_col_offset=33), 'placeholder_13', Load(), lineno=40, col_offset=29, end_lineno=40, end_col_offset=41), Attribute(Name('self', Load(), lineno=41, col_offset=29, end_lineno=41, end_col_offset=33), 'placeholder_15', Load(), lineno=41, col_offset=29, end_lineno=41, end_col_offset=44), Attribute(Name('self', Load(), lineno=42, col_offset=29, end_lineno=42, end_col_offset=33), 'placeholder_14', Load(), lineno=42, col_offset=29, end_lineno=42, end_col_offset=43)], lineno=40, col_offset=23, end_lineno=42, end_col_offset=44), lineno=40, col_offset=8, end_lineno=42, end_col_offset=44), For(Name('placeholder_19', Store(), lineno=43, col_offset=12, end_lineno=43, end_col_offset=15), Name('placeholder_17', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=27), [If(Compare(Name('placeholder_19', Load(), lineno=44, col_offset=15, end_lineno=44, end_col_offset=18), [In()], [Name('placeholder_18', Load(), lineno=44, col_offset=22, end_lineno=44, end_col_offset=34)], lineno=44, col_offset=15, end_lineno=44, end_col_offset=34), [Expr(Call(Subscript(Name('placeholder_18', Load(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=28), Name('placeholder_19', Load(), lineno=45, col_offset=29, end_lineno=45, end_col_offset=32), Load(), lineno=45, col_offset=16, end_lineno=45, end_col_offset=33), [], [], lineno=45, col_offset=16, end_lineno=45, end_col_offset=35), lineno=45, col_offset=16, end_lineno=45, end_col_offset=35)], [], lineno=44, col_offset=12, end_lineno=45, end_col_offset=35)], [], lineno=43, col_offset=8, end_lineno=45, end_col_offset=35)], [], lineno=39, col_offset=4, end_lineno=45, end_col_offset=35), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=48, col_offset=18, end_lineno=48, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Attribute(Name('self', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=19), 'placeholder_5', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=27), 'placeholder_7', Load(), lineno=49, col_offset=15, end_lineno=49, end_col_offset=37), lineno=49, col_offset=8, end_lineno=49, end_col_offset=37)], [Name('property', Load(), lineno=47, col_offset=5, end_lineno=47, end_col_offset=13)], lineno=48, col_offset=4, end_lineno=49, end_col_offset=37), FunctionDef('placeholder_20', arguments([], [arg('self', lineno=52, col_offset=20, end_lineno=52, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Tuple([Attribute(Name('self', Load(), lineno=53, col_offset=16, end_lineno=53, end_col_offset=20), 'placeholder_11', Load(), lineno=53, col_offset=16, end_lineno=53, end_col_offset=26), Attribute(Name('self', Load(), lineno=53, col_offset=28, end_lineno=53, end_col_offset=32), 'placeholder_12', Load(), lineno=53, col_offset=28, end_lineno=53, end_col_offset=38)], Load(), lineno=53, col_offset=15, end_lineno=53, end_col_offset=39), lineno=53, col_offset=8, end_lineno=53, end_col_offset=39)], [Name('property', Load(), lineno=51, col_offset=5, end_lineno=51, end_col_offset=13)], lineno=52, col_offset=4, end_lineno=53, end_col_offset=39)], [], lineno=17, col_offset=0, end_lineno=53, end_col_offset=39)], []) \ No newline at end of file diff --git a/test/practice-robot-simulator/robot_simulator.py b/test/practice-robot-simulator/robot_simulator.py new file mode 100644 index 0000000..20caf3b --- /dev/null +++ b/test/practice-robot-simulator/robot_simulator.py @@ -0,0 +1,53 @@ +NORTH, EAST, SOUTH, WEST = range(4) + + +class Compass: + compass = [NORTH, EAST, SOUTH, WEST] + + def __init__(self, direction=NORTH): + self.direction = direction + + def left(self): + self.direction = self.compass[self.direction - 1] + + def right(self): + self.direction = self.compass[(self.direction + 1) % 4] + + +class Robot: + def __init__(self, direction=NORTH, x_pos=0, y_pos=0): + self.compass = Compass(direction) + self.x_pos = x_pos + self.y_pos = y_pos + + def advance(self): + if self.direction == NORTH: + self.y_pos += 1 + elif self.direction == SOUTH: + self.y_pos -= 1 + elif self.direction == EAST: + self.x_pos += 1 + elif self.direction == WEST: + self.x_pos -= 1 + + def turn_left(self): + self.compass.left() + + def turn_right(self): + self.compass.right() + + def move(self, commands): + instructions = {'A': self.advance, + 'R': self.turn_right, + 'L': self.turn_left} + for cmd in commands: + if cmd in instructions: + instructions[cmd]() + + @property + def direction(self): + return self.compass.direction + + @property + def coordinates(self): + return (self.x_pos, self.y_pos) diff --git a/test/practice-roman-numerals/.meta/config.json b/test/practice-roman-numerals/.meta/config.json new file mode 100644 index 0000000..eab034a --- /dev/null +++ b/test/practice-roman-numerals/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "dotrungkien", + "ikhadykin", + "kytrinyx", + "lowks", + "mpatibandla", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "roman_numerals.py" + ], + "test": [ + "roman_numerals_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Write a function to convert from normal numbers to Roman Numerals.", + "source": "The Roman Numeral Kata", + "source_url": "https://codingdojo.org/kata/RomanNumerals/" +} diff --git a/test/practice-roman-numerals/mapping.json b/test/practice-roman-numerals/mapping.json new file mode 100644 index 0000000..8d6c5d5 --- /dev/null +++ b/test/practice-roman-numerals/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "NUMERAL_MAPPINGS", + "placeholder_1": "roman", + "placeholder_2": "number", + "placeholder_3": "result", + "placeholder_4": "arabic_num", + "placeholder_5": "roman_num" +} \ No newline at end of file diff --git a/test/practice-roman-numerals/representation.json b/test/practice-roman-numerals/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-roman-numerals/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-roman-numerals/representation.out b/test/practice-roman-numerals/representation.out new file mode 100644 index 0000000..0f92dc3 --- /dev/null +++ b/test/practice-roman-numerals/representation.out @@ -0,0 +1,883 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = ( + (1000, "M"), + (900, "CM"), + (500, "D"), + (400, "CD"), + (100, "C"), + (90, "XC"), + (50, "L"), + (40, "XL"), + (10, "X"), + (9, "IX"), + (5, "V"), + (4, "IV"), + (1, "I"), +) + + +def placeholder_1(placeholder_2): + placeholder_3 = "" + for placeholder_4, placeholder_5 in placeholder_0: + while placeholder_2 >= placeholder_4: + placeholder_3 += placeholder_5 + placeholder_2 -= placeholder_4 + return placeholder_3 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'NUMERAL_MAPPINGS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16)], + Tuple( + [ + Tuple( + [ + Constant( + 1000, + lineno=2, + col_offset=5, + end_lineno=2, + end_col_offset=9), + Constant( + 'M', + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14)], + Load(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=15), + Tuple( + [ + Constant( + 900, + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=21), + Constant( + 'CM', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=27)], + Load(), + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=28), + Tuple( + [ + Constant( + 500, + lineno=3, + col_offset=5, + end_lineno=3, + end_col_offset=8), + Constant( + 'D', + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=13)], + Load(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=14), + Tuple( + [ + Constant( + 400, + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=20), + Constant( + 'CD', + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=26)], + Load(), + lineno=3, + col_offset=16, + end_lineno=3, + end_col_offset=27), + Tuple( + [ + Constant( + 100, + lineno=4, + col_offset=5, + end_lineno=4, + end_col_offset=8), + Constant( + 'C', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=13)], + Load(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=14), + Tuple( + [ + Constant( + 90, + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=19), + Constant( + 'XC', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=25)], + Load(), + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=26), + Tuple( + [ + Constant( + 50, + lineno=5, + col_offset=5, + end_lineno=5, + end_col_offset=7), + Constant( + 'L', + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=12)], + Load(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=13), + Tuple( + [ + Constant( + 40, + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=18), + Constant( + 'XL', + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=24)], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=25), + Tuple( + [ + Constant( + 10, + lineno=6, + col_offset=5, + end_lineno=6, + end_col_offset=7), + Constant( + 'X', + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=12)], + Load(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=13), + Tuple( + [ + Constant( + 9, + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=17), + Constant( + 'IX', + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=23)], + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=24), + Tuple( + [ + Constant( + 5, + lineno=7, + col_offset=5, + end_lineno=7, + end_col_offset=6), + Constant( + 'V', + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=11)], + Load(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=12), + Tuple( + [ + Constant( + 4, + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=16), + Constant( + 'IV', + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=22)], + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=23), + Tuple( + [ + Constant( + 1, + lineno=8, + col_offset=5, + end_lineno=8, + end_col_offset=6), + Constant( + 'I', + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=11)], + Load(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=12)], + Load(), + lineno=1, + col_offset=19, + end_lineno=9, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=9, + end_col_offset=1), + FunctionDef( + 'roman', + arguments( + [], + [ + arg( + 'number', + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=10)], + Constant( + '', + lineno=13, + col_offset=13, + end_lineno=13, + end_col_offset=15), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'arabic_num', + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=18), + Name( + 'roman_num', + Store(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=29)], + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=29), + Name( + 'NUMERAL_MAPPINGS', + Load(), + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=49), + [ + While( + Compare( + Name( + 'number', + Load(), + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=20), + [ + GtE()], + [ + Name( + 'arabic_num', + Load(), + lineno=15, + col_offset=24, + end_lineno=15, + end_col_offset=34)], + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=34), + [ + AugAssign( + Name( + 'result', + Store(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=18), + Add(), + Name( + 'roman_num', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=31), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=31), + AugAssign( + Name( + 'number', + Store(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=18), + Sub(), + Name( + 'arabic_num', + Load(), + lineno=17, + col_offset=22, + end_lineno=17, + end_col_offset=32), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=32)], + [], + lineno=15, + col_offset=8, + end_lineno=17, + end_col_offset=32)], + [], + lineno=14, + col_offset=4, + end_lineno=17, + end_col_offset=32), + Return( + Name( + 'result', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=17), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=17)], + [], + lineno=12, + col_offset=0, + end_lineno=18, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=16)], + Tuple( + [ + Tuple( + [ + Constant( + 1000, + lineno=2, + col_offset=5, + end_lineno=2, + end_col_offset=9), + Constant( + 'M', + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14)], + Load(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=15), + Tuple( + [ + Constant( + 900, + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=21), + Constant( + 'CM', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=27)], + Load(), + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=28), + Tuple( + [ + Constant( + 500, + lineno=3, + col_offset=5, + end_lineno=3, + end_col_offset=8), + Constant( + 'D', + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=13)], + Load(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=14), + Tuple( + [ + Constant( + 400, + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=20), + Constant( + 'CD', + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=26)], + Load(), + lineno=3, + col_offset=16, + end_lineno=3, + end_col_offset=27), + Tuple( + [ + Constant( + 100, + lineno=4, + col_offset=5, + end_lineno=4, + end_col_offset=8), + Constant( + 'C', + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=13)], + Load(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=14), + Tuple( + [ + Constant( + 90, + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=19), + Constant( + 'XC', + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=25)], + Load(), + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=26), + Tuple( + [ + Constant( + 50, + lineno=5, + col_offset=5, + end_lineno=5, + end_col_offset=7), + Constant( + 'L', + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=12)], + Load(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=13), + Tuple( + [ + Constant( + 40, + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=18), + Constant( + 'XL', + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=24)], + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=25), + Tuple( + [ + Constant( + 10, + lineno=6, + col_offset=5, + end_lineno=6, + end_col_offset=7), + Constant( + 'X', + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=12)], + Load(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=13), + Tuple( + [ + Constant( + 9, + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=17), + Constant( + 'IX', + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=23)], + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=24), + Tuple( + [ + Constant( + 5, + lineno=7, + col_offset=5, + end_lineno=7, + end_col_offset=6), + Constant( + 'V', + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=11)], + Load(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=12), + Tuple( + [ + Constant( + 4, + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=16), + Constant( + 'IV', + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=22)], + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=23), + Tuple( + [ + Constant( + 1, + lineno=8, + col_offset=5, + end_lineno=8, + end_col_offset=6), + Constant( + 'I', + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=11)], + Load(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=12)], + Load(), + lineno=1, + col_offset=19, + end_lineno=9, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=9, + end_col_offset=1), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=12, + col_offset=10, + end_lineno=12, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=10)], + Constant( + '', + lineno=13, + col_offset=13, + end_lineno=13, + end_col_offset=15), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'placeholder_4', + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=18), + Name( + 'placeholder_5', + Store(), + lineno=14, + col_offset=20, + end_lineno=14, + end_col_offset=29)], + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=29), + Name( + 'placeholder_0', + Load(), + lineno=14, + col_offset=33, + end_lineno=14, + end_col_offset=49), + [ + While( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=20), + [ + GtE()], + [ + Name( + 'placeholder_4', + Load(), + lineno=15, + col_offset=24, + end_lineno=15, + end_col_offset=34)], + lineno=15, + col_offset=14, + end_lineno=15, + end_col_offset=34), + [ + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=18), + Add(), + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=31), + lineno=16, + col_offset=12, + end_lineno=16, + end_col_offset=31), + AugAssign( + Name( + 'placeholder_2', + Store(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=18), + Sub(), + Name( + 'placeholder_4', + Load(), + lineno=17, + col_offset=22, + end_lineno=17, + end_col_offset=32), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=32)], + [], + lineno=15, + col_offset=8, + end_lineno=17, + end_col_offset=32)], + [], + lineno=14, + col_offset=4, + end_lineno=17, + end_col_offset=32), + Return( + Name( + 'placeholder_3', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=17), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=17)], + [], + lineno=12, + col_offset=0, + end_lineno=18, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-roman-numerals/representation.txt b/test/practice-roman-numerals/representation.txt new file mode 100644 index 0000000..83e460d --- /dev/null +++ b/test/practice-roman-numerals/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=16)], Tuple([Tuple([Constant(1000, lineno=2, col_offset=5, end_lineno=2, end_col_offset=9), Constant('M', lineno=2, col_offset=11, end_lineno=2, end_col_offset=14)], Load(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=15), Tuple([Constant(900, lineno=2, col_offset=18, end_lineno=2, end_col_offset=21), Constant('CM', lineno=2, col_offset=23, end_lineno=2, end_col_offset=27)], Load(), lineno=2, col_offset=17, end_lineno=2, end_col_offset=28), Tuple([Constant(500, lineno=3, col_offset=5, end_lineno=3, end_col_offset=8), Constant('D', lineno=3, col_offset=10, end_lineno=3, end_col_offset=13)], Load(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=14), Tuple([Constant(400, lineno=3, col_offset=17, end_lineno=3, end_col_offset=20), Constant('CD', lineno=3, col_offset=22, end_lineno=3, end_col_offset=26)], Load(), lineno=3, col_offset=16, end_lineno=3, end_col_offset=27), Tuple([Constant(100, lineno=4, col_offset=5, end_lineno=4, end_col_offset=8), Constant('C', lineno=4, col_offset=10, end_lineno=4, end_col_offset=13)], Load(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=14), Tuple([Constant(90, lineno=4, col_offset=17, end_lineno=4, end_col_offset=19), Constant('XC', lineno=4, col_offset=21, end_lineno=4, end_col_offset=25)], Load(), lineno=4, col_offset=16, end_lineno=4, end_col_offset=26), Tuple([Constant(50, lineno=5, col_offset=5, end_lineno=5, end_col_offset=7), Constant('L', lineno=5, col_offset=9, end_lineno=5, end_col_offset=12)], Load(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=13), Tuple([Constant(40, lineno=5, col_offset=16, end_lineno=5, end_col_offset=18), Constant('XL', lineno=5, col_offset=20, end_lineno=5, end_col_offset=24)], Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=25), Tuple([Constant(10, lineno=6, col_offset=5, end_lineno=6, end_col_offset=7), Constant('X', lineno=6, col_offset=9, end_lineno=6, end_col_offset=12)], Load(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=13), Tuple([Constant(9, lineno=6, col_offset=16, end_lineno=6, end_col_offset=17), Constant('IX', lineno=6, col_offset=19, end_lineno=6, end_col_offset=23)], Load(), lineno=6, col_offset=15, end_lineno=6, end_col_offset=24), Tuple([Constant(5, lineno=7, col_offset=5, end_lineno=7, end_col_offset=6), Constant('V', lineno=7, col_offset=8, end_lineno=7, end_col_offset=11)], Load(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=12), Tuple([Constant(4, lineno=7, col_offset=15, end_lineno=7, end_col_offset=16), Constant('IV', lineno=7, col_offset=18, end_lineno=7, end_col_offset=22)], Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=23), Tuple([Constant(1, lineno=8, col_offset=5, end_lineno=8, end_col_offset=6), Constant('I', lineno=8, col_offset=8, end_lineno=8, end_col_offset=11)], Load(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=12)], Load(), lineno=1, col_offset=19, end_lineno=9, end_col_offset=1), lineno=1, col_offset=0, end_lineno=9, end_col_offset=1), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=12, col_offset=10, end_lineno=12, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_3', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=10)], Constant('', lineno=13, col_offset=13, end_lineno=13, end_col_offset=15), lineno=13, col_offset=4, end_lineno=13, end_col_offset=15), For(Tuple([Name('placeholder_4', Store(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=18), Name('placeholder_5', Store(), lineno=14, col_offset=20, end_lineno=14, end_col_offset=29)], Store(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=29), Name('placeholder_0', Load(), lineno=14, col_offset=33, end_lineno=14, end_col_offset=49), [While(Compare(Name('placeholder_2', Load(), lineno=15, col_offset=14, end_lineno=15, end_col_offset=20), [GtE()], [Name('placeholder_4', Load(), lineno=15, col_offset=24, end_lineno=15, end_col_offset=34)], lineno=15, col_offset=14, end_lineno=15, end_col_offset=34), [AugAssign(Name('placeholder_3', Store(), lineno=16, col_offset=12, end_lineno=16, end_col_offset=18), Add(), Name('placeholder_5', Load(), lineno=16, col_offset=22, end_lineno=16, end_col_offset=31), lineno=16, col_offset=12, end_lineno=16, end_col_offset=31), AugAssign(Name('placeholder_2', Store(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=18), Sub(), Name('placeholder_4', Load(), lineno=17, col_offset=22, end_lineno=17, end_col_offset=32), lineno=17, col_offset=12, end_lineno=17, end_col_offset=32)], [], lineno=15, col_offset=8, end_lineno=17, end_col_offset=32)], [], lineno=14, col_offset=4, end_lineno=17, end_col_offset=32), Return(Name('placeholder_3', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=17), lineno=18, col_offset=4, end_lineno=18, end_col_offset=17)], [], lineno=12, col_offset=0, end_lineno=18, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-roman-numerals/roman_numerals.py b/test/practice-roman-numerals/roman_numerals.py new file mode 100644 index 0000000..c6e56ec --- /dev/null +++ b/test/practice-roman-numerals/roman_numerals.py @@ -0,0 +1,18 @@ +NUMERAL_MAPPINGS = ( + (1000, 'M'), (900, 'CM'), + (500, 'D'), (400, 'CD'), + (100, 'C'), (90, 'XC'), + (50, 'L'), (40, 'XL'), + (10, 'X'), (9, 'IX'), + (5, 'V'), (4, 'IV'), + (1, 'I') +) + + +def roman(number): + result = '' + for arabic_num, roman_num in NUMERAL_MAPPINGS: + while number >= arabic_num: + result += roman_num + number -= arabic_num + return result diff --git a/test/practice-rotational-cipher/.meta/config.json b/test/practice-rotational-cipher/.meta/config.json new file mode 100644 index 0000000..d21c3ca --- /dev/null +++ b/test/practice-rotational-cipher/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "krapes" + ], + "contributors": [ + "akashsara", + "behrtam", + "cmccandless", + "Dog", + "dotrungkien", + "ikhadykin", + "lekum", + "N-Parsons", + "tqa236" + ], + "files": { + "solution": [ + "rotational_cipher.py" + ], + "test": [ + "rotational_cipher_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Create an implementation of the rotational cipher, also sometimes called the Caesar cipher.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Caesar_cipher" +} diff --git a/test/practice-rotational-cipher/mapping.json b/test/practice-rotational-cipher/mapping.json new file mode 100644 index 0000000..29cde3e --- /dev/null +++ b/test/practice-rotational-cipher/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "ALPHA_LEN", + "placeholder_1": "rotate", + "placeholder_2": "message", + "placeholder_3": "key", + "placeholder_4": "coded_message", + "placeholder_5": "char" +} \ No newline at end of file diff --git a/test/practice-rotational-cipher/representation.json b/test/practice-rotational-cipher/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-rotational-cipher/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-rotational-cipher/representation.out b/test/practice-rotational-cipher/representation.out new file mode 100644 index 0000000..dfd8f31 --- /dev/null +++ b/test/practice-rotational-cipher/representation.out @@ -0,0 +1,773 @@ +## BEGIN NORMALIZED CODE ## +from string import ascii_lowercase, ascii_uppercase + +placeholder_0 = len(ascii_lowercase) + + +def placeholder_1(placeholder_2, placeholder_3): + placeholder_4 = "" + for placeholder_5 in placeholder_2: + if placeholder_5 in ascii_lowercase: + placeholder_5 = ascii_lowercase[ + (ascii_lowercase.index(placeholder_5) + placeholder_3) % placeholder_0 + ] + elif placeholder_5 in ascii_uppercase: + placeholder_5 = ascii_uppercase[ + (ascii_uppercase.index(placeholder_5) + placeholder_3) % placeholder_0 + ] + placeholder_4 += placeholder_5 + return placeholder_4 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'string', + [ + alias( + 'ascii_lowercase', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=34), + alias( + 'ascii_uppercase', + lineno=1, + col_offset=36, + end_lineno=1, + end_col_offset=51)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=51), + Assign( + [ + Name( + 'ALPHA_LEN', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=9)], + Call( + Name( + 'len', + Load(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=15), + [ + Name( + 'ascii_lowercase', + Load(), + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=31)], + [], + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=32), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=32), + FunctionDef( + 'rotate', + arguments( + [], + [ + arg( + 'message', + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=18), + arg( + 'key', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'coded_message', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=17)], + Constant( + '', + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=22), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=22), + For( + Name( + 'char', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + Name( + 'message', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=23), + [ + If( + Compare( + Name( + 'char', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=15), + [ + In()], + [ + Name( + 'ascii_lowercase', + Load(), + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=34)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=34), + [ + Assign( + [ + Name( + 'char', + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=16)], + Subscript( + Name( + 'ascii_lowercase', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=34), + BinOp( + BinOp( + Call( + Attribute( + Name( + 'ascii_lowercase', + Load(), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=51), + 'index', + Load(), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=57), + [ + Name( + 'char', + Load(), + lineno=11, + col_offset=58, + end_lineno=11, + end_col_offset=62)], + [], + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=63), + Add(), + Name( + 'key', + Load(), + lineno=11, + col_offset=66, + end_lineno=11, + end_col_offset=69), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=69), + Mod(), + Name( + 'ALPHA_LEN', + Load(), + lineno=11, + col_offset=73, + end_lineno=11, + end_col_offset=82), + lineno=11, + col_offset=35, + end_lineno=11, + end_col_offset=82), + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=83), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=83)], + [ + If( + Compare( + Name( + 'char', + Load(), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=17), + [ + In()], + [ + Name( + 'ascii_uppercase', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=36)], + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=36), + [ + Assign( + [ + Name( + 'char', + Store(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=16)], + Subscript( + Name( + 'ascii_uppercase', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=34), + BinOp( + BinOp( + Call( + Attribute( + Name( + 'ascii_uppercase', + Load(), + lineno=13, + col_offset=36, + end_lineno=13, + end_col_offset=51), + 'index', + Load(), + lineno=13, + col_offset=36, + end_lineno=13, + end_col_offset=57), + [ + Name( + 'char', + Load(), + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=62)], + [], + lineno=13, + col_offset=36, + end_lineno=13, + end_col_offset=63), + Add(), + Name( + 'key', + Load(), + lineno=13, + col_offset=66, + end_lineno=13, + end_col_offset=69), + lineno=13, + col_offset=36, + end_lineno=13, + end_col_offset=69), + Mod(), + Name( + 'ALPHA_LEN', + Load(), + lineno=13, + col_offset=73, + end_lineno=13, + end_col_offset=82), + lineno=13, + col_offset=35, + end_lineno=13, + end_col_offset=82), + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=83), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=83)], + [], + lineno=12, + col_offset=8, + end_lineno=13, + end_col_offset=83)], + lineno=10, + col_offset=8, + end_lineno=13, + end_col_offset=83), + AugAssign( + Name( + 'coded_message', + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=21), + Add(), + Name( + 'char', + Load(), + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=29), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=29)], + [], + lineno=9, + col_offset=4, + end_lineno=14, + end_col_offset=29), + Return( + Name( + 'coded_message', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=24), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=24)], + [], + lineno=7, + col_offset=0, + end_lineno=15, + end_col_offset=24)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'string', + [ + alias( + 'ascii_lowercase', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=34), + alias( + 'ascii_uppercase', + lineno=1, + col_offset=36, + end_lineno=1, + end_col_offset=51)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=51), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=9)], + Call( + Name( + 'len', + Load(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=15), + [ + Name( + 'ascii_lowercase', + Load(), + lineno=4, + col_offset=16, + end_lineno=4, + end_col_offset=31)], + [], + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=32), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=32), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=18), + arg( + 'placeholder_3', + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=17)], + Constant( + '', + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=22), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=22), + For( + Name( + 'placeholder_5', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=23), + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=15), + [ + In()], + [ + Name( + 'ascii_lowercase', + Load(), + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=34)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=34), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=16)], + Subscript( + Name( + 'ascii_lowercase', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=34), + BinOp( + BinOp( + Call( + Attribute( + Name( + 'ascii_lowercase', + Load(), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=51), + 'index', + Load(), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=57), + [ + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=58, + end_lineno=11, + end_col_offset=62)], + [], + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=63), + Add(), + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=66, + end_lineno=11, + end_col_offset=69), + lineno=11, + col_offset=36, + end_lineno=11, + end_col_offset=69), + Mod(), + Name( + 'placeholder_0', + Load(), + lineno=11, + col_offset=73, + end_lineno=11, + end_col_offset=82), + lineno=11, + col_offset=35, + end_lineno=11, + end_col_offset=82), + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=83), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=83)], + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=17), + [ + In()], + [ + Name( + 'ascii_uppercase', + Load(), + lineno=12, + col_offset=21, + end_lineno=12, + end_col_offset=36)], + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=36), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=16)], + Subscript( + Name( + 'ascii_uppercase', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=34), + BinOp( + BinOp( + Call( + Attribute( + Name( + 'ascii_uppercase', + Load(), + lineno=13, + col_offset=36, + end_lineno=13, + end_col_offset=51), + 'index', + Load(), + lineno=13, + col_offset=36, + end_lineno=13, + end_col_offset=57), + [ + Name( + 'placeholder_5', + Load(), + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=62)], + [], + lineno=13, + col_offset=36, + end_lineno=13, + end_col_offset=63), + Add(), + Name( + 'placeholder_3', + Load(), + lineno=13, + col_offset=66, + end_lineno=13, + end_col_offset=69), + lineno=13, + col_offset=36, + end_lineno=13, + end_col_offset=69), + Mod(), + Name( + 'placeholder_0', + Load(), + lineno=13, + col_offset=73, + end_lineno=13, + end_col_offset=82), + lineno=13, + col_offset=35, + end_lineno=13, + end_col_offset=82), + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=83), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=83)], + [], + lineno=12, + col_offset=8, + end_lineno=13, + end_col_offset=83)], + lineno=10, + col_offset=8, + end_lineno=13, + end_col_offset=83), + AugAssign( + Name( + 'placeholder_4', + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=21), + Add(), + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=25, + end_lineno=14, + end_col_offset=29), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=29)], + [], + lineno=9, + col_offset=4, + end_lineno=14, + end_col_offset=29), + Return( + Name( + 'placeholder_4', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=24), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=24)], + [], + lineno=7, + col_offset=0, + end_lineno=15, + end_col_offset=24)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-rotational-cipher/representation.txt b/test/practice-rotational-cipher/representation.txt new file mode 100644 index 0000000..9af8134 --- /dev/null +++ b/test/practice-rotational-cipher/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('string', [alias('ascii_lowercase', lineno=1, col_offset=19, end_lineno=1, end_col_offset=34), alias('ascii_uppercase', lineno=1, col_offset=36, end_lineno=1, end_col_offset=51)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=51), Assign([Name('placeholder_0', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=9)], Call(Name('len', Load(), lineno=4, col_offset=12, end_lineno=4, end_col_offset=15), [Name('ascii_lowercase', Load(), lineno=4, col_offset=16, end_lineno=4, end_col_offset=31)], [], lineno=4, col_offset=12, end_lineno=4, end_col_offset=32), lineno=4, col_offset=0, end_lineno=4, end_col_offset=32), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=7, col_offset=11, end_lineno=7, end_col_offset=18), arg('placeholder_3', lineno=7, col_offset=20, end_lineno=7, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=17)], Constant('', lineno=8, col_offset=20, end_lineno=8, end_col_offset=22), lineno=8, col_offset=4, end_lineno=8, end_col_offset=22), For(Name('placeholder_5', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), Name('placeholder_2', Load(), lineno=9, col_offset=16, end_lineno=9, end_col_offset=23), [If(Compare(Name('placeholder_5', Load(), lineno=10, col_offset=11, end_lineno=10, end_col_offset=15), [In()], [Name('ascii_lowercase', Load(), lineno=10, col_offset=19, end_lineno=10, end_col_offset=34)], lineno=10, col_offset=11, end_lineno=10, end_col_offset=34), [Assign([Name('placeholder_5', Store(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=16)], Subscript(Name('ascii_lowercase', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=34), BinOp(BinOp(Call(Attribute(Name('ascii_lowercase', Load(), lineno=11, col_offset=36, end_lineno=11, end_col_offset=51), 'index', Load(), lineno=11, col_offset=36, end_lineno=11, end_col_offset=57), [Name('placeholder_5', Load(), lineno=11, col_offset=58, end_lineno=11, end_col_offset=62)], [], lineno=11, col_offset=36, end_lineno=11, end_col_offset=63), Add(), Name('placeholder_3', Load(), lineno=11, col_offset=66, end_lineno=11, end_col_offset=69), lineno=11, col_offset=36, end_lineno=11, end_col_offset=69), Mod(), Name('placeholder_0', Load(), lineno=11, col_offset=73, end_lineno=11, end_col_offset=82), lineno=11, col_offset=35, end_lineno=11, end_col_offset=82), Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=83), lineno=11, col_offset=12, end_lineno=11, end_col_offset=83)], [If(Compare(Name('placeholder_5', Load(), lineno=12, col_offset=13, end_lineno=12, end_col_offset=17), [In()], [Name('ascii_uppercase', Load(), lineno=12, col_offset=21, end_lineno=12, end_col_offset=36)], lineno=12, col_offset=13, end_lineno=12, end_col_offset=36), [Assign([Name('placeholder_5', Store(), lineno=13, col_offset=12, end_lineno=13, end_col_offset=16)], Subscript(Name('ascii_uppercase', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=34), BinOp(BinOp(Call(Attribute(Name('ascii_uppercase', Load(), lineno=13, col_offset=36, end_lineno=13, end_col_offset=51), 'index', Load(), lineno=13, col_offset=36, end_lineno=13, end_col_offset=57), [Name('placeholder_5', Load(), lineno=13, col_offset=58, end_lineno=13, end_col_offset=62)], [], lineno=13, col_offset=36, end_lineno=13, end_col_offset=63), Add(), Name('placeholder_3', Load(), lineno=13, col_offset=66, end_lineno=13, end_col_offset=69), lineno=13, col_offset=36, end_lineno=13, end_col_offset=69), Mod(), Name('placeholder_0', Load(), lineno=13, col_offset=73, end_lineno=13, end_col_offset=82), lineno=13, col_offset=35, end_lineno=13, end_col_offset=82), Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=83), lineno=13, col_offset=12, end_lineno=13, end_col_offset=83)], [], lineno=12, col_offset=8, end_lineno=13, end_col_offset=83)], lineno=10, col_offset=8, end_lineno=13, end_col_offset=83), AugAssign(Name('placeholder_4', Store(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=21), Add(), Name('placeholder_5', Load(), lineno=14, col_offset=25, end_lineno=14, end_col_offset=29), lineno=14, col_offset=8, end_lineno=14, end_col_offset=29)], [], lineno=9, col_offset=4, end_lineno=14, end_col_offset=29), Return(Name('placeholder_4', Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=24), lineno=15, col_offset=4, end_lineno=15, end_col_offset=24)], [], lineno=7, col_offset=0, end_lineno=15, end_col_offset=24)], []) \ No newline at end of file diff --git a/test/practice-rotational-cipher/rotational_cipher.py b/test/practice-rotational-cipher/rotational_cipher.py new file mode 100644 index 0000000..3326327 --- /dev/null +++ b/test/practice-rotational-cipher/rotational_cipher.py @@ -0,0 +1,15 @@ +from string import ascii_lowercase, ascii_uppercase + + +ALPHA_LEN = len(ascii_lowercase) + + +def rotate(message, key): + coded_message = '' + for char in message: + if char in ascii_lowercase: + char = ascii_lowercase[(ascii_lowercase.index(char) + key) % ALPHA_LEN] + elif char in ascii_uppercase: + char = ascii_uppercase[(ascii_uppercase.index(char) + key) % ALPHA_LEN] + coded_message += char + return coded_message diff --git a/test/practice-run-length-encoding/.meta/config.json b/test/practice-run-length-encoding/.meta/config.json new file mode 100644 index 0000000..7d8f389 --- /dev/null +++ b/test/practice-run-length-encoding/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "cmccandless", + "crsmi", + "Dog", + "dotrungkien", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "run_length_encoding.py" + ], + "test": [ + "run_length_encoding_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement run-length encoding and decoding.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Run-length_encoding" +} diff --git a/test/practice-run-length-encoding/mapping.json b/test/practice-run-length-encoding/mapping.json new file mode 100644 index 0000000..1aefb52 --- /dev/null +++ b/test/practice-run-length-encoding/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "decode", + "placeholder_1": "string", + "placeholder_2": "main", + "placeholder_3": "encode", + "placeholder_4": "single_helper", + "placeholder_5": "key", + "placeholder_6": "group", + "placeholder_7": "size" +} \ No newline at end of file diff --git a/test/practice-run-length-encoding/representation.json b/test/practice-run-length-encoding/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-run-length-encoding/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-run-length-encoding/representation.out b/test/practice-run-length-encoding/representation.out new file mode 100644 index 0000000..5308682 --- /dev/null +++ b/test/practice-run-length-encoding/representation.out @@ -0,0 +1,922 @@ +## BEGIN NORMALIZED CODE ## +from itertools import groupby +from re import sub + + +def placeholder_0(placeholder_1): + return sub( + "(\\d+)(\\D)", + lambda placeholder_2: placeholder_2.group(2) * int(placeholder_2.group(1)), + placeholder_1, + ) + + +def placeholder_3(placeholder_1): + def placeholder_4(placeholder_5, placeholder_6): + placeholder_7 = len(list(placeholder_6)) + return ( + placeholder_5 if placeholder_7 == 1 else str(placeholder_7) + placeholder_5 + ) + + return "".join( + ( + placeholder_4(placeholder_5, placeholder_6) + for placeholder_5, placeholder_6 in groupby(placeholder_1) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'groupby', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=29)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=29), + ImportFrom( + 're', + [ + alias( + 'sub', + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=18)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=18), + FunctionDef( + 'decode', + arguments( + [], + [ + arg( + 'string', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sub', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=14), + [ + Constant( + '(\\d+)(\\D)', + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=27), + Lambda( + arguments( + [], + [ + arg( + 'main', + lineno=6, + col_offset=36, + end_lineno=6, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + BinOp( + Call( + Attribute( + Name( + 'main', + Load(), + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=46), + 'group', + Load(), + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=52), + [ + Constant( + 2, + lineno=6, + col_offset=53, + end_lineno=6, + end_col_offset=54)], + [], + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=55), + Mult(), + Call( + Name( + 'int', + Load(), + lineno=6, + col_offset=58, + end_lineno=6, + end_col_offset=61), + [ + Call( + Attribute( + Name( + 'main', + Load(), + lineno=6, + col_offset=62, + end_lineno=6, + end_col_offset=66), + 'group', + Load(), + lineno=6, + col_offset=62, + end_lineno=6, + end_col_offset=72), + [ + Constant( + 1, + lineno=6, + col_offset=73, + end_lineno=6, + end_col_offset=74)], + [], + lineno=6, + col_offset=62, + end_lineno=6, + end_col_offset=75)], + [], + lineno=6, + col_offset=58, + end_lineno=6, + end_col_offset=76), + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=76), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=76), + Name( + 'string', + Load(), + lineno=6, + col_offset=78, + end_lineno=6, + end_col_offset=84)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=85), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=85)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=85), + FunctionDef( + 'encode', + arguments( + [], + [ + arg( + 'string', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + FunctionDef( + 'single_helper', + arguments( + [], + [ + arg( + 'key', + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=25), + arg( + 'group', + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'size', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12)], + Call( + Name( + 'len', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=18), + [ + Call( + Name( + 'list', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=23), + [ + Name( + 'group', + Load(), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=29)], + [], + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=30)], + [], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=31), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=31), + Return( + IfExp( + Compare( + Name( + 'size', + Load(), + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=26), + [ + Eq()], + [ + Constant( + 1, + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=31)], + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=31), + Name( + 'key', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=18), + BinOp( + Call( + Name( + 'str', + Load(), + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=40), + [ + Name( + 'size', + Load(), + lineno=12, + col_offset=41, + end_lineno=12, + end_col_offset=45)], + [], + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=46), + Add(), + Name( + 'key', + Load(), + lineno=12, + col_offset=49, + end_lineno=12, + end_col_offset=52), + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=52), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=52), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=52)], + [], + lineno=10, + col_offset=4, + end_lineno=12, + end_col_offset=52), + Return( + Call( + Attribute( + Constant( + '', + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=13), + 'join', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=18), + [ + GeneratorExp( + Call( + Name( + 'single_helper', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=32), + [ + Name( + 'key', + Load(), + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=36), + Name( + 'group', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=43)], + [], + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=44), + [ + comprehension( + Tuple( + [ + Name( + 'key', + Store(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=52), + Name( + 'group', + Store(), + lineno=13, + col_offset=54, + end_lineno=13, + end_col_offset=59)], + Store(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=59), + Call( + Name( + 'groupby', + Load(), + lineno=13, + col_offset=63, + end_lineno=13, + end_col_offset=70), + [ + Name( + 'string', + Load(), + lineno=13, + col_offset=71, + end_lineno=13, + end_col_offset=77)], + [], + lineno=13, + col_offset=63, + end_lineno=13, + end_col_offset=78), + [], + 0)], + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=79)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=79), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=79)], + [], + lineno=9, + col_offset=0, + end_lineno=13, + end_col_offset=79)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'groupby', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=29)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=29), + ImportFrom( + 're', + [ + alias( + 'sub', + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=18)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=18), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sub', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=14), + [ + Constant( + '(\\d+)(\\D)', + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=27), + Lambda( + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=6, + col_offset=36, + end_lineno=6, + end_col_offset=40)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + BinOp( + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=46), + 'group', + Load(), + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=52), + [ + Constant( + 2, + lineno=6, + col_offset=53, + end_lineno=6, + end_col_offset=54)], + [], + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=55), + Mult(), + Call( + Name( + 'int', + Load(), + lineno=6, + col_offset=58, + end_lineno=6, + end_col_offset=61), + [ + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=62, + end_lineno=6, + end_col_offset=66), + 'group', + Load(), + lineno=6, + col_offset=62, + end_lineno=6, + end_col_offset=72), + [ + Constant( + 1, + lineno=6, + col_offset=73, + end_lineno=6, + end_col_offset=74)], + [], + lineno=6, + col_offset=62, + end_lineno=6, + end_col_offset=75)], + [], + lineno=6, + col_offset=58, + end_lineno=6, + end_col_offset=76), + lineno=6, + col_offset=42, + end_lineno=6, + end_col_offset=76), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=76), + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=78, + end_lineno=6, + end_col_offset=84)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=85), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=85)], + [], + lineno=5, + col_offset=0, + end_lineno=6, + end_col_offset=85), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=25), + arg( + 'placeholder_6', + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=12)], + Call( + Name( + 'len', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=18), + [ + Call( + Name( + 'list', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=23), + [ + Name( + 'placeholder_6', + Load(), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=29)], + [], + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=30)], + [], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=31), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=31), + Return( + IfExp( + Compare( + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=26), + [ + Eq()], + [ + Constant( + 1, + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=31)], + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=31), + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=18), + BinOp( + Call( + Name( + 'str', + Load(), + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=40), + [ + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=41, + end_lineno=12, + end_col_offset=45)], + [], + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=46), + Add(), + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=49, + end_lineno=12, + end_col_offset=52), + lineno=12, + col_offset=37, + end_lineno=12, + end_col_offset=52), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=52), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=52)], + [], + lineno=10, + col_offset=4, + end_lineno=12, + end_col_offset=52), + Return( + Call( + Attribute( + Constant( + '', + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=13), + 'join', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=18), + [ + GeneratorExp( + Call( + Name( + 'placeholder_4', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=32), + [ + Name( + 'placeholder_5', + Load(), + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=36), + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=38, + end_lineno=13, + end_col_offset=43)], + [], + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=44), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_5', + Store(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=52), + Name( + 'placeholder_6', + Store(), + lineno=13, + col_offset=54, + end_lineno=13, + end_col_offset=59)], + Store(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=59), + Call( + Name( + 'groupby', + Load(), + lineno=13, + col_offset=63, + end_lineno=13, + end_col_offset=70), + [ + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=71, + end_lineno=13, + end_col_offset=77)], + [], + lineno=13, + col_offset=63, + end_lineno=13, + end_col_offset=78), + [], + 0)], + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=79)], + [], + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=79), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=79)], + [], + lineno=9, + col_offset=0, + end_lineno=13, + end_col_offset=79)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-run-length-encoding/representation.txt b/test/practice-run-length-encoding/representation.txt new file mode 100644 index 0000000..733159b --- /dev/null +++ b/test/practice-run-length-encoding/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('itertools', [alias('groupby', lineno=1, col_offset=22, end_lineno=1, end_col_offset=29)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=29), ImportFrom('re', [alias('sub', lineno=2, col_offset=15, end_lineno=2, end_col_offset=18)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=18), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=5, col_offset=11, end_lineno=5, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sub', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=14), [Constant('(\\d+)(\\D)', lineno=6, col_offset=15, end_lineno=6, end_col_offset=27), Lambda(arguments([], [arg('placeholder_2', lineno=6, col_offset=36, end_lineno=6, end_col_offset=40)], kwonlyargs=[], kw_defaults=[], defaults=[]), BinOp(Call(Attribute(Name('placeholder_2', Load(), lineno=6, col_offset=42, end_lineno=6, end_col_offset=46), 'group', Load(), lineno=6, col_offset=42, end_lineno=6, end_col_offset=52), [Constant(2, lineno=6, col_offset=53, end_lineno=6, end_col_offset=54)], [], lineno=6, col_offset=42, end_lineno=6, end_col_offset=55), Mult(), Call(Name('int', Load(), lineno=6, col_offset=58, end_lineno=6, end_col_offset=61), [Call(Attribute(Name('placeholder_2', Load(), lineno=6, col_offset=62, end_lineno=6, end_col_offset=66), 'group', Load(), lineno=6, col_offset=62, end_lineno=6, end_col_offset=72), [Constant(1, lineno=6, col_offset=73, end_lineno=6, end_col_offset=74)], [], lineno=6, col_offset=62, end_lineno=6, end_col_offset=75)], [], lineno=6, col_offset=58, end_lineno=6, end_col_offset=76), lineno=6, col_offset=42, end_lineno=6, end_col_offset=76), lineno=6, col_offset=29, end_lineno=6, end_col_offset=76), Name('placeholder_1', Load(), lineno=6, col_offset=78, end_lineno=6, end_col_offset=84)], [], lineno=6, col_offset=11, end_lineno=6, end_col_offset=85), lineno=6, col_offset=4, end_lineno=6, end_col_offset=85)], [], lineno=5, col_offset=0, end_lineno=6, end_col_offset=85), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=9, col_offset=11, end_lineno=9, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=10, col_offset=22, end_lineno=10, end_col_offset=25), arg('placeholder_6', lineno=10, col_offset=27, end_lineno=10, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=12)], Call(Name('len', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=18), [Call(Name('list', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=23), [Name('placeholder_6', Load(), lineno=11, col_offset=24, end_lineno=11, end_col_offset=29)], [], lineno=11, col_offset=19, end_lineno=11, end_col_offset=30)], [], lineno=11, col_offset=15, end_lineno=11, end_col_offset=31), lineno=11, col_offset=8, end_lineno=11, end_col_offset=31), Return(IfExp(Compare(Name('placeholder_7', Load(), lineno=12, col_offset=22, end_lineno=12, end_col_offset=26), [Eq()], [Constant(1, lineno=12, col_offset=30, end_lineno=12, end_col_offset=31)], lineno=12, col_offset=22, end_lineno=12, end_col_offset=31), Name('placeholder_5', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=18), BinOp(Call(Name('str', Load(), lineno=12, col_offset=37, end_lineno=12, end_col_offset=40), [Name('placeholder_7', Load(), lineno=12, col_offset=41, end_lineno=12, end_col_offset=45)], [], lineno=12, col_offset=37, end_lineno=12, end_col_offset=46), Add(), Name('placeholder_5', Load(), lineno=12, col_offset=49, end_lineno=12, end_col_offset=52), lineno=12, col_offset=37, end_lineno=12, end_col_offset=52), lineno=12, col_offset=15, end_lineno=12, end_col_offset=52), lineno=12, col_offset=8, end_lineno=12, end_col_offset=52)], [], lineno=10, col_offset=4, end_lineno=12, end_col_offset=52), Return(Call(Attribute(Constant('', lineno=13, col_offset=11, end_lineno=13, end_col_offset=13), 'join', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=18), [GeneratorExp(Call(Name('placeholder_4', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=32), [Name('placeholder_5', Load(), lineno=13, col_offset=33, end_lineno=13, end_col_offset=36), Name('placeholder_6', Load(), lineno=13, col_offset=38, end_lineno=13, end_col_offset=43)], [], lineno=13, col_offset=19, end_lineno=13, end_col_offset=44), [comprehension(Tuple([Name('placeholder_5', Store(), lineno=13, col_offset=49, end_lineno=13, end_col_offset=52), Name('placeholder_6', Store(), lineno=13, col_offset=54, end_lineno=13, end_col_offset=59)], Store(), lineno=13, col_offset=49, end_lineno=13, end_col_offset=59), Call(Name('groupby', Load(), lineno=13, col_offset=63, end_lineno=13, end_col_offset=70), [Name('placeholder_1', Load(), lineno=13, col_offset=71, end_lineno=13, end_col_offset=77)], [], lineno=13, col_offset=63, end_lineno=13, end_col_offset=78), [], 0)], lineno=13, col_offset=18, end_lineno=13, end_col_offset=79)], [], lineno=13, col_offset=11, end_lineno=13, end_col_offset=79), lineno=13, col_offset=4, end_lineno=13, end_col_offset=79)], [], lineno=9, col_offset=0, end_lineno=13, end_col_offset=79)], []) \ No newline at end of file diff --git a/test/practice-run-length-encoding/run_length_encoding.py b/test/practice-run-length-encoding/run_length_encoding.py new file mode 100644 index 0000000..309c8a3 --- /dev/null +++ b/test/practice-run-length-encoding/run_length_encoding.py @@ -0,0 +1,13 @@ +from itertools import groupby +from re import sub + + +def decode(string): + return sub(r'(\d+)(\D)', lambda main: main.group(2) * int(main.group(1)), string) + + +def encode(string): + def single_helper(key, group): + size = len(list(group)) + return key if size == 1 else str(size) + key + return ''.join(single_helper(key, group) for key, group in groupby(string)) diff --git a/test/practice-saddle-points/.meta/additional_tests.json b/test/practice-saddle-points/.meta/additional_tests.json new file mode 100644 index 0000000..458950c --- /dev/null +++ b/test/practice-saddle-points/.meta/additional_tests.json @@ -0,0 +1,18 @@ +{ + "cases": [ + { + "description": "irregular Matrix", + "property": "saddlePoints", + "input": { + "matrix": [ + [3, 2, 1], + [0, 1], + [2, 1, 0] + ] + }, + "expected": { + "error": "irregular matrix" + } + } + ] +} diff --git a/test/practice-saddle-points/.meta/config.json b/test/practice-saddle-points/.meta/config.json new file mode 100644 index 0000000..ba7ae52 --- /dev/null +++ b/test/practice-saddle-points/.meta/config.json @@ -0,0 +1,40 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "Alexhans", + "AnAccountForReportingBugs", + "behrtam", + "BethanyG", + "cmccandless", + "crsmi", + "ctholho", + "DocFogel", + "Dog", + "elyssonmr", + "ikhadykin", + "ilmanzo", + "kytrinyx", + "N-Parsons", + "pheanex", + "pywkm", + "sjakobi", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "saddle_points.py" + ], + "test": [ + "saddle_points_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Detect saddle points in a matrix.", + "source": "J Dalbey's Programming Practice problems", + "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" +} diff --git a/test/practice-saddle-points/mapping.json b/test/practice-saddle-points/mapping.json new file mode 100644 index 0000000..636a4ee --- /dev/null +++ b/test/practice-saddle-points/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "saddle_points", + "placeholder_1": "matrix", + "placeholder_2": "row", + "placeholder_3": "mmax", + "placeholder_4": "mmin", + "placeholder_5": "col", + "placeholder_6": "points", + "placeholder_7": "index", + "placeholder_8": "_", + "placeholder_9": "col_index" +} \ No newline at end of file diff --git a/test/practice-saddle-points/representation.json b/test/practice-saddle-points/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-saddle-points/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-saddle-points/representation.out b/test/practice-saddle-points/representation.out new file mode 100644 index 0000000..7ae3285 --- /dev/null +++ b/test/practice-saddle-points/representation.out @@ -0,0 +1,1169 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + if not placeholder_1: + return [] + if any( + (len(placeholder_2) != len(placeholder_1[0]) for placeholder_2 in placeholder_1) + ): + raise ValueError("irregular matrix") + placeholder_3 = [max(placeholder_2) for placeholder_2 in placeholder_1] + placeholder_4 = [min(placeholder_5) for placeholder_5 in zip(*placeholder_1)] + placeholder_6 = [ + {"row": placeholder_7 + 1, "column": placeholder_9 + 1} + for placeholder_7, placeholder_8 in enumerate(placeholder_1) + for placeholder_9, placeholder_8 in enumerate(placeholder_1[0]) + if placeholder_3[placeholder_7] == placeholder_4[placeholder_9] + ] + return placeholder_6 or [] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'saddle_points', + arguments( + [], + [ + arg( + 'matrix', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'matrix', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=17), + [ + Return( + List( + [], + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=17), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=17)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=17), + If( + Call( + Name( + 'any', + Load(), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=10), + [ + GeneratorExp( + Compare( + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + Name( + 'row', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=18)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=19), + [ + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=26), + [ + Subscript( + Name( + 'matrix', + Load(), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=33), + Constant( + 0, + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=35), + Load(), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=36)], + [], + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=37)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=37), + [ + comprehension( + Name( + 'row', + Store(), + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=45), + Name( + 'matrix', + Load(), + lineno=5, + col_offset=49, + end_lineno=5, + end_col_offset=55), + [], + 0)], + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=56)], + [], + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=56), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=24), + [ + Constant( + 'irregular matrix', + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=43)], + [], + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=44), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=44)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=44), + Assign( + [ + Name( + 'mmax', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=8)], + ListComp( + Call( + Name( + 'max', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=15), + [ + Name( + 'row', + Load(), + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=19)], + [], + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=20), + [ + comprehension( + Name( + 'row', + Store(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=28), + Name( + 'matrix', + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=38), + [], + 0)], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=39), + Assign( + [ + Name( + 'mmin', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=8)], + ListComp( + Call( + Name( + 'min', + Load(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=15), + [ + Name( + 'col', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=19)], + [], + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=20), + [ + comprehension( + Name( + 'col', + Store(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=28), + Call( + Name( + 'zip', + Load(), + lineno=9, + col_offset=32, + end_lineno=9, + end_col_offset=35), + [ + Starred( + Name( + 'matrix', + Load(), + lineno=9, + col_offset=37, + end_lineno=9, + end_col_offset=43), + Load(), + lineno=9, + col_offset=36, + end_lineno=9, + end_col_offset=43)], + [], + lineno=9, + col_offset=32, + end_lineno=9, + end_col_offset=44), + [], + 0)], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=45), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=45), + Assign( + [ + Name( + 'points', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=10)], + ListComp( + Dict( + [ + Constant( + 'row', + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=20), + Constant( + 'column', + lineno=11, + col_offset=33, + end_lineno=11, + end_col_offset=41)], + [ + BinOp( + Name( + 'index', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=27), + Add(), + Constant( + 1, + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=31), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=31), + BinOp( + Name( + 'col_index', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=52), + Add(), + Constant( + 1, + lineno=11, + col_offset=55, + end_lineno=11, + end_col_offset=56), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=56)], + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=57), + [ + comprehension( + Tuple( + [ + Name( + 'index', + Store(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=23), + Name( + '_', + Store(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=26)], + Store(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=26), + Call( + Name( + 'enumerate', + Load(), + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=39), + [ + Name( + 'matrix', + Load(), + lineno=12, + col_offset=40, + end_lineno=12, + end_col_offset=46)], + [], + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=47), + [], + 0), + comprehension( + Tuple( + [ + Name( + 'col_index', + Store(), + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=27), + Name( + '_', + Store(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=30)], + Store(), + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=30), + Call( + Name( + 'enumerate', + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=43), + [ + Subscript( + Name( + 'matrix', + Load(), + lineno=13, + col_offset=44, + end_lineno=13, + end_col_offset=50), + Constant( + 0, + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=52), + Load(), + lineno=13, + col_offset=44, + end_lineno=13, + end_col_offset=53)], + [], + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=54), + [ + Compare( + Subscript( + Name( + 'mmax', + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + Name( + 'index', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=27), + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=28), + [ + Eq()], + [ + Subscript( + Name( + 'mmin', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=36), + Name( + 'col_index', + Load(), + lineno=14, + col_offset=37, + end_lineno=14, + end_col_offset=46), + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=47)], + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=47)], + 0)], + lineno=11, + col_offset=13, + end_lineno=14, + end_col_offset=48), + lineno=11, + col_offset=4, + end_lineno=14, + end_col_offset=48), + Return( + BoolOp( + Or(), + [ + Name( + 'points', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + List( + [], + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=23)], + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=23), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=23)], + [], + lineno=1, + col_offset=0, + end_lineno=16, + end_col_offset=23)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=17), + [ + Return( + List( + [], + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=17), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=17)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=17), + If( + Call( + Name( + 'any', + Load(), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=10), + [ + GeneratorExp( + Compare( + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=14), + [ + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=15, + end_lineno=5, + end_col_offset=18)], + [], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=19), + [ + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=26), + [ + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=33), + Constant( + 0, + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=35), + Load(), + lineno=5, + col_offset=27, + end_lineno=5, + end_col_offset=36)], + [], + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=37)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=37), + [ + comprehension( + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=45), + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=49, + end_lineno=5, + end_col_offset=55), + [], + 0)], + lineno=5, + col_offset=10, + end_lineno=5, + end_col_offset=56)], + [], + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=56), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=24), + [ + Constant( + 'irregular matrix', + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=43)], + [], + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=44), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=44)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=8)], + ListComp( + Call( + Name( + 'max', + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=15), + [ + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=19)], + [], + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=20), + [ + comprehension( + Name( + 'placeholder_2', + Store(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=28), + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=38), + [], + 0)], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=39), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=8)], + ListComp( + Call( + Name( + 'min', + Load(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=15), + [ + Name( + 'placeholder_5', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=19)], + [], + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=20), + [ + comprehension( + Name( + 'placeholder_5', + Store(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=28), + Call( + Name( + 'zip', + Load(), + lineno=9, + col_offset=32, + end_lineno=9, + end_col_offset=35), + [ + Starred( + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=37, + end_lineno=9, + end_col_offset=43), + Load(), + lineno=9, + col_offset=36, + end_lineno=9, + end_col_offset=43)], + [], + lineno=9, + col_offset=32, + end_lineno=9, + end_col_offset=44), + [], + 0)], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=45), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=10)], + ListComp( + Dict( + [ + Constant( + 'row', + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=20), + Constant( + 'column', + lineno=11, + col_offset=33, + end_lineno=11, + end_col_offset=41)], + [ + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=27), + Add(), + Constant( + 1, + lineno=11, + col_offset=30, + end_lineno=11, + end_col_offset=31), + lineno=11, + col_offset=22, + end_lineno=11, + end_col_offset=31), + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=52), + Add(), + Constant( + 1, + lineno=11, + col_offset=55, + end_lineno=11, + end_col_offset=56), + lineno=11, + col_offset=43, + end_lineno=11, + end_col_offset=56)], + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=57), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=23), + Name( + 'placeholder_8', + Store(), + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=26)], + Store(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=26), + Call( + Name( + 'enumerate', + Load(), + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=39), + [ + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=40, + end_lineno=12, + end_col_offset=46)], + [], + lineno=12, + col_offset=30, + end_lineno=12, + end_col_offset=47), + [], + 0), + comprehension( + Tuple( + [ + Name( + 'placeholder_9', + Store(), + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=27), + Name( + 'placeholder_8', + Store(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=30)], + Store(), + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=30), + Call( + Name( + 'enumerate', + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=43), + [ + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=44, + end_lineno=13, + end_col_offset=50), + Constant( + 0, + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=52), + Load(), + lineno=13, + col_offset=44, + end_lineno=13, + end_col_offset=53)], + [], + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=54), + [ + Compare( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + Name( + 'placeholder_7', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=27), + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=28), + [ + Eq()], + [ + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=36), + Name( + 'placeholder_9', + Load(), + lineno=14, + col_offset=37, + end_lineno=14, + end_col_offset=46), + Load(), + lineno=14, + col_offset=32, + end_lineno=14, + end_col_offset=47)], + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=47)], + 0)], + lineno=11, + col_offset=13, + end_lineno=14, + end_col_offset=48), + lineno=11, + col_offset=4, + end_lineno=14, + end_col_offset=48), + Return( + BoolOp( + Or(), + [ + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + List( + [], + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=23)], + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=23), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=23)], + [], + lineno=1, + col_offset=0, + end_lineno=16, + end_col_offset=23)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-saddle-points/representation.txt b/test/practice-saddle-points/representation.txt new file mode 100644 index 0000000..89aed3b --- /dev/null +++ b/test/practice-saddle-points/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=18, end_lineno=1, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=17), lineno=2, col_offset=7, end_lineno=2, end_col_offset=17), [Return(List([], Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=17), lineno=3, col_offset=8, end_lineno=3, end_col_offset=17)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=17), If(Call(Name('any', Load(), lineno=5, col_offset=7, end_lineno=5, end_col_offset=10), [GeneratorExp(Compare(Call(Name('len', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=14), [Name('placeholder_2', Load(), lineno=5, col_offset=15, end_lineno=5, end_col_offset=18)], [], lineno=5, col_offset=11, end_lineno=5, end_col_offset=19), [NotEq()], [Call(Name('len', Load(), lineno=5, col_offset=23, end_lineno=5, end_col_offset=26), [Subscript(Name('placeholder_1', Load(), lineno=5, col_offset=27, end_lineno=5, end_col_offset=33), Constant(0, lineno=5, col_offset=34, end_lineno=5, end_col_offset=35), Load(), lineno=5, col_offset=27, end_lineno=5, end_col_offset=36)], [], lineno=5, col_offset=23, end_lineno=5, end_col_offset=37)], lineno=5, col_offset=11, end_lineno=5, end_col_offset=37), [comprehension(Name('placeholder_2', Store(), lineno=5, col_offset=42, end_lineno=5, end_col_offset=45), Name('placeholder_1', Load(), lineno=5, col_offset=49, end_lineno=5, end_col_offset=55), [], 0)], lineno=5, col_offset=10, end_lineno=5, end_col_offset=56)], [], lineno=5, col_offset=7, end_lineno=5, end_col_offset=56), [Raise(Call(Name('ValueError', Load(), lineno=6, col_offset=14, end_lineno=6, end_col_offset=24), [Constant('irregular matrix', lineno=6, col_offset=25, end_lineno=6, end_col_offset=43)], [], lineno=6, col_offset=14, end_lineno=6, end_col_offset=44), lineno=6, col_offset=8, end_lineno=6, end_col_offset=44)], [], lineno=5, col_offset=4, end_lineno=6, end_col_offset=44), Assign([Name('placeholder_3', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=8)], ListComp(Call(Name('max', Load(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=15), [Name('placeholder_2', Load(), lineno=8, col_offset=16, end_lineno=8, end_col_offset=19)], [], lineno=8, col_offset=12, end_lineno=8, end_col_offset=20), [comprehension(Name('placeholder_2', Store(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=28), Name('placeholder_1', Load(), lineno=8, col_offset=32, end_lineno=8, end_col_offset=38), [], 0)], lineno=8, col_offset=11, end_lineno=8, end_col_offset=39), lineno=8, col_offset=4, end_lineno=8, end_col_offset=39), Assign([Name('placeholder_4', Store(), lineno=9, col_offset=4, end_lineno=9, end_col_offset=8)], ListComp(Call(Name('min', Load(), lineno=9, col_offset=12, end_lineno=9, end_col_offset=15), [Name('placeholder_5', Load(), lineno=9, col_offset=16, end_lineno=9, end_col_offset=19)], [], lineno=9, col_offset=12, end_lineno=9, end_col_offset=20), [comprehension(Name('placeholder_5', Store(), lineno=9, col_offset=25, end_lineno=9, end_col_offset=28), Call(Name('zip', Load(), lineno=9, col_offset=32, end_lineno=9, end_col_offset=35), [Starred(Name('placeholder_1', Load(), lineno=9, col_offset=37, end_lineno=9, end_col_offset=43), Load(), lineno=9, col_offset=36, end_lineno=9, end_col_offset=43)], [], lineno=9, col_offset=32, end_lineno=9, end_col_offset=44), [], 0)], lineno=9, col_offset=11, end_lineno=9, end_col_offset=45), lineno=9, col_offset=4, end_lineno=9, end_col_offset=45), Assign([Name('placeholder_6', Store(), lineno=11, col_offset=4, end_lineno=11, end_col_offset=10)], ListComp(Dict([Constant('row', lineno=11, col_offset=15, end_lineno=11, end_col_offset=20), Constant('column', lineno=11, col_offset=33, end_lineno=11, end_col_offset=41)], [BinOp(Name('placeholder_7', Load(), lineno=11, col_offset=22, end_lineno=11, end_col_offset=27), Add(), Constant(1, lineno=11, col_offset=30, end_lineno=11, end_col_offset=31), lineno=11, col_offset=22, end_lineno=11, end_col_offset=31), BinOp(Name('placeholder_9', Load(), lineno=11, col_offset=43, end_lineno=11, end_col_offset=52), Add(), Constant(1, lineno=11, col_offset=55, end_lineno=11, end_col_offset=56), lineno=11, col_offset=43, end_lineno=11, end_col_offset=56)], lineno=11, col_offset=14, end_lineno=11, end_col_offset=57), [comprehension(Tuple([Name('placeholder_7', Store(), lineno=12, col_offset=18, end_lineno=12, end_col_offset=23), Name('placeholder_8', Store(), lineno=12, col_offset=25, end_lineno=12, end_col_offset=26)], Store(), lineno=12, col_offset=18, end_lineno=12, end_col_offset=26), Call(Name('enumerate', Load(), lineno=12, col_offset=30, end_lineno=12, end_col_offset=39), [Name('placeholder_1', Load(), lineno=12, col_offset=40, end_lineno=12, end_col_offset=46)], [], lineno=12, col_offset=30, end_lineno=12, end_col_offset=47), [], 0), comprehension(Tuple([Name('placeholder_9', Store(), lineno=13, col_offset=18, end_lineno=13, end_col_offset=27), Name('placeholder_8', Store(), lineno=13, col_offset=29, end_lineno=13, end_col_offset=30)], Store(), lineno=13, col_offset=18, end_lineno=13, end_col_offset=30), Call(Name('enumerate', Load(), lineno=13, col_offset=34, end_lineno=13, end_col_offset=43), [Subscript(Name('placeholder_1', Load(), lineno=13, col_offset=44, end_lineno=13, end_col_offset=50), Constant(0, lineno=13, col_offset=51, end_lineno=13, end_col_offset=52), Load(), lineno=13, col_offset=44, end_lineno=13, end_col_offset=53)], [], lineno=13, col_offset=34, end_lineno=13, end_col_offset=54), [Compare(Subscript(Name('placeholder_3', Load(), lineno=14, col_offset=17, end_lineno=14, end_col_offset=21), Name('placeholder_7', Load(), lineno=14, col_offset=22, end_lineno=14, end_col_offset=27), Load(), lineno=14, col_offset=17, end_lineno=14, end_col_offset=28), [Eq()], [Subscript(Name('placeholder_4', Load(), lineno=14, col_offset=32, end_lineno=14, end_col_offset=36), Name('placeholder_9', Load(), lineno=14, col_offset=37, end_lineno=14, end_col_offset=46), Load(), lineno=14, col_offset=32, end_lineno=14, end_col_offset=47)], lineno=14, col_offset=17, end_lineno=14, end_col_offset=47)], 0)], lineno=11, col_offset=13, end_lineno=14, end_col_offset=48), lineno=11, col_offset=4, end_lineno=14, end_col_offset=48), Return(BoolOp(Or(), [Name('placeholder_6', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=17), List([], Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=23)], lineno=16, col_offset=11, end_lineno=16, end_col_offset=23), lineno=16, col_offset=4, end_lineno=16, end_col_offset=23)], [], lineno=1, col_offset=0, end_lineno=16, end_col_offset=23)], []) \ No newline at end of file diff --git a/test/practice-saddle-points/saddle_points.py b/test/practice-saddle-points/saddle_points.py new file mode 100644 index 0000000..ff11e68 --- /dev/null +++ b/test/practice-saddle-points/saddle_points.py @@ -0,0 +1,16 @@ +def saddle_points(matrix): + if not matrix: + return [] + + if any(len(row) != len(matrix[0]) for row in matrix): + raise ValueError('irregular matrix') + + mmax = [max(row) for row in matrix] + mmin = [min(col) for col in zip(*matrix)] + + points = [{'row': index + 1, 'column': col_index + 1} + for index, _ in enumerate(matrix) + for col_index, _ in enumerate(matrix[0]) + if mmax[index] == mmin[col_index]] + + return points or [] diff --git a/test/practice-satellite/.meta/config.json b/test/practice-satellite/.meta/config.json new file mode 100644 index 0000000..19dadf3 --- /dev/null +++ b/test/practice-satellite/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "AnAccountForReportingBugs" + ], + "contributors": [ + "aaditkamat", + "BethanyG", + "cmccandless", + "Dog", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "satellite.py" + ], + "test": [ + "satellite_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Rebuild binary trees from pre-order and in-order traversals." +} diff --git a/test/practice-satellite/mapping.json b/test/practice-satellite/mapping.json new file mode 100644 index 0000000..2aeeeb7 --- /dev/null +++ b/test/practice-satellite/mapping.json @@ -0,0 +1,14 @@ +{ + "placeholder_0": "tree_from_traversals", + "placeholder_1": "preorder", + "placeholder_2": "inorder", + "placeholder_3": "value", + "placeholder_4": "index", + "placeholder_5": "left_inorder", + "placeholder_6": "right_inorder", + "placeholder_7": "left_preorder", + "placeholder_8": "idx", + "placeholder_9": "right_preorder", + "placeholder_10": "left", + "placeholder_11": "right" +} \ No newline at end of file diff --git a/test/practice-satellite/representation.json b/test/practice-satellite/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-satellite/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-satellite/representation.out b/test/practice-satellite/representation.out new file mode 100644 index 0000000..1494a3e --- /dev/null +++ b/test/practice-satellite/representation.out @@ -0,0 +1,1631 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + if len(placeholder_1) != len(placeholder_2): + raise ValueError("traversals must have the same length") + if set(placeholder_1) != set(placeholder_2): + raise ValueError("traversals must have the same elements") + if len(set(placeholder_1)) != len(placeholder_1) != len(set(placeholder_2)): + raise ValueError("traversals must contain unique items") + if not placeholder_1: + return {} + placeholder_3 = placeholder_1.pop(0) + placeholder_4 = placeholder_2.placeholder_4(placeholder_3) + placeholder_5, placeholder_6 = ( + placeholder_2[:placeholder_4], + placeholder_2[placeholder_4 + 1 :], + ) + placeholder_7 = [ + placeholder_8 + for placeholder_8 in placeholder_1 + if placeholder_8 in placeholder_5 + ] + placeholder_9 = [ + placeholder_8 + for placeholder_8 in placeholder_1 + if placeholder_8 in placeholder_6 + ] + placeholder_10 = placeholder_0(placeholder_7, placeholder_5) + placeholder_11 = placeholder_0(placeholder_9, placeholder_6) + return {"v": placeholder_3, "l": placeholder_10, "r": placeholder_11} + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'tree_from_traversals', + arguments( + [], + [ + arg( + 'preorder', + lineno=1, + col_offset=25, + end_lineno=1, + end_col_offset=33), + arg( + 'inorder', + lineno=1, + col_offset=35, + end_lineno=1, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=10), + [ + Name( + 'preorder', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=19)], + [], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=27), + [ + Name( + 'inorder', + Load(), + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=35)], + [], + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=36)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'traversals must have the same length', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=63)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=64), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=64)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=64), + If( + Compare( + Call( + Name( + 'set', + Load(), + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=10), + [ + Name( + 'preorder', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=19)], + [], + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=20), + [ + NotEq()], + [ + Call( + Name( + 'set', + Load(), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=27), + [ + Name( + 'inorder', + Load(), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=35)], + [], + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=36)], + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=24), + [ + Constant( + 'traversals must have the same elements', + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=65)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=66), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=66)], + [], + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=66), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=10), + [ + Call( + Name( + 'set', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=14), + [ + Name( + 'preorder', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=23)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=24)], + [], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=25), + [ + NotEq(), + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=32), + [ + Name( + 'preorder', + Load(), + lineno=6, + col_offset=33, + end_lineno=6, + end_col_offset=41)], + [], + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=42), + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=46, + end_lineno=6, + end_col_offset=49), + [ + Call( + Name( + 'set', + Load(), + lineno=6, + col_offset=50, + end_lineno=6, + end_col_offset=53), + [ + Name( + 'inorder', + Load(), + lineno=6, + col_offset=54, + end_lineno=6, + end_col_offset=61)], + [], + lineno=6, + col_offset=50, + end_lineno=6, + end_col_offset=62)], + [], + lineno=6, + col_offset=46, + end_lineno=6, + end_col_offset=63)], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=63), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'traversals must contain unique items', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=63)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=64), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=64)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=64), + If( + UnaryOp( + Not(), + Name( + 'preorder', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=19), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=19), + [ + Return( + Dict( + [], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=17), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=17)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=17), + Assign( + [ + Name( + 'value', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=9)], + Call( + Attribute( + Name( + 'preorder', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=20), + 'pop', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=24), + [ + Constant( + 0, + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=26)], + [], + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=27), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=27), + Assign( + [ + Name( + 'index', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=9)], + Call( + Attribute( + Name( + 'inorder', + Load(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=19), + 'index', + Load(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=25), + [ + Name( + 'value', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=31)], + [], + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=32), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=32), + Assign( + [ + Tuple( + [ + Name( + 'left_inorder', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=16), + Name( + 'right_inorder', + Store(), + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=31)], + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=31)], + Tuple( + [ + Subscript( + Name( + 'inorder', + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=41), + Slice( + upper=Name( + 'index', + Load(), + lineno=13, + col_offset=43, + end_lineno=13, + end_col_offset=48), + lineno=13, + col_offset=42, + end_lineno=13, + end_col_offset=48), + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=49), + Subscript( + Name( + 'inorder', + Load(), + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=58), + Slice( + BinOp( + Name( + 'index', + Load(), + lineno=13, + col_offset=59, + end_lineno=13, + end_col_offset=64), + Add(), + Constant( + 1, + lineno=13, + col_offset=65, + end_lineno=13, + end_col_offset=66), + lineno=13, + col_offset=59, + end_lineno=13, + end_col_offset=66), + lineno=13, + col_offset=59, + end_lineno=13, + end_col_offset=67), + Load(), + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=68)], + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=68), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=68), + Assign( + [ + Name( + 'left_preorder', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=17)], + ListComp( + Name( + 'idx', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=24), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=15, + col_offset=29, + end_lineno=15, + end_col_offset=32), + Name( + 'preorder', + Load(), + lineno=15, + col_offset=36, + end_lineno=15, + end_col_offset=44), + [ + Compare( + Name( + 'idx', + Load(), + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=51), + [ + In()], + [ + Name( + 'left_inorder', + Load(), + lineno=15, + col_offset=55, + end_lineno=15, + end_col_offset=67)], + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=67)], + 0)], + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=68), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=68), + Assign( + [ + Name( + 'right_preorder', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=18)], + ListComp( + Name( + 'idx', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=25), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=33), + Name( + 'preorder', + Load(), + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=45), + [ + Compare( + Name( + 'idx', + Load(), + lineno=16, + col_offset=49, + end_lineno=16, + end_col_offset=52), + [ + In()], + [ + Name( + 'right_inorder', + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=69)], + lineno=16, + col_offset=49, + end_lineno=16, + end_col_offset=69)], + 0)], + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=70), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=70), + Assign( + [ + Name( + 'left', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=8)], + Call( + Name( + 'tree_from_traversals', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=31), + [ + Name( + 'left_preorder', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=45), + Name( + 'left_inorder', + Load(), + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=59)], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=60), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=60), + Assign( + [ + Name( + 'right', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=9)], + Call( + Name( + 'tree_from_traversals', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=32), + [ + Name( + 'right_preorder', + Load(), + lineno=19, + col_offset=33, + end_lineno=19, + end_col_offset=47), + Name( + 'right_inorder', + Load(), + lineno=19, + col_offset=49, + end_lineno=19, + end_col_offset=62)], + [], + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=63), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=63), + Return( + Dict( + [ + Constant( + 'v', + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=15), + Constant( + 'l', + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=27), + Constant( + 'r', + lineno=21, + col_offset=35, + end_lineno=21, + end_col_offset=38)], + [ + Name( + 'value', + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=22), + Name( + 'left', + Load(), + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=33), + Name( + 'right', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=45)], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=46), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=46)], + [], + lineno=1, + col_offset=0, + end_lineno=21, + end_col_offset=46)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=25, + end_lineno=1, + end_col_offset=33), + arg( + 'placeholder_2', + lineno=1, + col_offset=35, + end_lineno=1, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=10), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=19)], + [], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=20), + [ + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=27), + [ + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=35)], + [], + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=36)], + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'traversals must have the same length', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=63)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=64), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=64)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=64), + If( + Compare( + Call( + Name( + 'set', + Load(), + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=10), + [ + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=19)], + [], + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=20), + [ + NotEq()], + [ + Call( + Name( + 'set', + Load(), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=27), + [ + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=35)], + [], + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=36)], + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=24), + [ + Constant( + 'traversals must have the same elements', + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=65)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=66), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=66)], + [], + lineno=4, + col_offset=4, + end_lineno=5, + end_col_offset=66), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=10), + [ + Call( + Name( + 'set', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=14), + [ + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=23)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=24)], + [], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=25), + [ + NotEq(), + NotEq()], + [ + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=32), + [ + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=33, + end_lineno=6, + end_col_offset=41)], + [], + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=42), + Call( + Name( + 'len', + Load(), + lineno=6, + col_offset=46, + end_lineno=6, + end_col_offset=49), + [ + Call( + Name( + 'set', + Load(), + lineno=6, + col_offset=50, + end_lineno=6, + end_col_offset=53), + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=54, + end_lineno=6, + end_col_offset=61)], + [], + lineno=6, + col_offset=50, + end_lineno=6, + end_col_offset=62)], + [], + lineno=6, + col_offset=46, + end_lineno=6, + end_col_offset=63)], + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=63), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'traversals must contain unique items', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=63)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=64), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=64)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=64), + If( + UnaryOp( + Not(), + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=19), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=19), + [ + Return( + Dict( + [], + [], + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=17), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=17)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=9)], + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=20), + 'pop', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=24), + [ + Constant( + 0, + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=26)], + [], + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=27), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=9)], + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=19), + 'placeholder_4', + Load(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=25), + [ + Name( + 'placeholder_3', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=31)], + [], + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=32), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=32), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_5', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=16), + Name( + 'placeholder_6', + Store(), + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=31)], + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=31)], + Tuple( + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=41), + Slice( + upper=Name( + 'placeholder_4', + Load(), + lineno=13, + col_offset=43, + end_lineno=13, + end_col_offset=48), + lineno=13, + col_offset=42, + end_lineno=13, + end_col_offset=48), + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=49), + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=58), + Slice( + BinOp( + Name( + 'placeholder_4', + Load(), + lineno=13, + col_offset=59, + end_lineno=13, + end_col_offset=64), + Add(), + Constant( + 1, + lineno=13, + col_offset=65, + end_lineno=13, + end_col_offset=66), + lineno=13, + col_offset=59, + end_lineno=13, + end_col_offset=66), + lineno=13, + col_offset=59, + end_lineno=13, + end_col_offset=67), + Load(), + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=68)], + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=68), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=68), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=17)], + ListComp( + Name( + 'placeholder_8', + Load(), + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=24), + [ + comprehension( + Name( + 'placeholder_8', + Store(), + lineno=15, + col_offset=29, + end_lineno=15, + end_col_offset=32), + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=36, + end_lineno=15, + end_col_offset=44), + [ + Compare( + Name( + 'placeholder_8', + Load(), + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=51), + [ + In()], + [ + Name( + 'placeholder_5', + Load(), + lineno=15, + col_offset=55, + end_lineno=15, + end_col_offset=67)], + lineno=15, + col_offset=48, + end_lineno=15, + end_col_offset=67)], + 0)], + lineno=15, + col_offset=20, + end_lineno=15, + end_col_offset=68), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=68), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=18)], + ListComp( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=25), + [ + comprehension( + Name( + 'placeholder_8', + Store(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=33), + Name( + 'placeholder_1', + Load(), + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=45), + [ + Compare( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=49, + end_lineno=16, + end_col_offset=52), + [ + In()], + [ + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=69)], + lineno=16, + col_offset=49, + end_lineno=16, + end_col_offset=69)], + 0)], + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=70), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=70), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=8)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=31), + [ + Name( + 'placeholder_7', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=45), + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=47, + end_lineno=18, + end_col_offset=59)], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=60), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=60), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=9)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=32), + [ + Name( + 'placeholder_9', + Load(), + lineno=19, + col_offset=33, + end_lineno=19, + end_col_offset=47), + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=49, + end_lineno=19, + end_col_offset=62)], + [], + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=63), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=63), + Return( + Dict( + [ + Constant( + 'v', + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=15), + Constant( + 'l', + lineno=21, + col_offset=24, + end_lineno=21, + end_col_offset=27), + Constant( + 'r', + lineno=21, + col_offset=35, + end_lineno=21, + end_col_offset=38)], + [ + Name( + 'placeholder_3', + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=22), + Name( + 'placeholder_10', + Load(), + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=33), + Name( + 'placeholder_11', + Load(), + lineno=21, + col_offset=40, + end_lineno=21, + end_col_offset=45)], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=46), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=46)], + [], + lineno=1, + col_offset=0, + end_lineno=21, + end_col_offset=46)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-satellite/representation.txt b/test/practice-satellite/representation.txt new file mode 100644 index 0000000..3f6c632 --- /dev/null +++ b/test/practice-satellite/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=25, end_lineno=1, end_col_offset=33), arg('placeholder_2', lineno=1, col_offset=35, end_lineno=1, end_col_offset=42)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Call(Name('len', Load(), lineno=2, col_offset=7, end_lineno=2, end_col_offset=10), [Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=19)], [], lineno=2, col_offset=7, end_lineno=2, end_col_offset=20), [NotEq()], [Call(Name('len', Load(), lineno=2, col_offset=24, end_lineno=2, end_col_offset=27), [Name('placeholder_2', Load(), lineno=2, col_offset=28, end_lineno=2, end_col_offset=35)], [], lineno=2, col_offset=24, end_lineno=2, end_col_offset=36)], lineno=2, col_offset=7, end_lineno=2, end_col_offset=36), [Raise(Call(Name('ValueError', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=24), [Constant('traversals must have the same length', lineno=3, col_offset=25, end_lineno=3, end_col_offset=63)], [], lineno=3, col_offset=14, end_lineno=3, end_col_offset=64), lineno=3, col_offset=8, end_lineno=3, end_col_offset=64)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=64), If(Compare(Call(Name('set', Load(), lineno=4, col_offset=7, end_lineno=4, end_col_offset=10), [Name('placeholder_1', Load(), lineno=4, col_offset=11, end_lineno=4, end_col_offset=19)], [], lineno=4, col_offset=7, end_lineno=4, end_col_offset=20), [NotEq()], [Call(Name('set', Load(), lineno=4, col_offset=24, end_lineno=4, end_col_offset=27), [Name('placeholder_2', Load(), lineno=4, col_offset=28, end_lineno=4, end_col_offset=35)], [], lineno=4, col_offset=24, end_lineno=4, end_col_offset=36)], lineno=4, col_offset=7, end_lineno=4, end_col_offset=36), [Raise(Call(Name('ValueError', Load(), lineno=5, col_offset=14, end_lineno=5, end_col_offset=24), [Constant('traversals must have the same elements', lineno=5, col_offset=25, end_lineno=5, end_col_offset=65)], [], lineno=5, col_offset=14, end_lineno=5, end_col_offset=66), lineno=5, col_offset=8, end_lineno=5, end_col_offset=66)], [], lineno=4, col_offset=4, end_lineno=5, end_col_offset=66), If(Compare(Call(Name('len', Load(), lineno=6, col_offset=7, end_lineno=6, end_col_offset=10), [Call(Name('set', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=14), [Name('placeholder_1', Load(), lineno=6, col_offset=15, end_lineno=6, end_col_offset=23)], [], lineno=6, col_offset=11, end_lineno=6, end_col_offset=24)], [], lineno=6, col_offset=7, end_lineno=6, end_col_offset=25), [NotEq(), NotEq()], [Call(Name('len', Load(), lineno=6, col_offset=29, end_lineno=6, end_col_offset=32), [Name('placeholder_1', Load(), lineno=6, col_offset=33, end_lineno=6, end_col_offset=41)], [], lineno=6, col_offset=29, end_lineno=6, end_col_offset=42), Call(Name('len', Load(), lineno=6, col_offset=46, end_lineno=6, end_col_offset=49), [Call(Name('set', Load(), lineno=6, col_offset=50, end_lineno=6, end_col_offset=53), [Name('placeholder_2', Load(), lineno=6, col_offset=54, end_lineno=6, end_col_offset=61)], [], lineno=6, col_offset=50, end_lineno=6, end_col_offset=62)], [], lineno=6, col_offset=46, end_lineno=6, end_col_offset=63)], lineno=6, col_offset=7, end_lineno=6, end_col_offset=63), [Raise(Call(Name('ValueError', Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=24), [Constant('traversals must contain unique items', lineno=7, col_offset=25, end_lineno=7, end_col_offset=63)], [], lineno=7, col_offset=14, end_lineno=7, end_col_offset=64), lineno=7, col_offset=8, end_lineno=7, end_col_offset=64)], [], lineno=6, col_offset=4, end_lineno=7, end_col_offset=64), If(UnaryOp(Not(), Name('placeholder_1', Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=19), lineno=8, col_offset=7, end_lineno=8, end_col_offset=19), [Return(Dict([], [], lineno=9, col_offset=15, end_lineno=9, end_col_offset=17), lineno=9, col_offset=8, end_lineno=9, end_col_offset=17)], [], lineno=8, col_offset=4, end_lineno=9, end_col_offset=17), Assign([Name('placeholder_3', Store(), lineno=11, col_offset=4, end_lineno=11, end_col_offset=9)], Call(Attribute(Name('placeholder_1', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=20), 'pop', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=24), [Constant(0, lineno=11, col_offset=25, end_lineno=11, end_col_offset=26)], [], lineno=11, col_offset=12, end_lineno=11, end_col_offset=27), lineno=11, col_offset=4, end_lineno=11, end_col_offset=27), Assign([Name('placeholder_4', Store(), lineno=12, col_offset=4, end_lineno=12, end_col_offset=9)], Call(Attribute(Name('placeholder_2', Load(), lineno=12, col_offset=12, end_lineno=12, end_col_offset=19), 'placeholder_4', Load(), lineno=12, col_offset=12, end_lineno=12, end_col_offset=25), [Name('placeholder_3', Load(), lineno=12, col_offset=26, end_lineno=12, end_col_offset=31)], [], lineno=12, col_offset=12, end_lineno=12, end_col_offset=32), lineno=12, col_offset=4, end_lineno=12, end_col_offset=32), Assign([Tuple([Name('placeholder_5', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=16), Name('placeholder_6', Store(), lineno=13, col_offset=18, end_lineno=13, end_col_offset=31)], Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=31)], Tuple([Subscript(Name('placeholder_2', Load(), lineno=13, col_offset=34, end_lineno=13, end_col_offset=41), Slice(upper=Name('placeholder_4', Load(), lineno=13, col_offset=43, end_lineno=13, end_col_offset=48), lineno=13, col_offset=42, end_lineno=13, end_col_offset=48), Load(), lineno=13, col_offset=34, end_lineno=13, end_col_offset=49), Subscript(Name('placeholder_2', Load(), lineno=13, col_offset=51, end_lineno=13, end_col_offset=58), Slice(BinOp(Name('placeholder_4', Load(), lineno=13, col_offset=59, end_lineno=13, end_col_offset=64), Add(), Constant(1, lineno=13, col_offset=65, end_lineno=13, end_col_offset=66), lineno=13, col_offset=59, end_lineno=13, end_col_offset=66), lineno=13, col_offset=59, end_lineno=13, end_col_offset=67), Load(), lineno=13, col_offset=51, end_lineno=13, end_col_offset=68)], Load(), lineno=13, col_offset=34, end_lineno=13, end_col_offset=68), lineno=13, col_offset=4, end_lineno=13, end_col_offset=68), Assign([Name('placeholder_7', Store(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=17)], ListComp(Name('placeholder_8', Load(), lineno=15, col_offset=21, end_lineno=15, end_col_offset=24), [comprehension(Name('placeholder_8', Store(), lineno=15, col_offset=29, end_lineno=15, end_col_offset=32), Name('placeholder_1', Load(), lineno=15, col_offset=36, end_lineno=15, end_col_offset=44), [Compare(Name('placeholder_8', Load(), lineno=15, col_offset=48, end_lineno=15, end_col_offset=51), [In()], [Name('placeholder_5', Load(), lineno=15, col_offset=55, end_lineno=15, end_col_offset=67)], lineno=15, col_offset=48, end_lineno=15, end_col_offset=67)], 0)], lineno=15, col_offset=20, end_lineno=15, end_col_offset=68), lineno=15, col_offset=4, end_lineno=15, end_col_offset=68), Assign([Name('placeholder_9', Store(), lineno=16, col_offset=4, end_lineno=16, end_col_offset=18)], ListComp(Name('placeholder_8', Load(), lineno=16, col_offset=22, end_lineno=16, end_col_offset=25), [comprehension(Name('placeholder_8', Store(), lineno=16, col_offset=30, end_lineno=16, end_col_offset=33), Name('placeholder_1', Load(), lineno=16, col_offset=37, end_lineno=16, end_col_offset=45), [Compare(Name('placeholder_8', Load(), lineno=16, col_offset=49, end_lineno=16, end_col_offset=52), [In()], [Name('placeholder_6', Load(), lineno=16, col_offset=56, end_lineno=16, end_col_offset=69)], lineno=16, col_offset=49, end_lineno=16, end_col_offset=69)], 0)], lineno=16, col_offset=21, end_lineno=16, end_col_offset=70), lineno=16, col_offset=4, end_lineno=16, end_col_offset=70), Assign([Name('placeholder_10', Store(), lineno=18, col_offset=4, end_lineno=18, end_col_offset=8)], Call(Name('placeholder_0', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=31), [Name('placeholder_7', Load(), lineno=18, col_offset=32, end_lineno=18, end_col_offset=45), Name('placeholder_5', Load(), lineno=18, col_offset=47, end_lineno=18, end_col_offset=59)], [], lineno=18, col_offset=11, end_lineno=18, end_col_offset=60), lineno=18, col_offset=4, end_lineno=18, end_col_offset=60), Assign([Name('placeholder_11', Store(), lineno=19, col_offset=4, end_lineno=19, end_col_offset=9)], Call(Name('placeholder_0', Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=32), [Name('placeholder_9', Load(), lineno=19, col_offset=33, end_lineno=19, end_col_offset=47), Name('placeholder_6', Load(), lineno=19, col_offset=49, end_lineno=19, end_col_offset=62)], [], lineno=19, col_offset=12, end_lineno=19, end_col_offset=63), lineno=19, col_offset=4, end_lineno=19, end_col_offset=63), Return(Dict([Constant('v', lineno=21, col_offset=12, end_lineno=21, end_col_offset=15), Constant('l', lineno=21, col_offset=24, end_lineno=21, end_col_offset=27), Constant('r', lineno=21, col_offset=35, end_lineno=21, end_col_offset=38)], [Name('placeholder_3', Load(), lineno=21, col_offset=17, end_lineno=21, end_col_offset=22), Name('placeholder_10', Load(), lineno=21, col_offset=29, end_lineno=21, end_col_offset=33), Name('placeholder_11', Load(), lineno=21, col_offset=40, end_lineno=21, end_col_offset=45)], lineno=21, col_offset=11, end_lineno=21, end_col_offset=46), lineno=21, col_offset=4, end_lineno=21, end_col_offset=46)], [], lineno=1, col_offset=0, end_lineno=21, end_col_offset=46)], []) \ No newline at end of file diff --git a/test/practice-satellite/satellite.py b/test/practice-satellite/satellite.py new file mode 100644 index 0000000..310a89a --- /dev/null +++ b/test/practice-satellite/satellite.py @@ -0,0 +1,21 @@ +def tree_from_traversals(preorder, inorder): + if len(preorder) != len(inorder): + raise ValueError('traversals must have the same length') + if set(preorder) != set(inorder): + raise ValueError('traversals must have the same elements') + if len(set(preorder)) != len(preorder) != len(set(inorder)): + raise ValueError('traversals must contain unique items') + if not preorder: + return {} + + value = preorder.pop(0) + index = inorder.index(value) + left_inorder, right_inorder = inorder[:index], inorder[index+1:] + + left_preorder = [idx for idx in preorder if idx in left_inorder] + right_preorder = [idx for idx in preorder if idx in right_inorder] + + left = tree_from_traversals(left_preorder, left_inorder) + right = tree_from_traversals(right_preorder, right_inorder) + + return {'v': value, 'l': left, 'r': right} diff --git a/test/practice-say/.meta/additional_tests.json b/test/practice-say/.meta/additional_tests.json new file mode 100644 index 0000000..dffca11 --- /dev/null +++ b/test/practice-say/.meta/additional_tests.json @@ -0,0 +1,12 @@ +{ + "cases": [ + { + "description": "one hundred seventy", + "property": "say", + "input": { + "number": 170 + }, + "expected": "one hundred seventy" + } + ] +} diff --git a/test/practice-say/.meta/config.json b/test/practice-say/.meta/config.json new file mode 100644 index 0000000..1090a04 --- /dev/null +++ b/test/practice-say/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "AndrejTS", + "cmccandless", + "csabella", + "Dog", + "fortrieb", + "gabriellhrn", + "ikhadykin", + "mandel01", + "N-Parsons", + "pheanex", + "pranasziaukas", + "tqa236", + "tsamoglou" + ], + "files": { + "solution": [ + "say.py" + ], + "test": [ + "say_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a number from 0 to 999,999,999,999, spell out that number in English.", + "source": "A variation on the JavaRanch CattleDrive, Assignment 4", + "source_url": "https://coderanch.com/wiki/718804" +} diff --git a/test/practice-say/mapping.json b/test/practice-say/mapping.json new file mode 100644 index 0000000..3a42bff --- /dev/null +++ b/test/practice-say/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "say", + "placeholder_1": "number", + "placeholder_2": "small", + "placeholder_3": "tens", + "placeholder_4": "kilo", + "placeholder_5": "mega", + "placeholder_6": "giga", + "placeholder_7": "tera" +} \ No newline at end of file diff --git a/test/practice-say/representation.json b/test/practice-say/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-say/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-say/representation.out b/test/practice-say/representation.out new file mode 100644 index 0000000..1ed8ee1 --- /dev/null +++ b/test/practice-say/representation.out @@ -0,0 +1,3191 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = dict( + enumerate( + ( + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "ten", + "eleven", + "twelve", + "thirteen", + "fourteen", + "fifteen", + "sixteen", + "seventeen", + "eighteen", + "nineteen", + ) + ) + ) + placeholder_3 = { + 20: "twenty", + 30: "thirty", + 40: "forty", + 50: "fifty", + 60: "sixty", + 70: "seventy", + 80: "eighty", + 90: "ninety", + } + placeholder_4 = 1000.0 + placeholder_5 = 1000000.0 + placeholder_6 = 1000000000.0 + placeholder_7 = 1000000000000.0 + if placeholder_1 < 0: + raise ValueError("input out of range") + if placeholder_1 >= placeholder_7: + raise ValueError("input out of range") + if placeholder_1 < 20: + return placeholder_2[placeholder_1] + if placeholder_1 < 100: + if placeholder_1 % 10 == 0: + return placeholder_3[placeholder_1] + return ( + placeholder_3[placeholder_1 // 10 * 10] + + "-" + + placeholder_2[placeholder_1 % 10] + ) + if placeholder_1 < placeholder_4: + if placeholder_1 % 100 == 0: + return placeholder_2[placeholder_1 // 100] + " hundred" + return ( + placeholder_2[placeholder_1 // 100] + + " hundred " + + placeholder_0(placeholder_1 % 100) + ) + if placeholder_1 < placeholder_5: + if placeholder_1 % placeholder_4 == 0: + return placeholder_0(placeholder_1 // placeholder_4) + " thousand" + return ( + placeholder_0(placeholder_1 // placeholder_4) + + " thousand " + + placeholder_0(placeholder_1 % placeholder_4) + ) + if placeholder_1 < placeholder_6: + if placeholder_1 % placeholder_5 == 0: + return placeholder_0(placeholder_1 // placeholder_5) + " million" + return ( + placeholder_0(placeholder_1 // placeholder_5) + + " million " + + placeholder_0(placeholder_1 % placeholder_5) + ) + if placeholder_1 % placeholder_6 == 0: + return placeholder_0(placeholder_1 // placeholder_6) + " billion" + return ( + placeholder_0(placeholder_1 // placeholder_6) + + " billion " + + placeholder_0(placeholder_1 % placeholder_6) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'say', + arguments( + [], + [ + arg( + 'number', + lineno=1, + col_offset=8, + end_lineno=1, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'small', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9)], + Call( + Name( + 'dict', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=16), + [ + Call( + Name( + 'enumerate', + Load(), + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=26), + [ + Tuple( + [ + Constant( + 'zero', + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=18), + Constant( + 'one', + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=25), + Constant( + 'two', + lineno=3, + col_offset=27, + end_lineno=3, + end_col_offset=32), + Constant( + 'three', + lineno=3, + col_offset=34, + end_lineno=3, + end_col_offset=41), + Constant( + 'four', + lineno=3, + col_offset=43, + end_lineno=3, + end_col_offset=49), + Constant( + 'five', + lineno=3, + col_offset=51, + end_lineno=3, + end_col_offset=57), + Constant( + 'six', + lineno=3, + col_offset=59, + end_lineno=3, + end_col_offset=64), + Constant( + 'seven', + lineno=3, + col_offset=66, + end_lineno=3, + end_col_offset=73), + Constant( + 'eight', + lineno=3, + col_offset=75, + end_lineno=3, + end_col_offset=82), + Constant( + 'nine', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=18), + Constant( + 'ten', + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=25), + Constant( + 'eleven', + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=35), + Constant( + 'twelve', + lineno=4, + col_offset=37, + end_lineno=4, + end_col_offset=45), + Constant( + 'thirteen', + lineno=4, + col_offset=47, + end_lineno=4, + end_col_offset=57), + Constant( + 'fourteen', + lineno=4, + col_offset=59, + end_lineno=4, + end_col_offset=69), + Constant( + 'fifteen', + lineno=4, + col_offset=71, + end_lineno=4, + end_col_offset=80), + Constant( + 'sixteen', + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=21), + Constant( + 'seventeen', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=34), + Constant( + 'eighteen', + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=46), + Constant( + 'nineteen', + lineno=5, + col_offset=48, + end_lineno=5, + end_col_offset=58)], + Load(), + lineno=2, + col_offset=27, + end_lineno=5, + end_col_offset=59)], + [], + lineno=2, + col_offset=17, + end_lineno=5, + end_col_offset=60)], + [], + lineno=2, + col_offset=12, + end_lineno=5, + end_col_offset=61), + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=61), + Assign( + [ + Name( + 'tens', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=8)], + Dict( + [ + Constant( + 20, + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=14), + Constant( + 30, + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=28), + Constant( + 40, + lineno=7, + col_offset=40, + end_lineno=7, + end_col_offset=42), + Constant( + 50, + lineno=7, + col_offset=53, + end_lineno=7, + end_col_offset=55), + Constant( + 60, + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=14), + Constant( + 70, + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=27), + Constant( + 80, + lineno=8, + col_offset=40, + end_lineno=8, + end_col_offset=42), + Constant( + 90, + lineno=8, + col_offset=54, + end_lineno=8, + end_col_offset=56)], + [ + Constant( + 'twenty', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=24), + Constant( + 'thirty', + lineno=7, + col_offset=30, + end_lineno=7, + end_col_offset=38), + Constant( + 'forty', + lineno=7, + col_offset=44, + end_lineno=7, + end_col_offset=51), + Constant( + 'fifty', + lineno=7, + col_offset=57, + end_lineno=7, + end_col_offset=64), + Constant( + 'sixty', + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=23), + Constant( + 'seventy', + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=38), + Constant( + 'eighty', + lineno=8, + col_offset=44, + end_lineno=8, + end_col_offset=52), + Constant( + 'ninety', + lineno=8, + col_offset=58, + end_lineno=8, + end_col_offset=66)], + lineno=7, + col_offset=11, + end_lineno=8, + end_col_offset=67), + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=67), + Assign( + [ + Name( + 'kilo', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=8)], + Constant( + 1000.0, + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=14), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14), + Assign( + [ + Name( + 'mega', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=8)], + Constant( + 1000000.0, + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=14), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=14), + Assign( + [ + Name( + 'giga', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=8)], + Constant( + 1000000000.0, + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=14), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=14), + Assign( + [ + Name( + 'tera', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=8)], + Constant( + 1000000000000.0, + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=15), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=15), + If( + Compare( + Name( + 'number', + Load(), + lineno=15, + col_offset=7, + end_lineno=15, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 0, + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=17)], + lineno=15, + col_offset=7, + end_lineno=15, + end_col_offset=17), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=24), + [ + Constant( + 'input out of range', + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=45)], + [], + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=46), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=46)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=46), + If( + Compare( + Name( + 'number', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=13), + [ + GtE()], + [ + Name( + 'tera', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=21), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + Constant( + 'input out of range', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=45)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=46), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=46)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=46), + If( + Compare( + Name( + 'number', + Load(), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 20, + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=18)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=18), + [ + Return( + Subscript( + Name( + 'small', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=20), + Name( + 'number', + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=27), + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=28), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=28)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=28), + If( + Compare( + Name( + 'number', + Load(), + lineno=23, + col_offset=7, + end_lineno=23, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 100, + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=19)], + lineno=23, + col_offset=7, + end_lineno=23, + end_col_offset=19), + [ + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=17), + Mod(), + Constant( + 10, + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=22), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=27), + [ + Return( + Subscript( + Name( + 'tens', + Load(), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=23), + Name( + 'number', + Load(), + lineno=25, + col_offset=24, + end_lineno=25, + end_col_offset=30), + Load(), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=31), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=31)], + [], + lineno=24, + col_offset=8, + end_lineno=25, + end_col_offset=31), + Return( + BinOp( + BinOp( + Subscript( + Name( + 'tens', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=19), + BinOp( + BinOp( + Name( + 'number', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=26), + FloorDiv(), + Constant( + 10, + lineno=26, + col_offset=30, + end_lineno=26, + end_col_offset=32), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=32), + Mult(), + Constant( + 10, + lineno=26, + col_offset=35, + end_lineno=26, + end_col_offset=37), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=37), + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=38), + Add(), + Constant( + '-', + lineno=26, + col_offset=41, + end_lineno=26, + end_col_offset=44), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=44), + Add(), + Subscript( + Name( + 'small', + Load(), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=52), + BinOp( + Name( + 'number', + Load(), + lineno=26, + col_offset=53, + end_lineno=26, + end_col_offset=59), + Mod(), + Constant( + 10, + lineno=26, + col_offset=62, + end_lineno=26, + end_col_offset=64), + lineno=26, + col_offset=53, + end_lineno=26, + end_col_offset=64), + Load(), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=65), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=65), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=65)], + [], + lineno=23, + col_offset=4, + end_lineno=26, + end_col_offset=65), + If( + Compare( + Name( + 'number', + Load(), + lineno=28, + col_offset=7, + end_lineno=28, + end_col_offset=13), + [ + Lt()], + [ + Name( + 'kilo', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=20)], + lineno=28, + col_offset=7, + end_lineno=28, + end_col_offset=20), + [ + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=17), + Mod(), + Constant( + 100, + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=23), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=23), + [ + Eq()], + [ + Constant( + 0, + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=28)], + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=28), + [ + Return( + BinOp( + Subscript( + Name( + 'small', + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=24), + BinOp( + Name( + 'number', + Load(), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=31), + FloorDiv(), + Constant( + 100, + lineno=30, + col_offset=35, + end_lineno=30, + end_col_offset=38), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=38), + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=39), + Add(), + Constant( + ' hundred', + lineno=30, + col_offset=42, + end_lineno=30, + end_col_offset=52), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=52), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=52)], + [], + lineno=29, + col_offset=8, + end_lineno=30, + end_col_offset=52), + Return( + BinOp( + BinOp( + Subscript( + Name( + 'small', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=20), + BinOp( + Name( + 'number', + Load(), + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=27), + FloorDiv(), + Constant( + 100, + lineno=31, + col_offset=31, + end_lineno=31, + end_col_offset=34), + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=34), + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=35), + Add(), + Constant( + ' hundred ', + lineno=31, + col_offset=38, + end_lineno=31, + end_col_offset=49), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=49), + Add(), + Call( + Name( + 'say', + Load(), + lineno=31, + col_offset=52, + end_lineno=31, + end_col_offset=55), + [ + BinOp( + Name( + 'number', + Load(), + lineno=31, + col_offset=56, + end_lineno=31, + end_col_offset=62), + Mod(), + Constant( + 100, + lineno=31, + col_offset=65, + end_lineno=31, + end_col_offset=68), + lineno=31, + col_offset=56, + end_lineno=31, + end_col_offset=68)], + [], + lineno=31, + col_offset=52, + end_lineno=31, + end_col_offset=69), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=69), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=69)], + [], + lineno=28, + col_offset=4, + end_lineno=31, + end_col_offset=69), + If( + Compare( + Name( + 'number', + Load(), + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=13), + [ + Lt()], + [ + Name( + 'mega', + Load(), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=20)], + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=20), + [ + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=17), + Mod(), + Name( + 'kilo', + Load(), + lineno=34, + col_offset=20, + end_lineno=34, + end_col_offset=24), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=24), + [ + Eq()], + [ + Constant( + 0, + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=29)], + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=29), + [ + Return( + BinOp( + Call( + Name( + 'say', + Load(), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=22), + [ + BinOp( + Name( + 'number', + Load(), + lineno=35, + col_offset=23, + end_lineno=35, + end_col_offset=29), + FloorDiv(), + Name( + 'kilo', + Load(), + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=37), + lineno=35, + col_offset=23, + end_lineno=35, + end_col_offset=37)], + [], + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=38), + Add(), + Constant( + ' thousand', + lineno=35, + col_offset=41, + end_lineno=35, + end_col_offset=52), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=52), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=52)], + [], + lineno=34, + col_offset=8, + end_lineno=35, + end_col_offset=52), + Return( + BinOp( + BinOp( + Call( + Name( + 'say', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=18), + [ + BinOp( + Name( + 'number', + Load(), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=25), + FloorDiv(), + Name( + 'kilo', + Load(), + lineno=36, + col_offset=29, + end_lineno=36, + end_col_offset=33), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=33)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=34), + Add(), + Constant( + ' thousand ', + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=49), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=49), + Add(), + Call( + Name( + 'say', + Load(), + lineno=36, + col_offset=52, + end_lineno=36, + end_col_offset=55), + [ + BinOp( + Name( + 'number', + Load(), + lineno=36, + col_offset=56, + end_lineno=36, + end_col_offset=62), + Mod(), + Name( + 'kilo', + Load(), + lineno=36, + col_offset=65, + end_lineno=36, + end_col_offset=69), + lineno=36, + col_offset=56, + end_lineno=36, + end_col_offset=69)], + [], + lineno=36, + col_offset=52, + end_lineno=36, + end_col_offset=70), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=70), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=70)], + [], + lineno=33, + col_offset=4, + end_lineno=36, + end_col_offset=70), + If( + Compare( + Name( + 'number', + Load(), + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=13), + [ + Lt()], + [ + Name( + 'giga', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=20)], + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=20), + [ + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=17), + Mod(), + Name( + 'mega', + Load(), + lineno=39, + col_offset=20, + end_lineno=39, + end_col_offset=24), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=24), + [ + Eq()], + [ + Constant( + 0, + lineno=39, + col_offset=28, + end_lineno=39, + end_col_offset=29)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=29), + [ + Return( + BinOp( + Call( + Name( + 'say', + Load(), + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=22), + [ + BinOp( + Name( + 'number', + Load(), + lineno=40, + col_offset=23, + end_lineno=40, + end_col_offset=29), + FloorDiv(), + Name( + 'mega', + Load(), + lineno=40, + col_offset=33, + end_lineno=40, + end_col_offset=37), + lineno=40, + col_offset=23, + end_lineno=40, + end_col_offset=37)], + [], + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=38), + Add(), + Constant( + ' million', + lineno=40, + col_offset=41, + end_lineno=40, + end_col_offset=51), + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=51), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=51)], + [], + lineno=39, + col_offset=8, + end_lineno=40, + end_col_offset=51), + Return( + BinOp( + BinOp( + Call( + Name( + 'say', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=18), + [ + BinOp( + Name( + 'number', + Load(), + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=25), + FloorDiv(), + Name( + 'mega', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=33), + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=33)], + [], + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=34), + Add(), + Constant( + ' million ', + lineno=41, + col_offset=37, + end_lineno=41, + end_col_offset=48), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=48), + Add(), + Call( + Name( + 'say', + Load(), + lineno=41, + col_offset=51, + end_lineno=41, + end_col_offset=54), + [ + BinOp( + Name( + 'number', + Load(), + lineno=41, + col_offset=55, + end_lineno=41, + end_col_offset=61), + Mod(), + Name( + 'mega', + Load(), + lineno=41, + col_offset=64, + end_lineno=41, + end_col_offset=68), + lineno=41, + col_offset=55, + end_lineno=41, + end_col_offset=68)], + [], + lineno=41, + col_offset=51, + end_lineno=41, + end_col_offset=69), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=69), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=69)], + [], + lineno=38, + col_offset=4, + end_lineno=41, + end_col_offset=69), + If( + Compare( + BinOp( + Name( + 'number', + Load(), + lineno=43, + col_offset=7, + end_lineno=43, + end_col_offset=13), + Mod(), + Name( + 'giga', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=20), + lineno=43, + col_offset=7, + end_lineno=43, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 0, + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=25)], + lineno=43, + col_offset=7, + end_lineno=43, + end_col_offset=25), + [ + Return( + BinOp( + Call( + Name( + 'say', + Load(), + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=18), + [ + BinOp( + Name( + 'number', + Load(), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=25), + FloorDiv(), + Name( + 'giga', + Load(), + lineno=44, + col_offset=29, + end_lineno=44, + end_col_offset=33), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=33)], + [], + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=34), + Add(), + Constant( + ' billion', + lineno=44, + col_offset=37, + end_lineno=44, + end_col_offset=47), + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=47), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=47)], + [], + lineno=43, + col_offset=4, + end_lineno=44, + end_col_offset=47), + Return( + BinOp( + BinOp( + Call( + Name( + 'say', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=14), + [ + BinOp( + Name( + 'number', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=21), + FloorDiv(), + Name( + 'giga', + Load(), + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=29), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=29)], + [], + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=30), + Add(), + Constant( + ' billion ', + lineno=45, + col_offset=33, + end_lineno=45, + end_col_offset=44), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=44), + Add(), + Call( + Name( + 'say', + Load(), + lineno=45, + col_offset=47, + end_lineno=45, + end_col_offset=50), + [ + BinOp( + Name( + 'number', + Load(), + lineno=45, + col_offset=51, + end_lineno=45, + end_col_offset=57), + Mod(), + Name( + 'giga', + Load(), + lineno=45, + col_offset=60, + end_lineno=45, + end_col_offset=64), + lineno=45, + col_offset=51, + end_lineno=45, + end_col_offset=64)], + [], + lineno=45, + col_offset=47, + end_lineno=45, + end_col_offset=65), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=65), + lineno=45, + col_offset=4, + end_lineno=45, + end_col_offset=65)], + [], + lineno=1, + col_offset=0, + end_lineno=45, + end_col_offset=65)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=8, + end_lineno=1, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9)], + Call( + Name( + 'dict', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=16), + [ + Call( + Name( + 'enumerate', + Load(), + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=26), + [ + Tuple( + [ + Constant( + 'zero', + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=18), + Constant( + 'one', + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=25), + Constant( + 'two', + lineno=3, + col_offset=27, + end_lineno=3, + end_col_offset=32), + Constant( + 'three', + lineno=3, + col_offset=34, + end_lineno=3, + end_col_offset=41), + Constant( + 'four', + lineno=3, + col_offset=43, + end_lineno=3, + end_col_offset=49), + Constant( + 'five', + lineno=3, + col_offset=51, + end_lineno=3, + end_col_offset=57), + Constant( + 'six', + lineno=3, + col_offset=59, + end_lineno=3, + end_col_offset=64), + Constant( + 'seven', + lineno=3, + col_offset=66, + end_lineno=3, + end_col_offset=73), + Constant( + 'eight', + lineno=3, + col_offset=75, + end_lineno=3, + end_col_offset=82), + Constant( + 'nine', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=18), + Constant( + 'ten', + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=25), + Constant( + 'eleven', + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=35), + Constant( + 'twelve', + lineno=4, + col_offset=37, + end_lineno=4, + end_col_offset=45), + Constant( + 'thirteen', + lineno=4, + col_offset=47, + end_lineno=4, + end_col_offset=57), + Constant( + 'fourteen', + lineno=4, + col_offset=59, + end_lineno=4, + end_col_offset=69), + Constant( + 'fifteen', + lineno=4, + col_offset=71, + end_lineno=4, + end_col_offset=80), + Constant( + 'sixteen', + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=21), + Constant( + 'seventeen', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=34), + Constant( + 'eighteen', + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=46), + Constant( + 'nineteen', + lineno=5, + col_offset=48, + end_lineno=5, + end_col_offset=58)], + Load(), + lineno=2, + col_offset=27, + end_lineno=5, + end_col_offset=59)], + [], + lineno=2, + col_offset=17, + end_lineno=5, + end_col_offset=60)], + [], + lineno=2, + col_offset=12, + end_lineno=5, + end_col_offset=61), + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=61), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=8)], + Dict( + [ + Constant( + 20, + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=14), + Constant( + 30, + lineno=7, + col_offset=26, + end_lineno=7, + end_col_offset=28), + Constant( + 40, + lineno=7, + col_offset=40, + end_lineno=7, + end_col_offset=42), + Constant( + 50, + lineno=7, + col_offset=53, + end_lineno=7, + end_col_offset=55), + Constant( + 60, + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=14), + Constant( + 70, + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=27), + Constant( + 80, + lineno=8, + col_offset=40, + end_lineno=8, + end_col_offset=42), + Constant( + 90, + lineno=8, + col_offset=54, + end_lineno=8, + end_col_offset=56)], + [ + Constant( + 'twenty', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=24), + Constant( + 'thirty', + lineno=7, + col_offset=30, + end_lineno=7, + end_col_offset=38), + Constant( + 'forty', + lineno=7, + col_offset=44, + end_lineno=7, + end_col_offset=51), + Constant( + 'fifty', + lineno=7, + col_offset=57, + end_lineno=7, + end_col_offset=64), + Constant( + 'sixty', + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=23), + Constant( + 'seventy', + lineno=8, + col_offset=29, + end_lineno=8, + end_col_offset=38), + Constant( + 'eighty', + lineno=8, + col_offset=44, + end_lineno=8, + end_col_offset=52), + Constant( + 'ninety', + lineno=8, + col_offset=58, + end_lineno=8, + end_col_offset=66)], + lineno=7, + col_offset=11, + end_lineno=8, + end_col_offset=67), + lineno=7, + col_offset=4, + end_lineno=8, + end_col_offset=67), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=8)], + Constant( + 1000.0, + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=14), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=8)], + Constant( + 1000000.0, + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=14), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=8)], + Constant( + 1000000000.0, + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=14), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=8)], + Constant( + 1000000000000.0, + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=15), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=15), + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=15, + col_offset=7, + end_lineno=15, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 0, + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=17)], + lineno=15, + col_offset=7, + end_lineno=15, + end_col_offset=17), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=24), + [ + Constant( + 'input out of range', + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=45)], + [], + lineno=16, + col_offset=14, + end_lineno=16, + end_col_offset=46), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=46)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=46), + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=13), + [ + GtE()], + [ + Name( + 'placeholder_7', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=21), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + Constant( + 'input out of range', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=45)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=46), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=46)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=46), + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 20, + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=18)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=18), + [ + Return( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=20), + Name( + 'placeholder_1', + Load(), + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=27), + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=28), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=28)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=28), + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=23, + col_offset=7, + end_lineno=23, + end_col_offset=13), + [ + Lt()], + [ + Constant( + 100, + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=19)], + lineno=23, + col_offset=7, + end_lineno=23, + end_col_offset=19), + [ + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=17), + Mod(), + Constant( + 10, + lineno=24, + col_offset=20, + end_lineno=24, + end_col_offset=22), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=22), + [ + Eq()], + [ + Constant( + 0, + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=27)], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=27), + [ + Return( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=23), + Name( + 'placeholder_1', + Load(), + lineno=25, + col_offset=24, + end_lineno=25, + end_col_offset=30), + Load(), + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=31), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=31)], + [], + lineno=24, + col_offset=8, + end_lineno=25, + end_col_offset=31), + Return( + BinOp( + BinOp( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=19), + BinOp( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=26), + FloorDiv(), + Constant( + 10, + lineno=26, + col_offset=30, + end_lineno=26, + end_col_offset=32), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=32), + Mult(), + Constant( + 10, + lineno=26, + col_offset=35, + end_lineno=26, + end_col_offset=37), + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=37), + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=38), + Add(), + Constant( + '-', + lineno=26, + col_offset=41, + end_lineno=26, + end_col_offset=44), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=44), + Add(), + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=52), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=26, + col_offset=53, + end_lineno=26, + end_col_offset=59), + Mod(), + Constant( + 10, + lineno=26, + col_offset=62, + end_lineno=26, + end_col_offset=64), + lineno=26, + col_offset=53, + end_lineno=26, + end_col_offset=64), + Load(), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=65), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=65), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=65)], + [], + lineno=23, + col_offset=4, + end_lineno=26, + end_col_offset=65), + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=28, + col_offset=7, + end_lineno=28, + end_col_offset=13), + [ + Lt()], + [ + Name( + 'placeholder_4', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=20)], + lineno=28, + col_offset=7, + end_lineno=28, + end_col_offset=20), + [ + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=17), + Mod(), + Constant( + 100, + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=23), + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=23), + [ + Eq()], + [ + Constant( + 0, + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=28)], + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=28), + [ + Return( + BinOp( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=24), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=31), + FloorDiv(), + Constant( + 100, + lineno=30, + col_offset=35, + end_lineno=30, + end_col_offset=38), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=38), + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=39), + Add(), + Constant( + ' hundred', + lineno=30, + col_offset=42, + end_lineno=30, + end_col_offset=52), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=52), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=52)], + [], + lineno=29, + col_offset=8, + end_lineno=30, + end_col_offset=52), + Return( + BinOp( + BinOp( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=20), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=27), + FloorDiv(), + Constant( + 100, + lineno=31, + col_offset=31, + end_lineno=31, + end_col_offset=34), + lineno=31, + col_offset=21, + end_lineno=31, + end_col_offset=34), + Load(), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=35), + Add(), + Constant( + ' hundred ', + lineno=31, + col_offset=38, + end_lineno=31, + end_col_offset=49), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=49), + Add(), + Call( + Name( + 'placeholder_0', + Load(), + lineno=31, + col_offset=52, + end_lineno=31, + end_col_offset=55), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=31, + col_offset=56, + end_lineno=31, + end_col_offset=62), + Mod(), + Constant( + 100, + lineno=31, + col_offset=65, + end_lineno=31, + end_col_offset=68), + lineno=31, + col_offset=56, + end_lineno=31, + end_col_offset=68)], + [], + lineno=31, + col_offset=52, + end_lineno=31, + end_col_offset=69), + lineno=31, + col_offset=15, + end_lineno=31, + end_col_offset=69), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=69)], + [], + lineno=28, + col_offset=4, + end_lineno=31, + end_col_offset=69), + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=13), + [ + Lt()], + [ + Name( + 'placeholder_5', + Load(), + lineno=33, + col_offset=16, + end_lineno=33, + end_col_offset=20)], + lineno=33, + col_offset=7, + end_lineno=33, + end_col_offset=20), + [ + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=17), + Mod(), + Name( + 'placeholder_4', + Load(), + lineno=34, + col_offset=20, + end_lineno=34, + end_col_offset=24), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=24), + [ + Eq()], + [ + Constant( + 0, + lineno=34, + col_offset=28, + end_lineno=34, + end_col_offset=29)], + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=29), + [ + Return( + BinOp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=22), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=35, + col_offset=23, + end_lineno=35, + end_col_offset=29), + FloorDiv(), + Name( + 'placeholder_4', + Load(), + lineno=35, + col_offset=33, + end_lineno=35, + end_col_offset=37), + lineno=35, + col_offset=23, + end_lineno=35, + end_col_offset=37)], + [], + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=38), + Add(), + Constant( + ' thousand', + lineno=35, + col_offset=41, + end_lineno=35, + end_col_offset=52), + lineno=35, + col_offset=19, + end_lineno=35, + end_col_offset=52), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=52)], + [], + lineno=34, + col_offset=8, + end_lineno=35, + end_col_offset=52), + Return( + BinOp( + BinOp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=18), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=25), + FloorDiv(), + Name( + 'placeholder_4', + Load(), + lineno=36, + col_offset=29, + end_lineno=36, + end_col_offset=33), + lineno=36, + col_offset=19, + end_lineno=36, + end_col_offset=33)], + [], + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=34), + Add(), + Constant( + ' thousand ', + lineno=36, + col_offset=37, + end_lineno=36, + end_col_offset=49), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=49), + Add(), + Call( + Name( + 'placeholder_0', + Load(), + lineno=36, + col_offset=52, + end_lineno=36, + end_col_offset=55), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=36, + col_offset=56, + end_lineno=36, + end_col_offset=62), + Mod(), + Name( + 'placeholder_4', + Load(), + lineno=36, + col_offset=65, + end_lineno=36, + end_col_offset=69), + lineno=36, + col_offset=56, + end_lineno=36, + end_col_offset=69)], + [], + lineno=36, + col_offset=52, + end_lineno=36, + end_col_offset=70), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=70), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=70)], + [], + lineno=33, + col_offset=4, + end_lineno=36, + end_col_offset=70), + If( + Compare( + Name( + 'placeholder_1', + Load(), + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=13), + [ + Lt()], + [ + Name( + 'placeholder_6', + Load(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=20)], + lineno=38, + col_offset=7, + end_lineno=38, + end_col_offset=20), + [ + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=17), + Mod(), + Name( + 'placeholder_5', + Load(), + lineno=39, + col_offset=20, + end_lineno=39, + end_col_offset=24), + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=24), + [ + Eq()], + [ + Constant( + 0, + lineno=39, + col_offset=28, + end_lineno=39, + end_col_offset=29)], + lineno=39, + col_offset=11, + end_lineno=39, + end_col_offset=29), + [ + Return( + BinOp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=22), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=40, + col_offset=23, + end_lineno=40, + end_col_offset=29), + FloorDiv(), + Name( + 'placeholder_5', + Load(), + lineno=40, + col_offset=33, + end_lineno=40, + end_col_offset=37), + lineno=40, + col_offset=23, + end_lineno=40, + end_col_offset=37)], + [], + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=38), + Add(), + Constant( + ' million', + lineno=40, + col_offset=41, + end_lineno=40, + end_col_offset=51), + lineno=40, + col_offset=19, + end_lineno=40, + end_col_offset=51), + lineno=40, + col_offset=12, + end_lineno=40, + end_col_offset=51)], + [], + lineno=39, + col_offset=8, + end_lineno=40, + end_col_offset=51), + Return( + BinOp( + BinOp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=18), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=25), + FloorDiv(), + Name( + 'placeholder_5', + Load(), + lineno=41, + col_offset=29, + end_lineno=41, + end_col_offset=33), + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=33)], + [], + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=34), + Add(), + Constant( + ' million ', + lineno=41, + col_offset=37, + end_lineno=41, + end_col_offset=48), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=48), + Add(), + Call( + Name( + 'placeholder_0', + Load(), + lineno=41, + col_offset=51, + end_lineno=41, + end_col_offset=54), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=41, + col_offset=55, + end_lineno=41, + end_col_offset=61), + Mod(), + Name( + 'placeholder_5', + Load(), + lineno=41, + col_offset=64, + end_lineno=41, + end_col_offset=68), + lineno=41, + col_offset=55, + end_lineno=41, + end_col_offset=68)], + [], + lineno=41, + col_offset=51, + end_lineno=41, + end_col_offset=69), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=69), + lineno=41, + col_offset=8, + end_lineno=41, + end_col_offset=69)], + [], + lineno=38, + col_offset=4, + end_lineno=41, + end_col_offset=69), + If( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=43, + col_offset=7, + end_lineno=43, + end_col_offset=13), + Mod(), + Name( + 'placeholder_6', + Load(), + lineno=43, + col_offset=16, + end_lineno=43, + end_col_offset=20), + lineno=43, + col_offset=7, + end_lineno=43, + end_col_offset=20), + [ + Eq()], + [ + Constant( + 0, + lineno=43, + col_offset=24, + end_lineno=43, + end_col_offset=25)], + lineno=43, + col_offset=7, + end_lineno=43, + end_col_offset=25), + [ + Return( + BinOp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=18), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=25), + FloorDiv(), + Name( + 'placeholder_6', + Load(), + lineno=44, + col_offset=29, + end_lineno=44, + end_col_offset=33), + lineno=44, + col_offset=19, + end_lineno=44, + end_col_offset=33)], + [], + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=34), + Add(), + Constant( + ' billion', + lineno=44, + col_offset=37, + end_lineno=44, + end_col_offset=47), + lineno=44, + col_offset=15, + end_lineno=44, + end_col_offset=47), + lineno=44, + col_offset=8, + end_lineno=44, + end_col_offset=47)], + [], + lineno=43, + col_offset=4, + end_lineno=44, + end_col_offset=47), + Return( + BinOp( + BinOp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=14), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=21), + FloorDiv(), + Name( + 'placeholder_6', + Load(), + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=29), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=29)], + [], + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=30), + Add(), + Constant( + ' billion ', + lineno=45, + col_offset=33, + end_lineno=45, + end_col_offset=44), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=44), + Add(), + Call( + Name( + 'placeholder_0', + Load(), + lineno=45, + col_offset=47, + end_lineno=45, + end_col_offset=50), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=45, + col_offset=51, + end_lineno=45, + end_col_offset=57), + Mod(), + Name( + 'placeholder_6', + Load(), + lineno=45, + col_offset=60, + end_lineno=45, + end_col_offset=64), + lineno=45, + col_offset=51, + end_lineno=45, + end_col_offset=64)], + [], + lineno=45, + col_offset=47, + end_lineno=45, + end_col_offset=65), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=65), + lineno=45, + col_offset=4, + end_lineno=45, + end_col_offset=65)], + [], + lineno=1, + col_offset=0, + end_lineno=45, + end_col_offset=65)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-say/representation.txt b/test/practice-say/representation.txt new file mode 100644 index 0000000..cbdb26e --- /dev/null +++ b/test/practice-say/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=8, end_lineno=1, end_col_offset=14)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=9)], Call(Name('dict', Load(), lineno=2, col_offset=12, end_lineno=2, end_col_offset=16), [Call(Name('enumerate', Load(), lineno=2, col_offset=17, end_lineno=2, end_col_offset=26), [Tuple([Constant('zero', lineno=3, col_offset=12, end_lineno=3, end_col_offset=18), Constant('one', lineno=3, col_offset=20, end_lineno=3, end_col_offset=25), Constant('two', lineno=3, col_offset=27, end_lineno=3, end_col_offset=32), Constant('three', lineno=3, col_offset=34, end_lineno=3, end_col_offset=41), Constant('four', lineno=3, col_offset=43, end_lineno=3, end_col_offset=49), Constant('five', lineno=3, col_offset=51, end_lineno=3, end_col_offset=57), Constant('six', lineno=3, col_offset=59, end_lineno=3, end_col_offset=64), Constant('seven', lineno=3, col_offset=66, end_lineno=3, end_col_offset=73), Constant('eight', lineno=3, col_offset=75, end_lineno=3, end_col_offset=82), Constant('nine', lineno=4, col_offset=12, end_lineno=4, end_col_offset=18), Constant('ten', lineno=4, col_offset=20, end_lineno=4, end_col_offset=25), Constant('eleven', lineno=4, col_offset=27, end_lineno=4, end_col_offset=35), Constant('twelve', lineno=4, col_offset=37, end_lineno=4, end_col_offset=45), Constant('thirteen', lineno=4, col_offset=47, end_lineno=4, end_col_offset=57), Constant('fourteen', lineno=4, col_offset=59, end_lineno=4, end_col_offset=69), Constant('fifteen', lineno=4, col_offset=71, end_lineno=4, end_col_offset=80), Constant('sixteen', lineno=5, col_offset=12, end_lineno=5, end_col_offset=21), Constant('seventeen', lineno=5, col_offset=23, end_lineno=5, end_col_offset=34), Constant('eighteen', lineno=5, col_offset=36, end_lineno=5, end_col_offset=46), Constant('nineteen', lineno=5, col_offset=48, end_lineno=5, end_col_offset=58)], Load(), lineno=2, col_offset=27, end_lineno=5, end_col_offset=59)], [], lineno=2, col_offset=17, end_lineno=5, end_col_offset=60)], [], lineno=2, col_offset=12, end_lineno=5, end_col_offset=61), lineno=2, col_offset=4, end_lineno=5, end_col_offset=61), Assign([Name('placeholder_3', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=8)], Dict([Constant(20, lineno=7, col_offset=12, end_lineno=7, end_col_offset=14), Constant(30, lineno=7, col_offset=26, end_lineno=7, end_col_offset=28), Constant(40, lineno=7, col_offset=40, end_lineno=7, end_col_offset=42), Constant(50, lineno=7, col_offset=53, end_lineno=7, end_col_offset=55), Constant(60, lineno=8, col_offset=12, end_lineno=8, end_col_offset=14), Constant(70, lineno=8, col_offset=25, end_lineno=8, end_col_offset=27), Constant(80, lineno=8, col_offset=40, end_lineno=8, end_col_offset=42), Constant(90, lineno=8, col_offset=54, end_lineno=8, end_col_offset=56)], [Constant('twenty', lineno=7, col_offset=16, end_lineno=7, end_col_offset=24), Constant('thirty', lineno=7, col_offset=30, end_lineno=7, end_col_offset=38), Constant('forty', lineno=7, col_offset=44, end_lineno=7, end_col_offset=51), Constant('fifty', lineno=7, col_offset=57, end_lineno=7, end_col_offset=64), Constant('sixty', lineno=8, col_offset=16, end_lineno=8, end_col_offset=23), Constant('seventy', lineno=8, col_offset=29, end_lineno=8, end_col_offset=38), Constant('eighty', lineno=8, col_offset=44, end_lineno=8, end_col_offset=52), Constant('ninety', lineno=8, col_offset=58, end_lineno=8, end_col_offset=66)], lineno=7, col_offset=11, end_lineno=8, end_col_offset=67), lineno=7, col_offset=4, end_lineno=8, end_col_offset=67), Assign([Name('placeholder_4', Store(), lineno=10, col_offset=4, end_lineno=10, end_col_offset=8)], Constant(1000.0, lineno=10, col_offset=11, end_lineno=10, end_col_offset=14), lineno=10, col_offset=4, end_lineno=10, end_col_offset=14), Assign([Name('placeholder_5', Store(), lineno=11, col_offset=4, end_lineno=11, end_col_offset=8)], Constant(1000000.0, lineno=11, col_offset=11, end_lineno=11, end_col_offset=14), lineno=11, col_offset=4, end_lineno=11, end_col_offset=14), Assign([Name('placeholder_6', Store(), lineno=12, col_offset=4, end_lineno=12, end_col_offset=8)], Constant(1000000000.0, lineno=12, col_offset=11, end_lineno=12, end_col_offset=14), lineno=12, col_offset=4, end_lineno=12, end_col_offset=14), Assign([Name('placeholder_7', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=8)], Constant(1000000000000.0, lineno=13, col_offset=11, end_lineno=13, end_col_offset=15), lineno=13, col_offset=4, end_lineno=13, end_col_offset=15), If(Compare(Name('placeholder_1', Load(), lineno=15, col_offset=7, end_lineno=15, end_col_offset=13), [Lt()], [Constant(0, lineno=15, col_offset=16, end_lineno=15, end_col_offset=17)], lineno=15, col_offset=7, end_lineno=15, end_col_offset=17), [Raise(Call(Name('ValueError', Load(), lineno=16, col_offset=14, end_lineno=16, end_col_offset=24), [Constant('input out of range', lineno=16, col_offset=25, end_lineno=16, end_col_offset=45)], [], lineno=16, col_offset=14, end_lineno=16, end_col_offset=46), lineno=16, col_offset=8, end_lineno=16, end_col_offset=46)], [], lineno=15, col_offset=4, end_lineno=16, end_col_offset=46), If(Compare(Name('placeholder_1', Load(), lineno=17, col_offset=7, end_lineno=17, end_col_offset=13), [GtE()], [Name('placeholder_7', Load(), lineno=17, col_offset=17, end_lineno=17, end_col_offset=21)], lineno=17, col_offset=7, end_lineno=17, end_col_offset=21), [Raise(Call(Name('ValueError', Load(), lineno=18, col_offset=14, end_lineno=18, end_col_offset=24), [Constant('input out of range', lineno=18, col_offset=25, end_lineno=18, end_col_offset=45)], [], lineno=18, col_offset=14, end_lineno=18, end_col_offset=46), lineno=18, col_offset=8, end_lineno=18, end_col_offset=46)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=46), If(Compare(Name('placeholder_1', Load(), lineno=20, col_offset=7, end_lineno=20, end_col_offset=13), [Lt()], [Constant(20, lineno=20, col_offset=16, end_lineno=20, end_col_offset=18)], lineno=20, col_offset=7, end_lineno=20, end_col_offset=18), [Return(Subscript(Name('placeholder_2', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=20), Name('placeholder_1', Load(), lineno=21, col_offset=21, end_lineno=21, end_col_offset=27), Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=28), lineno=21, col_offset=8, end_lineno=21, end_col_offset=28)], [], lineno=20, col_offset=4, end_lineno=21, end_col_offset=28), If(Compare(Name('placeholder_1', Load(), lineno=23, col_offset=7, end_lineno=23, end_col_offset=13), [Lt()], [Constant(100, lineno=23, col_offset=16, end_lineno=23, end_col_offset=19)], lineno=23, col_offset=7, end_lineno=23, end_col_offset=19), [If(Compare(BinOp(Name('placeholder_1', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=17), Mod(), Constant(10, lineno=24, col_offset=20, end_lineno=24, end_col_offset=22), lineno=24, col_offset=11, end_lineno=24, end_col_offset=22), [Eq()], [Constant(0, lineno=24, col_offset=26, end_lineno=24, end_col_offset=27)], lineno=24, col_offset=11, end_lineno=24, end_col_offset=27), [Return(Subscript(Name('placeholder_3', Load(), lineno=25, col_offset=19, end_lineno=25, end_col_offset=23), Name('placeholder_1', Load(), lineno=25, col_offset=24, end_lineno=25, end_col_offset=30), Load(), lineno=25, col_offset=19, end_lineno=25, end_col_offset=31), lineno=25, col_offset=12, end_lineno=25, end_col_offset=31)], [], lineno=24, col_offset=8, end_lineno=25, end_col_offset=31), Return(BinOp(BinOp(Subscript(Name('placeholder_3', Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=19), BinOp(BinOp(Name('placeholder_1', Load(), lineno=26, col_offset=20, end_lineno=26, end_col_offset=26), FloorDiv(), Constant(10, lineno=26, col_offset=30, end_lineno=26, end_col_offset=32), lineno=26, col_offset=20, end_lineno=26, end_col_offset=32), Mult(), Constant(10, lineno=26, col_offset=35, end_lineno=26, end_col_offset=37), lineno=26, col_offset=20, end_lineno=26, end_col_offset=37), Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=38), Add(), Constant('-', lineno=26, col_offset=41, end_lineno=26, end_col_offset=44), lineno=26, col_offset=15, end_lineno=26, end_col_offset=44), Add(), Subscript(Name('placeholder_2', Load(), lineno=26, col_offset=47, end_lineno=26, end_col_offset=52), BinOp(Name('placeholder_1', Load(), lineno=26, col_offset=53, end_lineno=26, end_col_offset=59), Mod(), Constant(10, lineno=26, col_offset=62, end_lineno=26, end_col_offset=64), lineno=26, col_offset=53, end_lineno=26, end_col_offset=64), Load(), lineno=26, col_offset=47, end_lineno=26, end_col_offset=65), lineno=26, col_offset=15, end_lineno=26, end_col_offset=65), lineno=26, col_offset=8, end_lineno=26, end_col_offset=65)], [], lineno=23, col_offset=4, end_lineno=26, end_col_offset=65), If(Compare(Name('placeholder_1', Load(), lineno=28, col_offset=7, end_lineno=28, end_col_offset=13), [Lt()], [Name('placeholder_4', Load(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=20)], lineno=28, col_offset=7, end_lineno=28, end_col_offset=20), [If(Compare(BinOp(Name('placeholder_1', Load(), lineno=29, col_offset=11, end_lineno=29, end_col_offset=17), Mod(), Constant(100, lineno=29, col_offset=20, end_lineno=29, end_col_offset=23), lineno=29, col_offset=11, end_lineno=29, end_col_offset=23), [Eq()], [Constant(0, lineno=29, col_offset=27, end_lineno=29, end_col_offset=28)], lineno=29, col_offset=11, end_lineno=29, end_col_offset=28), [Return(BinOp(Subscript(Name('placeholder_2', Load(), lineno=30, col_offset=19, end_lineno=30, end_col_offset=24), BinOp(Name('placeholder_1', Load(), lineno=30, col_offset=25, end_lineno=30, end_col_offset=31), FloorDiv(), Constant(100, lineno=30, col_offset=35, end_lineno=30, end_col_offset=38), lineno=30, col_offset=25, end_lineno=30, end_col_offset=38), Load(), lineno=30, col_offset=19, end_lineno=30, end_col_offset=39), Add(), Constant(' hundred', lineno=30, col_offset=42, end_lineno=30, end_col_offset=52), lineno=30, col_offset=19, end_lineno=30, end_col_offset=52), lineno=30, col_offset=12, end_lineno=30, end_col_offset=52)], [], lineno=29, col_offset=8, end_lineno=30, end_col_offset=52), Return(BinOp(BinOp(Subscript(Name('placeholder_2', Load(), lineno=31, col_offset=15, end_lineno=31, end_col_offset=20), BinOp(Name('placeholder_1', Load(), lineno=31, col_offset=21, end_lineno=31, end_col_offset=27), FloorDiv(), Constant(100, lineno=31, col_offset=31, end_lineno=31, end_col_offset=34), lineno=31, col_offset=21, end_lineno=31, end_col_offset=34), Load(), lineno=31, col_offset=15, end_lineno=31, end_col_offset=35), Add(), Constant(' hundred ', lineno=31, col_offset=38, end_lineno=31, end_col_offset=49), lineno=31, col_offset=15, end_lineno=31, end_col_offset=49), Add(), Call(Name('placeholder_0', Load(), lineno=31, col_offset=52, end_lineno=31, end_col_offset=55), [BinOp(Name('placeholder_1', Load(), lineno=31, col_offset=56, end_lineno=31, end_col_offset=62), Mod(), Constant(100, lineno=31, col_offset=65, end_lineno=31, end_col_offset=68), lineno=31, col_offset=56, end_lineno=31, end_col_offset=68)], [], lineno=31, col_offset=52, end_lineno=31, end_col_offset=69), lineno=31, col_offset=15, end_lineno=31, end_col_offset=69), lineno=31, col_offset=8, end_lineno=31, end_col_offset=69)], [], lineno=28, col_offset=4, end_lineno=31, end_col_offset=69), If(Compare(Name('placeholder_1', Load(), lineno=33, col_offset=7, end_lineno=33, end_col_offset=13), [Lt()], [Name('placeholder_5', Load(), lineno=33, col_offset=16, end_lineno=33, end_col_offset=20)], lineno=33, col_offset=7, end_lineno=33, end_col_offset=20), [If(Compare(BinOp(Name('placeholder_1', Load(), lineno=34, col_offset=11, end_lineno=34, end_col_offset=17), Mod(), Name('placeholder_4', Load(), lineno=34, col_offset=20, end_lineno=34, end_col_offset=24), lineno=34, col_offset=11, end_lineno=34, end_col_offset=24), [Eq()], [Constant(0, lineno=34, col_offset=28, end_lineno=34, end_col_offset=29)], lineno=34, col_offset=11, end_lineno=34, end_col_offset=29), [Return(BinOp(Call(Name('placeholder_0', Load(), lineno=35, col_offset=19, end_lineno=35, end_col_offset=22), [BinOp(Name('placeholder_1', Load(), lineno=35, col_offset=23, end_lineno=35, end_col_offset=29), FloorDiv(), Name('placeholder_4', Load(), lineno=35, col_offset=33, end_lineno=35, end_col_offset=37), lineno=35, col_offset=23, end_lineno=35, end_col_offset=37)], [], lineno=35, col_offset=19, end_lineno=35, end_col_offset=38), Add(), Constant(' thousand', lineno=35, col_offset=41, end_lineno=35, end_col_offset=52), lineno=35, col_offset=19, end_lineno=35, end_col_offset=52), lineno=35, col_offset=12, end_lineno=35, end_col_offset=52)], [], lineno=34, col_offset=8, end_lineno=35, end_col_offset=52), Return(BinOp(BinOp(Call(Name('placeholder_0', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=18), [BinOp(Name('placeholder_1', Load(), lineno=36, col_offset=19, end_lineno=36, end_col_offset=25), FloorDiv(), Name('placeholder_4', Load(), lineno=36, col_offset=29, end_lineno=36, end_col_offset=33), lineno=36, col_offset=19, end_lineno=36, end_col_offset=33)], [], lineno=36, col_offset=15, end_lineno=36, end_col_offset=34), Add(), Constant(' thousand ', lineno=36, col_offset=37, end_lineno=36, end_col_offset=49), lineno=36, col_offset=15, end_lineno=36, end_col_offset=49), Add(), Call(Name('placeholder_0', Load(), lineno=36, col_offset=52, end_lineno=36, end_col_offset=55), [BinOp(Name('placeholder_1', Load(), lineno=36, col_offset=56, end_lineno=36, end_col_offset=62), Mod(), Name('placeholder_4', Load(), lineno=36, col_offset=65, end_lineno=36, end_col_offset=69), lineno=36, col_offset=56, end_lineno=36, end_col_offset=69)], [], lineno=36, col_offset=52, end_lineno=36, end_col_offset=70), lineno=36, col_offset=15, end_lineno=36, end_col_offset=70), lineno=36, col_offset=8, end_lineno=36, end_col_offset=70)], [], lineno=33, col_offset=4, end_lineno=36, end_col_offset=70), If(Compare(Name('placeholder_1', Load(), lineno=38, col_offset=7, end_lineno=38, end_col_offset=13), [Lt()], [Name('placeholder_6', Load(), lineno=38, col_offset=16, end_lineno=38, end_col_offset=20)], lineno=38, col_offset=7, end_lineno=38, end_col_offset=20), [If(Compare(BinOp(Name('placeholder_1', Load(), lineno=39, col_offset=11, end_lineno=39, end_col_offset=17), Mod(), Name('placeholder_5', Load(), lineno=39, col_offset=20, end_lineno=39, end_col_offset=24), lineno=39, col_offset=11, end_lineno=39, end_col_offset=24), [Eq()], [Constant(0, lineno=39, col_offset=28, end_lineno=39, end_col_offset=29)], lineno=39, col_offset=11, end_lineno=39, end_col_offset=29), [Return(BinOp(Call(Name('placeholder_0', Load(), lineno=40, col_offset=19, end_lineno=40, end_col_offset=22), [BinOp(Name('placeholder_1', Load(), lineno=40, col_offset=23, end_lineno=40, end_col_offset=29), FloorDiv(), Name('placeholder_5', Load(), lineno=40, col_offset=33, end_lineno=40, end_col_offset=37), lineno=40, col_offset=23, end_lineno=40, end_col_offset=37)], [], lineno=40, col_offset=19, end_lineno=40, end_col_offset=38), Add(), Constant(' million', lineno=40, col_offset=41, end_lineno=40, end_col_offset=51), lineno=40, col_offset=19, end_lineno=40, end_col_offset=51), lineno=40, col_offset=12, end_lineno=40, end_col_offset=51)], [], lineno=39, col_offset=8, end_lineno=40, end_col_offset=51), Return(BinOp(BinOp(Call(Name('placeholder_0', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=18), [BinOp(Name('placeholder_1', Load(), lineno=41, col_offset=19, end_lineno=41, end_col_offset=25), FloorDiv(), Name('placeholder_5', Load(), lineno=41, col_offset=29, end_lineno=41, end_col_offset=33), lineno=41, col_offset=19, end_lineno=41, end_col_offset=33)], [], lineno=41, col_offset=15, end_lineno=41, end_col_offset=34), Add(), Constant(' million ', lineno=41, col_offset=37, end_lineno=41, end_col_offset=48), lineno=41, col_offset=15, end_lineno=41, end_col_offset=48), Add(), Call(Name('placeholder_0', Load(), lineno=41, col_offset=51, end_lineno=41, end_col_offset=54), [BinOp(Name('placeholder_1', Load(), lineno=41, col_offset=55, end_lineno=41, end_col_offset=61), Mod(), Name('placeholder_5', Load(), lineno=41, col_offset=64, end_lineno=41, end_col_offset=68), lineno=41, col_offset=55, end_lineno=41, end_col_offset=68)], [], lineno=41, col_offset=51, end_lineno=41, end_col_offset=69), lineno=41, col_offset=15, end_lineno=41, end_col_offset=69), lineno=41, col_offset=8, end_lineno=41, end_col_offset=69)], [], lineno=38, col_offset=4, end_lineno=41, end_col_offset=69), If(Compare(BinOp(Name('placeholder_1', Load(), lineno=43, col_offset=7, end_lineno=43, end_col_offset=13), Mod(), Name('placeholder_6', Load(), lineno=43, col_offset=16, end_lineno=43, end_col_offset=20), lineno=43, col_offset=7, end_lineno=43, end_col_offset=20), [Eq()], [Constant(0, lineno=43, col_offset=24, end_lineno=43, end_col_offset=25)], lineno=43, col_offset=7, end_lineno=43, end_col_offset=25), [Return(BinOp(Call(Name('placeholder_0', Load(), lineno=44, col_offset=15, end_lineno=44, end_col_offset=18), [BinOp(Name('placeholder_1', Load(), lineno=44, col_offset=19, end_lineno=44, end_col_offset=25), FloorDiv(), Name('placeholder_6', Load(), lineno=44, col_offset=29, end_lineno=44, end_col_offset=33), lineno=44, col_offset=19, end_lineno=44, end_col_offset=33)], [], lineno=44, col_offset=15, end_lineno=44, end_col_offset=34), Add(), Constant(' billion', lineno=44, col_offset=37, end_lineno=44, end_col_offset=47), lineno=44, col_offset=15, end_lineno=44, end_col_offset=47), lineno=44, col_offset=8, end_lineno=44, end_col_offset=47)], [], lineno=43, col_offset=4, end_lineno=44, end_col_offset=47), Return(BinOp(BinOp(Call(Name('placeholder_0', Load(), lineno=45, col_offset=11, end_lineno=45, end_col_offset=14), [BinOp(Name('placeholder_1', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=21), FloorDiv(), Name('placeholder_6', Load(), lineno=45, col_offset=25, end_lineno=45, end_col_offset=29), lineno=45, col_offset=15, end_lineno=45, end_col_offset=29)], [], lineno=45, col_offset=11, end_lineno=45, end_col_offset=30), Add(), Constant(' billion ', lineno=45, col_offset=33, end_lineno=45, end_col_offset=44), lineno=45, col_offset=11, end_lineno=45, end_col_offset=44), Add(), Call(Name('placeholder_0', Load(), lineno=45, col_offset=47, end_lineno=45, end_col_offset=50), [BinOp(Name('placeholder_1', Load(), lineno=45, col_offset=51, end_lineno=45, end_col_offset=57), Mod(), Name('placeholder_6', Load(), lineno=45, col_offset=60, end_lineno=45, end_col_offset=64), lineno=45, col_offset=51, end_lineno=45, end_col_offset=64)], [], lineno=45, col_offset=47, end_lineno=45, end_col_offset=65), lineno=45, col_offset=11, end_lineno=45, end_col_offset=65), lineno=45, col_offset=4, end_lineno=45, end_col_offset=65)], [], lineno=1, col_offset=0, end_lineno=45, end_col_offset=65)], []) \ No newline at end of file diff --git a/test/practice-say/say.py b/test/practice-say/say.py new file mode 100644 index 0000000..95d6d44 --- /dev/null +++ b/test/practice-say/say.py @@ -0,0 +1,45 @@ +def say(number): + small = dict(enumerate(( + 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', + 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', + 'sixteen', 'seventeen', 'eighteen', 'nineteen'))) + + tens = {20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty', + 60: 'sixty', 70: 'seventy', 80: 'eighty', 90: 'ninety'} + + kilo = 1e3 + mega = 1e6 + giga = 1e9 + tera = 1e12 + + if number < 0: + raise ValueError('input out of range') + if number >= tera: + raise ValueError('input out of range') + + if number < 20: + return small[number] + + if number < 100: + if number % 10 == 0: + return tens[number] + return tens[number // 10 * 10] + '-' + small[number % 10] + + if number < kilo: + if number % 100 == 0: + return small[number // 100] + ' hundred' + return small[number // 100] + ' hundred ' + say(number % 100) + + if number < mega: + if number % kilo == 0: + return say(number // kilo) + ' thousand' + return say(number // kilo) + ' thousand ' + say(number % kilo) + + if number < giga: + if number % mega == 0: + return say(number // mega) + ' million' + return say(number // mega) + ' million ' + say(number % mega) + + if number % giga == 0: + return say(number // giga) + ' billion' + return say(number // giga) + ' billion ' + say(number % giga) \ No newline at end of file diff --git a/test/practice-scale-generator/.meta/config.json b/test/practice-scale-generator/.meta/config.json new file mode 100644 index 0000000..26c07d5 --- /dev/null +++ b/test/practice-scale-generator/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "cptjackson" + ], + "contributors": [ + "behrtam", + "cmccandless", + "crsmi", + "Dog", + "ikhadykin", + "N-Parsons", + "nikamirrr", + "tqa236" + ], + "files": { + "solution": [ + "scale_generator.py" + ], + "test": [ + "scale_generator_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Generate musical scales, given a starting note and a set of intervals." +} diff --git a/test/practice-scale-generator/mapping.json b/test/practice-scale-generator/mapping.json new file mode 100644 index 0000000..f3198a0 --- /dev/null +++ b/test/practice-scale-generator/mapping.json @@ -0,0 +1,19 @@ +{ + "placeholder_0": "Scale", + "placeholder_1": "ASCENDING_INTERVALS", + "placeholder_2": "CHROMATIC_SCALE", + "placeholder_3": "FLAT_CHROMATIC_SCALE", + "placeholder_4": "FLAT_KEYS", + "placeholder_5": "__init__", + "placeholder_6": "tonic", + "placeholder_7": "intervals", + "placeholder_8": "chromatic_scale", + "placeholder_9": "chromatic", + "placeholder_10": "interval", + "placeholder_11": "last_index", + "placeholder_12": "pitches", + "placeholder_13": "scale", + "placeholder_14": "_", + "placeholder_15": "_reorder_chromatic_scale", + "placeholder_16": "index" +} \ No newline at end of file diff --git a/test/practice-scale-generator/representation.json b/test/practice-scale-generator/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-scale-generator/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-scale-generator/representation.out b/test/practice-scale-generator/representation.out new file mode 100644 index 0000000..e66afb9 --- /dev/null +++ b/test/practice-scale-generator/representation.out @@ -0,0 +1,2074 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + placeholder_1 = ["m", "M", "A"] + placeholder_2 = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"] + placeholder_3 = ["A", "Bb", "B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab"] + placeholder_4 = ["F", "Bb", "Eb", "Ab", "Db", "Gb", "d", "g", "c", "f", "bb", "eb"] + + def placeholder_5(self, placeholder_6, placeholder_7=None): + self.placeholder_6 = placeholder_6.capitalize() + self.placeholder_7 = placeholder_7 + self.placeholder_8 = ( + self.placeholder_3 + if placeholder_6 in self.placeholder_4 + else self.placeholder_2 + ) + + def placeholder_9(self): + return self._reorder_chromatic_scale() + + def placeholder_10(self, placeholder_7): + placeholder_11 = 0 + placeholder_12 = [] + placeholder_13 = self._reorder_chromatic_scale() + for placeholder_14, placeholder_10 in enumerate(placeholder_7): + placeholder_12.append(placeholder_13[placeholder_11]) + placeholder_11 += self.placeholder_1.index(placeholder_10) + 1 + placeholder_12.append(self.placeholder_6) + return placeholder_12 + + def placeholder_15(self): + placeholder_16 = self.placeholder_8.placeholder_16(self.placeholder_6) + return self.placeholder_8[placeholder_16:] + self.placeholder_8[:placeholder_16] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Scale', + [], + [], + [ + Assign( + [ + Name( + 'ASCENDING_INTERVALS', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=23)], + List( + [ + Constant( + 'm', + lineno=2, + col_offset=27, + end_lineno=2, + end_col_offset=30), + Constant( + 'M', + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=35), + Constant( + 'A', + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=40)], + Load(), + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=41), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=41), + Assign( + [ + Name( + 'CHROMATIC_SCALE', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=19)], + List( + [ + Constant( + 'A', + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=26), + Constant( + 'A#', + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=32), + Constant( + 'B', + lineno=3, + col_offset=34, + end_lineno=3, + end_col_offset=37), + Constant( + 'C', + lineno=3, + col_offset=39, + end_lineno=3, + end_col_offset=42), + Constant( + 'C#', + lineno=3, + col_offset=44, + end_lineno=3, + end_col_offset=48), + Constant( + 'D', + lineno=3, + col_offset=50, + end_lineno=3, + end_col_offset=53), + Constant( + 'D#', + lineno=3, + col_offset=55, + end_lineno=3, + end_col_offset=59), + Constant( + 'E', + lineno=3, + col_offset=61, + end_lineno=3, + end_col_offset=64), + Constant( + 'F', + lineno=3, + col_offset=66, + end_lineno=3, + end_col_offset=69), + Constant( + 'F#', + lineno=3, + col_offset=71, + end_lineno=3, + end_col_offset=75), + Constant( + 'G', + lineno=3, + col_offset=77, + end_lineno=3, + end_col_offset=80), + Constant( + 'G#', + lineno=3, + col_offset=82, + end_lineno=3, + end_col_offset=86)], + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=87), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=87), + Assign( + [ + Name( + 'FLAT_CHROMATIC_SCALE', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=24)], + List( + [ + Constant( + 'A', + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=31), + Constant( + 'Bb', + lineno=4, + col_offset=33, + end_lineno=4, + end_col_offset=37), + Constant( + 'B', + lineno=4, + col_offset=39, + end_lineno=4, + end_col_offset=42), + Constant( + 'C', + lineno=4, + col_offset=44, + end_lineno=4, + end_col_offset=47), + Constant( + 'Db', + lineno=4, + col_offset=49, + end_lineno=4, + end_col_offset=53), + Constant( + 'D', + lineno=4, + col_offset=55, + end_lineno=4, + end_col_offset=58), + Constant( + 'Eb', + lineno=4, + col_offset=60, + end_lineno=4, + end_col_offset=64), + Constant( + 'E', + lineno=4, + col_offset=66, + end_lineno=4, + end_col_offset=69), + Constant( + 'F', + lineno=4, + col_offset=71, + end_lineno=4, + end_col_offset=74), + Constant( + 'Gb', + lineno=4, + col_offset=76, + end_lineno=4, + end_col_offset=80), + Constant( + 'G', + lineno=4, + col_offset=82, + end_lineno=4, + end_col_offset=85), + Constant( + 'Ab', + lineno=4, + col_offset=87, + end_lineno=4, + end_col_offset=91)], + Load(), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=92), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=92), + Assign( + [ + Name( + 'FLAT_KEYS', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=13)], + List( + [ + Constant( + 'F', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=20), + Constant( + 'Bb', + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=26), + Constant( + 'Eb', + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=32), + Constant( + 'Ab', + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=38), + Constant( + 'Db', + lineno=5, + col_offset=40, + end_lineno=5, + end_col_offset=44), + Constant( + 'Gb', + lineno=5, + col_offset=46, + end_lineno=5, + end_col_offset=50), + Constant( + 'd', + lineno=5, + col_offset=52, + end_lineno=5, + end_col_offset=55), + Constant( + 'g', + lineno=5, + col_offset=57, + end_lineno=5, + end_col_offset=60), + Constant( + 'c', + lineno=5, + col_offset=62, + end_lineno=5, + end_col_offset=65), + Constant( + 'f', + lineno=5, + col_offset=67, + end_lineno=5, + end_col_offset=70), + Constant( + 'bb', + lineno=5, + col_offset=72, + end_lineno=5, + end_col_offset=76), + Constant( + 'eb', + lineno=5, + col_offset=78, + end_lineno=5, + end_col_offset=82)], + Load(), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=83), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=83), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21), + arg( + 'tonic', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=28), + arg( + 'intervals', + lineno=7, + col_offset=30, + end_lineno=7, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=7, + col_offset=40, + end_lineno=7, + end_col_offset=44)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'tonic', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=18)], + Call( + Attribute( + Name( + 'tonic', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=26), + 'capitalize', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=37), + [], + [], + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'intervals', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=22)], + Name( + 'intervals', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=34), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'chromatic_scale', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=28)], + IfExp( + Compare( + Name( + 'tonic', + Load(), + lineno=10, + col_offset=61, + end_lineno=10, + end_col_offset=66), + [ + In()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=70, + end_lineno=10, + end_col_offset=74), + 'FLAT_KEYS', + Load(), + lineno=10, + col_offset=70, + end_lineno=10, + end_col_offset=84)], + lineno=10, + col_offset=61, + end_lineno=10, + end_col_offset=84), + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=36), + 'FLAT_CHROMATIC_SCALE', + Load(), + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=57), + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=90, + end_lineno=10, + end_col_offset=94), + 'CHROMATIC_SCALE', + Load(), + lineno=10, + col_offset=90, + end_lineno=10, + end_col_offset=110), + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=110), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=111)], + [], + lineno=7, + col_offset=4, + end_lineno=10, + end_col_offset=111), + FunctionDef( + 'chromatic', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=19), + '_reorder_chromatic_scale', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=44), + [], + [], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=46), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=46)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=46), + FunctionDef( + 'interval', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=21), + arg( + 'intervals', + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'last_index', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18)], + Constant( + 0, + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=22), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=22), + Assign( + [ + Name( + 'pitches', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=15)], + List( + [], + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=20), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=20), + Assign( + [ + Name( + 'scale', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=13)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=20), + '_reorder_chromatic_scale', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=45), + [], + [], + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=47), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=47), + For( + Tuple( + [ + Name( + '_', + Store(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=13), + Name( + 'interval', + Store(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=23)], + Store(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=23), + Call( + Name( + 'enumerate', + Load(), + lineno=20, + col_offset=27, + end_lineno=20, + end_col_offset=36), + [ + Name( + 'intervals', + Load(), + lineno=20, + col_offset=37, + end_lineno=20, + end_col_offset=46)], + [], + lineno=20, + col_offset=27, + end_lineno=20, + end_col_offset=47), + [ + Expr( + Call( + Attribute( + Name( + 'pitches', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=19), + 'append', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=26), + [ + Subscript( + Name( + 'scale', + Load(), + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=32), + Name( + 'last_index', + Load(), + lineno=21, + col_offset=33, + end_lineno=21, + end_col_offset=43), + Load(), + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=44)], + [], + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=45), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=45), + AugAssign( + Name( + 'last_index', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=22), + Add(), + BinOp( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=30), + 'ASCENDING_INTERVALS', + Load(), + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=50), + 'index', + Load(), + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=56), + [ + Name( + 'interval', + Load(), + lineno=22, + col_offset=57, + end_lineno=22, + end_col_offset=65)], + [], + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=66), + Add(), + Constant( + 1, + lineno=22, + col_offset=69, + end_lineno=22, + end_col_offset=70), + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=70), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=70)], + [], + lineno=20, + col_offset=8, + end_lineno=22, + end_col_offset=70), + Expr( + Call( + Attribute( + Name( + 'pitches', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=15), + 'append', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=22), + [ + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=27), + 'tonic', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=33)], + [], + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=34), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=34), + Return( + Name( + 'pitches', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=22), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=22)], + [], + lineno=15, + col_offset=4, + end_lineno=26, + end_col_offset=22), + FunctionDef( + '_reorder_chromatic_scale', + arguments( + [], + [ + arg( + 'self', + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'index', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=13)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=20), + 'chromatic_scale', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=36), + 'index', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=42), + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=47), + 'tonic', + Load(), + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=53)], + [], + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=54), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=54), + Return( + BinOp( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=20), + 'chromatic_scale', + Load(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=36), + Slice( + Name( + 'index', + Load(), + lineno=30, + col_offset=37, + end_lineno=30, + end_col_offset=42), + lineno=30, + col_offset=37, + end_lineno=30, + end_col_offset=43), + Load(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=44), + Add(), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=51), + 'chromatic_scale', + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=67), + Slice( + upper=Name( + 'index', + Load(), + lineno=30, + col_offset=69, + end_lineno=30, + end_col_offset=74), + lineno=30, + col_offset=68, + end_lineno=30, + end_col_offset=74), + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=75), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=75), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=75)], + [], + lineno=28, + col_offset=4, + end_lineno=30, + end_col_offset=75)], + [], + lineno=1, + col_offset=0, + end_lineno=30, + end_col_offset=75)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=23)], + List( + [ + Constant( + 'm', + lineno=2, + col_offset=27, + end_lineno=2, + end_col_offset=30), + Constant( + 'M', + lineno=2, + col_offset=32, + end_lineno=2, + end_col_offset=35), + Constant( + 'A', + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=40)], + Load(), + lineno=2, + col_offset=26, + end_lineno=2, + end_col_offset=41), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=41), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=19)], + List( + [ + Constant( + 'A', + lineno=3, + col_offset=23, + end_lineno=3, + end_col_offset=26), + Constant( + 'A#', + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=32), + Constant( + 'B', + lineno=3, + col_offset=34, + end_lineno=3, + end_col_offset=37), + Constant( + 'C', + lineno=3, + col_offset=39, + end_lineno=3, + end_col_offset=42), + Constant( + 'C#', + lineno=3, + col_offset=44, + end_lineno=3, + end_col_offset=48), + Constant( + 'D', + lineno=3, + col_offset=50, + end_lineno=3, + end_col_offset=53), + Constant( + 'D#', + lineno=3, + col_offset=55, + end_lineno=3, + end_col_offset=59), + Constant( + 'E', + lineno=3, + col_offset=61, + end_lineno=3, + end_col_offset=64), + Constant( + 'F', + lineno=3, + col_offset=66, + end_lineno=3, + end_col_offset=69), + Constant( + 'F#', + lineno=3, + col_offset=71, + end_lineno=3, + end_col_offset=75), + Constant( + 'G', + lineno=3, + col_offset=77, + end_lineno=3, + end_col_offset=80), + Constant( + 'G#', + lineno=3, + col_offset=82, + end_lineno=3, + end_col_offset=86)], + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=87), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=87), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=24)], + List( + [ + Constant( + 'A', + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=31), + Constant( + 'Bb', + lineno=4, + col_offset=33, + end_lineno=4, + end_col_offset=37), + Constant( + 'B', + lineno=4, + col_offset=39, + end_lineno=4, + end_col_offset=42), + Constant( + 'C', + lineno=4, + col_offset=44, + end_lineno=4, + end_col_offset=47), + Constant( + 'Db', + lineno=4, + col_offset=49, + end_lineno=4, + end_col_offset=53), + Constant( + 'D', + lineno=4, + col_offset=55, + end_lineno=4, + end_col_offset=58), + Constant( + 'Eb', + lineno=4, + col_offset=60, + end_lineno=4, + end_col_offset=64), + Constant( + 'E', + lineno=4, + col_offset=66, + end_lineno=4, + end_col_offset=69), + Constant( + 'F', + lineno=4, + col_offset=71, + end_lineno=4, + end_col_offset=74), + Constant( + 'Gb', + lineno=4, + col_offset=76, + end_lineno=4, + end_col_offset=80), + Constant( + 'G', + lineno=4, + col_offset=82, + end_lineno=4, + end_col_offset=85), + Constant( + 'Ab', + lineno=4, + col_offset=87, + end_lineno=4, + end_col_offset=91)], + Load(), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=92), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=92), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=13)], + List( + [ + Constant( + 'F', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=20), + Constant( + 'Bb', + lineno=5, + col_offset=22, + end_lineno=5, + end_col_offset=26), + Constant( + 'Eb', + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=32), + Constant( + 'Ab', + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=38), + Constant( + 'Db', + lineno=5, + col_offset=40, + end_lineno=5, + end_col_offset=44), + Constant( + 'Gb', + lineno=5, + col_offset=46, + end_lineno=5, + end_col_offset=50), + Constant( + 'd', + lineno=5, + col_offset=52, + end_lineno=5, + end_col_offset=55), + Constant( + 'g', + lineno=5, + col_offset=57, + end_lineno=5, + end_col_offset=60), + Constant( + 'c', + lineno=5, + col_offset=62, + end_lineno=5, + end_col_offset=65), + Constant( + 'f', + lineno=5, + col_offset=67, + end_lineno=5, + end_col_offset=70), + Constant( + 'bb', + lineno=5, + col_offset=72, + end_lineno=5, + end_col_offset=76), + Constant( + 'eb', + lineno=5, + col_offset=78, + end_lineno=5, + end_col_offset=82)], + Load(), + lineno=5, + col_offset=16, + end_lineno=5, + end_col_offset=83), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=83), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=21), + arg( + 'placeholder_6', + lineno=7, + col_offset=23, + end_lineno=7, + end_col_offset=28), + arg( + 'placeholder_7', + lineno=7, + col_offset=30, + end_lineno=7, + end_col_offset=39)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=7, + col_offset=40, + end_lineno=7, + end_col_offset=44)]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=18)], + Call( + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=26), + 'capitalize', + Load(), + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=37), + [], + [], + lineno=8, + col_offset=21, + end_lineno=8, + end_col_offset=39), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=39), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=22)], + Name( + 'placeholder_7', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=34), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=12), + 'placeholder_8', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=28)], + IfExp( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=10, + col_offset=61, + end_lineno=10, + end_col_offset=66), + [ + In()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=70, + end_lineno=10, + end_col_offset=74), + 'placeholder_4', + Load(), + lineno=10, + col_offset=70, + end_lineno=10, + end_col_offset=84)], + lineno=10, + col_offset=61, + end_lineno=10, + end_col_offset=84), + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=36), + 'placeholder_3', + Load(), + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=57), + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=90, + end_lineno=10, + end_col_offset=94), + 'placeholder_2', + Load(), + lineno=10, + col_offset=90, + end_lineno=10, + end_col_offset=110), + lineno=10, + col_offset=32, + end_lineno=10, + end_col_offset=110), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=111)], + [], + lineno=7, + col_offset=4, + end_lineno=10, + end_col_offset=111), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=19), + '_reorder_chromatic_scale', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=44), + [], + [], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=46), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=46)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=46), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=17, + end_lineno=15, + end_col_offset=21), + arg( + 'placeholder_7', + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=18)], + Constant( + 0, + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=22), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=22), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=15)], + List( + [], + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=20), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=20), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=13)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=20), + '_reorder_chromatic_scale', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=45), + [], + [], + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=47), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=47), + For( + Tuple( + [ + Name( + 'placeholder_14', + Store(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=13), + Name( + 'placeholder_10', + Store(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=23)], + Store(), + lineno=20, + col_offset=12, + end_lineno=20, + end_col_offset=23), + Call( + Name( + 'enumerate', + Load(), + lineno=20, + col_offset=27, + end_lineno=20, + end_col_offset=36), + [ + Name( + 'placeholder_7', + Load(), + lineno=20, + col_offset=37, + end_lineno=20, + end_col_offset=46)], + [], + lineno=20, + col_offset=27, + end_lineno=20, + end_col_offset=47), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=19), + 'append', + Load(), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=26), + [ + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=32), + Name( + 'placeholder_11', + Load(), + lineno=21, + col_offset=33, + end_lineno=21, + end_col_offset=43), + Load(), + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=44)], + [], + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=45), + lineno=21, + col_offset=12, + end_lineno=21, + end_col_offset=45), + AugAssign( + Name( + 'placeholder_11', + Store(), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=22), + Add(), + BinOp( + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=30), + 'placeholder_1', + Load(), + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=50), + 'index', + Load(), + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=56), + [ + Name( + 'placeholder_10', + Load(), + lineno=22, + col_offset=57, + end_lineno=22, + end_col_offset=65)], + [], + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=66), + Add(), + Constant( + 1, + lineno=22, + col_offset=69, + end_lineno=22, + end_col_offset=70), + lineno=22, + col_offset=26, + end_lineno=22, + end_col_offset=70), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=70)], + [], + lineno=20, + col_offset=8, + end_lineno=22, + end_col_offset=70), + Expr( + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=15), + 'append', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=22), + [ + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=27), + 'placeholder_6', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=33)], + [], + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=34), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=34), + Return( + Name( + 'placeholder_12', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=22), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=22)], + [], + lineno=15, + col_offset=4, + end_lineno=26, + end_col_offset=22), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=28, + col_offset=33, + end_lineno=28, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=13)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=20), + 'placeholder_8', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=36), + 'placeholder_16', + Load(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=42), + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=47), + 'placeholder_6', + Load(), + lineno=29, + col_offset=43, + end_lineno=29, + end_col_offset=53)], + [], + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=54), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=54), + Return( + BinOp( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=20), + 'placeholder_8', + Load(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=36), + Slice( + Name( + 'placeholder_16', + Load(), + lineno=30, + col_offset=37, + end_lineno=30, + end_col_offset=42), + lineno=30, + col_offset=37, + end_lineno=30, + end_col_offset=43), + Load(), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=44), + Add(), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=51), + 'placeholder_8', + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=67), + Slice( + upper=Name( + 'placeholder_16', + Load(), + lineno=30, + col_offset=69, + end_lineno=30, + end_col_offset=74), + lineno=30, + col_offset=68, + end_lineno=30, + end_col_offset=74), + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=75), + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=75), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=75)], + [], + lineno=28, + col_offset=4, + end_lineno=30, + end_col_offset=75)], + [], + lineno=1, + col_offset=0, + end_lineno=30, + end_col_offset=75)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-scale-generator/representation.txt b/test/practice-scale-generator/representation.txt new file mode 100644 index 0000000..22a4138 --- /dev/null +++ b/test/practice-scale-generator/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [Assign([Name('placeholder_1', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=23)], List([Constant('m', lineno=2, col_offset=27, end_lineno=2, end_col_offset=30), Constant('M', lineno=2, col_offset=32, end_lineno=2, end_col_offset=35), Constant('A', lineno=2, col_offset=37, end_lineno=2, end_col_offset=40)], Load(), lineno=2, col_offset=26, end_lineno=2, end_col_offset=41), lineno=2, col_offset=4, end_lineno=2, end_col_offset=41), Assign([Name('placeholder_2', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=19)], List([Constant('A', lineno=3, col_offset=23, end_lineno=3, end_col_offset=26), Constant('A#', lineno=3, col_offset=28, end_lineno=3, end_col_offset=32), Constant('B', lineno=3, col_offset=34, end_lineno=3, end_col_offset=37), Constant('C', lineno=3, col_offset=39, end_lineno=3, end_col_offset=42), Constant('C#', lineno=3, col_offset=44, end_lineno=3, end_col_offset=48), Constant('D', lineno=3, col_offset=50, end_lineno=3, end_col_offset=53), Constant('D#', lineno=3, col_offset=55, end_lineno=3, end_col_offset=59), Constant('E', lineno=3, col_offset=61, end_lineno=3, end_col_offset=64), Constant('F', lineno=3, col_offset=66, end_lineno=3, end_col_offset=69), Constant('F#', lineno=3, col_offset=71, end_lineno=3, end_col_offset=75), Constant('G', lineno=3, col_offset=77, end_lineno=3, end_col_offset=80), Constant('G#', lineno=3, col_offset=82, end_lineno=3, end_col_offset=86)], Load(), lineno=3, col_offset=22, end_lineno=3, end_col_offset=87), lineno=3, col_offset=4, end_lineno=3, end_col_offset=87), Assign([Name('placeholder_3', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=24)], List([Constant('A', lineno=4, col_offset=28, end_lineno=4, end_col_offset=31), Constant('Bb', lineno=4, col_offset=33, end_lineno=4, end_col_offset=37), Constant('B', lineno=4, col_offset=39, end_lineno=4, end_col_offset=42), Constant('C', lineno=4, col_offset=44, end_lineno=4, end_col_offset=47), Constant('Db', lineno=4, col_offset=49, end_lineno=4, end_col_offset=53), Constant('D', lineno=4, col_offset=55, end_lineno=4, end_col_offset=58), Constant('Eb', lineno=4, col_offset=60, end_lineno=4, end_col_offset=64), Constant('E', lineno=4, col_offset=66, end_lineno=4, end_col_offset=69), Constant('F', lineno=4, col_offset=71, end_lineno=4, end_col_offset=74), Constant('Gb', lineno=4, col_offset=76, end_lineno=4, end_col_offset=80), Constant('G', lineno=4, col_offset=82, end_lineno=4, end_col_offset=85), Constant('Ab', lineno=4, col_offset=87, end_lineno=4, end_col_offset=91)], Load(), lineno=4, col_offset=27, end_lineno=4, end_col_offset=92), lineno=4, col_offset=4, end_lineno=4, end_col_offset=92), Assign([Name('placeholder_4', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=13)], List([Constant('F', lineno=5, col_offset=17, end_lineno=5, end_col_offset=20), Constant('Bb', lineno=5, col_offset=22, end_lineno=5, end_col_offset=26), Constant('Eb', lineno=5, col_offset=28, end_lineno=5, end_col_offset=32), Constant('Ab', lineno=5, col_offset=34, end_lineno=5, end_col_offset=38), Constant('Db', lineno=5, col_offset=40, end_lineno=5, end_col_offset=44), Constant('Gb', lineno=5, col_offset=46, end_lineno=5, end_col_offset=50), Constant('d', lineno=5, col_offset=52, end_lineno=5, end_col_offset=55), Constant('g', lineno=5, col_offset=57, end_lineno=5, end_col_offset=60), Constant('c', lineno=5, col_offset=62, end_lineno=5, end_col_offset=65), Constant('f', lineno=5, col_offset=67, end_lineno=5, end_col_offset=70), Constant('bb', lineno=5, col_offset=72, end_lineno=5, end_col_offset=76), Constant('eb', lineno=5, col_offset=78, end_lineno=5, end_col_offset=82)], Load(), lineno=5, col_offset=16, end_lineno=5, end_col_offset=83), lineno=5, col_offset=4, end_lineno=5, end_col_offset=83), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=7, col_offset=17, end_lineno=7, end_col_offset=21), arg('placeholder_6', lineno=7, col_offset=23, end_lineno=7, end_col_offset=28), arg('placeholder_7', lineno=7, col_offset=30, end_lineno=7, end_col_offset=39)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=7, col_offset=40, end_lineno=7, end_col_offset=44)]), [Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_6', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=18)], Call(Attribute(Name('placeholder_6', Load(), lineno=8, col_offset=21, end_lineno=8, end_col_offset=26), 'capitalize', Load(), lineno=8, col_offset=21, end_lineno=8, end_col_offset=37), [], [], lineno=8, col_offset=21, end_lineno=8, end_col_offset=39), lineno=8, col_offset=8, end_lineno=8, end_col_offset=39), Assign([Attribute(Name('self', Load(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=12), 'placeholder_7', Store(), lineno=9, col_offset=8, end_lineno=9, end_col_offset=22)], Name('placeholder_7', Load(), lineno=9, col_offset=25, end_lineno=9, end_col_offset=34), lineno=9, col_offset=8, end_lineno=9, end_col_offset=34), Assign([Attribute(Name('self', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=12), 'placeholder_8', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=28)], IfExp(Compare(Name('placeholder_6', Load(), lineno=10, col_offset=61, end_lineno=10, end_col_offset=66), [In()], [Attribute(Name('self', Load(), lineno=10, col_offset=70, end_lineno=10, end_col_offset=74), 'placeholder_4', Load(), lineno=10, col_offset=70, end_lineno=10, end_col_offset=84)], lineno=10, col_offset=61, end_lineno=10, end_col_offset=84), Attribute(Name('self', Load(), lineno=10, col_offset=32, end_lineno=10, end_col_offset=36), 'placeholder_3', Load(), lineno=10, col_offset=32, end_lineno=10, end_col_offset=57), Attribute(Name('self', Load(), lineno=10, col_offset=90, end_lineno=10, end_col_offset=94), 'placeholder_2', Load(), lineno=10, col_offset=90, end_lineno=10, end_col_offset=110), lineno=10, col_offset=32, end_lineno=10, end_col_offset=110), lineno=10, col_offset=8, end_lineno=10, end_col_offset=111)], [], lineno=7, col_offset=4, end_lineno=10, end_col_offset=111), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=12, col_offset=18, end_lineno=12, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('self', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=19), '_reorder_chromatic_scale', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=44), [], [], lineno=13, col_offset=15, end_lineno=13, end_col_offset=46), lineno=13, col_offset=8, end_lineno=13, end_col_offset=46)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=46), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=15, col_offset=17, end_lineno=15, end_col_offset=21), arg('placeholder_7', lineno=15, col_offset=23, end_lineno=15, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_11', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=18)], Constant(0, lineno=16, col_offset=21, end_lineno=16, end_col_offset=22), lineno=16, col_offset=8, end_lineno=16, end_col_offset=22), Assign([Name('placeholder_12', Store(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=15)], List([], Load(), lineno=17, col_offset=18, end_lineno=17, end_col_offset=20), lineno=17, col_offset=8, end_lineno=17, end_col_offset=20), Assign([Name('placeholder_13', Store(), lineno=18, col_offset=8, end_lineno=18, end_col_offset=13)], Call(Attribute(Name('self', Load(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=20), '_reorder_chromatic_scale', Load(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=45), [], [], lineno=18, col_offset=16, end_lineno=18, end_col_offset=47), lineno=18, col_offset=8, end_lineno=18, end_col_offset=47), For(Tuple([Name('placeholder_14', Store(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=13), Name('placeholder_10', Store(), lineno=20, col_offset=15, end_lineno=20, end_col_offset=23)], Store(), lineno=20, col_offset=12, end_lineno=20, end_col_offset=23), Call(Name('enumerate', Load(), lineno=20, col_offset=27, end_lineno=20, end_col_offset=36), [Name('placeholder_7', Load(), lineno=20, col_offset=37, end_lineno=20, end_col_offset=46)], [], lineno=20, col_offset=27, end_lineno=20, end_col_offset=47), [Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=19), 'append', Load(), lineno=21, col_offset=12, end_lineno=21, end_col_offset=26), [Subscript(Name('placeholder_13', Load(), lineno=21, col_offset=27, end_lineno=21, end_col_offset=32), Name('placeholder_11', Load(), lineno=21, col_offset=33, end_lineno=21, end_col_offset=43), Load(), lineno=21, col_offset=27, end_lineno=21, end_col_offset=44)], [], lineno=21, col_offset=12, end_lineno=21, end_col_offset=45), lineno=21, col_offset=12, end_lineno=21, end_col_offset=45), AugAssign(Name('placeholder_11', Store(), lineno=22, col_offset=12, end_lineno=22, end_col_offset=22), Add(), BinOp(Call(Attribute(Attribute(Name('self', Load(), lineno=22, col_offset=26, end_lineno=22, end_col_offset=30), 'placeholder_1', Load(), lineno=22, col_offset=26, end_lineno=22, end_col_offset=50), 'index', Load(), lineno=22, col_offset=26, end_lineno=22, end_col_offset=56), [Name('placeholder_10', Load(), lineno=22, col_offset=57, end_lineno=22, end_col_offset=65)], [], lineno=22, col_offset=26, end_lineno=22, end_col_offset=66), Add(), Constant(1, lineno=22, col_offset=69, end_lineno=22, end_col_offset=70), lineno=22, col_offset=26, end_lineno=22, end_col_offset=70), lineno=22, col_offset=12, end_lineno=22, end_col_offset=70)], [], lineno=20, col_offset=8, end_lineno=22, end_col_offset=70), Expr(Call(Attribute(Name('placeholder_12', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=15), 'append', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=22), [Attribute(Name('self', Load(), lineno=24, col_offset=23, end_lineno=24, end_col_offset=27), 'placeholder_6', Load(), lineno=24, col_offset=23, end_lineno=24, end_col_offset=33)], [], lineno=24, col_offset=8, end_lineno=24, end_col_offset=34), lineno=24, col_offset=8, end_lineno=24, end_col_offset=34), Return(Name('placeholder_12', Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=22), lineno=26, col_offset=8, end_lineno=26, end_col_offset=22)], [], lineno=15, col_offset=4, end_lineno=26, end_col_offset=22), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=28, col_offset=33, end_lineno=28, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_16', Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=13)], Call(Attribute(Attribute(Name('self', Load(), lineno=29, col_offset=16, end_lineno=29, end_col_offset=20), 'placeholder_8', Load(), lineno=29, col_offset=16, end_lineno=29, end_col_offset=36), 'placeholder_16', Load(), lineno=29, col_offset=16, end_lineno=29, end_col_offset=42), [Attribute(Name('self', Load(), lineno=29, col_offset=43, end_lineno=29, end_col_offset=47), 'placeholder_6', Load(), lineno=29, col_offset=43, end_lineno=29, end_col_offset=53)], [], lineno=29, col_offset=16, end_lineno=29, end_col_offset=54), lineno=29, col_offset=8, end_lineno=29, end_col_offset=54), Return(BinOp(Subscript(Attribute(Name('self', Load(), lineno=30, col_offset=16, end_lineno=30, end_col_offset=20), 'placeholder_8', Load(), lineno=30, col_offset=16, end_lineno=30, end_col_offset=36), Slice(Name('placeholder_16', Load(), lineno=30, col_offset=37, end_lineno=30, end_col_offset=42), lineno=30, col_offset=37, end_lineno=30, end_col_offset=43), Load(), lineno=30, col_offset=16, end_lineno=30, end_col_offset=44), Add(), Subscript(Attribute(Name('self', Load(), lineno=30, col_offset=47, end_lineno=30, end_col_offset=51), 'placeholder_8', Load(), lineno=30, col_offset=47, end_lineno=30, end_col_offset=67), Slice(upper=Name('placeholder_16', Load(), lineno=30, col_offset=69, end_lineno=30, end_col_offset=74), lineno=30, col_offset=68, end_lineno=30, end_col_offset=74), Load(), lineno=30, col_offset=47, end_lineno=30, end_col_offset=75), lineno=30, col_offset=16, end_lineno=30, end_col_offset=75), lineno=30, col_offset=8, end_lineno=30, end_col_offset=75)], [], lineno=28, col_offset=4, end_lineno=30, end_col_offset=75)], [], lineno=1, col_offset=0, end_lineno=30, end_col_offset=75)], []) \ No newline at end of file diff --git a/test/practice-scale-generator/scale_generator.py b/test/practice-scale-generator/scale_generator.py new file mode 100644 index 0000000..19c0c81 --- /dev/null +++ b/test/practice-scale-generator/scale_generator.py @@ -0,0 +1,30 @@ +class Scale: + ASCENDING_INTERVALS = ['m', 'M', 'A'] + CHROMATIC_SCALE = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'] + FLAT_CHROMATIC_SCALE = ['A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab'] + FLAT_KEYS = ['F', 'Bb', 'Eb', 'Ab', 'Db', 'Gb', 'd', 'g', 'c', 'f', 'bb', 'eb'] + + def __init__(self, tonic, intervals=None): + self.tonic = tonic.capitalize() + self.intervals = intervals + self.chromatic_scale = (self.FLAT_CHROMATIC_SCALE if tonic in self.FLAT_KEYS else self.CHROMATIC_SCALE) + + def chromatic(self): + return self._reorder_chromatic_scale() + + def interval(self, intervals): + last_index = 0 + pitches = [] + scale = self._reorder_chromatic_scale() + + for _, interval in enumerate(intervals): + pitches.append(scale[last_index]) + last_index += self.ASCENDING_INTERVALS.index(interval) + 1 + + pitches.append(self.tonic) + + return pitches + + def _reorder_chromatic_scale(self): + index = self.chromatic_scale.index(self.tonic) + return self.chromatic_scale[index:] + self.chromatic_scale[:index] diff --git a/test/practice-scrabble-score/.meta/config.json b/test/practice-scrabble-score/.meta/config.json new file mode 100644 index 0000000..d8ff8fb --- /dev/null +++ b/test/practice-scrabble-score/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "kotp", + "kytrinyx", + "lowks", + "N-Parsons", + "parinporecha", + "Peque", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "scrabble_score.py" + ], + "test": [ + "scrabble_score_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a word, compute the Scrabble score for that word.", + "source": "Inspired by the Extreme Startup game", + "source_url": "https://github.com/rchatley/extreme_startup" +} diff --git a/test/practice-scrabble-score/mapping.json b/test/practice-scrabble-score/mapping.json new file mode 100644 index 0000000..d176388 --- /dev/null +++ b/test/practice-scrabble-score/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "POINTS", + "placeholder_1": "score", + "placeholder_2": "word", + "placeholder_3": "letter" +} \ No newline at end of file diff --git a/test/practice-scrabble-score/representation.json b/test/practice-scrabble-score/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-scrabble-score/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-scrabble-score/representation.out b/test/practice-scrabble-score/representation.out new file mode 100644 index 0000000..a27e70a --- /dev/null +++ b/test/practice-scrabble-score/representation.out @@ -0,0 +1,997 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = { + "a": 1, + "b": 3, + "c": 3, + "d": 2, + "e": 1, + "f": 4, + "g": 2, + "h": 4, + "i": 1, + "j": 8, + "k": 5, + "l": 1, + "m": 3, + "n": 1, + "o": 1, + "p": 3, + "q": 10, + "r": 1, + "s": 1, + "t": 1, + "u": 1, + "v": 4, + "w": 4, + "x": 8, + "y": 4, + "z": 10, +} + + +def placeholder_1(placeholder_2): + if not placeholder_2.isalpha(): + return 0 + return sum( + (placeholder_0[placeholder_3] for placeholder_3 in placeholder_2.lower()) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'POINTS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + Dict( + [ + Constant( + 'a', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=7), + Constant( + 'b', + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=15), + Constant( + 'c', + lineno=2, + col_offset=20, + end_lineno=2, + end_col_offset=23), + Constant( + 'd', + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=31), + Constant( + 'e', + lineno=2, + col_offset=36, + end_lineno=2, + end_col_offset=39), + Constant( + 'f', + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=7), + Constant( + 'g', + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=15), + Constant( + 'h', + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=23), + Constant( + 'i', + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=31), + Constant( + 'j', + lineno=3, + col_offset=36, + end_lineno=3, + end_col_offset=39), + Constant( + 'k', + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=7), + Constant( + 'l', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=15), + Constant( + 'm', + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=23), + Constant( + 'n', + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=31), + Constant( + 'o', + lineno=4, + col_offset=36, + end_lineno=4, + end_col_offset=39), + Constant( + 'p', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=7), + Constant( + 'q', + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=15), + Constant( + 'r', + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + Constant( + 's', + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=32), + Constant( + 't', + lineno=5, + col_offset=37, + end_lineno=5, + end_col_offset=40), + Constant( + 'u', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=7), + Constant( + 'v', + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=15), + Constant( + 'w', + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=23), + Constant( + 'x', + lineno=6, + col_offset=28, + end_lineno=6, + end_col_offset=31), + Constant( + 'y', + lineno=6, + col_offset=36, + end_lineno=6, + end_col_offset=39), + Constant( + 'z', + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=7)], + [ + Constant( + 1, + lineno=2, + col_offset=9, + end_lineno=2, + end_col_offset=10), + Constant( + 3, + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=18), + Constant( + 3, + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=26), + Constant( + 2, + lineno=2, + col_offset=33, + end_lineno=2, + end_col_offset=34), + Constant( + 1, + lineno=2, + col_offset=41, + end_lineno=2, + end_col_offset=42), + Constant( + 4, + lineno=3, + col_offset=9, + end_lineno=3, + end_col_offset=10), + Constant( + 2, + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=18), + Constant( + 4, + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=26), + Constant( + 1, + lineno=3, + col_offset=33, + end_lineno=3, + end_col_offset=34), + Constant( + 8, + lineno=3, + col_offset=41, + end_lineno=3, + end_col_offset=42), + Constant( + 5, + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=10), + Constant( + 1, + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=18), + Constant( + 3, + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=26), + Constant( + 1, + lineno=4, + col_offset=33, + end_lineno=4, + end_col_offset=34), + Constant( + 1, + lineno=4, + col_offset=41, + end_lineno=4, + end_col_offset=42), + Constant( + 3, + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=10), + Constant( + 10, + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=19), + Constant( + 1, + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=27), + Constant( + 1, + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=35), + Constant( + 1, + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=43), + Constant( + 1, + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=10), + Constant( + 4, + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=18), + Constant( + 4, + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=26), + Constant( + 8, + lineno=6, + col_offset=33, + end_lineno=6, + end_col_offset=34), + Constant( + 4, + lineno=6, + col_offset=41, + end_lineno=6, + end_col_offset=42), + Constant( + 10, + lineno=7, + col_offset=9, + end_lineno=7, + end_col_offset=11)], + lineno=1, + col_offset=9, + end_lineno=8, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=1), + FunctionDef( + 'score', + arguments( + [], + [ + arg( + 'word', + lineno=11, + col_offset=10, + end_lineno=11, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'word', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=15), + 'isalpha', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=23), + [], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=25), + lineno=12, + col_offset=7, + end_lineno=12, + end_col_offset=25), + [ + Return( + Constant( + 0, + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=16), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=16)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=16), + Return( + Call( + Name( + 'sum', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + [ + GeneratorExp( + Subscript( + Name( + 'POINTS', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=21), + Name( + 'letter', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=28), + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=29), + [ + comprehension( + Name( + 'letter', + Store(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=40), + Call( + Attribute( + Name( + 'word', + Load(), + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=48), + 'lower', + Load(), + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=54), + [], + [], + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=56), + [], + 0)], + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=57)], + [], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=57), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=57)], + [], + lineno=11, + col_offset=0, + end_lineno=14, + end_col_offset=57)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=6)], + Dict( + [ + Constant( + 'a', + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=7), + Constant( + 'b', + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=15), + Constant( + 'c', + lineno=2, + col_offset=20, + end_lineno=2, + end_col_offset=23), + Constant( + 'd', + lineno=2, + col_offset=28, + end_lineno=2, + end_col_offset=31), + Constant( + 'e', + lineno=2, + col_offset=36, + end_lineno=2, + end_col_offset=39), + Constant( + 'f', + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=7), + Constant( + 'g', + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=15), + Constant( + 'h', + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=23), + Constant( + 'i', + lineno=3, + col_offset=28, + end_lineno=3, + end_col_offset=31), + Constant( + 'j', + lineno=3, + col_offset=36, + end_lineno=3, + end_col_offset=39), + Constant( + 'k', + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=7), + Constant( + 'l', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=15), + Constant( + 'm', + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=23), + Constant( + 'n', + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=31), + Constant( + 'o', + lineno=4, + col_offset=36, + end_lineno=4, + end_col_offset=39), + Constant( + 'p', + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=7), + Constant( + 'q', + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=15), + Constant( + 'r', + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + Constant( + 's', + lineno=5, + col_offset=29, + end_lineno=5, + end_col_offset=32), + Constant( + 't', + lineno=5, + col_offset=37, + end_lineno=5, + end_col_offset=40), + Constant( + 'u', + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=7), + Constant( + 'v', + lineno=6, + col_offset=12, + end_lineno=6, + end_col_offset=15), + Constant( + 'w', + lineno=6, + col_offset=20, + end_lineno=6, + end_col_offset=23), + Constant( + 'x', + lineno=6, + col_offset=28, + end_lineno=6, + end_col_offset=31), + Constant( + 'y', + lineno=6, + col_offset=36, + end_lineno=6, + end_col_offset=39), + Constant( + 'z', + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=7)], + [ + Constant( + 1, + lineno=2, + col_offset=9, + end_lineno=2, + end_col_offset=10), + Constant( + 3, + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=18), + Constant( + 3, + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=26), + Constant( + 2, + lineno=2, + col_offset=33, + end_lineno=2, + end_col_offset=34), + Constant( + 1, + lineno=2, + col_offset=41, + end_lineno=2, + end_col_offset=42), + Constant( + 4, + lineno=3, + col_offset=9, + end_lineno=3, + end_col_offset=10), + Constant( + 2, + lineno=3, + col_offset=17, + end_lineno=3, + end_col_offset=18), + Constant( + 4, + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=26), + Constant( + 1, + lineno=3, + col_offset=33, + end_lineno=3, + end_col_offset=34), + Constant( + 8, + lineno=3, + col_offset=41, + end_lineno=3, + end_col_offset=42), + Constant( + 5, + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=10), + Constant( + 1, + lineno=4, + col_offset=17, + end_lineno=4, + end_col_offset=18), + Constant( + 3, + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=26), + Constant( + 1, + lineno=4, + col_offset=33, + end_lineno=4, + end_col_offset=34), + Constant( + 1, + lineno=4, + col_offset=41, + end_lineno=4, + end_col_offset=42), + Constant( + 3, + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=10), + Constant( + 10, + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=19), + Constant( + 1, + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=27), + Constant( + 1, + lineno=5, + col_offset=34, + end_lineno=5, + end_col_offset=35), + Constant( + 1, + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=43), + Constant( + 1, + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=10), + Constant( + 4, + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=18), + Constant( + 4, + lineno=6, + col_offset=25, + end_lineno=6, + end_col_offset=26), + Constant( + 8, + lineno=6, + col_offset=33, + end_lineno=6, + end_col_offset=34), + Constant( + 4, + lineno=6, + col_offset=41, + end_lineno=6, + end_col_offset=42), + Constant( + 10, + lineno=7, + col_offset=9, + end_lineno=7, + end_col_offset=11)], + lineno=1, + col_offset=9, + end_lineno=8, + end_col_offset=1), + lineno=1, + col_offset=0, + end_lineno=8, + end_col_offset=1), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=11, + col_offset=10, + end_lineno=11, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=15), + 'isalpha', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=23), + [], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=25), + lineno=12, + col_offset=7, + end_lineno=12, + end_col_offset=25), + [ + Return( + Constant( + 0, + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=16), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=16)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=16), + Return( + Call( + Name( + 'sum', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + [ + GeneratorExp( + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=21), + Name( + 'placeholder_3', + Load(), + lineno=14, + col_offset=22, + end_lineno=14, + end_col_offset=28), + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=29), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=40), + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=48), + 'lower', + Load(), + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=54), + [], + [], + lineno=14, + col_offset=44, + end_lineno=14, + end_col_offset=56), + [], + 0)], + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=57)], + [], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=57), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=57)], + [], + lineno=11, + col_offset=0, + end_lineno=14, + end_col_offset=57)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-scrabble-score/representation.txt b/test/practice-scrabble-score/representation.txt new file mode 100644 index 0000000..e46970e --- /dev/null +++ b/test/practice-scrabble-score/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=6)], Dict([Constant('a', lineno=2, col_offset=4, end_lineno=2, end_col_offset=7), Constant('b', lineno=2, col_offset=12, end_lineno=2, end_col_offset=15), Constant('c', lineno=2, col_offset=20, end_lineno=2, end_col_offset=23), Constant('d', lineno=2, col_offset=28, end_lineno=2, end_col_offset=31), Constant('e', lineno=2, col_offset=36, end_lineno=2, end_col_offset=39), Constant('f', lineno=3, col_offset=4, end_lineno=3, end_col_offset=7), Constant('g', lineno=3, col_offset=12, end_lineno=3, end_col_offset=15), Constant('h', lineno=3, col_offset=20, end_lineno=3, end_col_offset=23), Constant('i', lineno=3, col_offset=28, end_lineno=3, end_col_offset=31), Constant('j', lineno=3, col_offset=36, end_lineno=3, end_col_offset=39), Constant('k', lineno=4, col_offset=4, end_lineno=4, end_col_offset=7), Constant('l', lineno=4, col_offset=12, end_lineno=4, end_col_offset=15), Constant('m', lineno=4, col_offset=20, end_lineno=4, end_col_offset=23), Constant('n', lineno=4, col_offset=28, end_lineno=4, end_col_offset=31), Constant('o', lineno=4, col_offset=36, end_lineno=4, end_col_offset=39), Constant('p', lineno=5, col_offset=4, end_lineno=5, end_col_offset=7), Constant('q', lineno=5, col_offset=12, end_lineno=5, end_col_offset=15), Constant('r', lineno=5, col_offset=21, end_lineno=5, end_col_offset=24), Constant('s', lineno=5, col_offset=29, end_lineno=5, end_col_offset=32), Constant('t', lineno=5, col_offset=37, end_lineno=5, end_col_offset=40), Constant('u', lineno=6, col_offset=4, end_lineno=6, end_col_offset=7), Constant('v', lineno=6, col_offset=12, end_lineno=6, end_col_offset=15), Constant('w', lineno=6, col_offset=20, end_lineno=6, end_col_offset=23), Constant('x', lineno=6, col_offset=28, end_lineno=6, end_col_offset=31), Constant('y', lineno=6, col_offset=36, end_lineno=6, end_col_offset=39), Constant('z', lineno=7, col_offset=4, end_lineno=7, end_col_offset=7)], [Constant(1, lineno=2, col_offset=9, end_lineno=2, end_col_offset=10), Constant(3, lineno=2, col_offset=17, end_lineno=2, end_col_offset=18), Constant(3, lineno=2, col_offset=25, end_lineno=2, end_col_offset=26), Constant(2, lineno=2, col_offset=33, end_lineno=2, end_col_offset=34), Constant(1, lineno=2, col_offset=41, end_lineno=2, end_col_offset=42), Constant(4, lineno=3, col_offset=9, end_lineno=3, end_col_offset=10), Constant(2, lineno=3, col_offset=17, end_lineno=3, end_col_offset=18), Constant(4, lineno=3, col_offset=25, end_lineno=3, end_col_offset=26), Constant(1, lineno=3, col_offset=33, end_lineno=3, end_col_offset=34), Constant(8, lineno=3, col_offset=41, end_lineno=3, end_col_offset=42), Constant(5, lineno=4, col_offset=9, end_lineno=4, end_col_offset=10), Constant(1, lineno=4, col_offset=17, end_lineno=4, end_col_offset=18), Constant(3, lineno=4, col_offset=25, end_lineno=4, end_col_offset=26), Constant(1, lineno=4, col_offset=33, end_lineno=4, end_col_offset=34), Constant(1, lineno=4, col_offset=41, end_lineno=4, end_col_offset=42), Constant(3, lineno=5, col_offset=9, end_lineno=5, end_col_offset=10), Constant(10, lineno=5, col_offset=17, end_lineno=5, end_col_offset=19), Constant(1, lineno=5, col_offset=26, end_lineno=5, end_col_offset=27), Constant(1, lineno=5, col_offset=34, end_lineno=5, end_col_offset=35), Constant(1, lineno=5, col_offset=42, end_lineno=5, end_col_offset=43), Constant(1, lineno=6, col_offset=9, end_lineno=6, end_col_offset=10), Constant(4, lineno=6, col_offset=17, end_lineno=6, end_col_offset=18), Constant(4, lineno=6, col_offset=25, end_lineno=6, end_col_offset=26), Constant(8, lineno=6, col_offset=33, end_lineno=6, end_col_offset=34), Constant(4, lineno=6, col_offset=41, end_lineno=6, end_col_offset=42), Constant(10, lineno=7, col_offset=9, end_lineno=7, end_col_offset=11)], lineno=1, col_offset=9, end_lineno=8, end_col_offset=1), lineno=1, col_offset=0, end_lineno=8, end_col_offset=1), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=11, col_offset=10, end_lineno=11, end_col_offset=14)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Attribute(Name('placeholder_2', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=15), 'isalpha', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=23), [], [], lineno=12, col_offset=11, end_lineno=12, end_col_offset=25), lineno=12, col_offset=7, end_lineno=12, end_col_offset=25), [Return(Constant(0, lineno=13, col_offset=15, end_lineno=13, end_col_offset=16), lineno=13, col_offset=8, end_lineno=13, end_col_offset=16)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=16), Return(Call(Name('sum', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=14), [GeneratorExp(Subscript(Name('placeholder_0', Load(), lineno=14, col_offset=15, end_lineno=14, end_col_offset=21), Name('placeholder_3', Load(), lineno=14, col_offset=22, end_lineno=14, end_col_offset=28), Load(), lineno=14, col_offset=15, end_lineno=14, end_col_offset=29), [comprehension(Name('placeholder_3', Store(), lineno=14, col_offset=34, end_lineno=14, end_col_offset=40), Call(Attribute(Name('placeholder_2', Load(), lineno=14, col_offset=44, end_lineno=14, end_col_offset=48), 'lower', Load(), lineno=14, col_offset=44, end_lineno=14, end_col_offset=54), [], [], lineno=14, col_offset=44, end_lineno=14, end_col_offset=56), [], 0)], lineno=14, col_offset=14, end_lineno=14, end_col_offset=57)], [], lineno=14, col_offset=11, end_lineno=14, end_col_offset=57), lineno=14, col_offset=4, end_lineno=14, end_col_offset=57)], [], lineno=11, col_offset=0, end_lineno=14, end_col_offset=57)], []) \ No newline at end of file diff --git a/test/practice-scrabble-score/scrabble_score.py b/test/practice-scrabble-score/scrabble_score.py new file mode 100644 index 0000000..8ab7d58 --- /dev/null +++ b/test/practice-scrabble-score/scrabble_score.py @@ -0,0 +1,14 @@ +POINTS = { + 'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, + 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, + 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, + 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, + 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, + 'z': 10 +} + + +def score(word): + if not word.isalpha(): + return 0 + return sum(POINTS[letter] for letter in word.lower()) diff --git a/test/practice-secret-handshake/.meta/config.json b/test/practice-secret-handshake/.meta/config.json new file mode 100644 index 0000000..7972aa1 --- /dev/null +++ b/test/practice-secret-handshake/.meta/config.json @@ -0,0 +1,35 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cmccandless", + "crsmi", + "Dog", + "Grociu", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "pheanex", + "sjakobi", + "sjwarner-bp", + "subkrish", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "secret_handshake.py" + ], + "test": [ + "secret_handshake_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.", + "source": "Bert, in Mary Poppins", + "source_url": "https://www.imdb.com/title/tt0058331/quotes/?item=qt0437047" +} diff --git a/test/practice-secret-handshake/.meta/plugins.py b/test/practice-secret-handshake/.meta/plugins.py new file mode 100644 index 0000000..dc53ada --- /dev/null +++ b/test/practice-secret-handshake/.meta/plugins.py @@ -0,0 +1,2 @@ +def to_binary(num, digits=5): + return bin(num)[2:].zfill(digits) diff --git a/test/practice-secret-handshake/mapping.json b/test/practice-secret-handshake/mapping.json new file mode 100644 index 0000000..20c20c2 --- /dev/null +++ b/test/practice-secret-handshake/mapping.json @@ -0,0 +1,4 @@ +{ + "placeholder_0": "commands", + "placeholder_1": "binary_str" +} \ No newline at end of file diff --git a/test/practice-secret-handshake/representation.json b/test/practice-secret-handshake/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-secret-handshake/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-secret-handshake/representation.out b/test/practice-secret-handshake/representation.out new file mode 100644 index 0000000..29a6c02 --- /dev/null +++ b/test/practice-secret-handshake/representation.out @@ -0,0 +1,67 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + pass + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'commands', + arguments( + [], + [ + arg( + 'binary_str', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Pass( + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=8)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=8)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=13, + end_lineno=1, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Pass( + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=8)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=8)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-secret-handshake/representation.txt b/test/practice-secret-handshake/representation.txt new file mode 100644 index 0000000..62421a7 --- /dev/null +++ b/test/practice-secret-handshake/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=13, end_lineno=1, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Pass(lineno=2, col_offset=4, end_lineno=2, end_col_offset=8)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=8)], []) \ No newline at end of file diff --git a/test/practice-secret-handshake/secret_handshake.py b/test/practice-secret-handshake/secret_handshake.py new file mode 100644 index 0000000..e3691e1 --- /dev/null +++ b/test/practice-secret-handshake/secret_handshake.py @@ -0,0 +1,2 @@ +def commands(binary_str): + pass diff --git a/test/practice-series/.meta/config.json b/test/practice-series/.meta/config.json new file mode 100644 index 0000000..3faaa9a --- /dev/null +++ b/test/practice-series/.meta/config.json @@ -0,0 +1,32 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "behrtam", + "cmccandless", + "crsmi", + "Dog", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "pheanex", + "rohitrango", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "series.py" + ], + "test": [ + "series_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a string of digits, output all the contiguous substrings of length `n` in that string.", + "source": "A subset of the Problem 8 at Project Euler", + "source_url": "https://projecteuler.net/problem=8" +} diff --git a/test/practice-series/mapping.json b/test/practice-series/mapping.json new file mode 100644 index 0000000..f326635 --- /dev/null +++ b/test/practice-series/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "slices", + "placeholder_1": "series", + "placeholder_2": "length", + "placeholder_3": "idx" +} \ No newline at end of file diff --git a/test/practice-series/representation.json b/test/practice-series/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-series/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-series/representation.out b/test/practice-series/representation.out new file mode 100644 index 0000000..d7e8e6b --- /dev/null +++ b/test/practice-series/representation.out @@ -0,0 +1,770 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + if not placeholder_1: + raise ValueError("series cannot be empty") + elif placeholder_2 == 0: + raise ValueError("slice length cannot be zero") + elif placeholder_2 < 0: + raise ValueError("slice length cannot be negative") + elif len(placeholder_1) < placeholder_2: + raise ValueError("slice length cannot be greater than series length") + return [ + placeholder_1[placeholder_3 : placeholder_3 + placeholder_2] + for placeholder_3 in range(len(placeholder_1) - placeholder_2 + 1) + ] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'slices', + arguments( + [], + [ + arg( + 'series', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=17), + arg( + 'length', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'series', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=17), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'series cannot be empty', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=49)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=50), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=50)], + [ + If( + Compare( + Name( + 'length', + Load(), + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 0, + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=20)], + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=24), + [ + Constant( + 'slice length cannot be zero', + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=54)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=55), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=55)], + [ + If( + Compare( + Name( + 'length', + Load(), + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=15), + [ + Lt()], + [ + Constant( + 0, + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=19)], + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=19), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'slice length cannot be negative', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=58)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=59), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=59)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=12), + [ + Name( + 'series', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=19)], + [], + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=20), + [ + Lt()], + [ + Name( + 'length', + Load(), + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=29)], + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=29), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=9, + col_offset=14, + end_lineno=9, + end_col_offset=24), + [ + Constant( + 'slice length cannot be greater than series length', + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=76)], + [], + lineno=9, + col_offset=14, + end_lineno=9, + end_col_offset=77), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=77)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=77)], + lineno=6, + col_offset=4, + end_lineno=9, + end_col_offset=77)], + lineno=4, + col_offset=4, + end_lineno=9, + end_col_offset=77)], + lineno=2, + col_offset=4, + end_lineno=9, + end_col_offset=77), + Return( + ListComp( + Subscript( + Name( + 'series', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18), + Slice( + Name( + 'idx', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=22), + BinOp( + Name( + 'idx', + Load(), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=26), + Add(), + Name( + 'length', + Load(), + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=35), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=35), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=35), + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=36), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=11, + col_offset=41, + end_lineno=11, + end_col_offset=44), + Call( + Name( + 'range', + Load(), + lineno=11, + col_offset=48, + end_lineno=11, + end_col_offset=53), + [ + BinOp( + BinOp( + Call( + Name( + 'len', + Load(), + lineno=11, + col_offset=54, + end_lineno=11, + end_col_offset=57), + [ + Name( + 'series', + Load(), + lineno=11, + col_offset=58, + end_lineno=11, + end_col_offset=64)], + [], + lineno=11, + col_offset=54, + end_lineno=11, + end_col_offset=65), + Sub(), + Name( + 'length', + Load(), + lineno=11, + col_offset=68, + end_lineno=11, + end_col_offset=74), + lineno=11, + col_offset=54, + end_lineno=11, + end_col_offset=74), + Add(), + Constant( + 1, + lineno=11, + col_offset=77, + end_lineno=11, + end_col_offset=78), + lineno=11, + col_offset=54, + end_lineno=11, + end_col_offset=78)], + [], + lineno=11, + col_offset=48, + end_lineno=11, + end_col_offset=79), + [], + 0)], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=80), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=80)], + [], + lineno=1, + col_offset=0, + end_lineno=11, + end_col_offset=80)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=17), + arg( + 'placeholder_2', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=17), + lineno=2, + col_offset=7, + end_lineno=2, + end_col_offset=17), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=24), + [ + Constant( + 'series cannot be empty', + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=49)], + [], + lineno=3, + col_offset=14, + end_lineno=3, + end_col_offset=50), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=50)], + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 0, + lineno=4, + col_offset=19, + end_lineno=4, + end_col_offset=20)], + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=20), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=24), + [ + Constant( + 'slice length cannot be zero', + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=54)], + [], + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=55), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=55)], + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=15), + [ + Lt()], + [ + Constant( + 0, + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=19)], + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=19), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=24), + [ + Constant( + 'slice length cannot be negative', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=58)], + [], + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=59), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=59)], + [ + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=12), + [ + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=19)], + [], + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=20), + [ + Lt()], + [ + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=29)], + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=29), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=9, + col_offset=14, + end_lineno=9, + end_col_offset=24), + [ + Constant( + 'slice length cannot be greater than series length', + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=76)], + [], + lineno=9, + col_offset=14, + end_lineno=9, + end_col_offset=77), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=77)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=77)], + lineno=6, + col_offset=4, + end_lineno=9, + end_col_offset=77)], + lineno=4, + col_offset=4, + end_lineno=9, + end_col_offset=77)], + lineno=2, + col_offset=4, + end_lineno=9, + end_col_offset=77), + Return( + ListComp( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18), + Slice( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=22), + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=26), + Add(), + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=29, + end_lineno=11, + end_col_offset=35), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=35), + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=35), + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=36), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=11, + col_offset=41, + end_lineno=11, + end_col_offset=44), + Call( + Name( + 'range', + Load(), + lineno=11, + col_offset=48, + end_lineno=11, + end_col_offset=53), + [ + BinOp( + BinOp( + Call( + Name( + 'len', + Load(), + lineno=11, + col_offset=54, + end_lineno=11, + end_col_offset=57), + [ + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=58, + end_lineno=11, + end_col_offset=64)], + [], + lineno=11, + col_offset=54, + end_lineno=11, + end_col_offset=65), + Sub(), + Name( + 'placeholder_2', + Load(), + lineno=11, + col_offset=68, + end_lineno=11, + end_col_offset=74), + lineno=11, + col_offset=54, + end_lineno=11, + end_col_offset=74), + Add(), + Constant( + 1, + lineno=11, + col_offset=77, + end_lineno=11, + end_col_offset=78), + lineno=11, + col_offset=54, + end_lineno=11, + end_col_offset=78)], + [], + lineno=11, + col_offset=48, + end_lineno=11, + end_col_offset=79), + [], + 0)], + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=80), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=80)], + [], + lineno=1, + col_offset=0, + end_lineno=11, + end_col_offset=80)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-series/representation.txt b/test/practice-series/representation.txt new file mode 100644 index 0000000..7a2a64d --- /dev/null +++ b/test/practice-series/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=11, end_lineno=1, end_col_offset=17), arg('placeholder_2', lineno=1, col_offset=19, end_lineno=1, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Name('placeholder_1', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=17), lineno=2, col_offset=7, end_lineno=2, end_col_offset=17), [Raise(Call(Name('ValueError', Load(), lineno=3, col_offset=14, end_lineno=3, end_col_offset=24), [Constant('series cannot be empty', lineno=3, col_offset=25, end_lineno=3, end_col_offset=49)], [], lineno=3, col_offset=14, end_lineno=3, end_col_offset=50), lineno=3, col_offset=8, end_lineno=3, end_col_offset=50)], [If(Compare(Name('placeholder_2', Load(), lineno=4, col_offset=9, end_lineno=4, end_col_offset=15), [Eq()], [Constant(0, lineno=4, col_offset=19, end_lineno=4, end_col_offset=20)], lineno=4, col_offset=9, end_lineno=4, end_col_offset=20), [Raise(Call(Name('ValueError', Load(), lineno=5, col_offset=14, end_lineno=5, end_col_offset=24), [Constant('slice length cannot be zero', lineno=5, col_offset=25, end_lineno=5, end_col_offset=54)], [], lineno=5, col_offset=14, end_lineno=5, end_col_offset=55), lineno=5, col_offset=8, end_lineno=5, end_col_offset=55)], [If(Compare(Name('placeholder_2', Load(), lineno=6, col_offset=9, end_lineno=6, end_col_offset=15), [Lt()], [Constant(0, lineno=6, col_offset=18, end_lineno=6, end_col_offset=19)], lineno=6, col_offset=9, end_lineno=6, end_col_offset=19), [Raise(Call(Name('ValueError', Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=24), [Constant('slice length cannot be negative', lineno=7, col_offset=25, end_lineno=7, end_col_offset=58)], [], lineno=7, col_offset=14, end_lineno=7, end_col_offset=59), lineno=7, col_offset=8, end_lineno=7, end_col_offset=59)], [If(Compare(Call(Name('len', Load(), lineno=8, col_offset=9, end_lineno=8, end_col_offset=12), [Name('placeholder_1', Load(), lineno=8, col_offset=13, end_lineno=8, end_col_offset=19)], [], lineno=8, col_offset=9, end_lineno=8, end_col_offset=20), [Lt()], [Name('placeholder_2', Load(), lineno=8, col_offset=23, end_lineno=8, end_col_offset=29)], lineno=8, col_offset=9, end_lineno=8, end_col_offset=29), [Raise(Call(Name('ValueError', Load(), lineno=9, col_offset=14, end_lineno=9, end_col_offset=24), [Constant('slice length cannot be greater than series length', lineno=9, col_offset=25, end_lineno=9, end_col_offset=76)], [], lineno=9, col_offset=14, end_lineno=9, end_col_offset=77), lineno=9, col_offset=8, end_lineno=9, end_col_offset=77)], [], lineno=8, col_offset=4, end_lineno=9, end_col_offset=77)], lineno=6, col_offset=4, end_lineno=9, end_col_offset=77)], lineno=4, col_offset=4, end_lineno=9, end_col_offset=77)], lineno=2, col_offset=4, end_lineno=9, end_col_offset=77), Return(ListComp(Subscript(Name('placeholder_1', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=18), Slice(Name('placeholder_3', Load(), lineno=11, col_offset=19, end_lineno=11, end_col_offset=22), BinOp(Name('placeholder_3', Load(), lineno=11, col_offset=23, end_lineno=11, end_col_offset=26), Add(), Name('placeholder_2', Load(), lineno=11, col_offset=29, end_lineno=11, end_col_offset=35), lineno=11, col_offset=23, end_lineno=11, end_col_offset=35), lineno=11, col_offset=19, end_lineno=11, end_col_offset=35), Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=36), [comprehension(Name('placeholder_3', Store(), lineno=11, col_offset=41, end_lineno=11, end_col_offset=44), Call(Name('range', Load(), lineno=11, col_offset=48, end_lineno=11, end_col_offset=53), [BinOp(BinOp(Call(Name('len', Load(), lineno=11, col_offset=54, end_lineno=11, end_col_offset=57), [Name('placeholder_1', Load(), lineno=11, col_offset=58, end_lineno=11, end_col_offset=64)], [], lineno=11, col_offset=54, end_lineno=11, end_col_offset=65), Sub(), Name('placeholder_2', Load(), lineno=11, col_offset=68, end_lineno=11, end_col_offset=74), lineno=11, col_offset=54, end_lineno=11, end_col_offset=74), Add(), Constant(1, lineno=11, col_offset=77, end_lineno=11, end_col_offset=78), lineno=11, col_offset=54, end_lineno=11, end_col_offset=78)], [], lineno=11, col_offset=48, end_lineno=11, end_col_offset=79), [], 0)], lineno=11, col_offset=11, end_lineno=11, end_col_offset=80), lineno=11, col_offset=4, end_lineno=11, end_col_offset=80)], [], lineno=1, col_offset=0, end_lineno=11, end_col_offset=80)], []) \ No newline at end of file diff --git a/test/practice-series/series.py b/test/practice-series/series.py new file mode 100644 index 0000000..447819f --- /dev/null +++ b/test/practice-series/series.py @@ -0,0 +1,11 @@ +def slices(series, length): + if not series: + raise ValueError('series cannot be empty') + elif length == 0: + raise ValueError('slice length cannot be zero') + elif length < 0: + raise ValueError('slice length cannot be negative') + elif len(series) < length: + raise ValueError('slice length cannot be greater than series length') + + return [series[idx:idx + length] for idx in range(len(series) - length + 1)] diff --git a/test/practice-sgf-parsing/.meta/config.json b/test/practice-sgf-parsing/.meta/config.json new file mode 100644 index 0000000..565a8ce --- /dev/null +++ b/test/practice-sgf-parsing/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "BethanyG", + "crsmi", + "Dog", + "elyashiv", + "IsaacG", + "thomasjpfan", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "sgf_parsing.py" + ], + "test": [ + "sgf_parsing_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Parsing a Smart Game Format string." +} diff --git a/test/practice-sgf-parsing/mapping.json b/test/practice-sgf-parsing/mapping.json new file mode 100644 index 0000000..d3bd722 --- /dev/null +++ b/test/practice-sgf-parsing/mapping.json @@ -0,0 +1,20 @@ +{ + "placeholder_0": "SgfTree", + "placeholder_1": "properties", + "placeholder_2": "default_factory", + "placeholder_3": "children", + "placeholder_4": "parse_property_vals", + "placeholder_5": "sgf", + "placeholder_6": "idx", + "placeholder_7": "values", + "placeholder_8": "prop_val", + "placeholder_9": "char", + "placeholder_10": "parse_node", + "placeholder_11": "prop_key_start", + "placeholder_12": "prop_key", + "placeholder_13": "prop_vals", + "placeholder_14": "child", + "placeholder_15": "child_start", + "placeholder_16": "parse", + "placeholder_17": "inside" +} \ No newline at end of file diff --git a/test/practice-sgf-parsing/representation.json b/test/practice-sgf-parsing/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-sgf-parsing/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-sgf-parsing/representation.out b/test/practice-sgf-parsing/representation.out new file mode 100644 index 0000000..7892ccf --- /dev/null +++ b/test/practice-sgf-parsing/representation.out @@ -0,0 +1,4796 @@ +## BEGIN NORMALIZED CODE ## +from __future__ import annotations +import collections +import dataclasses +import string + + +@dataclasses.dataclass +class placeholder_0: + placeholder_1 = dataclasses.field(placeholder_2=dict) + placeholder_3 = dataclasses.field(placeholder_2=list) + + +def placeholder_4(placeholder_5, placeholder_6): + placeholder_7 = [] + while placeholder_6 < len(placeholder_5): + if placeholder_5[placeholder_6] != "[": + break + placeholder_6 += 1 + placeholder_8 = "" + while placeholder_5[placeholder_6] != "]": + if placeholder_5[placeholder_6] == "\\": + if placeholder_5[placeholder_6 : placeholder_6 + 2] == "\\\n": + pass + else: + placeholder_8 += placeholder_5[placeholder_6 + 1] + placeholder_6 += 2 + else: + placeholder_8 += placeholder_5[placeholder_6] + placeholder_6 += 1 + for placeholder_9 in string.whitespace: + if placeholder_9 == "\n": + continue + placeholder_8 = placeholder_8.replace(placeholder_9, " ") + placeholder_7.append(placeholder_8) + placeholder_6 += 1 + return (placeholder_6, placeholder_7) + + +def placeholder_10(placeholder_5): + if not placeholder_5.startswith(";"): + raise ValueError("node must start with ';'") + placeholder_6 = 1 + placeholder_11 = placeholder_6 + placeholder_1 = collections.defaultdict(list) + placeholder_3 = [] + while placeholder_6 < len(placeholder_5): + if placeholder_5[placeholder_6] == "[": + if placeholder_6 == placeholder_11: + raise ValueError("propery key is empty") + placeholder_12 = placeholder_5[placeholder_11:placeholder_6] + if not placeholder_12.isupper(): + raise ValueError("property must be in uppercase") + placeholder_6, placeholder_13 = placeholder_4(placeholder_5, placeholder_6) + placeholder_1[placeholder_12].extend(placeholder_13) + placeholder_11 = placeholder_6 + elif placeholder_5[placeholder_6] == ";": + placeholder_14 = placeholder_10(placeholder_5[placeholder_6:]) + placeholder_3.append(placeholder_14) + break + elif placeholder_5[placeholder_6] == "(": + placeholder_3 = [] + while placeholder_6 < len(placeholder_5): + if placeholder_5[placeholder_6] != "(": + break + placeholder_6 += 1 + placeholder_15 = placeholder_6 + while placeholder_5[placeholder_6] != ")": + placeholder_6 += 1 + placeholder_14 = placeholder_10( + placeholder_5[placeholder_15:placeholder_6] + ) + placeholder_3.append(placeholder_14) + placeholder_6 += 1 + else: + placeholder_6 += 1 + if placeholder_6 > placeholder_11 and (not placeholder_1): + raise ValueError("properties without delimiter") + return placeholder_0(placeholder_3=placeholder_3, placeholder_1=dict(placeholder_1)) + + +def placeholder_16(placeholder_5): + if not placeholder_5.startswith("(") and (not placeholder_5.endswith(")")): + raise ValueError("tree missing") + if not placeholder_5.startswith("(;"): + raise ValueError("tree with no nodes") + placeholder_17 = placeholder_5[1:-1] + return placeholder_10(placeholder_17) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'Parse an SGF tree.', + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=24), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=24), + ImportFrom( + '__future__', + [ + alias( + 'annotations', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=34)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=34), + Import( + [ + alias( + 'collections', + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=18)], + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=18), + Import( + [ + alias( + 'dataclasses', + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=18)], + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=18), + Import( + [ + alias( + 'string', + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=13)], + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=13), + ClassDef( + 'SgfTree', + [], + [], + [ + Expr( + Constant( + 'SGF Node.', + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=19), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=19), + AnnAssign( + Name( + 'properties', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=14), + Subscript( + Name( + 'dict', + Load(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=20), + Tuple( + [ + Name( + 'str', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=24), + Name( + 'str', + Load(), + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=29)], + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=29), + Load(), + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=30), + Call( + Attribute( + Name( + 'dataclasses', + Load(), + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=44), + 'field', + Load(), + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=50), + [], + [ + keyword( + 'default_factory', + Name( + 'dict', + Load(), + lineno=13, + col_offset=67, + end_lineno=13, + end_col_offset=71), + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=71)], + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=72), + 1, + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=72), + AnnAssign( + Name( + 'children', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=12), + Subscript( + Name( + 'list', + Load(), + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=18), + Name( + 'SgfTree', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=26), + Load(), + lineno=14, + col_offset=14, + end_lineno=14, + end_col_offset=27), + Call( + Attribute( + Name( + 'dataclasses', + Load(), + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=41), + 'field', + Load(), + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=47), + [], + [ + keyword( + 'default_factory', + Name( + 'list', + Load(), + lineno=14, + col_offset=64, + end_lineno=14, + end_col_offset=68), + lineno=14, + col_offset=48, + end_lineno=14, + end_col_offset=68)], + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=69), + 1, + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=69)], + [ + Attribute( + Name( + 'dataclasses', + Load(), + lineno=9, + col_offset=1, + end_lineno=9, + end_col_offset=12), + 'dataclass', + Load(), + lineno=9, + col_offset=1, + end_lineno=9, + end_col_offset=22)], + lineno=10, + col_offset=0, + end_lineno=14, + end_col_offset=69), + FunctionDef( + 'parse_property_vals', + arguments( + [], + [ + arg( + 'sgf', + Name( + 'str', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=32), + lineno=17, + col_offset=24, + end_lineno=17, + end_col_offset=32), + arg( + 'idx', + Name( + 'int', + Load(), + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=42), + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Parse property values, returning the next index and values.', + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=69), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=69), + Assign( + [ + Name( + 'values', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=10)], + List( + [], + Load(), + lineno=19, + col_offset=13, + end_lineno=19, + end_col_offset=15), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=15), + While( + Compare( + Name( + 'idx', + Load(), + lineno=20, + col_offset=10, + end_lineno=20, + end_col_offset=13), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=19), + [ + Name( + 'sgf', + Load(), + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=23)], + [], + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=24)], + lineno=20, + col_offset=10, + end_lineno=20, + end_col_offset=24), + [ + If( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=14), + Name( + 'idx', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=18), + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=19), + [ + NotEq()], + [ + Constant( + '[', + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=26)], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=26), + [ + Break( + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=17)], + [], + lineno=21, + col_offset=8, + end_lineno=22, + end_col_offset=17), + AugAssign( + Name( + 'idx', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=11), + Add(), + Constant( + 1, + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=16), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=16), + Assign( + [ + Name( + 'prop_val', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=16)], + Constant( + '', + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=21), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=21), + While( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=17), + Name( + 'idx', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=21), + Load(), + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=22), + [ + NotEq()], + [ + Constant( + ']', + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=29)], + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=29), + [ + If( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=18), + Name( + 'idx', + Load(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=22), + Load(), + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=23), + [ + Eq()], + [ + Constant( + '\\', + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=31)], + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=31), + [ + If( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=22), + Slice( + Name( + 'idx', + Load(), + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=26), + BinOp( + Name( + 'idx', + Load(), + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=30), + Add(), + Constant( + 2, + lineno=30, + col_offset=33, + end_lineno=30, + end_col_offset=34), + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=34), + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=34), + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=35), + [ + Eq()], + [ + Constant( + '\\\n', + lineno=30, + col_offset=39, + end_lineno=30, + end_col_offset=45)], + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=45), + [ + Pass( + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=24)], + [ + AugAssign( + Name( + 'prop_val', + Store(), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=28), + Add(), + Subscript( + Name( + 'sgf', + Load(), + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=35), + BinOp( + Name( + 'idx', + Load(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=39), + Add(), + Constant( + 1, + lineno=37, + col_offset=42, + end_lineno=37, + end_col_offset=43), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=43), + Load(), + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=44), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=44)], + lineno=30, + col_offset=16, + end_lineno=37, + end_col_offset=44), + AugAssign( + Name( + 'idx', + Store(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=19), + Add(), + Constant( + 2, + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=24), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=24)], + [ + AugAssign( + Name( + 'prop_val', + Store(), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=24), + Add(), + Subscript( + Name( + 'sgf', + Load(), + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=31), + Name( + 'idx', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=35), + Load(), + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=36), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=36), + AugAssign( + Name( + 'idx', + Store(), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=41, + col_offset=23, + end_lineno=41, + end_col_offset=24), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=24)], + lineno=29, + col_offset=12, + end_lineno=41, + end_col_offset=24)], + [], + lineno=27, + col_offset=8, + end_lineno=41, + end_col_offset=24), + For( + Name( + 'char', + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=16), + Attribute( + Name( + 'string', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=26), + 'whitespace', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=37), + [ + If( + Compare( + Name( + 'char', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=19), + [ + Eq()], + [ + Constant( + '\n', + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=27)], + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=27), + [ + Continue( + lineno=46, + col_offset=16, + end_lineno=46, + end_col_offset=24)], + [], + lineno=45, + col_offset=12, + end_lineno=46, + end_col_offset=24), + Assign( + [ + Name( + 'prop_val', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=20)], + Call( + Attribute( + Name( + 'prop_val', + Load(), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=31), + 'replace', + Load(), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=39), + [ + Name( + 'char', + Load(), + lineno=47, + col_offset=40, + end_lineno=47, + end_col_offset=44), + Constant( + ' ', + lineno=47, + col_offset=46, + end_lineno=47, + end_col_offset=49)], + [], + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=50), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=50)], + [], + lineno=44, + col_offset=8, + end_lineno=47, + end_col_offset=50), + Expr( + Call( + Attribute( + Name( + 'values', + Load(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=14), + 'append', + Load(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=21), + [ + Name( + 'prop_val', + Load(), + lineno=49, + col_offset=22, + end_lineno=49, + end_col_offset=30)], + [], + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=31), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=31), + AugAssign( + Name( + 'idx', + Store(), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=11), + Add(), + Constant( + 1, + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=16), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=16)], + [], + lineno=20, + col_offset=4, + end_lineno=50, + end_col_offset=16), + Return( + Tuple( + [ + Name( + 'idx', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=14), + Name( + 'values', + Load(), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=22)], + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=22), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=22)], + [], + Subscript( + Name( + 'tuple', + Load(), + lineno=17, + col_offset=47, + end_lineno=17, + end_col_offset=52), + Tuple( + [ + Name( + 'int', + Load(), + lineno=17, + col_offset=53, + end_lineno=17, + end_col_offset=56), + Subscript( + Name( + 'list', + Load(), + lineno=17, + col_offset=58, + end_lineno=17, + end_col_offset=62), + Name( + 'str', + Load(), + lineno=17, + col_offset=63, + end_lineno=17, + end_col_offset=66), + Load(), + lineno=17, + col_offset=58, + end_lineno=17, + end_col_offset=67)], + Load(), + lineno=17, + col_offset=53, + end_lineno=17, + end_col_offset=67), + Load(), + lineno=17, + col_offset=47, + end_lineno=17, + end_col_offset=68), + lineno=17, + col_offset=0, + end_lineno=52, + end_col_offset=22), + FunctionDef( + 'parse_node', + arguments( + [], + [ + arg( + 'sgf', + Name( + 'str', + Load(), + lineno=55, + col_offset=20, + end_lineno=55, + end_col_offset=23), + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Parse and return a Node.', + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=34), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=34), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'sgf', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=14), + 'startswith', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=25), + [ + Constant( + ';', + lineno=57, + col_offset=26, + end_lineno=57, + end_col_offset=29)], + [], + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=30), + lineno=57, + col_offset=7, + end_lineno=57, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=58, + col_offset=14, + end_lineno=58, + end_col_offset=24), + [ + Constant( + "node must start with ';'", + lineno=58, + col_offset=25, + end_lineno=58, + end_col_offset=51)], + [], + lineno=58, + col_offset=14, + end_lineno=58, + end_col_offset=52), + lineno=58, + col_offset=8, + end_lineno=58, + end_col_offset=52)], + [], + lineno=57, + col_offset=4, + end_lineno=58, + end_col_offset=52), + Assign( + [ + Name( + 'idx', + Store(), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=7)], + Constant( + 1, + lineno=60, + col_offset=10, + end_lineno=60, + end_col_offset=11), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=11), + Assign( + [ + Name( + 'prop_key_start', + Store(), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=18)], + Name( + 'idx', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=24), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=24), + Assign( + [ + Name( + 'properties', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=14)], + Call( + Attribute( + Name( + 'collections', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=28), + 'defaultdict', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=40), + [ + Name( + 'list', + Load(), + lineno=63, + col_offset=41, + end_lineno=63, + end_col_offset=45)], + [], + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=46), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=46), + Assign( + [ + Name( + 'children', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=12)], + List( + [], + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=17), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=17), + While( + Compare( + Name( + 'idx', + Load(), + lineno=66, + col_offset=10, + end_lineno=66, + end_col_offset=13), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=19), + [ + Name( + 'sgf', + Load(), + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=23)], + [], + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=24)], + lineno=66, + col_offset=10, + end_lineno=66, + end_col_offset=24), + [ + If( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=14), + Name( + 'idx', + Load(), + lineno=67, + col_offset=15, + end_lineno=67, + end_col_offset=18), + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=19), + [ + Eq()], + [ + Constant( + '[', + lineno=67, + col_offset=23, + end_lineno=67, + end_col_offset=26)], + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=26), + [ + If( + Compare( + Name( + 'idx', + Load(), + lineno=69, + col_offset=15, + end_lineno=69, + end_col_offset=18), + [ + Eq()], + [ + Name( + 'prop_key_start', + Load(), + lineno=69, + col_offset=22, + end_lineno=69, + end_col_offset=36)], + lineno=69, + col_offset=15, + end_lineno=69, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=70, + col_offset=22, + end_lineno=70, + end_col_offset=32), + [ + Constant( + 'propery key is empty', + lineno=70, + col_offset=33, + end_lineno=70, + end_col_offset=55)], + [], + lineno=70, + col_offset=22, + end_lineno=70, + end_col_offset=56), + lineno=70, + col_offset=16, + end_lineno=70, + end_col_offset=56)], + [], + lineno=69, + col_offset=12, + end_lineno=70, + end_col_offset=56), + Assign( + [ + Name( + 'prop_key', + Store(), + lineno=71, + col_offset=12, + end_lineno=71, + end_col_offset=20)], + Subscript( + Name( + 'sgf', + Load(), + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=26), + Slice( + Name( + 'prop_key_start', + Load(), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=41), + Name( + 'idx', + Load(), + lineno=71, + col_offset=42, + end_lineno=71, + end_col_offset=45), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=45), + Load(), + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=46), + lineno=71, + col_offset=12, + end_lineno=71, + end_col_offset=46), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'prop_key', + Load(), + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=27), + 'isupper', + Load(), + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=35), + [], + [], + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=37), + lineno=72, + col_offset=15, + end_lineno=72, + end_col_offset=37), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=73, + col_offset=22, + end_lineno=73, + end_col_offset=32), + [ + Constant( + 'property must be in uppercase', + lineno=73, + col_offset=33, + end_lineno=73, + end_col_offset=64)], + [], + lineno=73, + col_offset=22, + end_lineno=73, + end_col_offset=65), + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=65)], + [], + lineno=72, + col_offset=12, + end_lineno=73, + end_col_offset=65), + Assign( + [ + Tuple( + [ + Name( + 'idx', + Store(), + lineno=75, + col_offset=12, + end_lineno=75, + end_col_offset=15), + Name( + 'prop_vals', + Store(), + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=26)], + Store(), + lineno=75, + col_offset=12, + end_lineno=75, + end_col_offset=26)], + Call( + Name( + 'parse_property_vals', + Load(), + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=48), + [ + Name( + 'sgf', + Load(), + lineno=75, + col_offset=49, + end_lineno=75, + end_col_offset=52), + Name( + 'idx', + Load(), + lineno=75, + col_offset=54, + end_lineno=75, + end_col_offset=57)], + [], + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=58), + lineno=75, + col_offset=12, + end_lineno=75, + end_col_offset=58), + Expr( + Call( + Attribute( + Subscript( + Name( + 'properties', + Load(), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=22), + Name( + 'prop_key', + Load(), + lineno=76, + col_offset=23, + end_lineno=76, + end_col_offset=31), + Load(), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=32), + 'extend', + Load(), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=39), + [ + Name( + 'prop_vals', + Load(), + lineno=76, + col_offset=40, + end_lineno=76, + end_col_offset=49)], + [], + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=50), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=50), + Assign( + [ + Name( + 'prop_key_start', + Store(), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=26)], + Name( + 'idx', + Load(), + lineno=79, + col_offset=29, + end_lineno=79, + end_col_offset=32), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=32)], + [ + If( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=80, + col_offset=13, + end_lineno=80, + end_col_offset=16), + Name( + 'idx', + Load(), + lineno=80, + col_offset=17, + end_lineno=80, + end_col_offset=20), + Load(), + lineno=80, + col_offset=13, + end_lineno=80, + end_col_offset=21), + [ + Eq()], + [ + Constant( + ';', + lineno=80, + col_offset=25, + end_lineno=80, + end_col_offset=28)], + lineno=80, + col_offset=13, + end_lineno=80, + end_col_offset=28), + [ + Assign( + [ + Name( + 'child', + Store(), + lineno=82, + col_offset=12, + end_lineno=82, + end_col_offset=17)], + Call( + Name( + 'parse_node', + Load(), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=30), + [ + Subscript( + Name( + 'sgf', + Load(), + lineno=82, + col_offset=31, + end_lineno=82, + end_col_offset=34), + Slice( + Name( + 'idx', + Load(), + lineno=82, + col_offset=35, + end_lineno=82, + end_col_offset=38), + lineno=82, + col_offset=35, + end_lineno=82, + end_col_offset=39), + Load(), + lineno=82, + col_offset=31, + end_lineno=82, + end_col_offset=40)], + [], + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=41), + lineno=82, + col_offset=12, + end_lineno=82, + end_col_offset=41), + Expr( + Call( + Attribute( + Name( + 'children', + Load(), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=20), + 'append', + Load(), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=27), + [ + Name( + 'child', + Load(), + lineno=83, + col_offset=28, + end_lineno=83, + end_col_offset=33)], + [], + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=34), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=34), + Break( + lineno=84, + col_offset=12, + end_lineno=84, + end_col_offset=17)], + [ + If( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=85, + col_offset=13, + end_lineno=85, + end_col_offset=16), + Name( + 'idx', + Load(), + lineno=85, + col_offset=17, + end_lineno=85, + end_col_offset=20), + Load(), + lineno=85, + col_offset=13, + end_lineno=85, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '(', + lineno=85, + col_offset=25, + end_lineno=85, + end_col_offset=28)], + lineno=85, + col_offset=13, + end_lineno=85, + end_col_offset=28), + [ + Assign( + [ + Name( + 'children', + Store(), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=20)], + List( + [], + Load(), + lineno=87, + col_offset=23, + end_lineno=87, + end_col_offset=25), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=25), + While( + Compare( + Name( + 'idx', + Load(), + lineno=88, + col_offset=18, + end_lineno=88, + end_col_offset=21), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=88, + col_offset=24, + end_lineno=88, + end_col_offset=27), + [ + Name( + 'sgf', + Load(), + lineno=88, + col_offset=28, + end_lineno=88, + end_col_offset=31)], + [], + lineno=88, + col_offset=24, + end_lineno=88, + end_col_offset=32)], + lineno=88, + col_offset=18, + end_lineno=88, + end_col_offset=32), + [ + If( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=89, + col_offset=19, + end_lineno=89, + end_col_offset=22), + Name( + 'idx', + Load(), + lineno=89, + col_offset=23, + end_lineno=89, + end_col_offset=26), + Load(), + lineno=89, + col_offset=19, + end_lineno=89, + end_col_offset=27), + [ + NotEq()], + [ + Constant( + '(', + lineno=89, + col_offset=31, + end_lineno=89, + end_col_offset=34)], + lineno=89, + col_offset=19, + end_lineno=89, + end_col_offset=34), + [ + Break( + lineno=90, + col_offset=20, + end_lineno=90, + end_col_offset=25)], + [], + lineno=89, + col_offset=16, + end_lineno=90, + end_col_offset=25), + AugAssign( + Name( + 'idx', + Store(), + lineno=92, + col_offset=16, + end_lineno=92, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=92, + col_offset=23, + end_lineno=92, + end_col_offset=24), + lineno=92, + col_offset=16, + end_lineno=92, + end_col_offset=24), + Assign( + [ + Name( + 'child_start', + Store(), + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=27)], + Name( + 'idx', + Load(), + lineno=93, + col_offset=30, + end_lineno=93, + end_col_offset=33), + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=33), + While( + Compare( + Subscript( + Name( + 'sgf', + Load(), + lineno=94, + col_offset=22, + end_lineno=94, + end_col_offset=25), + Name( + 'idx', + Load(), + lineno=94, + col_offset=26, + end_lineno=94, + end_col_offset=29), + Load(), + lineno=94, + col_offset=22, + end_lineno=94, + end_col_offset=30), + [ + NotEq()], + [ + Constant( + ')', + lineno=94, + col_offset=34, + end_lineno=94, + end_col_offset=37)], + lineno=94, + col_offset=22, + end_lineno=94, + end_col_offset=37), + [ + AugAssign( + Name( + 'idx', + Store(), + lineno=95, + col_offset=20, + end_lineno=95, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=95, + col_offset=27, + end_lineno=95, + end_col_offset=28), + lineno=95, + col_offset=20, + end_lineno=95, + end_col_offset=28)], + [], + lineno=94, + col_offset=16, + end_lineno=95, + end_col_offset=28), + Assign( + [ + Name( + 'child', + Store(), + lineno=97, + col_offset=16, + end_lineno=97, + end_col_offset=21)], + Call( + Name( + 'parse_node', + Load(), + lineno=97, + col_offset=24, + end_lineno=97, + end_col_offset=34), + [ + Subscript( + Name( + 'sgf', + Load(), + lineno=97, + col_offset=35, + end_lineno=97, + end_col_offset=38), + Slice( + Name( + 'child_start', + Load(), + lineno=97, + col_offset=39, + end_lineno=97, + end_col_offset=50), + Name( + 'idx', + Load(), + lineno=97, + col_offset=51, + end_lineno=97, + end_col_offset=54), + lineno=97, + col_offset=39, + end_lineno=97, + end_col_offset=54), + Load(), + lineno=97, + col_offset=35, + end_lineno=97, + end_col_offset=55)], + [], + lineno=97, + col_offset=24, + end_lineno=97, + end_col_offset=56), + lineno=97, + col_offset=16, + end_lineno=97, + end_col_offset=56), + Expr( + Call( + Attribute( + Name( + 'children', + Load(), + lineno=98, + col_offset=16, + end_lineno=98, + end_col_offset=24), + 'append', + Load(), + lineno=98, + col_offset=16, + end_lineno=98, + end_col_offset=31), + [ + Name( + 'child', + Load(), + lineno=98, + col_offset=32, + end_lineno=98, + end_col_offset=37)], + [], + lineno=98, + col_offset=16, + end_lineno=98, + end_col_offset=38), + lineno=98, + col_offset=16, + end_lineno=98, + end_col_offset=38), + AugAssign( + Name( + 'idx', + Store(), + lineno=99, + col_offset=16, + end_lineno=99, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=99, + col_offset=23, + end_lineno=99, + end_col_offset=24), + lineno=99, + col_offset=16, + end_lineno=99, + end_col_offset=24)], + [], + lineno=88, + col_offset=12, + end_lineno=99, + end_col_offset=24)], + [ + AugAssign( + Name( + 'idx', + Store(), + lineno=101, + col_offset=12, + end_lineno=101, + end_col_offset=15), + Add(), + Constant( + 1, + lineno=101, + col_offset=19, + end_lineno=101, + end_col_offset=20), + lineno=101, + col_offset=12, + end_lineno=101, + end_col_offset=20)], + lineno=85, + col_offset=8, + end_lineno=101, + end_col_offset=20)], + lineno=80, + col_offset=8, + end_lineno=101, + end_col_offset=20)], + lineno=67, + col_offset=8, + end_lineno=101, + end_col_offset=20)], + [], + lineno=66, + col_offset=4, + end_lineno=101, + end_col_offset=20), + If( + BoolOp( + And(), + [ + Compare( + Name( + 'idx', + Load(), + lineno=103, + col_offset=7, + end_lineno=103, + end_col_offset=10), + [ + Gt()], + [ + Name( + 'prop_key_start', + Load(), + lineno=103, + col_offset=13, + end_lineno=103, + end_col_offset=27)], + lineno=103, + col_offset=7, + end_lineno=103, + end_col_offset=27), + UnaryOp( + Not(), + Name( + 'properties', + Load(), + lineno=103, + col_offset=36, + end_lineno=103, + end_col_offset=46), + lineno=103, + col_offset=32, + end_lineno=103, + end_col_offset=46)], + lineno=103, + col_offset=7, + end_lineno=103, + end_col_offset=46), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=104, + col_offset=14, + end_lineno=104, + end_col_offset=24), + [ + Constant( + 'properties without delimiter', + lineno=104, + col_offset=25, + end_lineno=104, + end_col_offset=55)], + [], + lineno=104, + col_offset=14, + end_lineno=104, + end_col_offset=56), + lineno=104, + col_offset=8, + end_lineno=104, + end_col_offset=56)], + [], + lineno=103, + col_offset=4, + end_lineno=104, + end_col_offset=56), + Return( + Call( + Name( + 'SgfTree', + Load(), + lineno=105, + col_offset=11, + end_lineno=105, + end_col_offset=18), + [], + [ + keyword( + 'children', + Name( + 'children', + Load(), + lineno=105, + col_offset=28, + end_lineno=105, + end_col_offset=36), + lineno=105, + col_offset=19, + end_lineno=105, + end_col_offset=36), + keyword( + 'properties', + Call( + Name( + 'dict', + Load(), + lineno=105, + col_offset=49, + end_lineno=105, + end_col_offset=53), + [ + Name( + 'properties', + Load(), + lineno=105, + col_offset=54, + end_lineno=105, + end_col_offset=64)], + [], + lineno=105, + col_offset=49, + end_lineno=105, + end_col_offset=65), + lineno=105, + col_offset=38, + end_lineno=105, + end_col_offset=65)], + lineno=105, + col_offset=11, + end_lineno=105, + end_col_offset=66), + lineno=105, + col_offset=4, + end_lineno=105, + end_col_offset=66)], + [], + Name( + 'SgfTree', + Load(), + lineno=55, + col_offset=28, + end_lineno=55, + end_col_offset=35), + lineno=55, + col_offset=0, + end_lineno=105, + end_col_offset=66), + FunctionDef( + 'parse', + arguments( + [], + [ + arg( + 'sgf', + Name( + 'str', + Load(), + lineno=108, + col_offset=15, + end_lineno=108, + end_col_offset=18), + lineno=108, + col_offset=10, + end_lineno=108, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Expr( + Constant( + 'Parse an SGF tree.', + lineno=109, + col_offset=4, + end_lineno=109, + end_col_offset=28), + lineno=109, + col_offset=4, + end_lineno=109, + end_col_offset=28), + If( + BoolOp( + And(), + [ + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'sgf', + Load(), + lineno=110, + col_offset=11, + end_lineno=110, + end_col_offset=14), + 'startswith', + Load(), + lineno=110, + col_offset=11, + end_lineno=110, + end_col_offset=25), + [ + Constant( + '(', + lineno=110, + col_offset=26, + end_lineno=110, + end_col_offset=29)], + [], + lineno=110, + col_offset=11, + end_lineno=110, + end_col_offset=30), + lineno=110, + col_offset=7, + end_lineno=110, + end_col_offset=30), + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'sgf', + Load(), + lineno=110, + col_offset=39, + end_lineno=110, + end_col_offset=42), + 'endswith', + Load(), + lineno=110, + col_offset=39, + end_lineno=110, + end_col_offset=51), + [ + Constant( + ')', + lineno=110, + col_offset=52, + end_lineno=110, + end_col_offset=55)], + [], + lineno=110, + col_offset=39, + end_lineno=110, + end_col_offset=56), + lineno=110, + col_offset=35, + end_lineno=110, + end_col_offset=56)], + lineno=110, + col_offset=7, + end_lineno=110, + end_col_offset=56), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=111, + col_offset=14, + end_lineno=111, + end_col_offset=24), + [ + Constant( + 'tree missing', + lineno=111, + col_offset=25, + end_lineno=111, + end_col_offset=39)], + [], + lineno=111, + col_offset=14, + end_lineno=111, + end_col_offset=40), + lineno=111, + col_offset=8, + end_lineno=111, + end_col_offset=40)], + [], + lineno=110, + col_offset=4, + end_lineno=111, + end_col_offset=40), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'sgf', + Load(), + lineno=112, + col_offset=11, + end_lineno=112, + end_col_offset=14), + 'startswith', + Load(), + lineno=112, + col_offset=11, + end_lineno=112, + end_col_offset=25), + [ + Constant( + '(;', + lineno=112, + col_offset=26, + end_lineno=112, + end_col_offset=30)], + [], + lineno=112, + col_offset=11, + end_lineno=112, + end_col_offset=31), + lineno=112, + col_offset=7, + end_lineno=112, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=113, + col_offset=14, + end_lineno=113, + end_col_offset=24), + [ + Constant( + 'tree with no nodes', + lineno=113, + col_offset=25, + end_lineno=113, + end_col_offset=45)], + [], + lineno=113, + col_offset=14, + end_lineno=113, + end_col_offset=46), + lineno=113, + col_offset=8, + end_lineno=113, + end_col_offset=46)], + [], + lineno=112, + col_offset=4, + end_lineno=113, + end_col_offset=46), + Assign( + [ + Name( + 'inside', + Store(), + lineno=114, + col_offset=4, + end_lineno=114, + end_col_offset=10)], + Subscript( + Name( + 'sgf', + Load(), + lineno=114, + col_offset=13, + end_lineno=114, + end_col_offset=16), + Slice( + Constant( + 1, + lineno=114, + col_offset=17, + end_lineno=114, + end_col_offset=18), + UnaryOp( + USub(), + Constant( + 1, + lineno=114, + col_offset=20, + end_lineno=114, + end_col_offset=21), + lineno=114, + col_offset=19, + end_lineno=114, + end_col_offset=21), + lineno=114, + col_offset=17, + end_lineno=114, + end_col_offset=21), + Load(), + lineno=114, + col_offset=13, + end_lineno=114, + end_col_offset=22), + lineno=114, + col_offset=4, + end_lineno=114, + end_col_offset=22), + Return( + Call( + Name( + 'parse_node', + Load(), + lineno=115, + col_offset=11, + end_lineno=115, + end_col_offset=21), + [ + Name( + 'inside', + Load(), + lineno=115, + col_offset=22, + end_lineno=115, + end_col_offset=28)], + [], + lineno=115, + col_offset=11, + end_lineno=115, + end_col_offset=29), + lineno=115, + col_offset=4, + end_lineno=115, + end_col_offset=29)], + [], + Name( + 'SgfTree', + Load(), + lineno=108, + col_offset=23, + end_lineno=108, + end_col_offset=30), + lineno=108, + col_offset=0, + end_lineno=115, + end_col_offset=29)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + '__future__', + [ + alias( + 'annotations', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=34)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=34), + Import( + [ + alias( + 'collections', + lineno=4, + col_offset=7, + end_lineno=4, + end_col_offset=18)], + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=18), + Import( + [ + alias( + 'dataclasses', + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=18)], + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=18), + Import( + [ + alias( + 'string', + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=13)], + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=13), + ClassDef( + 'placeholder_0', + [], + [], + [ + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=14)], + Call( + Attribute( + Name( + 'dataclasses', + Load(), + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=44), + 'field', + Load(), + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=50), + [], + [ + keyword( + 'placeholder_2', + Name( + 'dict', + Load(), + lineno=13, + col_offset=67, + end_lineno=13, + end_col_offset=71), + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=71)], + lineno=13, + col_offset=33, + end_lineno=13, + end_col_offset=72), + lineno=13), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=12)], + Call( + Attribute( + Name( + 'dataclasses', + Load(), + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=41), + 'field', + Load(), + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=47), + [], + [ + keyword( + 'placeholder_2', + Name( + 'list', + Load(), + lineno=14, + col_offset=64, + end_lineno=14, + end_col_offset=68), + lineno=14, + col_offset=48, + end_lineno=14, + end_col_offset=68)], + lineno=14, + col_offset=30, + end_lineno=14, + end_col_offset=69), + lineno=14)], + [ + Attribute( + Name( + 'dataclasses', + Load(), + lineno=9, + col_offset=1, + end_lineno=9, + end_col_offset=12), + 'dataclass', + Load(), + lineno=9, + col_offset=1, + end_lineno=9, + end_col_offset=22)], + lineno=10, + col_offset=0, + end_lineno=14, + end_col_offset=69), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=17, + col_offset=24, + end_lineno=17, + end_col_offset=32), + arg( + 'placeholder_6', + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=42)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=10)], + List( + [], + Load(), + lineno=19, + col_offset=13, + end_lineno=19, + end_col_offset=15), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=15), + While( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=20, + col_offset=10, + end_lineno=20, + end_col_offset=13), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=19), + [ + Name( + 'placeholder_5', + Load(), + lineno=20, + col_offset=20, + end_lineno=20, + end_col_offset=23)], + [], + lineno=20, + col_offset=16, + end_lineno=20, + end_col_offset=24)], + lineno=20, + col_offset=10, + end_lineno=20, + end_col_offset=24), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=14), + Name( + 'placeholder_6', + Load(), + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=18), + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=19), + [ + NotEq()], + [ + Constant( + '[', + lineno=21, + col_offset=23, + end_lineno=21, + end_col_offset=26)], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=26), + [ + Break( + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=17)], + [], + lineno=21, + col_offset=8, + end_lineno=22, + end_col_offset=17), + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=11), + Add(), + Constant( + 1, + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=16), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=16), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=16)], + Constant( + '', + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=21), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=21), + While( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=17), + Name( + 'placeholder_6', + Load(), + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=21), + Load(), + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=22), + [ + NotEq()], + [ + Constant( + ']', + lineno=27, + col_offset=26, + end_lineno=27, + end_col_offset=29)], + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=29), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=18), + Name( + 'placeholder_6', + Load(), + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=22), + Load(), + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=23), + [ + Eq()], + [ + Constant( + '\\', + lineno=29, + col_offset=27, + end_lineno=29, + end_col_offset=31)], + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=31), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=22), + Slice( + Name( + 'placeholder_6', + Load(), + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=26), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=30), + Add(), + Constant( + 2, + lineno=30, + col_offset=33, + end_lineno=30, + end_col_offset=34), + lineno=30, + col_offset=27, + end_lineno=30, + end_col_offset=34), + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=34), + Load(), + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=35), + [ + Eq()], + [ + Constant( + '\\\n', + lineno=30, + col_offset=39, + end_lineno=30, + end_col_offset=45)], + lineno=30, + col_offset=19, + end_lineno=30, + end_col_offset=45), + [ + Pass( + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=24)], + [ + AugAssign( + Name( + 'placeholder_8', + Store(), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=28), + Add(), + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=35), + BinOp( + Name( + 'placeholder_6', + Load(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=39), + Add(), + Constant( + 1, + lineno=37, + col_offset=42, + end_lineno=37, + end_col_offset=43), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=43), + Load(), + lineno=37, + col_offset=32, + end_lineno=37, + end_col_offset=44), + lineno=37, + col_offset=20, + end_lineno=37, + end_col_offset=44)], + lineno=30, + col_offset=16, + end_lineno=37, + end_col_offset=44), + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=19), + Add(), + Constant( + 2, + lineno=38, + col_offset=23, + end_lineno=38, + end_col_offset=24), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=24)], + [ + AugAssign( + Name( + 'placeholder_8', + Store(), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=24), + Add(), + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=31), + Name( + 'placeholder_6', + Load(), + lineno=40, + col_offset=32, + end_lineno=40, + end_col_offset=35), + Load(), + lineno=40, + col_offset=28, + end_lineno=40, + end_col_offset=36), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=36), + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=41, + col_offset=23, + end_lineno=41, + end_col_offset=24), + lineno=41, + col_offset=16, + end_lineno=41, + end_col_offset=24)], + lineno=29, + col_offset=12, + end_lineno=41, + end_col_offset=24)], + [], + lineno=27, + col_offset=8, + end_lineno=41, + end_col_offset=24), + For( + Name( + 'placeholder_9', + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=16), + Attribute( + Name( + 'string', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=26), + 'whitespace', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=37), + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=19), + [ + Eq()], + [ + Constant( + '\n', + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=27)], + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=27), + [ + Continue( + lineno=46, + col_offset=16, + end_lineno=46, + end_col_offset=24)], + [], + lineno=45, + col_offset=12, + end_lineno=46, + end_col_offset=24), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=20)], + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=31), + 'replace', + Load(), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=39), + [ + Name( + 'placeholder_9', + Load(), + lineno=47, + col_offset=40, + end_lineno=47, + end_col_offset=44), + Constant( + ' ', + lineno=47, + col_offset=46, + end_lineno=47, + end_col_offset=49)], + [], + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=50), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=50)], + [], + lineno=44, + col_offset=8, + end_lineno=47, + end_col_offset=50), + Expr( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=14), + 'append', + Load(), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=21), + [ + Name( + 'placeholder_8', + Load(), + lineno=49, + col_offset=22, + end_lineno=49, + end_col_offset=30)], + [], + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=31), + lineno=49, + col_offset=8, + end_lineno=49, + end_col_offset=31), + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=11), + Add(), + Constant( + 1, + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=16), + lineno=50, + col_offset=8, + end_lineno=50, + end_col_offset=16)], + [], + lineno=20, + col_offset=4, + end_lineno=50, + end_col_offset=16), + Return( + Tuple( + [ + Name( + 'placeholder_6', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=14), + Name( + 'placeholder_7', + Load(), + lineno=52, + col_offset=16, + end_lineno=52, + end_col_offset=22)], + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=22), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=22)], + [], + lineno=17, + col_offset=0, + end_lineno=52, + end_col_offset=22), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=55, + col_offset=15, + end_lineno=55, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=14), + 'startswith', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=25), + [ + Constant( + ';', + lineno=57, + col_offset=26, + end_lineno=57, + end_col_offset=29)], + [], + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=30), + lineno=57, + col_offset=7, + end_lineno=57, + end_col_offset=30), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=58, + col_offset=14, + end_lineno=58, + end_col_offset=24), + [ + Constant( + "node must start with ';'", + lineno=58, + col_offset=25, + end_lineno=58, + end_col_offset=51)], + [], + lineno=58, + col_offset=14, + end_lineno=58, + end_col_offset=52), + lineno=58, + col_offset=8, + end_lineno=58, + end_col_offset=52)], + [], + lineno=57, + col_offset=4, + end_lineno=58, + end_col_offset=52), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=7)], + Constant( + 1, + lineno=60, + col_offset=10, + end_lineno=60, + end_col_offset=11), + lineno=60, + col_offset=4, + end_lineno=60, + end_col_offset=11), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=18)], + Name( + 'placeholder_6', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=24), + lineno=61, + col_offset=4, + end_lineno=61, + end_col_offset=24), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=14)], + Call( + Attribute( + Name( + 'collections', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=28), + 'defaultdict', + Load(), + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=40), + [ + Name( + 'list', + Load(), + lineno=63, + col_offset=41, + end_lineno=63, + end_col_offset=45)], + [], + lineno=63, + col_offset=17, + end_lineno=63, + end_col_offset=46), + lineno=63, + col_offset=4, + end_lineno=63, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=12)], + List( + [], + Load(), + lineno=64, + col_offset=15, + end_lineno=64, + end_col_offset=17), + lineno=64, + col_offset=4, + end_lineno=64, + end_col_offset=17), + While( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=66, + col_offset=10, + end_lineno=66, + end_col_offset=13), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=19), + [ + Name( + 'placeholder_5', + Load(), + lineno=66, + col_offset=20, + end_lineno=66, + end_col_offset=23)], + [], + lineno=66, + col_offset=16, + end_lineno=66, + end_col_offset=24)], + lineno=66, + col_offset=10, + end_lineno=66, + end_col_offset=24), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=14), + Name( + 'placeholder_6', + Load(), + lineno=67, + col_offset=15, + end_lineno=67, + end_col_offset=18), + Load(), + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=19), + [ + Eq()], + [ + Constant( + '[', + lineno=67, + col_offset=23, + end_lineno=67, + end_col_offset=26)], + lineno=67, + col_offset=11, + end_lineno=67, + end_col_offset=26), + [ + If( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=69, + col_offset=15, + end_lineno=69, + end_col_offset=18), + [ + Eq()], + [ + Name( + 'placeholder_11', + Load(), + lineno=69, + col_offset=22, + end_lineno=69, + end_col_offset=36)], + lineno=69, + col_offset=15, + end_lineno=69, + end_col_offset=36), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=70, + col_offset=22, + end_lineno=70, + end_col_offset=32), + [ + Constant( + 'propery key is empty', + lineno=70, + col_offset=33, + end_lineno=70, + end_col_offset=55)], + [], + lineno=70, + col_offset=22, + end_lineno=70, + end_col_offset=56), + lineno=70, + col_offset=16, + end_lineno=70, + end_col_offset=56)], + [], + lineno=69, + col_offset=12, + end_lineno=70, + end_col_offset=56), + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=71, + col_offset=12, + end_lineno=71, + end_col_offset=20)], + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=26), + Slice( + Name( + 'placeholder_11', + Load(), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=41), + Name( + 'placeholder_6', + Load(), + lineno=71, + col_offset=42, + end_lineno=71, + end_col_offset=45), + lineno=71, + col_offset=27, + end_lineno=71, + end_col_offset=45), + Load(), + lineno=71, + col_offset=23, + end_lineno=71, + end_col_offset=46), + lineno=71, + col_offset=12, + end_lineno=71, + end_col_offset=46), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=27), + 'isupper', + Load(), + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=35), + [], + [], + lineno=72, + col_offset=19, + end_lineno=72, + end_col_offset=37), + lineno=72, + col_offset=15, + end_lineno=72, + end_col_offset=37), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=73, + col_offset=22, + end_lineno=73, + end_col_offset=32), + [ + Constant( + 'property must be in uppercase', + lineno=73, + col_offset=33, + end_lineno=73, + end_col_offset=64)], + [], + lineno=73, + col_offset=22, + end_lineno=73, + end_col_offset=65), + lineno=73, + col_offset=16, + end_lineno=73, + end_col_offset=65)], + [], + lineno=72, + col_offset=12, + end_lineno=73, + end_col_offset=65), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_6', + Store(), + lineno=75, + col_offset=12, + end_lineno=75, + end_col_offset=15), + Name( + 'placeholder_13', + Store(), + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=26)], + Store(), + lineno=75, + col_offset=12, + end_lineno=75, + end_col_offset=26)], + Call( + Name( + 'placeholder_4', + Load(), + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=48), + [ + Name( + 'placeholder_5', + Load(), + lineno=75, + col_offset=49, + end_lineno=75, + end_col_offset=52), + Name( + 'placeholder_6', + Load(), + lineno=75, + col_offset=54, + end_lineno=75, + end_col_offset=57)], + [], + lineno=75, + col_offset=29, + end_lineno=75, + end_col_offset=58), + lineno=75, + col_offset=12, + end_lineno=75, + end_col_offset=58), + Expr( + Call( + Attribute( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=22), + Name( + 'placeholder_12', + Load(), + lineno=76, + col_offset=23, + end_lineno=76, + end_col_offset=31), + Load(), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=32), + 'extend', + Load(), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=39), + [ + Name( + 'placeholder_13', + Load(), + lineno=76, + col_offset=40, + end_lineno=76, + end_col_offset=49)], + [], + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=50), + lineno=76, + col_offset=12, + end_lineno=76, + end_col_offset=50), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=26)], + Name( + 'placeholder_6', + Load(), + lineno=79, + col_offset=29, + end_lineno=79, + end_col_offset=32), + lineno=79, + col_offset=12, + end_lineno=79, + end_col_offset=32)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=80, + col_offset=13, + end_lineno=80, + end_col_offset=16), + Name( + 'placeholder_6', + Load(), + lineno=80, + col_offset=17, + end_lineno=80, + end_col_offset=20), + Load(), + lineno=80, + col_offset=13, + end_lineno=80, + end_col_offset=21), + [ + Eq()], + [ + Constant( + ';', + lineno=80, + col_offset=25, + end_lineno=80, + end_col_offset=28)], + lineno=80, + col_offset=13, + end_lineno=80, + end_col_offset=28), + [ + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=82, + col_offset=12, + end_lineno=82, + end_col_offset=17)], + Call( + Name( + 'placeholder_10', + Load(), + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=30), + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=82, + col_offset=31, + end_lineno=82, + end_col_offset=34), + Slice( + Name( + 'placeholder_6', + Load(), + lineno=82, + col_offset=35, + end_lineno=82, + end_col_offset=38), + lineno=82, + col_offset=35, + end_lineno=82, + end_col_offset=39), + Load(), + lineno=82, + col_offset=31, + end_lineno=82, + end_col_offset=40)], + [], + lineno=82, + col_offset=20, + end_lineno=82, + end_col_offset=41), + lineno=82, + col_offset=12, + end_lineno=82, + end_col_offset=41), + Expr( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=20), + 'append', + Load(), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=27), + [ + Name( + 'placeholder_14', + Load(), + lineno=83, + col_offset=28, + end_lineno=83, + end_col_offset=33)], + [], + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=34), + lineno=83, + col_offset=12, + end_lineno=83, + end_col_offset=34), + Break( + lineno=84, + col_offset=12, + end_lineno=84, + end_col_offset=17)], + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=85, + col_offset=13, + end_lineno=85, + end_col_offset=16), + Name( + 'placeholder_6', + Load(), + lineno=85, + col_offset=17, + end_lineno=85, + end_col_offset=20), + Load(), + lineno=85, + col_offset=13, + end_lineno=85, + end_col_offset=21), + [ + Eq()], + [ + Constant( + '(', + lineno=85, + col_offset=25, + end_lineno=85, + end_col_offset=28)], + lineno=85, + col_offset=13, + end_lineno=85, + end_col_offset=28), + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=20)], + List( + [], + Load(), + lineno=87, + col_offset=23, + end_lineno=87, + end_col_offset=25), + lineno=87, + col_offset=12, + end_lineno=87, + end_col_offset=25), + While( + Compare( + Name( + 'placeholder_6', + Load(), + lineno=88, + col_offset=18, + end_lineno=88, + end_col_offset=21), + [ + Lt()], + [ + Call( + Name( + 'len', + Load(), + lineno=88, + col_offset=24, + end_lineno=88, + end_col_offset=27), + [ + Name( + 'placeholder_5', + Load(), + lineno=88, + col_offset=28, + end_lineno=88, + end_col_offset=31)], + [], + lineno=88, + col_offset=24, + end_lineno=88, + end_col_offset=32)], + lineno=88, + col_offset=18, + end_lineno=88, + end_col_offset=32), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=89, + col_offset=19, + end_lineno=89, + end_col_offset=22), + Name( + 'placeholder_6', + Load(), + lineno=89, + col_offset=23, + end_lineno=89, + end_col_offset=26), + Load(), + lineno=89, + col_offset=19, + end_lineno=89, + end_col_offset=27), + [ + NotEq()], + [ + Constant( + '(', + lineno=89, + col_offset=31, + end_lineno=89, + end_col_offset=34)], + lineno=89, + col_offset=19, + end_lineno=89, + end_col_offset=34), + [ + Break( + lineno=90, + col_offset=20, + end_lineno=90, + end_col_offset=25)], + [], + lineno=89, + col_offset=16, + end_lineno=90, + end_col_offset=25), + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=92, + col_offset=16, + end_lineno=92, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=92, + col_offset=23, + end_lineno=92, + end_col_offset=24), + lineno=92, + col_offset=16, + end_lineno=92, + end_col_offset=24), + Assign( + [ + Name( + 'placeholder_15', + Store(), + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=27)], + Name( + 'placeholder_6', + Load(), + lineno=93, + col_offset=30, + end_lineno=93, + end_col_offset=33), + lineno=93, + col_offset=16, + end_lineno=93, + end_col_offset=33), + While( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=94, + col_offset=22, + end_lineno=94, + end_col_offset=25), + Name( + 'placeholder_6', + Load(), + lineno=94, + col_offset=26, + end_lineno=94, + end_col_offset=29), + Load(), + lineno=94, + col_offset=22, + end_lineno=94, + end_col_offset=30), + [ + NotEq()], + [ + Constant( + ')', + lineno=94, + col_offset=34, + end_lineno=94, + end_col_offset=37)], + lineno=94, + col_offset=22, + end_lineno=94, + end_col_offset=37), + [ + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=95, + col_offset=20, + end_lineno=95, + end_col_offset=23), + Add(), + Constant( + 1, + lineno=95, + col_offset=27, + end_lineno=95, + end_col_offset=28), + lineno=95, + col_offset=20, + end_lineno=95, + end_col_offset=28)], + [], + lineno=94, + col_offset=16, + end_lineno=95, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=97, + col_offset=16, + end_lineno=97, + end_col_offset=21)], + Call( + Name( + 'placeholder_10', + Load(), + lineno=97, + col_offset=24, + end_lineno=97, + end_col_offset=34), + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=97, + col_offset=35, + end_lineno=97, + end_col_offset=38), + Slice( + Name( + 'placeholder_15', + Load(), + lineno=97, + col_offset=39, + end_lineno=97, + end_col_offset=50), + Name( + 'placeholder_6', + Load(), + lineno=97, + col_offset=51, + end_lineno=97, + end_col_offset=54), + lineno=97, + col_offset=39, + end_lineno=97, + end_col_offset=54), + Load(), + lineno=97, + col_offset=35, + end_lineno=97, + end_col_offset=55)], + [], + lineno=97, + col_offset=24, + end_lineno=97, + end_col_offset=56), + lineno=97, + col_offset=16, + end_lineno=97, + end_col_offset=56), + Expr( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=98, + col_offset=16, + end_lineno=98, + end_col_offset=24), + 'append', + Load(), + lineno=98, + col_offset=16, + end_lineno=98, + end_col_offset=31), + [ + Name( + 'placeholder_14', + Load(), + lineno=98, + col_offset=32, + end_lineno=98, + end_col_offset=37)], + [], + lineno=98, + col_offset=16, + end_lineno=98, + end_col_offset=38), + lineno=98, + col_offset=16, + end_lineno=98, + end_col_offset=38), + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=99, + col_offset=16, + end_lineno=99, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=99, + col_offset=23, + end_lineno=99, + end_col_offset=24), + lineno=99, + col_offset=16, + end_lineno=99, + end_col_offset=24)], + [], + lineno=88, + col_offset=12, + end_lineno=99, + end_col_offset=24)], + [ + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=101, + col_offset=12, + end_lineno=101, + end_col_offset=15), + Add(), + Constant( + 1, + lineno=101, + col_offset=19, + end_lineno=101, + end_col_offset=20), + lineno=101, + col_offset=12, + end_lineno=101, + end_col_offset=20)], + lineno=85, + col_offset=8, + end_lineno=101, + end_col_offset=20)], + lineno=80, + col_offset=8, + end_lineno=101, + end_col_offset=20)], + lineno=67, + col_offset=8, + end_lineno=101, + end_col_offset=20)], + [], + lineno=66, + col_offset=4, + end_lineno=101, + end_col_offset=20), + If( + BoolOp( + And(), + [ + Compare( + Name( + 'placeholder_6', + Load(), + lineno=103, + col_offset=7, + end_lineno=103, + end_col_offset=10), + [ + Gt()], + [ + Name( + 'placeholder_11', + Load(), + lineno=103, + col_offset=13, + end_lineno=103, + end_col_offset=27)], + lineno=103, + col_offset=7, + end_lineno=103, + end_col_offset=27), + UnaryOp( + Not(), + Name( + 'placeholder_1', + Load(), + lineno=103, + col_offset=36, + end_lineno=103, + end_col_offset=46), + lineno=103, + col_offset=32, + end_lineno=103, + end_col_offset=46)], + lineno=103, + col_offset=7, + end_lineno=103, + end_col_offset=46), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=104, + col_offset=14, + end_lineno=104, + end_col_offset=24), + [ + Constant( + 'properties without delimiter', + lineno=104, + col_offset=25, + end_lineno=104, + end_col_offset=55)], + [], + lineno=104, + col_offset=14, + end_lineno=104, + end_col_offset=56), + lineno=104, + col_offset=8, + end_lineno=104, + end_col_offset=56)], + [], + lineno=103, + col_offset=4, + end_lineno=104, + end_col_offset=56), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=105, + col_offset=11, + end_lineno=105, + end_col_offset=18), + [], + [ + keyword( + 'placeholder_3', + Name( + 'placeholder_3', + Load(), + lineno=105, + col_offset=28, + end_lineno=105, + end_col_offset=36), + lineno=105, + col_offset=19, + end_lineno=105, + end_col_offset=36), + keyword( + 'placeholder_1', + Call( + Name( + 'dict', + Load(), + lineno=105, + col_offset=49, + end_lineno=105, + end_col_offset=53), + [ + Name( + 'placeholder_1', + Load(), + lineno=105, + col_offset=54, + end_lineno=105, + end_col_offset=64)], + [], + lineno=105, + col_offset=49, + end_lineno=105, + end_col_offset=65), + lineno=105, + col_offset=38, + end_lineno=105, + end_col_offset=65)], + lineno=105, + col_offset=11, + end_lineno=105, + end_col_offset=66), + lineno=105, + col_offset=4, + end_lineno=105, + end_col_offset=66)], + [], + lineno=55, + col_offset=0, + end_lineno=105, + end_col_offset=66), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=108, + col_offset=10, + end_lineno=108, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BoolOp( + And(), + [ + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=110, + col_offset=11, + end_lineno=110, + end_col_offset=14), + 'startswith', + Load(), + lineno=110, + col_offset=11, + end_lineno=110, + end_col_offset=25), + [ + Constant( + '(', + lineno=110, + col_offset=26, + end_lineno=110, + end_col_offset=29)], + [], + lineno=110, + col_offset=11, + end_lineno=110, + end_col_offset=30), + lineno=110, + col_offset=7, + end_lineno=110, + end_col_offset=30), + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=110, + col_offset=39, + end_lineno=110, + end_col_offset=42), + 'endswith', + Load(), + lineno=110, + col_offset=39, + end_lineno=110, + end_col_offset=51), + [ + Constant( + ')', + lineno=110, + col_offset=52, + end_lineno=110, + end_col_offset=55)], + [], + lineno=110, + col_offset=39, + end_lineno=110, + end_col_offset=56), + lineno=110, + col_offset=35, + end_lineno=110, + end_col_offset=56)], + lineno=110, + col_offset=7, + end_lineno=110, + end_col_offset=56), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=111, + col_offset=14, + end_lineno=111, + end_col_offset=24), + [ + Constant( + 'tree missing', + lineno=111, + col_offset=25, + end_lineno=111, + end_col_offset=39)], + [], + lineno=111, + col_offset=14, + end_lineno=111, + end_col_offset=40), + lineno=111, + col_offset=8, + end_lineno=111, + end_col_offset=40)], + [], + lineno=110, + col_offset=4, + end_lineno=111, + end_col_offset=40), + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_5', + Load(), + lineno=112, + col_offset=11, + end_lineno=112, + end_col_offset=14), + 'startswith', + Load(), + lineno=112, + col_offset=11, + end_lineno=112, + end_col_offset=25), + [ + Constant( + '(;', + lineno=112, + col_offset=26, + end_lineno=112, + end_col_offset=30)], + [], + lineno=112, + col_offset=11, + end_lineno=112, + end_col_offset=31), + lineno=112, + col_offset=7, + end_lineno=112, + end_col_offset=31), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=113, + col_offset=14, + end_lineno=113, + end_col_offset=24), + [ + Constant( + 'tree with no nodes', + lineno=113, + col_offset=25, + end_lineno=113, + end_col_offset=45)], + [], + lineno=113, + col_offset=14, + end_lineno=113, + end_col_offset=46), + lineno=113, + col_offset=8, + end_lineno=113, + end_col_offset=46)], + [], + lineno=112, + col_offset=4, + end_lineno=113, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=114, + col_offset=4, + end_lineno=114, + end_col_offset=10)], + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=114, + col_offset=13, + end_lineno=114, + end_col_offset=16), + Slice( + Constant( + 1, + lineno=114, + col_offset=17, + end_lineno=114, + end_col_offset=18), + UnaryOp( + USub(), + Constant( + 1, + lineno=114, + col_offset=20, + end_lineno=114, + end_col_offset=21), + lineno=114, + col_offset=19, + end_lineno=114, + end_col_offset=21), + lineno=114, + col_offset=17, + end_lineno=114, + end_col_offset=21), + Load(), + lineno=114, + col_offset=13, + end_lineno=114, + end_col_offset=22), + lineno=114, + col_offset=4, + end_lineno=114, + end_col_offset=22), + Return( + Call( + Name( + 'placeholder_10', + Load(), + lineno=115, + col_offset=11, + end_lineno=115, + end_col_offset=21), + [ + Name( + 'placeholder_17', + Load(), + lineno=115, + col_offset=22, + end_lineno=115, + end_col_offset=28)], + [], + lineno=115, + col_offset=11, + end_lineno=115, + end_col_offset=29), + lineno=115, + col_offset=4, + end_lineno=115, + end_col_offset=29)], + [], + lineno=108, + col_offset=0, + end_lineno=115, + end_col_offset=29)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-sgf-parsing/representation.txt b/test/practice-sgf-parsing/representation.txt new file mode 100644 index 0000000..c6da28b --- /dev/null +++ b/test/practice-sgf-parsing/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('__future__', [alias('annotations', lineno=2, col_offset=23, end_lineno=2, end_col_offset=34)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=34), Import([alias('collections', lineno=4, col_offset=7, end_lineno=4, end_col_offset=18)], lineno=4, col_offset=0, end_lineno=4, end_col_offset=18), Import([alias('dataclasses', lineno=5, col_offset=7, end_lineno=5, end_col_offset=18)], lineno=5, col_offset=0, end_lineno=5, end_col_offset=18), Import([alias('string', lineno=6, col_offset=7, end_lineno=6, end_col_offset=13)], lineno=6, col_offset=0, end_lineno=6, end_col_offset=13), ClassDef('placeholder_0', [], [], [Assign([Name('placeholder_1', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=14)], Call(Attribute(Name('dataclasses', Load(), lineno=13, col_offset=33, end_lineno=13, end_col_offset=44), 'field', Load(), lineno=13, col_offset=33, end_lineno=13, end_col_offset=50), [], [keyword('placeholder_2', Name('dict', Load(), lineno=13, col_offset=67, end_lineno=13, end_col_offset=71), lineno=13, col_offset=51, end_lineno=13, end_col_offset=71)], lineno=13, col_offset=33, end_lineno=13, end_col_offset=72), lineno=13), Assign([Name('placeholder_3', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=12)], Call(Attribute(Name('dataclasses', Load(), lineno=14, col_offset=30, end_lineno=14, end_col_offset=41), 'field', Load(), lineno=14, col_offset=30, end_lineno=14, end_col_offset=47), [], [keyword('placeholder_2', Name('list', Load(), lineno=14, col_offset=64, end_lineno=14, end_col_offset=68), lineno=14, col_offset=48, end_lineno=14, end_col_offset=68)], lineno=14, col_offset=30, end_lineno=14, end_col_offset=69), lineno=14)], [Attribute(Name('dataclasses', Load(), lineno=9, col_offset=1, end_lineno=9, end_col_offset=12), 'dataclass', Load(), lineno=9, col_offset=1, end_lineno=9, end_col_offset=22)], lineno=10, col_offset=0, end_lineno=14, end_col_offset=69), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=17, col_offset=24, end_lineno=17, end_col_offset=32), arg('placeholder_6', lineno=17, col_offset=34, end_lineno=17, end_col_offset=42)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_7', Store(), lineno=19, col_offset=4, end_lineno=19, end_col_offset=10)], List([], Load(), lineno=19, col_offset=13, end_lineno=19, end_col_offset=15), lineno=19, col_offset=4, end_lineno=19, end_col_offset=15), While(Compare(Name('placeholder_6', Load(), lineno=20, col_offset=10, end_lineno=20, end_col_offset=13), [Lt()], [Call(Name('len', Load(), lineno=20, col_offset=16, end_lineno=20, end_col_offset=19), [Name('placeholder_5', Load(), lineno=20, col_offset=20, end_lineno=20, end_col_offset=23)], [], lineno=20, col_offset=16, end_lineno=20, end_col_offset=24)], lineno=20, col_offset=10, end_lineno=20, end_col_offset=24), [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=14), Name('placeholder_6', Load(), lineno=21, col_offset=15, end_lineno=21, end_col_offset=18), Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=19), [NotEq()], [Constant('[', lineno=21, col_offset=23, end_lineno=21, end_col_offset=26)], lineno=21, col_offset=11, end_lineno=21, end_col_offset=26), [Break(lineno=22, col_offset=12, end_lineno=22, end_col_offset=17)], [], lineno=21, col_offset=8, end_lineno=22, end_col_offset=17), AugAssign(Name('placeholder_6', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=11), Add(), Constant(1, lineno=25, col_offset=15, end_lineno=25, end_col_offset=16), lineno=25, col_offset=8, end_lineno=25, end_col_offset=16), Assign([Name('placeholder_8', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=16)], Constant('', lineno=26, col_offset=19, end_lineno=26, end_col_offset=21), lineno=26, col_offset=8, end_lineno=26, end_col_offset=21), While(Compare(Subscript(Name('placeholder_5', Load(), lineno=27, col_offset=14, end_lineno=27, end_col_offset=17), Name('placeholder_6', Load(), lineno=27, col_offset=18, end_lineno=27, end_col_offset=21), Load(), lineno=27, col_offset=14, end_lineno=27, end_col_offset=22), [NotEq()], [Constant(']', lineno=27, col_offset=26, end_lineno=27, end_col_offset=29)], lineno=27, col_offset=14, end_lineno=27, end_col_offset=29), [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=29, col_offset=15, end_lineno=29, end_col_offset=18), Name('placeholder_6', Load(), lineno=29, col_offset=19, end_lineno=29, end_col_offset=22), Load(), lineno=29, col_offset=15, end_lineno=29, end_col_offset=23), [Eq()], [Constant('\\', lineno=29, col_offset=27, end_lineno=29, end_col_offset=31)], lineno=29, col_offset=15, end_lineno=29, end_col_offset=31), [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=30, col_offset=19, end_lineno=30, end_col_offset=22), Slice(Name('placeholder_6', Load(), lineno=30, col_offset=23, end_lineno=30, end_col_offset=26), BinOp(Name('placeholder_6', Load(), lineno=30, col_offset=27, end_lineno=30, end_col_offset=30), Add(), Constant(2, lineno=30, col_offset=33, end_lineno=30, end_col_offset=34), lineno=30, col_offset=27, end_lineno=30, end_col_offset=34), lineno=30, col_offset=23, end_lineno=30, end_col_offset=34), Load(), lineno=30, col_offset=19, end_lineno=30, end_col_offset=35), [Eq()], [Constant('\\\n', lineno=30, col_offset=39, end_lineno=30, end_col_offset=45)], lineno=30, col_offset=19, end_lineno=30, end_col_offset=45), [Pass(lineno=33, col_offset=20, end_lineno=33, end_col_offset=24)], [AugAssign(Name('placeholder_8', Store(), lineno=37, col_offset=20, end_lineno=37, end_col_offset=28), Add(), Subscript(Name('placeholder_5', Load(), lineno=37, col_offset=32, end_lineno=37, end_col_offset=35), BinOp(Name('placeholder_6', Load(), lineno=37, col_offset=36, end_lineno=37, end_col_offset=39), Add(), Constant(1, lineno=37, col_offset=42, end_lineno=37, end_col_offset=43), lineno=37, col_offset=36, end_lineno=37, end_col_offset=43), Load(), lineno=37, col_offset=32, end_lineno=37, end_col_offset=44), lineno=37, col_offset=20, end_lineno=37, end_col_offset=44)], lineno=30, col_offset=16, end_lineno=37, end_col_offset=44), AugAssign(Name('placeholder_6', Store(), lineno=38, col_offset=16, end_lineno=38, end_col_offset=19), Add(), Constant(2, lineno=38, col_offset=23, end_lineno=38, end_col_offset=24), lineno=38, col_offset=16, end_lineno=38, end_col_offset=24)], [AugAssign(Name('placeholder_8', Store(), lineno=40, col_offset=16, end_lineno=40, end_col_offset=24), Add(), Subscript(Name('placeholder_5', Load(), lineno=40, col_offset=28, end_lineno=40, end_col_offset=31), Name('placeholder_6', Load(), lineno=40, col_offset=32, end_lineno=40, end_col_offset=35), Load(), lineno=40, col_offset=28, end_lineno=40, end_col_offset=36), lineno=40, col_offset=16, end_lineno=40, end_col_offset=36), AugAssign(Name('placeholder_6', Store(), lineno=41, col_offset=16, end_lineno=41, end_col_offset=19), Add(), Constant(1, lineno=41, col_offset=23, end_lineno=41, end_col_offset=24), lineno=41, col_offset=16, end_lineno=41, end_col_offset=24)], lineno=29, col_offset=12, end_lineno=41, end_col_offset=24)], [], lineno=27, col_offset=8, end_lineno=41, end_col_offset=24), For(Name('placeholder_9', Store(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=16), Attribute(Name('string', Load(), lineno=44, col_offset=20, end_lineno=44, end_col_offset=26), 'whitespace', Load(), lineno=44, col_offset=20, end_lineno=44, end_col_offset=37), [If(Compare(Name('placeholder_9', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=19), [Eq()], [Constant('\n', lineno=45, col_offset=23, end_lineno=45, end_col_offset=27)], lineno=45, col_offset=15, end_lineno=45, end_col_offset=27), [Continue(lineno=46, col_offset=16, end_lineno=46, end_col_offset=24)], [], lineno=45, col_offset=12, end_lineno=46, end_col_offset=24), Assign([Name('placeholder_8', Store(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=20)], Call(Attribute(Name('placeholder_8', Load(), lineno=47, col_offset=23, end_lineno=47, end_col_offset=31), 'replace', Load(), lineno=47, col_offset=23, end_lineno=47, end_col_offset=39), [Name('placeholder_9', Load(), lineno=47, col_offset=40, end_lineno=47, end_col_offset=44), Constant(' ', lineno=47, col_offset=46, end_lineno=47, end_col_offset=49)], [], lineno=47, col_offset=23, end_lineno=47, end_col_offset=50), lineno=47, col_offset=12, end_lineno=47, end_col_offset=50)], [], lineno=44, col_offset=8, end_lineno=47, end_col_offset=50), Expr(Call(Attribute(Name('placeholder_7', Load(), lineno=49, col_offset=8, end_lineno=49, end_col_offset=14), 'append', Load(), lineno=49, col_offset=8, end_lineno=49, end_col_offset=21), [Name('placeholder_8', Load(), lineno=49, col_offset=22, end_lineno=49, end_col_offset=30)], [], lineno=49, col_offset=8, end_lineno=49, end_col_offset=31), lineno=49, col_offset=8, end_lineno=49, end_col_offset=31), AugAssign(Name('placeholder_6', Store(), lineno=50, col_offset=8, end_lineno=50, end_col_offset=11), Add(), Constant(1, lineno=50, col_offset=15, end_lineno=50, end_col_offset=16), lineno=50, col_offset=8, end_lineno=50, end_col_offset=16)], [], lineno=20, col_offset=4, end_lineno=50, end_col_offset=16), Return(Tuple([Name('placeholder_6', Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=14), Name('placeholder_7', Load(), lineno=52, col_offset=16, end_lineno=52, end_col_offset=22)], Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=22), lineno=52, col_offset=4, end_lineno=52, end_col_offset=22)], [], lineno=17, col_offset=0, end_lineno=52, end_col_offset=22), FunctionDef('placeholder_10', arguments([], [arg('placeholder_5', lineno=55, col_offset=15, end_lineno=55, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Attribute(Name('placeholder_5', Load(), lineno=57, col_offset=11, end_lineno=57, end_col_offset=14), 'startswith', Load(), lineno=57, col_offset=11, end_lineno=57, end_col_offset=25), [Constant(';', lineno=57, col_offset=26, end_lineno=57, end_col_offset=29)], [], lineno=57, col_offset=11, end_lineno=57, end_col_offset=30), lineno=57, col_offset=7, end_lineno=57, end_col_offset=30), [Raise(Call(Name('ValueError', Load(), lineno=58, col_offset=14, end_lineno=58, end_col_offset=24), [Constant("node must start with ';'", lineno=58, col_offset=25, end_lineno=58, end_col_offset=51)], [], lineno=58, col_offset=14, end_lineno=58, end_col_offset=52), lineno=58, col_offset=8, end_lineno=58, end_col_offset=52)], [], lineno=57, col_offset=4, end_lineno=58, end_col_offset=52), Assign([Name('placeholder_6', Store(), lineno=60, col_offset=4, end_lineno=60, end_col_offset=7)], Constant(1, lineno=60, col_offset=10, end_lineno=60, end_col_offset=11), lineno=60, col_offset=4, end_lineno=60, end_col_offset=11), Assign([Name('placeholder_11', Store(), lineno=61, col_offset=4, end_lineno=61, end_col_offset=18)], Name('placeholder_6', Load(), lineno=61, col_offset=21, end_lineno=61, end_col_offset=24), lineno=61, col_offset=4, end_lineno=61, end_col_offset=24), Assign([Name('placeholder_1', Store(), lineno=63, col_offset=4, end_lineno=63, end_col_offset=14)], Call(Attribute(Name('collections', Load(), lineno=63, col_offset=17, end_lineno=63, end_col_offset=28), 'defaultdict', Load(), lineno=63, col_offset=17, end_lineno=63, end_col_offset=40), [Name('list', Load(), lineno=63, col_offset=41, end_lineno=63, end_col_offset=45)], [], lineno=63, col_offset=17, end_lineno=63, end_col_offset=46), lineno=63, col_offset=4, end_lineno=63, end_col_offset=46), Assign([Name('placeholder_3', Store(), lineno=64, col_offset=4, end_lineno=64, end_col_offset=12)], List([], Load(), lineno=64, col_offset=15, end_lineno=64, end_col_offset=17), lineno=64, col_offset=4, end_lineno=64, end_col_offset=17), While(Compare(Name('placeholder_6', Load(), lineno=66, col_offset=10, end_lineno=66, end_col_offset=13), [Lt()], [Call(Name('len', Load(), lineno=66, col_offset=16, end_lineno=66, end_col_offset=19), [Name('placeholder_5', Load(), lineno=66, col_offset=20, end_lineno=66, end_col_offset=23)], [], lineno=66, col_offset=16, end_lineno=66, end_col_offset=24)], lineno=66, col_offset=10, end_lineno=66, end_col_offset=24), [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=14), Name('placeholder_6', Load(), lineno=67, col_offset=15, end_lineno=67, end_col_offset=18), Load(), lineno=67, col_offset=11, end_lineno=67, end_col_offset=19), [Eq()], [Constant('[', lineno=67, col_offset=23, end_lineno=67, end_col_offset=26)], lineno=67, col_offset=11, end_lineno=67, end_col_offset=26), [If(Compare(Name('placeholder_6', Load(), lineno=69, col_offset=15, end_lineno=69, end_col_offset=18), [Eq()], [Name('placeholder_11', Load(), lineno=69, col_offset=22, end_lineno=69, end_col_offset=36)], lineno=69, col_offset=15, end_lineno=69, end_col_offset=36), [Raise(Call(Name('ValueError', Load(), lineno=70, col_offset=22, end_lineno=70, end_col_offset=32), [Constant('propery key is empty', lineno=70, col_offset=33, end_lineno=70, end_col_offset=55)], [], lineno=70, col_offset=22, end_lineno=70, end_col_offset=56), lineno=70, col_offset=16, end_lineno=70, end_col_offset=56)], [], lineno=69, col_offset=12, end_lineno=70, end_col_offset=56), Assign([Name('placeholder_12', Store(), lineno=71, col_offset=12, end_lineno=71, end_col_offset=20)], Subscript(Name('placeholder_5', Load(), lineno=71, col_offset=23, end_lineno=71, end_col_offset=26), Slice(Name('placeholder_11', Load(), lineno=71, col_offset=27, end_lineno=71, end_col_offset=41), Name('placeholder_6', Load(), lineno=71, col_offset=42, end_lineno=71, end_col_offset=45), lineno=71, col_offset=27, end_lineno=71, end_col_offset=45), Load(), lineno=71, col_offset=23, end_lineno=71, end_col_offset=46), lineno=71, col_offset=12, end_lineno=71, end_col_offset=46), If(UnaryOp(Not(), Call(Attribute(Name('placeholder_12', Load(), lineno=72, col_offset=19, end_lineno=72, end_col_offset=27), 'isupper', Load(), lineno=72, col_offset=19, end_lineno=72, end_col_offset=35), [], [], lineno=72, col_offset=19, end_lineno=72, end_col_offset=37), lineno=72, col_offset=15, end_lineno=72, end_col_offset=37), [Raise(Call(Name('ValueError', Load(), lineno=73, col_offset=22, end_lineno=73, end_col_offset=32), [Constant('property must be in uppercase', lineno=73, col_offset=33, end_lineno=73, end_col_offset=64)], [], lineno=73, col_offset=22, end_lineno=73, end_col_offset=65), lineno=73, col_offset=16, end_lineno=73, end_col_offset=65)], [], lineno=72, col_offset=12, end_lineno=73, end_col_offset=65), Assign([Tuple([Name('placeholder_6', Store(), lineno=75, col_offset=12, end_lineno=75, end_col_offset=15), Name('placeholder_13', Store(), lineno=75, col_offset=17, end_lineno=75, end_col_offset=26)], Store(), lineno=75, col_offset=12, end_lineno=75, end_col_offset=26)], Call(Name('placeholder_4', Load(), lineno=75, col_offset=29, end_lineno=75, end_col_offset=48), [Name('placeholder_5', Load(), lineno=75, col_offset=49, end_lineno=75, end_col_offset=52), Name('placeholder_6', Load(), lineno=75, col_offset=54, end_lineno=75, end_col_offset=57)], [], lineno=75, col_offset=29, end_lineno=75, end_col_offset=58), lineno=75, col_offset=12, end_lineno=75, end_col_offset=58), Expr(Call(Attribute(Subscript(Name('placeholder_1', Load(), lineno=76, col_offset=12, end_lineno=76, end_col_offset=22), Name('placeholder_12', Load(), lineno=76, col_offset=23, end_lineno=76, end_col_offset=31), Load(), lineno=76, col_offset=12, end_lineno=76, end_col_offset=32), 'extend', Load(), lineno=76, col_offset=12, end_lineno=76, end_col_offset=39), [Name('placeholder_13', Load(), lineno=76, col_offset=40, end_lineno=76, end_col_offset=49)], [], lineno=76, col_offset=12, end_lineno=76, end_col_offset=50), lineno=76, col_offset=12, end_lineno=76, end_col_offset=50), Assign([Name('placeholder_11', Store(), lineno=79, col_offset=12, end_lineno=79, end_col_offset=26)], Name('placeholder_6', Load(), lineno=79, col_offset=29, end_lineno=79, end_col_offset=32), lineno=79, col_offset=12, end_lineno=79, end_col_offset=32)], [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=80, col_offset=13, end_lineno=80, end_col_offset=16), Name('placeholder_6', Load(), lineno=80, col_offset=17, end_lineno=80, end_col_offset=20), Load(), lineno=80, col_offset=13, end_lineno=80, end_col_offset=21), [Eq()], [Constant(';', lineno=80, col_offset=25, end_lineno=80, end_col_offset=28)], lineno=80, col_offset=13, end_lineno=80, end_col_offset=28), [Assign([Name('placeholder_14', Store(), lineno=82, col_offset=12, end_lineno=82, end_col_offset=17)], Call(Name('placeholder_10', Load(), lineno=82, col_offset=20, end_lineno=82, end_col_offset=30), [Subscript(Name('placeholder_5', Load(), lineno=82, col_offset=31, end_lineno=82, end_col_offset=34), Slice(Name('placeholder_6', Load(), lineno=82, col_offset=35, end_lineno=82, end_col_offset=38), lineno=82, col_offset=35, end_lineno=82, end_col_offset=39), Load(), lineno=82, col_offset=31, end_lineno=82, end_col_offset=40)], [], lineno=82, col_offset=20, end_lineno=82, end_col_offset=41), lineno=82, col_offset=12, end_lineno=82, end_col_offset=41), Expr(Call(Attribute(Name('placeholder_3', Load(), lineno=83, col_offset=12, end_lineno=83, end_col_offset=20), 'append', Load(), lineno=83, col_offset=12, end_lineno=83, end_col_offset=27), [Name('placeholder_14', Load(), lineno=83, col_offset=28, end_lineno=83, end_col_offset=33)], [], lineno=83, col_offset=12, end_lineno=83, end_col_offset=34), lineno=83, col_offset=12, end_lineno=83, end_col_offset=34), Break(lineno=84, col_offset=12, end_lineno=84, end_col_offset=17)], [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=85, col_offset=13, end_lineno=85, end_col_offset=16), Name('placeholder_6', Load(), lineno=85, col_offset=17, end_lineno=85, end_col_offset=20), Load(), lineno=85, col_offset=13, end_lineno=85, end_col_offset=21), [Eq()], [Constant('(', lineno=85, col_offset=25, end_lineno=85, end_col_offset=28)], lineno=85, col_offset=13, end_lineno=85, end_col_offset=28), [Assign([Name('placeholder_3', Store(), lineno=87, col_offset=12, end_lineno=87, end_col_offset=20)], List([], Load(), lineno=87, col_offset=23, end_lineno=87, end_col_offset=25), lineno=87, col_offset=12, end_lineno=87, end_col_offset=25), While(Compare(Name('placeholder_6', Load(), lineno=88, col_offset=18, end_lineno=88, end_col_offset=21), [Lt()], [Call(Name('len', Load(), lineno=88, col_offset=24, end_lineno=88, end_col_offset=27), [Name('placeholder_5', Load(), lineno=88, col_offset=28, end_lineno=88, end_col_offset=31)], [], lineno=88, col_offset=24, end_lineno=88, end_col_offset=32)], lineno=88, col_offset=18, end_lineno=88, end_col_offset=32), [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=89, col_offset=19, end_lineno=89, end_col_offset=22), Name('placeholder_6', Load(), lineno=89, col_offset=23, end_lineno=89, end_col_offset=26), Load(), lineno=89, col_offset=19, end_lineno=89, end_col_offset=27), [NotEq()], [Constant('(', lineno=89, col_offset=31, end_lineno=89, end_col_offset=34)], lineno=89, col_offset=19, end_lineno=89, end_col_offset=34), [Break(lineno=90, col_offset=20, end_lineno=90, end_col_offset=25)], [], lineno=89, col_offset=16, end_lineno=90, end_col_offset=25), AugAssign(Name('placeholder_6', Store(), lineno=92, col_offset=16, end_lineno=92, end_col_offset=19), Add(), Constant(1, lineno=92, col_offset=23, end_lineno=92, end_col_offset=24), lineno=92, col_offset=16, end_lineno=92, end_col_offset=24), Assign([Name('placeholder_15', Store(), lineno=93, col_offset=16, end_lineno=93, end_col_offset=27)], Name('placeholder_6', Load(), lineno=93, col_offset=30, end_lineno=93, end_col_offset=33), lineno=93, col_offset=16, end_lineno=93, end_col_offset=33), While(Compare(Subscript(Name('placeholder_5', Load(), lineno=94, col_offset=22, end_lineno=94, end_col_offset=25), Name('placeholder_6', Load(), lineno=94, col_offset=26, end_lineno=94, end_col_offset=29), Load(), lineno=94, col_offset=22, end_lineno=94, end_col_offset=30), [NotEq()], [Constant(')', lineno=94, col_offset=34, end_lineno=94, end_col_offset=37)], lineno=94, col_offset=22, end_lineno=94, end_col_offset=37), [AugAssign(Name('placeholder_6', Store(), lineno=95, col_offset=20, end_lineno=95, end_col_offset=23), Add(), Constant(1, lineno=95, col_offset=27, end_lineno=95, end_col_offset=28), lineno=95, col_offset=20, end_lineno=95, end_col_offset=28)], [], lineno=94, col_offset=16, end_lineno=95, end_col_offset=28), Assign([Name('placeholder_14', Store(), lineno=97, col_offset=16, end_lineno=97, end_col_offset=21)], Call(Name('placeholder_10', Load(), lineno=97, col_offset=24, end_lineno=97, end_col_offset=34), [Subscript(Name('placeholder_5', Load(), lineno=97, col_offset=35, end_lineno=97, end_col_offset=38), Slice(Name('placeholder_15', Load(), lineno=97, col_offset=39, end_lineno=97, end_col_offset=50), Name('placeholder_6', Load(), lineno=97, col_offset=51, end_lineno=97, end_col_offset=54), lineno=97, col_offset=39, end_lineno=97, end_col_offset=54), Load(), lineno=97, col_offset=35, end_lineno=97, end_col_offset=55)], [], lineno=97, col_offset=24, end_lineno=97, end_col_offset=56), lineno=97, col_offset=16, end_lineno=97, end_col_offset=56), Expr(Call(Attribute(Name('placeholder_3', Load(), lineno=98, col_offset=16, end_lineno=98, end_col_offset=24), 'append', Load(), lineno=98, col_offset=16, end_lineno=98, end_col_offset=31), [Name('placeholder_14', Load(), lineno=98, col_offset=32, end_lineno=98, end_col_offset=37)], [], lineno=98, col_offset=16, end_lineno=98, end_col_offset=38), lineno=98, col_offset=16, end_lineno=98, end_col_offset=38), AugAssign(Name('placeholder_6', Store(), lineno=99, col_offset=16, end_lineno=99, end_col_offset=19), Add(), Constant(1, lineno=99, col_offset=23, end_lineno=99, end_col_offset=24), lineno=99, col_offset=16, end_lineno=99, end_col_offset=24)], [], lineno=88, col_offset=12, end_lineno=99, end_col_offset=24)], [AugAssign(Name('placeholder_6', Store(), lineno=101, col_offset=12, end_lineno=101, end_col_offset=15), Add(), Constant(1, lineno=101, col_offset=19, end_lineno=101, end_col_offset=20), lineno=101, col_offset=12, end_lineno=101, end_col_offset=20)], lineno=85, col_offset=8, end_lineno=101, end_col_offset=20)], lineno=80, col_offset=8, end_lineno=101, end_col_offset=20)], lineno=67, col_offset=8, end_lineno=101, end_col_offset=20)], [], lineno=66, col_offset=4, end_lineno=101, end_col_offset=20), If(BoolOp(And(), [Compare(Name('placeholder_6', Load(), lineno=103, col_offset=7, end_lineno=103, end_col_offset=10), [Gt()], [Name('placeholder_11', Load(), lineno=103, col_offset=13, end_lineno=103, end_col_offset=27)], lineno=103, col_offset=7, end_lineno=103, end_col_offset=27), UnaryOp(Not(), Name('placeholder_1', Load(), lineno=103, col_offset=36, end_lineno=103, end_col_offset=46), lineno=103, col_offset=32, end_lineno=103, end_col_offset=46)], lineno=103, col_offset=7, end_lineno=103, end_col_offset=46), [Raise(Call(Name('ValueError', Load(), lineno=104, col_offset=14, end_lineno=104, end_col_offset=24), [Constant('properties without delimiter', lineno=104, col_offset=25, end_lineno=104, end_col_offset=55)], [], lineno=104, col_offset=14, end_lineno=104, end_col_offset=56), lineno=104, col_offset=8, end_lineno=104, end_col_offset=56)], [], lineno=103, col_offset=4, end_lineno=104, end_col_offset=56), Return(Call(Name('placeholder_0', Load(), lineno=105, col_offset=11, end_lineno=105, end_col_offset=18), [], [keyword('placeholder_3', Name('placeholder_3', Load(), lineno=105, col_offset=28, end_lineno=105, end_col_offset=36), lineno=105, col_offset=19, end_lineno=105, end_col_offset=36), keyword('placeholder_1', Call(Name('dict', Load(), lineno=105, col_offset=49, end_lineno=105, end_col_offset=53), [Name('placeholder_1', Load(), lineno=105, col_offset=54, end_lineno=105, end_col_offset=64)], [], lineno=105, col_offset=49, end_lineno=105, end_col_offset=65), lineno=105, col_offset=38, end_lineno=105, end_col_offset=65)], lineno=105, col_offset=11, end_lineno=105, end_col_offset=66), lineno=105, col_offset=4, end_lineno=105, end_col_offset=66)], [], lineno=55, col_offset=0, end_lineno=105, end_col_offset=66), FunctionDef('placeholder_16', arguments([], [arg('placeholder_5', lineno=108, col_offset=10, end_lineno=108, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(BoolOp(And(), [UnaryOp(Not(), Call(Attribute(Name('placeholder_5', Load(), lineno=110, col_offset=11, end_lineno=110, end_col_offset=14), 'startswith', Load(), lineno=110, col_offset=11, end_lineno=110, end_col_offset=25), [Constant('(', lineno=110, col_offset=26, end_lineno=110, end_col_offset=29)], [], lineno=110, col_offset=11, end_lineno=110, end_col_offset=30), lineno=110, col_offset=7, end_lineno=110, end_col_offset=30), UnaryOp(Not(), Call(Attribute(Name('placeholder_5', Load(), lineno=110, col_offset=39, end_lineno=110, end_col_offset=42), 'endswith', Load(), lineno=110, col_offset=39, end_lineno=110, end_col_offset=51), [Constant(')', lineno=110, col_offset=52, end_lineno=110, end_col_offset=55)], [], lineno=110, col_offset=39, end_lineno=110, end_col_offset=56), lineno=110, col_offset=35, end_lineno=110, end_col_offset=56)], lineno=110, col_offset=7, end_lineno=110, end_col_offset=56), [Raise(Call(Name('ValueError', Load(), lineno=111, col_offset=14, end_lineno=111, end_col_offset=24), [Constant('tree missing', lineno=111, col_offset=25, end_lineno=111, end_col_offset=39)], [], lineno=111, col_offset=14, end_lineno=111, end_col_offset=40), lineno=111, col_offset=8, end_lineno=111, end_col_offset=40)], [], lineno=110, col_offset=4, end_lineno=111, end_col_offset=40), If(UnaryOp(Not(), Call(Attribute(Name('placeholder_5', Load(), lineno=112, col_offset=11, end_lineno=112, end_col_offset=14), 'startswith', Load(), lineno=112, col_offset=11, end_lineno=112, end_col_offset=25), [Constant('(;', lineno=112, col_offset=26, end_lineno=112, end_col_offset=30)], [], lineno=112, col_offset=11, end_lineno=112, end_col_offset=31), lineno=112, col_offset=7, end_lineno=112, end_col_offset=31), [Raise(Call(Name('ValueError', Load(), lineno=113, col_offset=14, end_lineno=113, end_col_offset=24), [Constant('tree with no nodes', lineno=113, col_offset=25, end_lineno=113, end_col_offset=45)], [], lineno=113, col_offset=14, end_lineno=113, end_col_offset=46), lineno=113, col_offset=8, end_lineno=113, end_col_offset=46)], [], lineno=112, col_offset=4, end_lineno=113, end_col_offset=46), Assign([Name('placeholder_17', Store(), lineno=114, col_offset=4, end_lineno=114, end_col_offset=10)], Subscript(Name('placeholder_5', Load(), lineno=114, col_offset=13, end_lineno=114, end_col_offset=16), Slice(Constant(1, lineno=114, col_offset=17, end_lineno=114, end_col_offset=18), UnaryOp(USub(), Constant(1, lineno=114, col_offset=20, end_lineno=114, end_col_offset=21), lineno=114, col_offset=19, end_lineno=114, end_col_offset=21), lineno=114, col_offset=17, end_lineno=114, end_col_offset=21), Load(), lineno=114, col_offset=13, end_lineno=114, end_col_offset=22), lineno=114, col_offset=4, end_lineno=114, end_col_offset=22), Return(Call(Name('placeholder_10', Load(), lineno=115, col_offset=11, end_lineno=115, end_col_offset=21), [Name('placeholder_17', Load(), lineno=115, col_offset=22, end_lineno=115, end_col_offset=28)], [], lineno=115, col_offset=11, end_lineno=115, end_col_offset=29), lineno=115, col_offset=4, end_lineno=115, end_col_offset=29)], [], lineno=108, col_offset=0, end_lineno=115, end_col_offset=29)], []) \ No newline at end of file diff --git a/test/practice-sgf-parsing/sgf_parsing.py b/test/practice-sgf-parsing/sgf_parsing.py new file mode 100644 index 0000000..2b14e37 --- /dev/null +++ b/test/practice-sgf-parsing/sgf_parsing.py @@ -0,0 +1,115 @@ +"""Parse an SGF tree.""" +from __future__ import annotations + +import collections +import dataclasses +import string + + +@dataclasses.dataclass +class SgfTree: + """SGF Node.""" + + properties: dict[str, str] = dataclasses.field(default_factory=dict) + children: list[SgfTree] = dataclasses.field(default_factory=list) + + +def parse_property_vals(sgf: str, idx: int) -> tuple[int, list[str]]: + """Parse property values, returning the next index and values.""" + values = [] + while idx < len(sgf): + if sgf[idx] != "[": + break + + # Start of the value. + idx += 1 + prop_val = "" + while sgf[idx] != "]": + # \ has special SGF handling. + if sgf[idx] == "\\": + if sgf[idx:idx + 2] == "\\\n": + # Newlines are removed if they come immediately after a \, + # otherwise they remain as newlines. + pass + else: + # \ is the escape character. Any non-whitespace character + # after \ is inserted as-is + prop_val += sgf[idx + 1] + idx += 2 + else: + prop_val += sgf[idx] + idx += 1 + + # All whitespace characters other than newline are converted to spaces. + for char in string.whitespace: + if char == "\n": + continue + prop_val = prop_val.replace(char, " ") + + values.append(prop_val) + idx += 1 + + return idx, values + + +def parse_node(sgf: str) -> SgfTree: + """Parse and return a Node.""" + if not sgf.startswith(";"): + raise ValueError("node must start with ';'") + + idx = 1 + prop_key_start = idx + + properties = collections.defaultdict(list) + children = [] + + while idx < len(sgf): + if sgf[idx] == "[": + # Parse property values. + if idx == prop_key_start: + raise ValueError("propery key is empty") + prop_key = sgf[prop_key_start:idx] + if not prop_key.isupper(): + raise ValueError('property must be in uppercase') + + idx, prop_vals = parse_property_vals(sgf, idx) + properties[prop_key].extend(prop_vals) + + # New property. + prop_key_start = idx + elif sgf[idx] == ";": + # Single child. + child = parse_node(sgf[idx:]) + children.append(child) + break + elif sgf[idx] == "(": + # Multiple children. + children = [] + while idx < len(sgf): + if sgf[idx] != "(": + break + # Child start. + idx += 1 + child_start = idx + while sgf[idx] != ")": + idx += 1 + # Child end. + child = parse_node(sgf[child_start:idx]) + children.append(child) + idx += 1 + else: + idx += 1 + + if idx > prop_key_start and not properties: + raise ValueError('properties without delimiter') + return SgfTree(children=children, properties=dict(properties)) + + +def parse(sgf: str) -> SgfTree: + """Parse an SGF tree.""" + if not sgf.startswith("(") and not sgf.endswith(")"): + raise ValueError('tree missing') + if not sgf.startswith("(;"): + raise ValueError('tree with no nodes') + inside = sgf[1:-1] + return parse_node(inside) diff --git a/test/practice-sieve/.meta/config.json b/test/practice-sieve/.meta/config.json new file mode 100644 index 0000000..7bf97ee --- /dev/null +++ b/test/practice-sieve/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "behrtam", + "cmccandless", + "crsmi", + "Dog", + "Grociu", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "Peque", + "pheanex", + "rootulp", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "sieve.py" + ], + "test": [ + "sieve_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.", + "source": "Sieve of Eratosthenes at Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" +} diff --git a/test/practice-sieve/mapping.json b/test/practice-sieve/mapping.json new file mode 100644 index 0000000..e6dd14a --- /dev/null +++ b/test/practice-sieve/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "primes", + "placeholder_1": "limit", + "placeholder_2": "prime", + "placeholder_3": "idx", + "placeholder_4": "edx" +} \ No newline at end of file diff --git a/test/practice-sieve/representation.json b/test/practice-sieve/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-sieve/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-sieve/representation.out b/test/practice-sieve/representation.out new file mode 100644 index 0000000..e828331 --- /dev/null +++ b/test/practice-sieve/representation.out @@ -0,0 +1,835 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = [True] * (placeholder_1 + 1) + placeholder_2[0] = placeholder_2[1] = False + for placeholder_3 in range(2, int(placeholder_1**0.5) + 1): + if placeholder_2[placeholder_3]: + for placeholder_4 in range( + placeholder_3 * placeholder_3, placeholder_1 + 1, placeholder_3 + ): + placeholder_2[placeholder_4] = False + return [ + placeholder_4 + for placeholder_4, placeholder_3 in enumerate(placeholder_2) + if placeholder_3 + ] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'primes', + arguments( + [], + [ + arg( + 'limit', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'prime', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9)], + BinOp( + List( + [ + Constant( + True, + lineno=2, + col_offset=13, + end_lineno=2, + end_col_offset=17)], + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=18), + Mult(), + BinOp( + Name( + 'limit', + Load(), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=27), + Add(), + Constant( + 1, + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=32), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=32), + Assign( + [ + Subscript( + Name( + 'prime', + Load(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=9), + Constant( + 0, + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=11), + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=12), + Subscript( + Name( + 'prime', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + Constant( + 1, + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=22), + Store(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=23)], + Constant( + False, + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=31), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=31), + For( + Name( + 'idx', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=20), + [ + Constant( + 2, + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=22), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=27), + [ + BinOp( + Name( + 'limit', + Load(), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=33), + Pow(), + Constant( + 0.5, + lineno=4, + col_offset=37, + end_lineno=4, + end_col_offset=40), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=40)], + [], + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=41), + Add(), + Constant( + 1, + lineno=4, + col_offset=44, + end_lineno=4, + end_col_offset=45), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=45)], + [], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=46), + [ + If( + Subscript( + Name( + 'prime', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=16), + Name( + 'idx', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=20), + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=21), + [ + For( + Name( + 'edx', + Store(), + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=28), + [ + BinOp( + Name( + 'idx', + Load(), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=32), + Mult(), + Name( + 'idx', + Load(), + lineno=6, + col_offset=35, + end_lineno=6, + end_col_offset=38), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=38), + BinOp( + Name( + 'limit', + Load(), + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=45), + Add(), + Constant( + 1, + lineno=6, + col_offset=48, + end_lineno=6, + end_col_offset=49), + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=49), + Name( + 'idx', + Load(), + lineno=6, + col_offset=51, + end_lineno=6, + end_col_offset=54)], + [], + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=55), + [ + Assign( + [ + Subscript( + Name( + 'prime', + Load(), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=21), + Name( + 'edx', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=25), + Store(), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=26)], + Constant( + False, + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=34), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=34)], + [], + lineno=6, + col_offset=12, + end_lineno=7, + end_col_offset=34)], + [], + lineno=5, + col_offset=8, + end_lineno=7, + end_col_offset=34)], + [], + lineno=4, + col_offset=4, + end_lineno=7, + end_col_offset=34), + Return( + ListComp( + Name( + 'edx', + Load(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=15), + [ + comprehension( + Tuple( + [ + Name( + 'edx', + Store(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=23), + Name( + 'idx', + Store(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=28)], + Store(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=28), + Call( + Name( + 'enumerate', + Load(), + lineno=9, + col_offset=32, + end_lineno=9, + end_col_offset=41), + [ + Name( + 'prime', + Load(), + lineno=9, + col_offset=42, + end_lineno=9, + end_col_offset=47)], + [], + lineno=9, + col_offset=32, + end_lineno=9, + end_col_offset=48), + [ + Name( + 'idx', + Load(), + lineno=9, + col_offset=52, + end_lineno=9, + end_col_offset=55)], + 0)], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=56), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=56)], + [], + lineno=1, + col_offset=0, + end_lineno=9, + end_col_offset=56)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=11, + end_lineno=1, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9)], + BinOp( + List( + [ + Constant( + True, + lineno=2, + col_offset=13, + end_lineno=2, + end_col_offset=17)], + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=18), + Mult(), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=27), + Add(), + Constant( + 1, + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=32), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=32), + Assign( + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=9), + Constant( + 0, + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=11), + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=12), + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + Constant( + 1, + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=22), + Store(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=23)], + Constant( + False, + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=31), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=31), + For( + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=20), + [ + Constant( + 2, + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=22), + BinOp( + Call( + Name( + 'int', + Load(), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=27), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=33), + Pow(), + Constant( + 0.5, + lineno=4, + col_offset=37, + end_lineno=4, + end_col_offset=40), + lineno=4, + col_offset=28, + end_lineno=4, + end_col_offset=40)], + [], + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=41), + Add(), + Constant( + 1, + lineno=4, + col_offset=44, + end_lineno=4, + end_col_offset=45), + lineno=4, + col_offset=24, + end_lineno=4, + end_col_offset=45)], + [], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=46), + [ + If( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=16), + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=20), + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=21), + [ + For( + Name( + 'placeholder_4', + Store(), + lineno=6, + col_offset=16, + end_lineno=6, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=28), + [ + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=32), + Mult(), + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=35, + end_lineno=6, + end_col_offset=38), + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=38), + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=45), + Add(), + Constant( + 1, + lineno=6, + col_offset=48, + end_lineno=6, + end_col_offset=49), + lineno=6, + col_offset=40, + end_lineno=6, + end_col_offset=49), + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=51, + end_lineno=6, + end_col_offset=54)], + [], + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=55), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=21), + Name( + 'placeholder_4', + Load(), + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=25), + Store(), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=26)], + Constant( + False, + lineno=7, + col_offset=29, + end_lineno=7, + end_col_offset=34), + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=34)], + [], + lineno=6, + col_offset=12, + end_lineno=7, + end_col_offset=34)], + [], + lineno=5, + col_offset=8, + end_lineno=7, + end_col_offset=34)], + [], + lineno=4, + col_offset=4, + end_lineno=7, + end_col_offset=34), + Return( + ListComp( + Name( + 'placeholder_4', + Load(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=15), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_4', + Store(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=23), + Name( + 'placeholder_3', + Store(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=28)], + Store(), + lineno=9, + col_offset=20, + end_lineno=9, + end_col_offset=28), + Call( + Name( + 'enumerate', + Load(), + lineno=9, + col_offset=32, + end_lineno=9, + end_col_offset=41), + [ + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=42, + end_lineno=9, + end_col_offset=47)], + [], + lineno=9, + col_offset=32, + end_lineno=9, + end_col_offset=48), + [ + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=52, + end_lineno=9, + end_col_offset=55)], + 0)], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=56), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=56)], + [], + lineno=1, + col_offset=0, + end_lineno=9, + end_col_offset=56)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-sieve/representation.txt b/test/practice-sieve/representation.txt new file mode 100644 index 0000000..10bdee0 --- /dev/null +++ b/test/practice-sieve/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=11, end_lineno=1, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=9)], BinOp(List([Constant(True, lineno=2, col_offset=13, end_lineno=2, end_col_offset=17)], Load(), lineno=2, col_offset=12, end_lineno=2, end_col_offset=18), Mult(), BinOp(Name('placeholder_1', Load(), lineno=2, col_offset=22, end_lineno=2, end_col_offset=27), Add(), Constant(1, lineno=2, col_offset=30, end_lineno=2, end_col_offset=31), lineno=2, col_offset=22, end_lineno=2, end_col_offset=31), lineno=2, col_offset=12, end_lineno=2, end_col_offset=32), lineno=2, col_offset=4, end_lineno=2, end_col_offset=32), Assign([Subscript(Name('placeholder_2', Load(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=9), Constant(0, lineno=3, col_offset=10, end_lineno=3, end_col_offset=11), Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=12), Subscript(Name('placeholder_2', Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=20), Constant(1, lineno=3, col_offset=21, end_lineno=3, end_col_offset=22), Store(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=23)], Constant(False, lineno=3, col_offset=26, end_lineno=3, end_col_offset=31), lineno=3, col_offset=4, end_lineno=3, end_col_offset=31), For(Name('placeholder_3', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=11), Call(Name('range', Load(), lineno=4, col_offset=15, end_lineno=4, end_col_offset=20), [Constant(2, lineno=4, col_offset=21, end_lineno=4, end_col_offset=22), BinOp(Call(Name('int', Load(), lineno=4, col_offset=24, end_lineno=4, end_col_offset=27), [BinOp(Name('placeholder_1', Load(), lineno=4, col_offset=28, end_lineno=4, end_col_offset=33), Pow(), Constant(0.5, lineno=4, col_offset=37, end_lineno=4, end_col_offset=40), lineno=4, col_offset=28, end_lineno=4, end_col_offset=40)], [], lineno=4, col_offset=24, end_lineno=4, end_col_offset=41), Add(), Constant(1, lineno=4, col_offset=44, end_lineno=4, end_col_offset=45), lineno=4, col_offset=24, end_lineno=4, end_col_offset=45)], [], lineno=4, col_offset=15, end_lineno=4, end_col_offset=46), [If(Subscript(Name('placeholder_2', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=16), Name('placeholder_3', Load(), lineno=5, col_offset=17, end_lineno=5, end_col_offset=20), Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=21), [For(Name('placeholder_4', Store(), lineno=6, col_offset=16, end_lineno=6, end_col_offset=19), Call(Name('range', Load(), lineno=6, col_offset=23, end_lineno=6, end_col_offset=28), [BinOp(Name('placeholder_3', Load(), lineno=6, col_offset=29, end_lineno=6, end_col_offset=32), Mult(), Name('placeholder_3', Load(), lineno=6, col_offset=35, end_lineno=6, end_col_offset=38), lineno=6, col_offset=29, end_lineno=6, end_col_offset=38), BinOp(Name('placeholder_1', Load(), lineno=6, col_offset=40, end_lineno=6, end_col_offset=45), Add(), Constant(1, lineno=6, col_offset=48, end_lineno=6, end_col_offset=49), lineno=6, col_offset=40, end_lineno=6, end_col_offset=49), Name('placeholder_3', Load(), lineno=6, col_offset=51, end_lineno=6, end_col_offset=54)], [], lineno=6, col_offset=23, end_lineno=6, end_col_offset=55), [Assign([Subscript(Name('placeholder_2', Load(), lineno=7, col_offset=16, end_lineno=7, end_col_offset=21), Name('placeholder_4', Load(), lineno=7, col_offset=22, end_lineno=7, end_col_offset=25), Store(), lineno=7, col_offset=16, end_lineno=7, end_col_offset=26)], Constant(False, lineno=7, col_offset=29, end_lineno=7, end_col_offset=34), lineno=7, col_offset=16, end_lineno=7, end_col_offset=34)], [], lineno=6, col_offset=12, end_lineno=7, end_col_offset=34)], [], lineno=5, col_offset=8, end_lineno=7, end_col_offset=34)], [], lineno=4, col_offset=4, end_lineno=7, end_col_offset=34), Return(ListComp(Name('placeholder_4', Load(), lineno=9, col_offset=12, end_lineno=9, end_col_offset=15), [comprehension(Tuple([Name('placeholder_4', Store(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=23), Name('placeholder_3', Store(), lineno=9, col_offset=25, end_lineno=9, end_col_offset=28)], Store(), lineno=9, col_offset=20, end_lineno=9, end_col_offset=28), Call(Name('enumerate', Load(), lineno=9, col_offset=32, end_lineno=9, end_col_offset=41), [Name('placeholder_2', Load(), lineno=9, col_offset=42, end_lineno=9, end_col_offset=47)], [], lineno=9, col_offset=32, end_lineno=9, end_col_offset=48), [Name('placeholder_3', Load(), lineno=9, col_offset=52, end_lineno=9, end_col_offset=55)], 0)], lineno=9, col_offset=11, end_lineno=9, end_col_offset=56), lineno=9, col_offset=4, end_lineno=9, end_col_offset=56)], [], lineno=1, col_offset=0, end_lineno=9, end_col_offset=56)], []) \ No newline at end of file diff --git a/test/practice-sieve/sieve.py b/test/practice-sieve/sieve.py new file mode 100644 index 0000000..0e8ae8a --- /dev/null +++ b/test/practice-sieve/sieve.py @@ -0,0 +1,9 @@ +def primes(limit): + prime = [True] * (limit + 1) + prime[0] = prime[1] = False + for idx in range(2, int(limit ** 0.5) + 1): + if prime[idx]: + for edx in range(idx * idx, limit + 1, idx): + prime[edx] = False + + return [edx for edx, idx in enumerate(prime) if idx] diff --git a/test/practice-simple-cipher/.meta/config.json b/test/practice-simple-cipher/.meta/config.json new file mode 100644 index 0000000..0dc1687 --- /dev/null +++ b/test/practice-simple-cipher/.meta/config.json @@ -0,0 +1,36 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "AnAccountForReportingBugs", + "beatorizu", + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "kytrinyx", + "lucasloisp", + "N-Parsons", + "Peque", + "pheanex", + "sjakobi", + "tqa236", + "twsh", + "yawpitch" + ], + "files": { + "solution": [ + "simple_cipher.py" + ], + "test": [ + "simple_cipher_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement a simple shift cipher like Caesar and a more secure substitution cipher.", + "source": "Substitution Cipher at Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Substitution_cipher" +} diff --git a/test/practice-simple-cipher/mapping.json b/test/practice-simple-cipher/mapping.json new file mode 100644 index 0000000..6e907de --- /dev/null +++ b/test/practice-simple-cipher/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "Cipher", + "placeholder_1": "__init__", + "placeholder_2": "key", + "placeholder_3": "_", + "placeholder_4": "encode", + "placeholder_5": "text", + "placeholder_6": "character", + "placeholder_7": "decode" +} \ No newline at end of file diff --git a/test/practice-simple-cipher/representation.json b/test/practice-simple-cipher/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-simple-cipher/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-simple-cipher/representation.out b/test/practice-simple-cipher/representation.out new file mode 100644 index 0000000..54db836 --- /dev/null +++ b/test/practice-simple-cipher/representation.out @@ -0,0 +1,1648 @@ +## BEGIN NORMALIZED CODE ## +from string import ascii_lowercase +from time import time +import random +from itertools import cycle + + +class placeholder_0: + def placeholder_1(self, placeholder_2=None): + if placeholder_2 is None: + random.seed(time()) + placeholder_2 = "".join( + (random.choice(ascii_lowercase) for placeholder_3 in range(100)) + ) + self.placeholder_2 = placeholder_2 + + def placeholder_4(self, placeholder_5): + return "".join( + ( + chr( + (ord(placeholder_6) - 2 * ord("a") + ord(placeholder_2)) % 26 + + ord("a") + ) + for placeholder_6, placeholder_2 in zip( + placeholder_5, cycle(self.placeholder_2) + ) + ) + ) + + def placeholder_7(self, placeholder_5): + return "".join( + ( + chr((ord(placeholder_6) - ord(placeholder_2) + 26) % 26 + ord("a")) + for placeholder_6, placeholder_2 in zip( + placeholder_5, cycle(self.placeholder_2) + ) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'string', + [ + alias( + 'ascii_lowercase', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + ImportFrom( + 'time', + [ + alias( + 'time', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=21), + Import( + [ + alias( + 'random', + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=13)], + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=13), + ImportFrom( + 'itertools', + [ + alias( + 'cycle', + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=27)], + 0, + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=27), + ClassDef( + 'Cipher', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21), + arg( + 'key', + lineno=9, + col_offset=23, + end_lineno=9, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=31)]), + [ + If( + Compare( + Name( + 'key', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=14), + [ + Is()], + [ + Constant( + None, + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=22)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=22), + [ + Expr( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18), + 'seed', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=23), + [ + Call( + Name( + 'time', + Load(), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=28), + [], + [], + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=30)], + [], + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=31), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=31), + Assign( + [ + Name( + 'key', + Store(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=15)], + Call( + Attribute( + Constant( + '', + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=20), + 'join', + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=25), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=32), + 'choice', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=39), + [ + Name( + 'ascii_lowercase', + Load(), + lineno=12, + col_offset=40, + end_lineno=12, + end_col_offset=55)], + [], + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=56), + [ + comprehension( + Name( + '_', + Store(), + lineno=12, + col_offset=61, + end_lineno=12, + end_col_offset=62), + Call( + Name( + 'range', + Load(), + lineno=12, + col_offset=66, + end_lineno=12, + end_col_offset=71), + [ + Constant( + 100, + lineno=12, + col_offset=72, + end_lineno=12, + end_col_offset=75)], + [], + lineno=12, + col_offset=66, + end_lineno=12, + end_col_offset=76), + [], + 0)], + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=77)], + [], + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=77), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=77)], + [], + lineno=10, + col_offset=8, + end_lineno=12, + end_col_offset=77), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'key', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=16)], + Name( + 'key', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=22), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + [], + lineno=9, + col_offset=4, + end_lineno=13, + end_col_offset=22), + FunctionDef( + 'encode', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + arg( + 'text', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '', + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=17), + 'join', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=22), + [ + GeneratorExp( + Call( + Name( + 'chr', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=15), + [ + BinOp( + BinOp( + BinOp( + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=21), + [ + Name( + 'character', + Load(), + lineno=17, + col_offset=22, + end_lineno=17, + end_col_offset=31)], + [], + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=32), + Sub(), + BinOp( + Constant( + 2, + lineno=17, + col_offset=35, + end_lineno=17, + end_col_offset=36), + Mult(), + Call( + Name( + 'ord', + Load(), + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=42), + [ + Constant( + 'a', + lineno=17, + col_offset=43, + end_lineno=17, + end_col_offset=46)], + [], + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=47), + lineno=17, + col_offset=35, + end_lineno=17, + end_col_offset=47), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=47), + Add(), + Call( + Name( + 'ord', + Load(), + lineno=17, + col_offset=50, + end_lineno=17, + end_col_offset=53), + [ + Name( + 'key', + Load(), + lineno=17, + col_offset=54, + end_lineno=17, + end_col_offset=57)], + [], + lineno=17, + col_offset=50, + end_lineno=17, + end_col_offset=58), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=58), + Mod(), + Constant( + 26, + lineno=17, + col_offset=62, + end_lineno=17, + end_col_offset=64), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=64), + Add(), + Call( + Name( + 'ord', + Load(), + lineno=17, + col_offset=68, + end_lineno=17, + end_col_offset=71), + [ + Constant( + 'a', + lineno=17, + col_offset=72, + end_lineno=17, + end_col_offset=75)], + [], + lineno=17, + col_offset=68, + end_lineno=17, + end_col_offset=76), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=76)], + [], + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=77), + [ + comprehension( + Tuple( + [ + Name( + 'character', + Store(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=25), + Name( + 'key', + Store(), + lineno=18, + col_offset=27, + end_lineno=18, + end_col_offset=30)], + Store(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=30), + Call( + Name( + 'zip', + Load(), + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=37), + [ + Name( + 'text', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=42), + Call( + Name( + 'cycle', + Load(), + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=49), + [ + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=50, + end_lineno=18, + end_col_offset=54), + 'key', + Load(), + lineno=18, + col_offset=50, + end_lineno=18, + end_col_offset=58)], + [], + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=59)], + [], + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=60), + [], + 0)], + lineno=16, + col_offset=22, + end_lineno=19, + end_col_offset=9)], + [], + lineno=16, + col_offset=15, + end_lineno=19, + end_col_offset=9), + lineno=16, + col_offset=8, + end_lineno=19, + end_col_offset=9)], + [], + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=9), + FunctionDef( + 'decode', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + arg( + 'text', + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '', + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=17), + 'join', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=22), + [ + GeneratorExp( + Call( + Name( + 'chr', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=15), + [ + BinOp( + BinOp( + BinOp( + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=21), + [ + Name( + 'character', + Load(), + lineno=23, + col_offset=22, + end_lineno=23, + end_col_offset=31)], + [], + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=32), + Sub(), + Call( + Name( + 'ord', + Load(), + lineno=23, + col_offset=35, + end_lineno=23, + end_col_offset=38), + [ + Name( + 'key', + Load(), + lineno=23, + col_offset=39, + end_lineno=23, + end_col_offset=42)], + [], + lineno=23, + col_offset=35, + end_lineno=23, + end_col_offset=43), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=43), + Add(), + Constant( + 26, + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=48), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=48), + Mod(), + Constant( + 26, + lineno=23, + col_offset=52, + end_lineno=23, + end_col_offset=54), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=54), + Add(), + Call( + Name( + 'ord', + Load(), + lineno=23, + col_offset=58, + end_lineno=23, + end_col_offset=61), + [ + Constant( + 'a', + lineno=23, + col_offset=62, + end_lineno=23, + end_col_offset=65)], + [], + lineno=23, + col_offset=58, + end_lineno=23, + end_col_offset=66), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=66)], + [], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=67), + [ + comprehension( + Tuple( + [ + Name( + 'character', + Store(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=25), + Name( + 'key', + Store(), + lineno=24, + col_offset=27, + end_lineno=24, + end_col_offset=30)], + Store(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=30), + Call( + Name( + 'zip', + Load(), + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=37), + [ + Name( + 'text', + Load(), + lineno=24, + col_offset=38, + end_lineno=24, + end_col_offset=42), + Call( + Name( + 'cycle', + Load(), + lineno=24, + col_offset=44, + end_lineno=24, + end_col_offset=49), + [ + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=50, + end_lineno=24, + end_col_offset=54), + 'key', + Load(), + lineno=24, + col_offset=50, + end_lineno=24, + end_col_offset=58)], + [], + lineno=24, + col_offset=44, + end_lineno=24, + end_col_offset=59)], + [], + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=60), + [], + 0)], + lineno=22, + col_offset=22, + end_lineno=25, + end_col_offset=9)], + [], + lineno=22, + col_offset=15, + end_lineno=25, + end_col_offset=9), + lineno=22, + col_offset=8, + end_lineno=25, + end_col_offset=9)], + [], + lineno=21, + col_offset=4, + end_lineno=25, + end_col_offset=9)], + [], + lineno=7, + col_offset=0, + end_lineno=25, + end_col_offset=9)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'string', + [ + alias( + 'ascii_lowercase', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + ImportFrom( + 'time', + [ + alias( + 'time', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=21), + Import( + [ + alias( + 'random', + lineno=3, + col_offset=7, + end_lineno=3, + end_col_offset=13)], + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=13), + ImportFrom( + 'itertools', + [ + alias( + 'cycle', + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=27)], + 0, + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=27), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=9, + col_offset=23, + end_lineno=9, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=31)]), + [ + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=14), + [ + Is()], + [ + Constant( + None, + lineno=10, + col_offset=18, + end_lineno=10, + end_col_offset=22)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=22), + [ + Expr( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=18), + 'seed', + Load(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=23), + [ + Call( + Name( + 'time', + Load(), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=28), + [], + [], + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=30)], + [], + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=31), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=31), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=15)], + Call( + Attribute( + Constant( + '', + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=20), + 'join', + Load(), + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=25), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'random', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=32), + 'choice', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=39), + [ + Name( + 'ascii_lowercase', + Load(), + lineno=12, + col_offset=40, + end_lineno=12, + end_col_offset=55)], + [], + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=56), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=12, + col_offset=61, + end_lineno=12, + end_col_offset=62), + Call( + Name( + 'range', + Load(), + lineno=12, + col_offset=66, + end_lineno=12, + end_col_offset=71), + [ + Constant( + 100, + lineno=12, + col_offset=72, + end_lineno=12, + end_col_offset=75)], + [], + lineno=12, + col_offset=66, + end_lineno=12, + end_col_offset=76), + [], + 0)], + lineno=12, + col_offset=25, + end_lineno=12, + end_col_offset=77)], + [], + lineno=12, + col_offset=18, + end_lineno=12, + end_col_offset=77), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=77)], + [], + lineno=10, + col_offset=8, + end_lineno=12, + end_col_offset=77), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=16)], + Name( + 'placeholder_2', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=22), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + [], + lineno=9, + col_offset=4, + end_lineno=13, + end_col_offset=22), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + arg( + 'placeholder_5', + lineno=15, + col_offset=21, + end_lineno=15, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '', + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=17), + 'join', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=22), + [ + GeneratorExp( + Call( + Name( + 'chr', + Load(), + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=15), + [ + BinOp( + BinOp( + BinOp( + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=21), + [ + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=22, + end_lineno=17, + end_col_offset=31)], + [], + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=32), + Sub(), + BinOp( + Constant( + 2, + lineno=17, + col_offset=35, + end_lineno=17, + end_col_offset=36), + Mult(), + Call( + Name( + 'ord', + Load(), + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=42), + [ + Constant( + 'a', + lineno=17, + col_offset=43, + end_lineno=17, + end_col_offset=46)], + [], + lineno=17, + col_offset=39, + end_lineno=17, + end_col_offset=47), + lineno=17, + col_offset=35, + end_lineno=17, + end_col_offset=47), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=47), + Add(), + Call( + Name( + 'ord', + Load(), + lineno=17, + col_offset=50, + end_lineno=17, + end_col_offset=53), + [ + Name( + 'placeholder_2', + Load(), + lineno=17, + col_offset=54, + end_lineno=17, + end_col_offset=57)], + [], + lineno=17, + col_offset=50, + end_lineno=17, + end_col_offset=58), + lineno=17, + col_offset=18, + end_lineno=17, + end_col_offset=58), + Mod(), + Constant( + 26, + lineno=17, + col_offset=62, + end_lineno=17, + end_col_offset=64), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=64), + Add(), + Call( + Name( + 'ord', + Load(), + lineno=17, + col_offset=68, + end_lineno=17, + end_col_offset=71), + [ + Constant( + 'a', + lineno=17, + col_offset=72, + end_lineno=17, + end_col_offset=75)], + [], + lineno=17, + col_offset=68, + end_lineno=17, + end_col_offset=76), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=76)], + [], + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=77), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_6', + Store(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=25), + Name( + 'placeholder_2', + Store(), + lineno=18, + col_offset=27, + end_lineno=18, + end_col_offset=30)], + Store(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=30), + Call( + Name( + 'zip', + Load(), + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=37), + [ + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=42), + Call( + Name( + 'cycle', + Load(), + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=49), + [ + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=50, + end_lineno=18, + end_col_offset=54), + 'placeholder_2', + Load(), + lineno=18, + col_offset=50, + end_lineno=18, + end_col_offset=58)], + [], + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=59)], + [], + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=60), + [], + 0)], + lineno=16, + col_offset=22, + end_lineno=19, + end_col_offset=9)], + [], + lineno=16, + col_offset=15, + end_lineno=19, + end_col_offset=9), + lineno=16, + col_offset=8, + end_lineno=19, + end_col_offset=9)], + [], + lineno=15, + col_offset=4, + end_lineno=19, + end_col_offset=9), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + arg( + 'placeholder_5', + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Constant( + '', + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=17), + 'join', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=22), + [ + GeneratorExp( + Call( + Name( + 'chr', + Load(), + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=15), + [ + BinOp( + BinOp( + BinOp( + BinOp( + Call( + Name( + 'ord', + Load(), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=21), + [ + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=22, + end_lineno=23, + end_col_offset=31)], + [], + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=32), + Sub(), + Call( + Name( + 'ord', + Load(), + lineno=23, + col_offset=35, + end_lineno=23, + end_col_offset=38), + [ + Name( + 'placeholder_2', + Load(), + lineno=23, + col_offset=39, + end_lineno=23, + end_col_offset=42)], + [], + lineno=23, + col_offset=35, + end_lineno=23, + end_col_offset=43), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=43), + Add(), + Constant( + 26, + lineno=23, + col_offset=46, + end_lineno=23, + end_col_offset=48), + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=48), + Mod(), + Constant( + 26, + lineno=23, + col_offset=52, + end_lineno=23, + end_col_offset=54), + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=54), + Add(), + Call( + Name( + 'ord', + Load(), + lineno=23, + col_offset=58, + end_lineno=23, + end_col_offset=61), + [ + Constant( + 'a', + lineno=23, + col_offset=62, + end_lineno=23, + end_col_offset=65)], + [], + lineno=23, + col_offset=58, + end_lineno=23, + end_col_offset=66), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=66)], + [], + lineno=23, + col_offset=12, + end_lineno=23, + end_col_offset=67), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_6', + Store(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=25), + Name( + 'placeholder_2', + Store(), + lineno=24, + col_offset=27, + end_lineno=24, + end_col_offset=30)], + Store(), + lineno=24, + col_offset=16, + end_lineno=24, + end_col_offset=30), + Call( + Name( + 'zip', + Load(), + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=37), + [ + Name( + 'placeholder_5', + Load(), + lineno=24, + col_offset=38, + end_lineno=24, + end_col_offset=42), + Call( + Name( + 'cycle', + Load(), + lineno=24, + col_offset=44, + end_lineno=24, + end_col_offset=49), + [ + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=50, + end_lineno=24, + end_col_offset=54), + 'placeholder_2', + Load(), + lineno=24, + col_offset=50, + end_lineno=24, + end_col_offset=58)], + [], + lineno=24, + col_offset=44, + end_lineno=24, + end_col_offset=59)], + [], + lineno=24, + col_offset=34, + end_lineno=24, + end_col_offset=60), + [], + 0)], + lineno=22, + col_offset=22, + end_lineno=25, + end_col_offset=9)], + [], + lineno=22, + col_offset=15, + end_lineno=25, + end_col_offset=9), + lineno=22, + col_offset=8, + end_lineno=25, + end_col_offset=9)], + [], + lineno=21, + col_offset=4, + end_lineno=25, + end_col_offset=9)], + [], + lineno=7, + col_offset=0, + end_lineno=25, + end_col_offset=9)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-simple-cipher/representation.txt b/test/practice-simple-cipher/representation.txt new file mode 100644 index 0000000..2e1eed3 --- /dev/null +++ b/test/practice-simple-cipher/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('string', [alias('ascii_lowercase', lineno=1, col_offset=19, end_lineno=1, end_col_offset=34)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=34), ImportFrom('time', [alias('time', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=21), Import([alias('random', lineno=3, col_offset=7, end_lineno=3, end_col_offset=13)], lineno=3, col_offset=0, end_lineno=3, end_col_offset=13), ImportFrom('itertools', [alias('cycle', lineno=4, col_offset=22, end_lineno=4, end_col_offset=27)], 0, lineno=4, col_offset=0, end_lineno=4, end_col_offset=27), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=9, col_offset=17, end_lineno=9, end_col_offset=21), arg('placeholder_2', lineno=9, col_offset=23, end_lineno=9, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=9, col_offset=27, end_lineno=9, end_col_offset=31)]), [If(Compare(Name('placeholder_2', Load(), lineno=10, col_offset=11, end_lineno=10, end_col_offset=14), [Is()], [Constant(None, lineno=10, col_offset=18, end_lineno=10, end_col_offset=22)], lineno=10, col_offset=11, end_lineno=10, end_col_offset=22), [Expr(Call(Attribute(Name('random', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=18), 'seed', Load(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=23), [Call(Name('time', Load(), lineno=11, col_offset=24, end_lineno=11, end_col_offset=28), [], [], lineno=11, col_offset=24, end_lineno=11, end_col_offset=30)], [], lineno=11, col_offset=12, end_lineno=11, end_col_offset=31), lineno=11, col_offset=12, end_lineno=11, end_col_offset=31), Assign([Name('placeholder_2', Store(), lineno=12, col_offset=12, end_lineno=12, end_col_offset=15)], Call(Attribute(Constant('', lineno=12, col_offset=18, end_lineno=12, end_col_offset=20), 'join', Load(), lineno=12, col_offset=18, end_lineno=12, end_col_offset=25), [GeneratorExp(Call(Attribute(Name('random', Load(), lineno=12, col_offset=26, end_lineno=12, end_col_offset=32), 'choice', Load(), lineno=12, col_offset=26, end_lineno=12, end_col_offset=39), [Name('ascii_lowercase', Load(), lineno=12, col_offset=40, end_lineno=12, end_col_offset=55)], [], lineno=12, col_offset=26, end_lineno=12, end_col_offset=56), [comprehension(Name('placeholder_3', Store(), lineno=12, col_offset=61, end_lineno=12, end_col_offset=62), Call(Name('range', Load(), lineno=12, col_offset=66, end_lineno=12, end_col_offset=71), [Constant(100, lineno=12, col_offset=72, end_lineno=12, end_col_offset=75)], [], lineno=12, col_offset=66, end_lineno=12, end_col_offset=76), [], 0)], lineno=12, col_offset=25, end_lineno=12, end_col_offset=77)], [], lineno=12, col_offset=18, end_lineno=12, end_col_offset=77), lineno=12, col_offset=12, end_lineno=12, end_col_offset=77)], [], lineno=10, col_offset=8, end_lineno=12, end_col_offset=77), Assign([Attribute(Name('self', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=12), 'placeholder_2', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=16)], Name('placeholder_2', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=22), lineno=13, col_offset=8, end_lineno=13, end_col_offset=22)], [], lineno=9, col_offset=4, end_lineno=13, end_col_offset=22), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), arg('placeholder_5', lineno=15, col_offset=21, end_lineno=15, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Constant('', lineno=16, col_offset=15, end_lineno=16, end_col_offset=17), 'join', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=22), [GeneratorExp(Call(Name('chr', Load(), lineno=17, col_offset=12, end_lineno=17, end_col_offset=15), [BinOp(BinOp(BinOp(BinOp(Call(Name('ord', Load(), lineno=17, col_offset=18, end_lineno=17, end_col_offset=21), [Name('placeholder_6', Load(), lineno=17, col_offset=22, end_lineno=17, end_col_offset=31)], [], lineno=17, col_offset=18, end_lineno=17, end_col_offset=32), Sub(), BinOp(Constant(2, lineno=17, col_offset=35, end_lineno=17, end_col_offset=36), Mult(), Call(Name('ord', Load(), lineno=17, col_offset=39, end_lineno=17, end_col_offset=42), [Constant('a', lineno=17, col_offset=43, end_lineno=17, end_col_offset=46)], [], lineno=17, col_offset=39, end_lineno=17, end_col_offset=47), lineno=17, col_offset=35, end_lineno=17, end_col_offset=47), lineno=17, col_offset=18, end_lineno=17, end_col_offset=47), Add(), Call(Name('ord', Load(), lineno=17, col_offset=50, end_lineno=17, end_col_offset=53), [Name('placeholder_2', Load(), lineno=17, col_offset=54, end_lineno=17, end_col_offset=57)], [], lineno=17, col_offset=50, end_lineno=17, end_col_offset=58), lineno=17, col_offset=18, end_lineno=17, end_col_offset=58), Mod(), Constant(26, lineno=17, col_offset=62, end_lineno=17, end_col_offset=64), lineno=17, col_offset=17, end_lineno=17, end_col_offset=64), Add(), Call(Name('ord', Load(), lineno=17, col_offset=68, end_lineno=17, end_col_offset=71), [Constant('a', lineno=17, col_offset=72, end_lineno=17, end_col_offset=75)], [], lineno=17, col_offset=68, end_lineno=17, end_col_offset=76), lineno=17, col_offset=16, end_lineno=17, end_col_offset=76)], [], lineno=17, col_offset=12, end_lineno=17, end_col_offset=77), [comprehension(Tuple([Name('placeholder_6', Store(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=25), Name('placeholder_2', Store(), lineno=18, col_offset=27, end_lineno=18, end_col_offset=30)], Store(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=30), Call(Name('zip', Load(), lineno=18, col_offset=34, end_lineno=18, end_col_offset=37), [Name('placeholder_5', Load(), lineno=18, col_offset=38, end_lineno=18, end_col_offset=42), Call(Name('cycle', Load(), lineno=18, col_offset=44, end_lineno=18, end_col_offset=49), [Attribute(Name('self', Load(), lineno=18, col_offset=50, end_lineno=18, end_col_offset=54), 'placeholder_2', Load(), lineno=18, col_offset=50, end_lineno=18, end_col_offset=58)], [], lineno=18, col_offset=44, end_lineno=18, end_col_offset=59)], [], lineno=18, col_offset=34, end_lineno=18, end_col_offset=60), [], 0)], lineno=16, col_offset=22, end_lineno=19, end_col_offset=9)], [], lineno=16, col_offset=15, end_lineno=19, end_col_offset=9), lineno=16, col_offset=8, end_lineno=19, end_col_offset=9)], [], lineno=15, col_offset=4, end_lineno=19, end_col_offset=9), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=21, col_offset=15, end_lineno=21, end_col_offset=19), arg('placeholder_5', lineno=21, col_offset=21, end_lineno=21, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Constant('', lineno=22, col_offset=15, end_lineno=22, end_col_offset=17), 'join', Load(), lineno=22, col_offset=15, end_lineno=22, end_col_offset=22), [GeneratorExp(Call(Name('chr', Load(), lineno=23, col_offset=12, end_lineno=23, end_col_offset=15), [BinOp(BinOp(BinOp(BinOp(Call(Name('ord', Load(), lineno=23, col_offset=18, end_lineno=23, end_col_offset=21), [Name('placeholder_6', Load(), lineno=23, col_offset=22, end_lineno=23, end_col_offset=31)], [], lineno=23, col_offset=18, end_lineno=23, end_col_offset=32), Sub(), Call(Name('ord', Load(), lineno=23, col_offset=35, end_lineno=23, end_col_offset=38), [Name('placeholder_2', Load(), lineno=23, col_offset=39, end_lineno=23, end_col_offset=42)], [], lineno=23, col_offset=35, end_lineno=23, end_col_offset=43), lineno=23, col_offset=18, end_lineno=23, end_col_offset=43), Add(), Constant(26, lineno=23, col_offset=46, end_lineno=23, end_col_offset=48), lineno=23, col_offset=18, end_lineno=23, end_col_offset=48), Mod(), Constant(26, lineno=23, col_offset=52, end_lineno=23, end_col_offset=54), lineno=23, col_offset=17, end_lineno=23, end_col_offset=54), Add(), Call(Name('ord', Load(), lineno=23, col_offset=58, end_lineno=23, end_col_offset=61), [Constant('a', lineno=23, col_offset=62, end_lineno=23, end_col_offset=65)], [], lineno=23, col_offset=58, end_lineno=23, end_col_offset=66), lineno=23, col_offset=16, end_lineno=23, end_col_offset=66)], [], lineno=23, col_offset=12, end_lineno=23, end_col_offset=67), [comprehension(Tuple([Name('placeholder_6', Store(), lineno=24, col_offset=16, end_lineno=24, end_col_offset=25), Name('placeholder_2', Store(), lineno=24, col_offset=27, end_lineno=24, end_col_offset=30)], Store(), lineno=24, col_offset=16, end_lineno=24, end_col_offset=30), Call(Name('zip', Load(), lineno=24, col_offset=34, end_lineno=24, end_col_offset=37), [Name('placeholder_5', Load(), lineno=24, col_offset=38, end_lineno=24, end_col_offset=42), Call(Name('cycle', Load(), lineno=24, col_offset=44, end_lineno=24, end_col_offset=49), [Attribute(Name('self', Load(), lineno=24, col_offset=50, end_lineno=24, end_col_offset=54), 'placeholder_2', Load(), lineno=24, col_offset=50, end_lineno=24, end_col_offset=58)], [], lineno=24, col_offset=44, end_lineno=24, end_col_offset=59)], [], lineno=24, col_offset=34, end_lineno=24, end_col_offset=60), [], 0)], lineno=22, col_offset=22, end_lineno=25, end_col_offset=9)], [], lineno=22, col_offset=15, end_lineno=25, end_col_offset=9), lineno=22, col_offset=8, end_lineno=25, end_col_offset=9)], [], lineno=21, col_offset=4, end_lineno=25, end_col_offset=9)], [], lineno=7, col_offset=0, end_lineno=25, end_col_offset=9)], []) \ No newline at end of file diff --git a/test/practice-simple-cipher/simple_cipher.py b/test/practice-simple-cipher/simple_cipher.py new file mode 100644 index 0000000..61abf58 --- /dev/null +++ b/test/practice-simple-cipher/simple_cipher.py @@ -0,0 +1,25 @@ +from string import ascii_lowercase +from time import time +import random +from itertools import cycle + + +class Cipher: + + def __init__(self, key=None): + if key is None: + random.seed(time()) + key = ''.join(random.choice(ascii_lowercase) for _ in range(100)) + self.key = key + + def encode(self, text): + return ''.join( + chr(((ord(character) - 2 * ord('a') + ord(key)) % 26) + ord('a')) + for character, key in zip(text, cycle(self.key)) + ) + + def decode(self, text): + return ''.join( + chr(((ord(character) - ord(key) + 26) % 26) + ord('a')) + for character, key in zip(text, cycle(self.key)) + ) diff --git a/test/practice-simple-linked-list/.meta/config.json b/test/practice-simple-linked-list/.meta/config.json new file mode 100644 index 0000000..2fc136a --- /dev/null +++ b/test/practice-simple-linked-list/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "Dog", + "N-Parsons", + "rootulp", + "tqa236" + ], + "files": { + "solution": [ + "simple_linked_list.py" + ], + "test": [ + "simple_linked_list_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Write a simple linked list implementation that uses Elements and a List.", + "source": "Inspired by 'Data Structures and Algorithms with Object-Oriented Design Patterns in Ruby', singly linked-lists.", + "source_url": "https://web.archive.org/web/20160731005714/http://brpreiss.com/books/opus8/html/page96.html" +} diff --git a/test/practice-simple-linked-list/mapping.json b/test/practice-simple-linked-list/mapping.json new file mode 100644 index 0000000..6f46d80 --- /dev/null +++ b/test/practice-simple-linked-list/mapping.json @@ -0,0 +1,24 @@ +{ + "placeholder_0": "Node", + "placeholder_1": "__init__", + "placeholder_2": "value", + "placeholder_3": "_value", + "placeholder_4": "_next", + "placeholder_5": "LinkedIterator", + "placeholder_6": "linked_list", + "placeholder_7": "current", + "placeholder_8": "__iter__", + "placeholder_9": "__next__", + "placeholder_10": "LinkedList", + "placeholder_11": "values", + "placeholder_12": "_head", + "placeholder_13": "_len", + "placeholder_14": "__len__", + "placeholder_15": "head", + "placeholder_16": "push", + "placeholder_17": "new_node", + "placeholder_18": "pop", + "placeholder_19": "ret", + "placeholder_20": "EmptyListException", + "placeholder_21": "message" +} \ No newline at end of file diff --git a/test/practice-simple-linked-list/representation.json b/test/practice-simple-linked-list/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-simple-linked-list/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-simple-linked-list/representation.out b/test/practice-simple-linked-list/representation.out new file mode 100644 index 0000000..884178e --- /dev/null +++ b/test/practice-simple-linked-list/representation.out @@ -0,0 +1,2772 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2): + self.placeholder_3 = placeholder_2 + self.placeholder_4 = None + + def placeholder_2(self): + return self.placeholder_3 + + def next(self): + return self.placeholder_4 + + +class placeholder_5: + def placeholder_1(self, placeholder_6): + self.placeholder_7 = placeholder_6._head + + def placeholder_8(self): + return self + + def placeholder_9(self): + if self.placeholder_7 is None: + raise StopIteration + placeholder_2 = self.placeholder_7.placeholder_2() + self.placeholder_7 = self.placeholder_7.next() + return placeholder_2 + + def next(self): + return self.placeholder_9() + + +class placeholder_10: + def placeholder_1(self, placeholder_11=None): + placeholder_11 = placeholder_11 if placeholder_11 is not None else [] + self.placeholder_12 = None + self.placeholder_13 = 0 + for placeholder_2 in placeholder_11: + self.push(placeholder_2) + + def placeholder_8(self): + return placeholder_5(self) + + def placeholder_14(self): + return self.placeholder_13 + + def placeholder_15(self): + if self.placeholder_12 is None: + raise EmptyListException("The list is empty.") + return self.placeholder_12 + + def placeholder_16(self, placeholder_2): + placeholder_17 = placeholder_0(placeholder_2) + placeholder_17.placeholder_4 = self.placeholder_12 + self.placeholder_12 = placeholder_17 + self.placeholder_13 += 1 + + def placeholder_18(self): + if self.placeholder_12 is None: + raise EmptyListException("The list is empty.") + self.placeholder_13 -= 1 + placeholder_19 = self.placeholder_12.placeholder_2() + self.placeholder_12 = self.placeholder_12.next() + return placeholder_19 + + def reversed(self): + return placeholder_10(self) + + +class placeholder_20(Exception): + def placeholder_1(self, placeholder_21): + self.placeholder_21 = placeholder_21 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Node', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'value', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + '_value', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=19)], + Name( + 'value', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + '_next', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=18)], + Constant( + None, + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=25), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=25)], + [], + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=25), + FunctionDef( + 'value', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=19), + '_value', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=26)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=26), + FunctionDef( + 'next', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=19), + '_next', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=25), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=25)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=25)], + [], + lineno=1, + col_offset=0, + end_lineno=10, + end_col_offset=25), + ClassDef( + 'LinkedIterator', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'linked_list', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + 'current', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=20)], + Attribute( + Name( + 'linked_list', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=34), + '_head', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=40), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=40)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=40), + FunctionDef( + '__iter__', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'self', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=19)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=19), + FunctionDef( + '__next__', + arguments( + [], + [ + arg( + 'self', + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=15), + 'current', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=23), + [ + Is()], + [ + Constant( + None, + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=31)], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=31), + [ + Raise( + Name( + 'StopIteration', + Load(), + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=31), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=31)], + [], + lineno=21, + col_offset=8, + end_lineno=22, + end_col_offset=31), + Assign( + [ + Name( + 'value', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=13)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=20), + 'current', + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=28), + 'value', + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=34), + [], + [], + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=36), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12), + 'current', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=20)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=27), + 'current', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=35), + 'next', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=40), + [], + [], + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=42), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=42), + Return( + Name( + 'value', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=20), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=20)], + [], + lineno=20, + col_offset=4, + end_lineno=25, + end_col_offset=20), + FunctionDef( + 'next', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=19), + '__next__', + Load(), + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=28), + [], + [], + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=30), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=30)], + [], + lineno=27, + col_offset=4, + end_lineno=28, + end_col_offset=30)], + [], + lineno=13, + col_offset=0, + end_lineno=28, + end_col_offset=30), + ClassDef( + 'LinkedList', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=32, + col_offset=17, + end_lineno=32, + end_col_offset=21), + arg( + 'values', + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=34)]), + [ + Assign( + [ + Name( + 'values', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=14)], + IfExp( + Compare( + Name( + 'values', + Load(), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=33), + [ + IsNot()], + [ + Constant( + None, + lineno=33, + col_offset=41, + end_lineno=33, + end_col_offset=45)], + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=45), + Name( + 'values', + Load(), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=23), + List( + [], + Load(), + lineno=33, + col_offset=51, + end_lineno=33, + end_col_offset=53), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=53), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=53), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + '_head', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=18)], + Constant( + None, + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=25), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=25), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=12), + '_len', + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=17)], + Constant( + 0, + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=21), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=21), + For( + Name( + 'value', + Store(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=17), + Name( + 'values', + Load(), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=27), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=16), + 'push', + Load(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=21), + [ + Name( + 'value', + Load(), + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=27)], + [], + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=28), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=28)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=28)], + [], + lineno=32, + col_offset=4, + end_lineno=37, + end_col_offset=28), + FunctionDef( + '__iter__', + arguments( + [], + [ + arg( + 'self', + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'LinkedIterator', + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=29), + [ + Name( + 'self', + Load(), + lineno=40, + col_offset=30, + end_lineno=40, + end_col_offset=34)], + [], + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=35), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=35)], + [], + lineno=39, + col_offset=4, + end_lineno=40, + end_col_offset=35), + FunctionDef( + '__len__', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=16, + end_lineno=42, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=19), + '_len', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=24), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=24)], + [], + lineno=42, + col_offset=4, + end_lineno=43, + end_col_offset=24), + FunctionDef( + 'head', + arguments( + [], + [ + arg( + 'self', + lineno=45, + col_offset=13, + end_lineno=45, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=15), + '_head', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=21), + [ + Is()], + [ + Constant( + None, + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=29)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=29), + [ + Raise( + Call( + Name( + 'EmptyListException', + Load(), + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=36), + [ + Constant( + 'The list is empty.', + lineno=47, + col_offset=37, + end_lineno=47, + end_col_offset=57)], + [], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=58), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=58)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=58), + Return( + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=19), + '_head', + Load(), + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=25), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=25)], + [], + lineno=45, + col_offset=4, + end_lineno=48, + end_col_offset=25), + FunctionDef( + 'push', + arguments( + [], + [ + arg( + 'self', + lineno=50, + col_offset=13, + end_lineno=50, + end_col_offset=17), + arg( + 'value', + lineno=50, + col_offset=19, + end_lineno=50, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'new_node', + Store(), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=16)], + Call( + Name( + 'Node', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=23), + [ + Name( + 'value', + Load(), + lineno=51, + col_offset=24, + end_lineno=51, + end_col_offset=29)], + [], + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=30), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=30), + Assign( + [ + Attribute( + Name( + 'new_node', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=16), + '_next', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=22)], + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=25, + end_lineno=52, + end_col_offset=29), + '_head', + Load(), + lineno=52, + col_offset=25, + end_lineno=52, + end_col_offset=35), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=35), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=12), + '_head', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=18)], + Name( + 'new_node', + Load(), + lineno=53, + col_offset=21, + end_lineno=53, + end_col_offset=29), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=29), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=12), + '_len', + Store(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=17), + Add(), + Constant( + 1, + lineno=54, + col_offset=21, + end_lineno=54, + end_col_offset=22), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=22)], + [], + lineno=50, + col_offset=4, + end_lineno=54, + end_col_offset=22), + FunctionDef( + 'pop', + arguments( + [], + [ + arg( + 'self', + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=15), + '_head', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=21), + [ + Is()], + [ + Constant( + None, + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=29)], + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=29), + [ + Raise( + Call( + Name( + 'EmptyListException', + Load(), + lineno=58, + col_offset=18, + end_lineno=58, + end_col_offset=36), + [ + Constant( + 'The list is empty.', + lineno=58, + col_offset=37, + end_lineno=58, + end_col_offset=57)], + [], + lineno=58, + col_offset=18, + end_lineno=58, + end_col_offset=58), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=58)], + [], + lineno=57, + col_offset=8, + end_lineno=58, + end_col_offset=58), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=12), + '_len', + Store(), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=17), + Sub(), + Constant( + 1, + lineno=59, + col_offset=21, + end_lineno=59, + end_col_offset=22), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=22), + Assign( + [ + Name( + 'ret', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=11)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=18), + '_head', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=24), + 'value', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=30), + [], + [], + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=32), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=12), + '_head', + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=18)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=25), + '_head', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=31), + 'next', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=36), + [], + [], + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=38), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=38), + Return( + Name( + 'ret', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=18), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=18)], + [], + lineno=56, + col_offset=4, + end_lineno=62, + end_col_offset=18), + FunctionDef( + 'reversed', + arguments( + [], + [ + arg( + 'self', + lineno=64, + col_offset=17, + end_lineno=64, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'LinkedList', + Load(), + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=25), + [ + Name( + 'self', + Load(), + lineno=65, + col_offset=26, + end_lineno=65, + end_col_offset=30)], + [], + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=31), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=31)], + [], + lineno=64, + col_offset=4, + end_lineno=65, + end_col_offset=31)], + [], + lineno=31, + col_offset=0, + end_lineno=65, + end_col_offset=31), + ClassDef( + 'EmptyListException', + [ + Name( + 'Exception', + Load(), + lineno=68, + col_offset=25, + end_lineno=68, + end_col_offset=34)], + [], + [ + Expr( + Constant( + 'Exception raised when the linked list is empty.\n\n message: explanation of the error.\n\n ', + lineno=69, + col_offset=4, + end_lineno=73, + end_col_offset=7), + lineno=69, + col_offset=4, + end_lineno=73, + end_col_offset=7), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=21), + arg( + 'message', + lineno=75, + col_offset=23, + end_lineno=75, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=12), + 'message', + Store(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=20)], + Name( + 'message', + Load(), + lineno=76, + col_offset=23, + end_lineno=76, + end_col_offset=30), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=30)], + [], + lineno=75, + col_offset=4, + end_lineno=76, + end_col_offset=30)], + [], + lineno=68, + col_offset=0, + end_lineno=76, + end_col_offset=30)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=19)], + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=27), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=27), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=18)], + Constant( + None, + lineno=4, + col_offset=21, + end_lineno=4, + end_col_offset=25), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=25)], + [], + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=25), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=14, + end_lineno=6, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=19), + 'placeholder_3', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=26)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=26), + FunctionDef( + 'next', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=19), + 'placeholder_4', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=25), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=25)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=25)], + [], + lineno=1, + col_offset=0, + end_lineno=10, + end_col_offset=25), + ClassDef( + 'placeholder_5', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=21), + arg( + 'placeholder_6', + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=20)], + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=34), + '_head', + Load(), + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=40), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=40)], + [], + lineno=14, + col_offset=4, + end_lineno=15, + end_col_offset=40), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Name( + 'self', + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=19)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=19), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=15), + 'placeholder_7', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=23), + [ + Is()], + [ + Constant( + None, + lineno=21, + col_offset=27, + end_lineno=21, + end_col_offset=31)], + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=31), + [ + Raise( + Name( + 'StopIteration', + Load(), + lineno=22, + col_offset=18, + end_lineno=22, + end_col_offset=31), + lineno=22, + col_offset=12, + end_lineno=22, + end_col_offset=31)], + [], + lineno=21, + col_offset=8, + end_lineno=22, + end_col_offset=31), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=13)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=20), + 'placeholder_7', + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=34), + [], + [], + lineno=23, + col_offset=16, + end_lineno=23, + end_col_offset=36), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=36), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=20)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=27), + 'placeholder_7', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=35), + 'next', + Load(), + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=40), + [], + [], + lineno=24, + col_offset=23, + end_lineno=24, + end_col_offset=42), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=42), + Return( + Name( + 'placeholder_2', + Load(), + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=20), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=20)], + [], + lineno=20, + col_offset=4, + end_lineno=25, + end_col_offset=20), + FunctionDef( + 'next', + arguments( + [], + [ + arg( + 'self', + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=19), + 'placeholder_9', + Load(), + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=28), + [], + [], + lineno=28, + col_offset=15, + end_lineno=28, + end_col_offset=30), + lineno=28, + col_offset=8, + end_lineno=28, + end_col_offset=30)], + [], + lineno=27, + col_offset=4, + end_lineno=28, + end_col_offset=30)], + [], + lineno=13, + col_offset=0, + end_lineno=28, + end_col_offset=30), + ClassDef( + 'placeholder_10', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=32, + col_offset=17, + end_lineno=32, + end_col_offset=21), + arg( + 'placeholder_11', + lineno=32, + col_offset=23, + end_lineno=32, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + None, + lineno=32, + col_offset=30, + end_lineno=32, + end_col_offset=34)]), + [ + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=14)], + IfExp( + Compare( + Name( + 'placeholder_11', + Load(), + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=33), + [ + IsNot()], + [ + Constant( + None, + lineno=33, + col_offset=41, + end_lineno=33, + end_col_offset=45)], + lineno=33, + col_offset=27, + end_lineno=33, + end_col_offset=45), + Name( + 'placeholder_11', + Load(), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=23), + List( + [], + Load(), + lineno=33, + col_offset=51, + end_lineno=33, + end_col_offset=53), + lineno=33, + col_offset=17, + end_lineno=33, + end_col_offset=53), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=53), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=12), + 'placeholder_12', + Store(), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=18)], + Constant( + None, + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=25), + lineno=34, + col_offset=8, + end_lineno=34, + end_col_offset=25), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=12), + 'placeholder_13', + Store(), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=17)], + Constant( + 0, + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=21), + lineno=35, + col_offset=8, + end_lineno=35, + end_col_offset=21), + For( + Name( + 'placeholder_2', + Store(), + lineno=36, + col_offset=12, + end_lineno=36, + end_col_offset=17), + Name( + 'placeholder_11', + Load(), + lineno=36, + col_offset=21, + end_lineno=36, + end_col_offset=27), + [ + Expr( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=16), + 'push', + Load(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=21), + [ + Name( + 'placeholder_2', + Load(), + lineno=37, + col_offset=22, + end_lineno=37, + end_col_offset=27)], + [], + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=28), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=28)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=28)], + [], + lineno=32, + col_offset=4, + end_lineno=37, + end_col_offset=28), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=39, + col_offset=17, + end_lineno=39, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_5', + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=29), + [ + Name( + 'self', + Load(), + lineno=40, + col_offset=30, + end_lineno=40, + end_col_offset=34)], + [], + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=35), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=35)], + [], + lineno=39, + col_offset=4, + end_lineno=40, + end_col_offset=35), + FunctionDef( + 'placeholder_14', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=16, + end_lineno=42, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=19), + 'placeholder_13', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=24), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=24)], + [], + lineno=42, + col_offset=4, + end_lineno=43, + end_col_offset=24), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'self', + lineno=45, + col_offset=13, + end_lineno=45, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=15), + 'placeholder_12', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=21), + [ + Is()], + [ + Constant( + None, + lineno=46, + col_offset=25, + end_lineno=46, + end_col_offset=29)], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=29), + [ + Raise( + Call( + Name( + 'EmptyListException', + Load(), + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=36), + [ + Constant( + 'The list is empty.', + lineno=47, + col_offset=37, + end_lineno=47, + end_col_offset=57)], + [], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=58), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=58)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=58), + Return( + Attribute( + Name( + 'self', + Load(), + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=19), + 'placeholder_12', + Load(), + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=25), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=25)], + [], + lineno=45, + col_offset=4, + end_lineno=48, + end_col_offset=25), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'self', + lineno=50, + col_offset=13, + end_lineno=50, + end_col_offset=17), + arg( + 'placeholder_2', + lineno=50, + col_offset=19, + end_lineno=50, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=16)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=23), + [ + Name( + 'placeholder_2', + Load(), + lineno=51, + col_offset=24, + end_lineno=51, + end_col_offset=29)], + [], + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=30), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=30), + Assign( + [ + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=16), + 'placeholder_4', + Store(), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=22)], + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=25, + end_lineno=52, + end_col_offset=29), + 'placeholder_12', + Load(), + lineno=52, + col_offset=25, + end_lineno=52, + end_col_offset=35), + lineno=52, + col_offset=8, + end_lineno=52, + end_col_offset=35), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=12), + 'placeholder_12', + Store(), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=18)], + Name( + 'placeholder_17', + Load(), + lineno=53, + col_offset=21, + end_lineno=53, + end_col_offset=29), + lineno=53, + col_offset=8, + end_lineno=53, + end_col_offset=29), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=12), + 'placeholder_13', + Store(), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=17), + Add(), + Constant( + 1, + lineno=54, + col_offset=21, + end_lineno=54, + end_col_offset=22), + lineno=54, + col_offset=8, + end_lineno=54, + end_col_offset=22)], + [], + lineno=50, + col_offset=4, + end_lineno=54, + end_col_offset=22), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'self', + lineno=56, + col_offset=12, + end_lineno=56, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=15), + 'placeholder_12', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=21), + [ + Is()], + [ + Constant( + None, + lineno=57, + col_offset=25, + end_lineno=57, + end_col_offset=29)], + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=29), + [ + Raise( + Call( + Name( + 'EmptyListException', + Load(), + lineno=58, + col_offset=18, + end_lineno=58, + end_col_offset=36), + [ + Constant( + 'The list is empty.', + lineno=58, + col_offset=37, + end_lineno=58, + end_col_offset=57)], + [], + lineno=58, + col_offset=18, + end_lineno=58, + end_col_offset=58), + lineno=58, + col_offset=12, + end_lineno=58, + end_col_offset=58)], + [], + lineno=57, + col_offset=8, + end_lineno=58, + end_col_offset=58), + AugAssign( + Attribute( + Name( + 'self', + Load(), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=12), + 'placeholder_13', + Store(), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=17), + Sub(), + Constant( + 1, + lineno=59, + col_offset=21, + end_lineno=59, + end_col_offset=22), + lineno=59, + col_offset=8, + end_lineno=59, + end_col_offset=22), + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=11)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=18), + 'placeholder_12', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=30), + [], + [], + lineno=60, + col_offset=14, + end_lineno=60, + end_col_offset=32), + lineno=60, + col_offset=8, + end_lineno=60, + end_col_offset=32), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=12), + 'placeholder_12', + Store(), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=18)], + Call( + Attribute( + Attribute( + Name( + 'self', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=25), + 'placeholder_12', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=31), + 'next', + Load(), + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=36), + [], + [], + lineno=61, + col_offset=21, + end_lineno=61, + end_col_offset=38), + lineno=61, + col_offset=8, + end_lineno=61, + end_col_offset=38), + Return( + Name( + 'placeholder_19', + Load(), + lineno=62, + col_offset=15, + end_lineno=62, + end_col_offset=18), + lineno=62, + col_offset=8, + end_lineno=62, + end_col_offset=18)], + [], + lineno=56, + col_offset=4, + end_lineno=62, + end_col_offset=18), + FunctionDef( + 'reversed', + arguments( + [], + [ + arg( + 'self', + lineno=64, + col_offset=17, + end_lineno=64, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_10', + Load(), + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=25), + [ + Name( + 'self', + Load(), + lineno=65, + col_offset=26, + end_lineno=65, + end_col_offset=30)], + [], + lineno=65, + col_offset=15, + end_lineno=65, + end_col_offset=31), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=31)], + [], + lineno=64, + col_offset=4, + end_lineno=65, + end_col_offset=31)], + [], + lineno=31, + col_offset=0, + end_lineno=65, + end_col_offset=31), + ClassDef( + 'placeholder_20', + [ + Name( + 'Exception', + Load(), + lineno=68, + col_offset=25, + end_lineno=68, + end_col_offset=34)], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=75, + col_offset=17, + end_lineno=75, + end_col_offset=21), + arg( + 'placeholder_21', + lineno=75, + col_offset=23, + end_lineno=75, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=12), + 'placeholder_21', + Store(), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=20)], + Name( + 'placeholder_21', + Load(), + lineno=76, + col_offset=23, + end_lineno=76, + end_col_offset=30), + lineno=76, + col_offset=8, + end_lineno=76, + end_col_offset=30)], + [], + lineno=75, + col_offset=4, + end_lineno=76, + end_col_offset=30)], + [], + lineno=68, + col_offset=0, + end_lineno=76, + end_col_offset=30)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-simple-linked-list/representation.txt b/test/practice-simple-linked-list/representation.txt new file mode 100644 index 0000000..1900147 --- /dev/null +++ b/test/practice-simple-linked-list/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_3', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=19)], Name('placeholder_2', Load(), lineno=3, col_offset=22, end_lineno=3, end_col_offset=27), lineno=3, col_offset=8, end_lineno=3, end_col_offset=27), Assign([Attribute(Name('self', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=12), 'placeholder_4', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=18)], Constant(None, lineno=4, col_offset=21, end_lineno=4, end_col_offset=25), lineno=4, col_offset=8, end_lineno=4, end_col_offset=25)], [], lineno=2, col_offset=4, end_lineno=4, end_col_offset=25), FunctionDef('placeholder_2', arguments([], [arg('self', lineno=6, col_offset=14, end_lineno=6, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=7, col_offset=15, end_lineno=7, end_col_offset=19), 'placeholder_3', Load(), lineno=7, col_offset=15, end_lineno=7, end_col_offset=26), lineno=7, col_offset=8, end_lineno=7, end_col_offset=26)], [], lineno=6, col_offset=4, end_lineno=7, end_col_offset=26), FunctionDef('next', arguments([], [arg('self', lineno=9, col_offset=13, end_lineno=9, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=19), 'placeholder_4', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=25), lineno=10, col_offset=8, end_lineno=10, end_col_offset=25)], [], lineno=9, col_offset=4, end_lineno=10, end_col_offset=25)], [], lineno=1, col_offset=0, end_lineno=10, end_col_offset=25), ClassDef('placeholder_5', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=14, col_offset=17, end_lineno=14, end_col_offset=21), arg('placeholder_6', lineno=14, col_offset=23, end_lineno=14, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=12), 'placeholder_7', Store(), lineno=15, col_offset=8, end_lineno=15, end_col_offset=20)], Attribute(Name('placeholder_6', Load(), lineno=15, col_offset=23, end_lineno=15, end_col_offset=34), '_head', Load(), lineno=15, col_offset=23, end_lineno=15, end_col_offset=40), lineno=15, col_offset=8, end_lineno=15, end_col_offset=40)], [], lineno=14, col_offset=4, end_lineno=15, end_col_offset=40), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=17, col_offset=17, end_lineno=17, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Name('self', Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=19), lineno=18, col_offset=8, end_lineno=18, end_col_offset=19)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=19), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=20, col_offset=17, end_lineno=20, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=15), 'placeholder_7', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=23), [Is()], [Constant(None, lineno=21, col_offset=27, end_lineno=21, end_col_offset=31)], lineno=21, col_offset=11, end_lineno=21, end_col_offset=31), [Raise(Name('StopIteration', Load(), lineno=22, col_offset=18, end_lineno=22, end_col_offset=31), lineno=22, col_offset=12, end_lineno=22, end_col_offset=31)], [], lineno=21, col_offset=8, end_lineno=22, end_col_offset=31), Assign([Name('placeholder_2', Store(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=13)], Call(Attribute(Attribute(Name('self', Load(), lineno=23, col_offset=16, end_lineno=23, end_col_offset=20), 'placeholder_7', Load(), lineno=23, col_offset=16, end_lineno=23, end_col_offset=28), 'placeholder_2', Load(), lineno=23, col_offset=16, end_lineno=23, end_col_offset=34), [], [], lineno=23, col_offset=16, end_lineno=23, end_col_offset=36), lineno=23, col_offset=8, end_lineno=23, end_col_offset=36), Assign([Attribute(Name('self', Load(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=12), 'placeholder_7', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=20)], Call(Attribute(Attribute(Name('self', Load(), lineno=24, col_offset=23, end_lineno=24, end_col_offset=27), 'placeholder_7', Load(), lineno=24, col_offset=23, end_lineno=24, end_col_offset=35), 'next', Load(), lineno=24, col_offset=23, end_lineno=24, end_col_offset=40), [], [], lineno=24, col_offset=23, end_lineno=24, end_col_offset=42), lineno=24, col_offset=8, end_lineno=24, end_col_offset=42), Return(Name('placeholder_2', Load(), lineno=25, col_offset=15, end_lineno=25, end_col_offset=20), lineno=25, col_offset=8, end_lineno=25, end_col_offset=20)], [], lineno=20, col_offset=4, end_lineno=25, end_col_offset=20), FunctionDef('next', arguments([], [arg('self', lineno=27, col_offset=13, end_lineno=27, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Attribute(Name('self', Load(), lineno=28, col_offset=15, end_lineno=28, end_col_offset=19), 'placeholder_9', Load(), lineno=28, col_offset=15, end_lineno=28, end_col_offset=28), [], [], lineno=28, col_offset=15, end_lineno=28, end_col_offset=30), lineno=28, col_offset=8, end_lineno=28, end_col_offset=30)], [], lineno=27, col_offset=4, end_lineno=28, end_col_offset=30)], [], lineno=13, col_offset=0, end_lineno=28, end_col_offset=30), ClassDef('placeholder_10', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=32, col_offset=17, end_lineno=32, end_col_offset=21), arg('placeholder_11', lineno=32, col_offset=23, end_lineno=32, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[Constant(None, lineno=32, col_offset=30, end_lineno=32, end_col_offset=34)]), [Assign([Name('placeholder_11', Store(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=14)], IfExp(Compare(Name('placeholder_11', Load(), lineno=33, col_offset=27, end_lineno=33, end_col_offset=33), [IsNot()], [Constant(None, lineno=33, col_offset=41, end_lineno=33, end_col_offset=45)], lineno=33, col_offset=27, end_lineno=33, end_col_offset=45), Name('placeholder_11', Load(), lineno=33, col_offset=17, end_lineno=33, end_col_offset=23), List([], Load(), lineno=33, col_offset=51, end_lineno=33, end_col_offset=53), lineno=33, col_offset=17, end_lineno=33, end_col_offset=53), lineno=33, col_offset=8, end_lineno=33, end_col_offset=53), Assign([Attribute(Name('self', Load(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=12), 'placeholder_12', Store(), lineno=34, col_offset=8, end_lineno=34, end_col_offset=18)], Constant(None, lineno=34, col_offset=21, end_lineno=34, end_col_offset=25), lineno=34, col_offset=8, end_lineno=34, end_col_offset=25), Assign([Attribute(Name('self', Load(), lineno=35, col_offset=8, end_lineno=35, end_col_offset=12), 'placeholder_13', Store(), lineno=35, col_offset=8, end_lineno=35, end_col_offset=17)], Constant(0, lineno=35, col_offset=20, end_lineno=35, end_col_offset=21), lineno=35, col_offset=8, end_lineno=35, end_col_offset=21), For(Name('placeholder_2', Store(), lineno=36, col_offset=12, end_lineno=36, end_col_offset=17), Name('placeholder_11', Load(), lineno=36, col_offset=21, end_lineno=36, end_col_offset=27), [Expr(Call(Attribute(Name('self', Load(), lineno=37, col_offset=12, end_lineno=37, end_col_offset=16), 'push', Load(), lineno=37, col_offset=12, end_lineno=37, end_col_offset=21), [Name('placeholder_2', Load(), lineno=37, col_offset=22, end_lineno=37, end_col_offset=27)], [], lineno=37, col_offset=12, end_lineno=37, end_col_offset=28), lineno=37, col_offset=12, end_lineno=37, end_col_offset=28)], [], lineno=36, col_offset=8, end_lineno=37, end_col_offset=28)], [], lineno=32, col_offset=4, end_lineno=37, end_col_offset=28), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=39, col_offset=17, end_lineno=39, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_5', Load(), lineno=40, col_offset=15, end_lineno=40, end_col_offset=29), [Name('self', Load(), lineno=40, col_offset=30, end_lineno=40, end_col_offset=34)], [], lineno=40, col_offset=15, end_lineno=40, end_col_offset=35), lineno=40, col_offset=8, end_lineno=40, end_col_offset=35)], [], lineno=39, col_offset=4, end_lineno=40, end_col_offset=35), FunctionDef('placeholder_14', arguments([], [arg('self', lineno=42, col_offset=16, end_lineno=42, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Attribute(Name('self', Load(), lineno=43, col_offset=15, end_lineno=43, end_col_offset=19), 'placeholder_13', Load(), lineno=43, col_offset=15, end_lineno=43, end_col_offset=24), lineno=43, col_offset=8, end_lineno=43, end_col_offset=24)], [], lineno=42, col_offset=4, end_lineno=43, end_col_offset=24), FunctionDef('placeholder_15', arguments([], [arg('self', lineno=45, col_offset=13, end_lineno=45, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=15), 'placeholder_12', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=21), [Is()], [Constant(None, lineno=46, col_offset=25, end_lineno=46, end_col_offset=29)], lineno=46, col_offset=11, end_lineno=46, end_col_offset=29), [Raise(Call(Name('EmptyListException', Load(), lineno=47, col_offset=18, end_lineno=47, end_col_offset=36), [Constant('The list is empty.', lineno=47, col_offset=37, end_lineno=47, end_col_offset=57)], [], lineno=47, col_offset=18, end_lineno=47, end_col_offset=58), lineno=47, col_offset=12, end_lineno=47, end_col_offset=58)], [], lineno=46, col_offset=8, end_lineno=47, end_col_offset=58), Return(Attribute(Name('self', Load(), lineno=48, col_offset=15, end_lineno=48, end_col_offset=19), 'placeholder_12', Load(), lineno=48, col_offset=15, end_lineno=48, end_col_offset=25), lineno=48, col_offset=8, end_lineno=48, end_col_offset=25)], [], lineno=45, col_offset=4, end_lineno=48, end_col_offset=25), FunctionDef('placeholder_16', arguments([], [arg('self', lineno=50, col_offset=13, end_lineno=50, end_col_offset=17), arg('placeholder_2', lineno=50, col_offset=19, end_lineno=50, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_17', Store(), lineno=51, col_offset=8, end_lineno=51, end_col_offset=16)], Call(Name('placeholder_0', Load(), lineno=51, col_offset=19, end_lineno=51, end_col_offset=23), [Name('placeholder_2', Load(), lineno=51, col_offset=24, end_lineno=51, end_col_offset=29)], [], lineno=51, col_offset=19, end_lineno=51, end_col_offset=30), lineno=51, col_offset=8, end_lineno=51, end_col_offset=30), Assign([Attribute(Name('placeholder_17', Load(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=16), 'placeholder_4', Store(), lineno=52, col_offset=8, end_lineno=52, end_col_offset=22)], Attribute(Name('self', Load(), lineno=52, col_offset=25, end_lineno=52, end_col_offset=29), 'placeholder_12', Load(), lineno=52, col_offset=25, end_lineno=52, end_col_offset=35), lineno=52, col_offset=8, end_lineno=52, end_col_offset=35), Assign([Attribute(Name('self', Load(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=12), 'placeholder_12', Store(), lineno=53, col_offset=8, end_lineno=53, end_col_offset=18)], Name('placeholder_17', Load(), lineno=53, col_offset=21, end_lineno=53, end_col_offset=29), lineno=53, col_offset=8, end_lineno=53, end_col_offset=29), AugAssign(Attribute(Name('self', Load(), lineno=54, col_offset=8, end_lineno=54, end_col_offset=12), 'placeholder_13', Store(), lineno=54, col_offset=8, end_lineno=54, end_col_offset=17), Add(), Constant(1, lineno=54, col_offset=21, end_lineno=54, end_col_offset=22), lineno=54, col_offset=8, end_lineno=54, end_col_offset=22)], [], lineno=50, col_offset=4, end_lineno=54, end_col_offset=22), FunctionDef('placeholder_18', arguments([], [arg('self', lineno=56, col_offset=12, end_lineno=56, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Attribute(Name('self', Load(), lineno=57, col_offset=11, end_lineno=57, end_col_offset=15), 'placeholder_12', Load(), lineno=57, col_offset=11, end_lineno=57, end_col_offset=21), [Is()], [Constant(None, lineno=57, col_offset=25, end_lineno=57, end_col_offset=29)], lineno=57, col_offset=11, end_lineno=57, end_col_offset=29), [Raise(Call(Name('EmptyListException', Load(), lineno=58, col_offset=18, end_lineno=58, end_col_offset=36), [Constant('The list is empty.', lineno=58, col_offset=37, end_lineno=58, end_col_offset=57)], [], lineno=58, col_offset=18, end_lineno=58, end_col_offset=58), lineno=58, col_offset=12, end_lineno=58, end_col_offset=58)], [], lineno=57, col_offset=8, end_lineno=58, end_col_offset=58), AugAssign(Attribute(Name('self', Load(), lineno=59, col_offset=8, end_lineno=59, end_col_offset=12), 'placeholder_13', Store(), lineno=59, col_offset=8, end_lineno=59, end_col_offset=17), Sub(), Constant(1, lineno=59, col_offset=21, end_lineno=59, end_col_offset=22), lineno=59, col_offset=8, end_lineno=59, end_col_offset=22), Assign([Name('placeholder_19', Store(), lineno=60, col_offset=8, end_lineno=60, end_col_offset=11)], Call(Attribute(Attribute(Name('self', Load(), lineno=60, col_offset=14, end_lineno=60, end_col_offset=18), 'placeholder_12', Load(), lineno=60, col_offset=14, end_lineno=60, end_col_offset=24), 'placeholder_2', Load(), lineno=60, col_offset=14, end_lineno=60, end_col_offset=30), [], [], lineno=60, col_offset=14, end_lineno=60, end_col_offset=32), lineno=60, col_offset=8, end_lineno=60, end_col_offset=32), Assign([Attribute(Name('self', Load(), lineno=61, col_offset=8, end_lineno=61, end_col_offset=12), 'placeholder_12', Store(), lineno=61, col_offset=8, end_lineno=61, end_col_offset=18)], Call(Attribute(Attribute(Name('self', Load(), lineno=61, col_offset=21, end_lineno=61, end_col_offset=25), 'placeholder_12', Load(), lineno=61, col_offset=21, end_lineno=61, end_col_offset=31), 'next', Load(), lineno=61, col_offset=21, end_lineno=61, end_col_offset=36), [], [], lineno=61, col_offset=21, end_lineno=61, end_col_offset=38), lineno=61, col_offset=8, end_lineno=61, end_col_offset=38), Return(Name('placeholder_19', Load(), lineno=62, col_offset=15, end_lineno=62, end_col_offset=18), lineno=62, col_offset=8, end_lineno=62, end_col_offset=18)], [], lineno=56, col_offset=4, end_lineno=62, end_col_offset=18), FunctionDef('reversed', arguments([], [arg('self', lineno=64, col_offset=17, end_lineno=64, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_10', Load(), lineno=65, col_offset=15, end_lineno=65, end_col_offset=25), [Name('self', Load(), lineno=65, col_offset=26, end_lineno=65, end_col_offset=30)], [], lineno=65, col_offset=15, end_lineno=65, end_col_offset=31), lineno=65, col_offset=8, end_lineno=65, end_col_offset=31)], [], lineno=64, col_offset=4, end_lineno=65, end_col_offset=31)], [], lineno=31, col_offset=0, end_lineno=65, end_col_offset=31), ClassDef('placeholder_20', [Name('Exception', Load(), lineno=68, col_offset=25, end_lineno=68, end_col_offset=34)], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=75, col_offset=17, end_lineno=75, end_col_offset=21), arg('placeholder_21', lineno=75, col_offset=23, end_lineno=75, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=76, col_offset=8, end_lineno=76, end_col_offset=12), 'placeholder_21', Store(), lineno=76, col_offset=8, end_lineno=76, end_col_offset=20)], Name('placeholder_21', Load(), lineno=76, col_offset=23, end_lineno=76, end_col_offset=30), lineno=76, col_offset=8, end_lineno=76, end_col_offset=30)], [], lineno=75, col_offset=4, end_lineno=76, end_col_offset=30)], [], lineno=68, col_offset=0, end_lineno=76, end_col_offset=30)], []) \ No newline at end of file diff --git a/test/practice-simple-linked-list/simple_linked_list.py b/test/practice-simple-linked-list/simple_linked_list.py new file mode 100644 index 0000000..f87b155 --- /dev/null +++ b/test/practice-simple-linked-list/simple_linked_list.py @@ -0,0 +1,76 @@ +class Node: + def __init__(self, value): + self._value = value + self._next = None + + def value(self): + return self._value + + def next(self): + return self._next + + +class LinkedIterator: + def __init__(self, linked_list): + self.current = linked_list._head + + def __iter__(self): + return self + + def __next__(self): + if self.current is None: + raise StopIteration + value = self.current.value() + self.current = self.current.next() + return value + + def next(self): + return self.__next__() + + +class LinkedList: + def __init__(self, values=None): + values = values if values is not None else [] + self._head = None + self._len = 0 + for value in values: + self.push(value) + + def __iter__(self): + return LinkedIterator(self) + + def __len__(self): + return self._len + + def head(self): + if self._head is None: + raise EmptyListException('The list is empty.') + return self._head + + def push(self, value): + new_node = Node(value) + new_node._next = self._head + self._head = new_node + self._len += 1 + + def pop(self): + if self._head is None: + raise EmptyListException('The list is empty.') + self._len -= 1 + ret = self._head.value() + self._head = self._head.next() + return ret + + def reversed(self): + return LinkedList(self) + + +class EmptyListException(Exception): + """Exception raised when the linked list is empty. + + message: explanation of the error. + + """ + + def __init__(self, message): + self.message = message diff --git a/test/practice-space-age/.meta/config.json b/test/practice-space-age/.meta/config.json new file mode 100644 index 0000000..2c6189d --- /dev/null +++ b/test/practice-space-age/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [], + "contributors": [ + "abhijitparida", + "behrtam", + "cmccandless", + "crsmi", + "Dog", + "gabriel376", + "gabriellhrn", + "ikhadykin", + "kytrinyx", + "lowks", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236", + "AndrewLawendy" + ], + "files": { + "solution": [ + "space_age.py" + ], + "test": [ + "space_age_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.", + "source": "Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial.", + "source_url": "https://pine.fm/LearnToProgram/?Chapter=01" +} diff --git a/test/practice-space-age/mapping.json b/test/practice-space-age/mapping.json new file mode 100644 index 0000000..437cb33 --- /dev/null +++ b/test/practice-space-age/mapping.json @@ -0,0 +1,16 @@ +{ + "placeholder_0": "period_converter", + "placeholder_1": "period", + "placeholder_2": "inner", + "placeholder_3": "SpaceAge", + "placeholder_4": "on_mercury", + "placeholder_5": "on_venus", + "placeholder_6": "on_earth", + "placeholder_7": "on_mars", + "placeholder_8": "on_jupiter", + "placeholder_9": "on_saturn", + "placeholder_10": "on_uranus", + "placeholder_11": "on_neptune", + "placeholder_12": "__init__", + "placeholder_13": "seconds" +} \ No newline at end of file diff --git a/test/practice-space-age/representation.json b/test/practice-space-age/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-space-age/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-space-age/representation.out b/test/practice-space-age/representation.out new file mode 100644 index 0000000..c214483 --- /dev/null +++ b/test/practice-space-age/representation.out @@ -0,0 +1,896 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + def placeholder_2(self): + return round(self.seconds / placeholder_1, 2) + + return placeholder_2 + + +class placeholder_3: + placeholder_4 = placeholder_0(7600530.24) + placeholder_5 = placeholder_0(19413907.2) + placeholder_6 = placeholder_0(31558149.76) + placeholder_7 = placeholder_0(59354294.4) + placeholder_8 = placeholder_0(374335776.0) + placeholder_9 = placeholder_0(929596608.0) + placeholder_10 = placeholder_0(2651370019.3) + placeholder_11 = placeholder_0(5200418592.0) + + def placeholder_12(self, placeholder_13): + self.placeholder_13 = placeholder_13 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'period_converter', + arguments( + [], + [ + arg( + 'period', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + FunctionDef( + 'inner', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'round', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=25), + 'seconds', + Load(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=33), + Div(), + Name( + 'period', + Load(), + lineno=3, + col_offset=36, + end_lineno=3, + end_col_offset=42), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=42), + Constant( + 2, + lineno=3, + col_offset=44, + end_lineno=3, + end_col_offset=45)], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=46), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=46)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=46), + Return( + Name( + 'inner', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=16), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=16)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=16), + ClassDef( + 'SpaceAge', + [], + [], + [ + Assign( + [ + Name( + 'on_mercury', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14)], + Call( + Name( + 'period_converter', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=33), + [ + Constant( + 7600530.24, + lineno=10, + col_offset=34, + end_lineno=10, + end_col_offset=44)], + [], + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=45), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=45), + Assign( + [ + Name( + 'on_venus', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=12)], + Call( + Name( + 'period_converter', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=31), + [ + Constant( + 19413907.2, + lineno=11, + col_offset=32, + end_lineno=11, + end_col_offset=42)], + [], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=43), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=43), + Assign( + [ + Name( + 'on_earth', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=12)], + Call( + Name( + 'period_converter', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=31), + [ + Constant( + 31558149.76, + lineno=12, + col_offset=32, + end_lineno=12, + end_col_offset=43)], + [], + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=44), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=44), + Assign( + [ + Name( + 'on_mars', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=11)], + Call( + Name( + 'period_converter', + Load(), + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=30), + [ + Constant( + 59354294.4, + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=41)], + [], + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=42), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=42), + Assign( + [ + Name( + 'on_jupiter', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=14)], + Call( + Name( + 'period_converter', + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=33), + [ + Constant( + 374335776.0, + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=45)], + [], + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=46), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=46), + Assign( + [ + Name( + 'on_saturn', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=13)], + Call( + Name( + 'period_converter', + Load(), + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=32), + [ + Constant( + 929596608.0, + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=44)], + [], + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=45), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=45), + Assign( + [ + Name( + 'on_uranus', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=13)], + Call( + Name( + 'period_converter', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=32), + [ + Constant( + 2651370019.3, + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=45)], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=46), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=46), + Assign( + [ + Name( + 'on_neptune', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=14)], + Call( + Name( + 'period_converter', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=33), + [ + Constant( + 5200418592.0, + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=46)], + [], + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=47), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=47), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=21), + arg( + 'seconds', + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=12), + 'seconds', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=20)], + Name( + 'seconds', + Load(), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=30), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=30)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=30)], + [], + lineno=8, + col_offset=0, + end_lineno=20, + end_col_offset=30)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'round', + Load(), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=25), + 'seconds', + Load(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=33), + Div(), + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=36, + end_lineno=3, + end_col_offset=42), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=42), + Constant( + 2, + lineno=3, + col_offset=44, + end_lineno=3, + end_col_offset=45)], + [], + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=46), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=46)], + [], + lineno=2, + col_offset=4, + end_lineno=3, + end_col_offset=46), + Return( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=16), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=16)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=16), + ClassDef( + 'placeholder_3', + [], + [], + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=33), + [ + Constant( + 7600530.24, + lineno=10, + col_offset=34, + end_lineno=10, + end_col_offset=44)], + [], + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=45), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=12)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=31), + [ + Constant( + 19413907.2, + lineno=11, + col_offset=32, + end_lineno=11, + end_col_offset=42)], + [], + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=43), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=43), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=12)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=31), + [ + Constant( + 31558149.76, + lineno=12, + col_offset=32, + end_lineno=12, + end_col_offset=43)], + [], + lineno=12, + col_offset=15, + end_lineno=12, + end_col_offset=44), + lineno=12, + col_offset=4, + end_lineno=12, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=11)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=30), + [ + Constant( + 59354294.4, + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=41)], + [], + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=42), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=14)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=33), + [ + Constant( + 374335776.0, + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=45)], + [], + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=46), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=13)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=32), + [ + Constant( + 929596608.0, + lineno=15, + col_offset=33, + end_lineno=15, + end_col_offset=44)], + [], + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=45), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=45), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=13)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=32), + [ + Constant( + 2651370019.3, + lineno=16, + col_offset=33, + end_lineno=16, + end_col_offset=45)], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=46), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=14)], + Call( + Name( + 'placeholder_0', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=33), + [ + Constant( + 5200418592.0, + lineno=17, + col_offset=34, + end_lineno=17, + end_col_offset=46)], + [], + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=47), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=47), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=21), + arg( + 'placeholder_13', + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=12), + 'placeholder_13', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=20)], + Name( + 'placeholder_13', + Load(), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=30), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=30)], + [], + lineno=19, + col_offset=4, + end_lineno=20, + end_col_offset=30)], + [], + lineno=8, + col_offset=0, + end_lineno=20, + end_col_offset=30)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-space-age/representation.txt b/test/practice-space-age/representation.txt new file mode 100644 index 0000000..205517e --- /dev/null +++ b/test/practice-space-age/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=21, end_lineno=1, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [FunctionDef('placeholder_2', arguments([], [arg('self', lineno=2, col_offset=14, end_lineno=2, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('round', Load(), lineno=3, col_offset=15, end_lineno=3, end_col_offset=20), [BinOp(Attribute(Name('self', Load(), lineno=3, col_offset=21, end_lineno=3, end_col_offset=25), 'seconds', Load(), lineno=3, col_offset=21, end_lineno=3, end_col_offset=33), Div(), Name('placeholder_1', Load(), lineno=3, col_offset=36, end_lineno=3, end_col_offset=42), lineno=3, col_offset=21, end_lineno=3, end_col_offset=42), Constant(2, lineno=3, col_offset=44, end_lineno=3, end_col_offset=45)], [], lineno=3, col_offset=15, end_lineno=3, end_col_offset=46), lineno=3, col_offset=8, end_lineno=3, end_col_offset=46)], [], lineno=2, col_offset=4, end_lineno=3, end_col_offset=46), Return(Name('placeholder_2', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=16), lineno=5, col_offset=4, end_lineno=5, end_col_offset=16)], [], lineno=1, col_offset=0, end_lineno=5, end_col_offset=16), ClassDef('placeholder_3', [], [], [Assign([Name('placeholder_4', Store(), lineno=10, col_offset=4, end_lineno=10, end_col_offset=14)], Call(Name('placeholder_0', Load(), lineno=10, col_offset=17, end_lineno=10, end_col_offset=33), [Constant(7600530.24, lineno=10, col_offset=34, end_lineno=10, end_col_offset=44)], [], lineno=10, col_offset=17, end_lineno=10, end_col_offset=45), lineno=10, col_offset=4, end_lineno=10, end_col_offset=45), Assign([Name('placeholder_5', Store(), lineno=11, col_offset=4, end_lineno=11, end_col_offset=12)], Call(Name('placeholder_0', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=31), [Constant(19413907.2, lineno=11, col_offset=32, end_lineno=11, end_col_offset=42)], [], lineno=11, col_offset=15, end_lineno=11, end_col_offset=43), lineno=11, col_offset=4, end_lineno=11, end_col_offset=43), Assign([Name('placeholder_6', Store(), lineno=12, col_offset=4, end_lineno=12, end_col_offset=12)], Call(Name('placeholder_0', Load(), lineno=12, col_offset=15, end_lineno=12, end_col_offset=31), [Constant(31558149.76, lineno=12, col_offset=32, end_lineno=12, end_col_offset=43)], [], lineno=12, col_offset=15, end_lineno=12, end_col_offset=44), lineno=12, col_offset=4, end_lineno=12, end_col_offset=44), Assign([Name('placeholder_7', Store(), lineno=13, col_offset=4, end_lineno=13, end_col_offset=11)], Call(Name('placeholder_0', Load(), lineno=13, col_offset=14, end_lineno=13, end_col_offset=30), [Constant(59354294.4, lineno=13, col_offset=31, end_lineno=13, end_col_offset=41)], [], lineno=13, col_offset=14, end_lineno=13, end_col_offset=42), lineno=13, col_offset=4, end_lineno=13, end_col_offset=42), Assign([Name('placeholder_8', Store(), lineno=14, col_offset=4, end_lineno=14, end_col_offset=14)], Call(Name('placeholder_0', Load(), lineno=14, col_offset=17, end_lineno=14, end_col_offset=33), [Constant(374335776.0, lineno=14, col_offset=34, end_lineno=14, end_col_offset=45)], [], lineno=14, col_offset=17, end_lineno=14, end_col_offset=46), lineno=14, col_offset=4, end_lineno=14, end_col_offset=46), Assign([Name('placeholder_9', Store(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=13)], Call(Name('placeholder_0', Load(), lineno=15, col_offset=16, end_lineno=15, end_col_offset=32), [Constant(929596608.0, lineno=15, col_offset=33, end_lineno=15, end_col_offset=44)], [], lineno=15, col_offset=16, end_lineno=15, end_col_offset=45), lineno=15, col_offset=4, end_lineno=15, end_col_offset=45), Assign([Name('placeholder_10', Store(), lineno=16, col_offset=4, end_lineno=16, end_col_offset=13)], Call(Name('placeholder_0', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=32), [Constant(2651370019.3, lineno=16, col_offset=33, end_lineno=16, end_col_offset=45)], [], lineno=16, col_offset=16, end_lineno=16, end_col_offset=46), lineno=16, col_offset=4, end_lineno=16, end_col_offset=46), Assign([Name('placeholder_11', Store(), lineno=17, col_offset=4, end_lineno=17, end_col_offset=14)], Call(Name('placeholder_0', Load(), lineno=17, col_offset=17, end_lineno=17, end_col_offset=33), [Constant(5200418592.0, lineno=17, col_offset=34, end_lineno=17, end_col_offset=46)], [], lineno=17, col_offset=17, end_lineno=17, end_col_offset=47), lineno=17, col_offset=4, end_lineno=17, end_col_offset=47), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=19, col_offset=17, end_lineno=19, end_col_offset=21), arg('placeholder_13', lineno=19, col_offset=23, end_lineno=19, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=12), 'placeholder_13', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=20)], Name('placeholder_13', Load(), lineno=20, col_offset=23, end_lineno=20, end_col_offset=30), lineno=20, col_offset=8, end_lineno=20, end_col_offset=30)], [], lineno=19, col_offset=4, end_lineno=20, end_col_offset=30)], [], lineno=8, col_offset=0, end_lineno=20, end_col_offset=30)], []) \ No newline at end of file diff --git a/test/practice-space-age/space_age.py b/test/practice-space-age/space_age.py new file mode 100644 index 0000000..92c502f --- /dev/null +++ b/test/practice-space-age/space_age.py @@ -0,0 +1,20 @@ +def period_converter(period): + def inner(self): + return round(self.seconds / period, 2) + + return inner + + +class SpaceAge: + + on_mercury = period_converter(7600530.24) + on_venus = period_converter(19413907.2) + on_earth = period_converter(31558149.76) + on_mars = period_converter(59354294.4) + on_jupiter = period_converter(374335776.0) + on_saturn = period_converter(929596608.0) + on_uranus = period_converter(2651370019.3) + on_neptune = period_converter(5200418592.0) + + def __init__(self, seconds): + self.seconds = seconds diff --git a/test/practice-spiral-matrix/.meta/config.json b/test/practice-spiral-matrix/.meta/config.json new file mode 100644 index 0000000..f6dfd5a --- /dev/null +++ b/test/practice-spiral-matrix/.meta/config.json @@ -0,0 +1,26 @@ +{ + "authors": [ + "chgraef" + ], + "contributors": [ + "cmccandless", + "crsmi", + "Dog", + "Grociu", + "tqa236" + ], + "files": { + "solution": [ + "spiral_matrix.py" + ], + "test": [ + "spiral_matrix_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given the size, return a square matrix of numbers in spiral order.", + "source": "Reddit r/dailyprogrammer challenge #320 [Easy] Spiral Ascension.", + "source_url": "https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/" +} diff --git a/test/practice-spiral-matrix/mapping.json b/test/practice-spiral-matrix/mapping.json new file mode 100644 index 0000000..93653ef --- /dev/null +++ b/test/practice-spiral-matrix/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "spiral_matrix", + "placeholder_1": "size", + "placeholder_2": "matrix", + "placeholder_3": "row", + "placeholder_4": "idx", + "placeholder_5": "jdx", + "placeholder_6": "element", + "placeholder_7": "digital", + "placeholder_8": "disco", + "placeholder_9": "edx", + "placeholder_10": "_" +} \ No newline at end of file diff --git a/test/practice-spiral-matrix/representation.json b/test/practice-spiral-matrix/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-spiral-matrix/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-spiral-matrix/representation.out b/test/practice-spiral-matrix/representation.out new file mode 100644 index 0000000..789b9ae --- /dev/null +++ b/test/practice-spiral-matrix/representation.out @@ -0,0 +1,1143 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = [[0] * placeholder_1 for placeholder_3 in range(placeholder_1)] + placeholder_4 = 0 + placeholder_5 = -1 + placeholder_6 = 1 + placeholder_7 = [0, 1, 0, -1] + placeholder_8 = [1, 0, -1, 0] + for placeholder_9 in range(2 * placeholder_1 - 1): + for placeholder_10 in range((2 * placeholder_1 - placeholder_9) // 2): + placeholder_4 += placeholder_7[placeholder_9 % 4] + placeholder_5 += placeholder_8[placeholder_9 % 4] + placeholder_2[placeholder_4][placeholder_5] = placeholder_6 + placeholder_6 += 1 + return placeholder_2 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'spiral_matrix', + arguments( + [], + [ + arg( + 'size', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'matrix', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=10)], + ListComp( + BinOp( + List( + [ + Constant( + 0, + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=16)], + Load(), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=17), + Mult(), + Name( + 'size', + Load(), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=22), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=22), + [ + comprehension( + Name( + 'row', + Store(), + lineno=2, + col_offset=27, + end_lineno=2, + end_col_offset=30), + Call( + Name( + 'range', + Load(), + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=39), + [ + Name( + 'size', + Load(), + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=44)], + [], + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=45), + [], + 0)], + lineno=2, + col_offset=13, + end_lineno=2, + end_col_offset=46), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=46), + Assign( + [ + Name( + 'idx', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=7)], + Constant( + 0, + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=11), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11), + Assign( + [ + Name( + 'jdx', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=7)], + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=12), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=12), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=12), + Assign( + [ + Name( + 'element', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + Constant( + 1, + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=15), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=15), + Assign( + [ + Name( + 'digital', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11)], + List( + [ + Constant( + 0, + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=16), + Constant( + 1, + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=19), + Constant( + 0, + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=22), + UnaryOp( + USub(), + Constant( + 1, + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=26)], + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=27), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=27), + Assign( + [ + Name( + 'disco', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=9)], + List( + [ + Constant( + 1, + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=14), + Constant( + 0, + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=17), + UnaryOp( + USub(), + Constant( + 1, + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=21), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=21), + Constant( + 0, + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=24)], + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=25), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=25), + For( + Name( + 'edx', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=20), + [ + BinOp( + BinOp( + Constant( + 2, + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=22), + Mult(), + Name( + 'size', + Load(), + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=27), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=27), + Sub(), + Constant( + 1, + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=31), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=31)], + [], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=32), + [ + For( + Name( + '_', + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=22), + [ + BinOp( + BinOp( + BinOp( + Constant( + 2, + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=25), + Mult(), + Name( + 'size', + Load(), + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=30), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=30), + Sub(), + Name( + 'edx', + Load(), + lineno=11, + col_offset=33, + end_lineno=11, + end_col_offset=36), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=36), + FloorDiv(), + Constant( + 2, + lineno=11, + col_offset=41, + end_lineno=11, + end_col_offset=42), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=42)], + [], + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=43), + [ + AugAssign( + Name( + 'idx', + Store(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=15), + Add(), + Subscript( + Name( + 'digital', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=26), + BinOp( + Name( + 'edx', + Load(), + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=30), + Mod(), + Constant( + 4, + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=34), + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=34), + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=35), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=35), + AugAssign( + Name( + 'jdx', + Store(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=15), + Add(), + Subscript( + Name( + 'disco', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=24), + BinOp( + Name( + 'edx', + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=28), + Mod(), + Constant( + 4, + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=32), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=32), + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=33), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=33), + Assign( + [ + Subscript( + Subscript( + Name( + 'matrix', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=18), + Name( + 'idx', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=22), + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=23), + Name( + 'jdx', + Load(), + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=27), + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=28)], + Name( + 'element', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=38), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=38), + AugAssign( + Name( + 'element', + Store(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=24), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=24)], + [], + lineno=11, + col_offset=8, + end_lineno=15, + end_col_offset=24)], + [], + lineno=10, + col_offset=4, + end_lineno=15, + end_col_offset=24), + Return( + Name( + 'matrix', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=17)], + [], + lineno=1, + col_offset=0, + end_lineno=16, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=18, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=10)], + ListComp( + BinOp( + List( + [ + Constant( + 0, + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=16)], + Load(), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=17), + Mult(), + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=18, + end_lineno=2, + end_col_offset=22), + lineno=2, + col_offset=14, + end_lineno=2, + end_col_offset=22), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=27, + end_lineno=2, + end_col_offset=30), + Call( + Name( + 'range', + Load(), + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=39), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=44)], + [], + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=45), + [], + 0)], + lineno=2, + col_offset=13, + end_lineno=2, + end_col_offset=46), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=7)], + Constant( + 0, + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=11), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=11), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=7)], + UnaryOp( + USub(), + Constant( + 1, + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=12), + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=12), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=12), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=11)], + Constant( + 1, + lineno=5, + col_offset=14, + end_lineno=5, + end_col_offset=15), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=15), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=11)], + List( + [ + Constant( + 0, + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=16), + Constant( + 1, + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=19), + Constant( + 0, + lineno=7, + col_offset=21, + end_lineno=7, + end_col_offset=22), + UnaryOp( + USub(), + Constant( + 1, + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=26), + lineno=7, + col_offset=24, + end_lineno=7, + end_col_offset=26)], + Load(), + lineno=7, + col_offset=14, + end_lineno=7, + end_col_offset=27), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=27), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=9)], + List( + [ + Constant( + 1, + lineno=8, + col_offset=13, + end_lineno=8, + end_col_offset=14), + Constant( + 0, + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=17), + UnaryOp( + USub(), + Constant( + 1, + lineno=8, + col_offset=20, + end_lineno=8, + end_col_offset=21), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=21), + Constant( + 0, + lineno=8, + col_offset=23, + end_lineno=8, + end_col_offset=24)], + Load(), + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=25), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=25), + For( + Name( + 'placeholder_9', + Store(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=20), + [ + BinOp( + BinOp( + Constant( + 2, + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=22), + Mult(), + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=23, + end_lineno=10, + end_col_offset=27), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=27), + Sub(), + Constant( + 1, + lineno=10, + col_offset=30, + end_lineno=10, + end_col_offset=31), + lineno=10, + col_offset=21, + end_lineno=10, + end_col_offset=31)], + [], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=32), + [ + For( + Name( + 'placeholder_10', + Store(), + lineno=11, + col_offset=12, + end_lineno=11, + end_col_offset=13), + Call( + Name( + 'range', + Load(), + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=22), + [ + BinOp( + BinOp( + BinOp( + Constant( + 2, + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=25), + Mult(), + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=26, + end_lineno=11, + end_col_offset=30), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=30), + Sub(), + Name( + 'placeholder_9', + Load(), + lineno=11, + col_offset=33, + end_lineno=11, + end_col_offset=36), + lineno=11, + col_offset=24, + end_lineno=11, + end_col_offset=36), + FloorDiv(), + Constant( + 2, + lineno=11, + col_offset=41, + end_lineno=11, + end_col_offset=42), + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=42)], + [], + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=43), + [ + AugAssign( + Name( + 'placeholder_4', + Store(), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=15), + Add(), + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=26), + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=30), + Mod(), + Constant( + 4, + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=34), + lineno=12, + col_offset=27, + end_lineno=12, + end_col_offset=34), + Load(), + lineno=12, + col_offset=19, + end_lineno=12, + end_col_offset=35), + lineno=12, + col_offset=12, + end_lineno=12, + end_col_offset=35), + AugAssign( + Name( + 'placeholder_5', + Store(), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=15), + Add(), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=24), + BinOp( + Name( + 'placeholder_9', + Load(), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=28), + Mod(), + Constant( + 4, + lineno=13, + col_offset=31, + end_lineno=13, + end_col_offset=32), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=32), + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=33), + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=33), + Assign( + [ + Subscript( + Subscript( + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=18), + Name( + 'placeholder_4', + Load(), + lineno=14, + col_offset=19, + end_lineno=14, + end_col_offset=22), + Load(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=23), + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=24, + end_lineno=14, + end_col_offset=27), + Store(), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=28)], + Name( + 'placeholder_6', + Load(), + lineno=14, + col_offset=31, + end_lineno=14, + end_col_offset=38), + lineno=14, + col_offset=12, + end_lineno=14, + end_col_offset=38), + AugAssign( + Name( + 'placeholder_6', + Store(), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=19), + Add(), + Constant( + 1, + lineno=15, + col_offset=23, + end_lineno=15, + end_col_offset=24), + lineno=15, + col_offset=12, + end_lineno=15, + end_col_offset=24)], + [], + lineno=11, + col_offset=8, + end_lineno=15, + end_col_offset=24)], + [], + lineno=10, + col_offset=4, + end_lineno=15, + end_col_offset=24), + Return( + Name( + 'placeholder_2', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=17), + lineno=16, + col_offset=4, + end_lineno=16, + end_col_offset=17)], + [], + lineno=1, + col_offset=0, + end_lineno=16, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-spiral-matrix/representation.txt b/test/practice-spiral-matrix/representation.txt new file mode 100644 index 0000000..7a57289 --- /dev/null +++ b/test/practice-spiral-matrix/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=18, end_lineno=1, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=10)], ListComp(BinOp(List([Constant(0, lineno=2, col_offset=15, end_lineno=2, end_col_offset=16)], Load(), lineno=2, col_offset=14, end_lineno=2, end_col_offset=17), Mult(), Name('placeholder_1', Load(), lineno=2, col_offset=18, end_lineno=2, end_col_offset=22), lineno=2, col_offset=14, end_lineno=2, end_col_offset=22), [comprehension(Name('placeholder_3', Store(), lineno=2, col_offset=27, end_lineno=2, end_col_offset=30), Call(Name('range', Load(), lineno=2, col_offset=34, end_lineno=2, end_col_offset=39), [Name('placeholder_1', Load(), lineno=2, col_offset=40, end_lineno=2, end_col_offset=44)], [], lineno=2, col_offset=34, end_lineno=2, end_col_offset=45), [], 0)], lineno=2, col_offset=13, end_lineno=2, end_col_offset=46), lineno=2, col_offset=4, end_lineno=2, end_col_offset=46), Assign([Name('placeholder_4', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=7)], Constant(0, lineno=3, col_offset=10, end_lineno=3, end_col_offset=11), lineno=3, col_offset=4, end_lineno=3, end_col_offset=11), Assign([Name('placeholder_5', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=7)], UnaryOp(USub(), Constant(1, lineno=4, col_offset=11, end_lineno=4, end_col_offset=12), lineno=4, col_offset=10, end_lineno=4, end_col_offset=12), lineno=4, col_offset=4, end_lineno=4, end_col_offset=12), Assign([Name('placeholder_6', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=11)], Constant(1, lineno=5, col_offset=14, end_lineno=5, end_col_offset=15), lineno=5, col_offset=4, end_lineno=5, end_col_offset=15), Assign([Name('placeholder_7', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=11)], List([Constant(0, lineno=7, col_offset=15, end_lineno=7, end_col_offset=16), Constant(1, lineno=7, col_offset=18, end_lineno=7, end_col_offset=19), Constant(0, lineno=7, col_offset=21, end_lineno=7, end_col_offset=22), UnaryOp(USub(), Constant(1, lineno=7, col_offset=25, end_lineno=7, end_col_offset=26), lineno=7, col_offset=24, end_lineno=7, end_col_offset=26)], Load(), lineno=7, col_offset=14, end_lineno=7, end_col_offset=27), lineno=7, col_offset=4, end_lineno=7, end_col_offset=27), Assign([Name('placeholder_8', Store(), lineno=8, col_offset=4, end_lineno=8, end_col_offset=9)], List([Constant(1, lineno=8, col_offset=13, end_lineno=8, end_col_offset=14), Constant(0, lineno=8, col_offset=16, end_lineno=8, end_col_offset=17), UnaryOp(USub(), Constant(1, lineno=8, col_offset=20, end_lineno=8, end_col_offset=21), lineno=8, col_offset=19, end_lineno=8, end_col_offset=21), Constant(0, lineno=8, col_offset=23, end_lineno=8, end_col_offset=24)], Load(), lineno=8, col_offset=12, end_lineno=8, end_col_offset=25), lineno=8, col_offset=4, end_lineno=8, end_col_offset=25), For(Name('placeholder_9', Store(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=11), Call(Name('range', Load(), lineno=10, col_offset=15, end_lineno=10, end_col_offset=20), [BinOp(BinOp(Constant(2, lineno=10, col_offset=21, end_lineno=10, end_col_offset=22), Mult(), Name('placeholder_1', Load(), lineno=10, col_offset=23, end_lineno=10, end_col_offset=27), lineno=10, col_offset=21, end_lineno=10, end_col_offset=27), Sub(), Constant(1, lineno=10, col_offset=30, end_lineno=10, end_col_offset=31), lineno=10, col_offset=21, end_lineno=10, end_col_offset=31)], [], lineno=10, col_offset=15, end_lineno=10, end_col_offset=32), [For(Name('placeholder_10', Store(), lineno=11, col_offset=12, end_lineno=11, end_col_offset=13), Call(Name('range', Load(), lineno=11, col_offset=17, end_lineno=11, end_col_offset=22), [BinOp(BinOp(BinOp(Constant(2, lineno=11, col_offset=24, end_lineno=11, end_col_offset=25), Mult(), Name('placeholder_1', Load(), lineno=11, col_offset=26, end_lineno=11, end_col_offset=30), lineno=11, col_offset=24, end_lineno=11, end_col_offset=30), Sub(), Name('placeholder_9', Load(), lineno=11, col_offset=33, end_lineno=11, end_col_offset=36), lineno=11, col_offset=24, end_lineno=11, end_col_offset=36), FloorDiv(), Constant(2, lineno=11, col_offset=41, end_lineno=11, end_col_offset=42), lineno=11, col_offset=23, end_lineno=11, end_col_offset=42)], [], lineno=11, col_offset=17, end_lineno=11, end_col_offset=43), [AugAssign(Name('placeholder_4', Store(), lineno=12, col_offset=12, end_lineno=12, end_col_offset=15), Add(), Subscript(Name('placeholder_7', Load(), lineno=12, col_offset=19, end_lineno=12, end_col_offset=26), BinOp(Name('placeholder_9', Load(), lineno=12, col_offset=27, end_lineno=12, end_col_offset=30), Mod(), Constant(4, lineno=12, col_offset=33, end_lineno=12, end_col_offset=34), lineno=12, col_offset=27, end_lineno=12, end_col_offset=34), Load(), lineno=12, col_offset=19, end_lineno=12, end_col_offset=35), lineno=12, col_offset=12, end_lineno=12, end_col_offset=35), AugAssign(Name('placeholder_5', Store(), lineno=13, col_offset=12, end_lineno=13, end_col_offset=15), Add(), Subscript(Name('placeholder_8', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=24), BinOp(Name('placeholder_9', Load(), lineno=13, col_offset=25, end_lineno=13, end_col_offset=28), Mod(), Constant(4, lineno=13, col_offset=31, end_lineno=13, end_col_offset=32), lineno=13, col_offset=25, end_lineno=13, end_col_offset=32), Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=33), lineno=13, col_offset=12, end_lineno=13, end_col_offset=33), Assign([Subscript(Subscript(Name('placeholder_2', Load(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=18), Name('placeholder_4', Load(), lineno=14, col_offset=19, end_lineno=14, end_col_offset=22), Load(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=23), Name('placeholder_5', Load(), lineno=14, col_offset=24, end_lineno=14, end_col_offset=27), Store(), lineno=14, col_offset=12, end_lineno=14, end_col_offset=28)], Name('placeholder_6', Load(), lineno=14, col_offset=31, end_lineno=14, end_col_offset=38), lineno=14, col_offset=12, end_lineno=14, end_col_offset=38), AugAssign(Name('placeholder_6', Store(), lineno=15, col_offset=12, end_lineno=15, end_col_offset=19), Add(), Constant(1, lineno=15, col_offset=23, end_lineno=15, end_col_offset=24), lineno=15, col_offset=12, end_lineno=15, end_col_offset=24)], [], lineno=11, col_offset=8, end_lineno=15, end_col_offset=24)], [], lineno=10, col_offset=4, end_lineno=15, end_col_offset=24), Return(Name('placeholder_2', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=17), lineno=16, col_offset=4, end_lineno=16, end_col_offset=17)], [], lineno=1, col_offset=0, end_lineno=16, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-spiral-matrix/spiral_matrix.py b/test/practice-spiral-matrix/spiral_matrix.py new file mode 100644 index 0000000..cc25fb3 --- /dev/null +++ b/test/practice-spiral-matrix/spiral_matrix.py @@ -0,0 +1,16 @@ +def spiral_matrix(size): + matrix = [[0]*size for row in range(size)] + idx = 0 + jdx = -1 + element = 1 + + digital = [0, 1, 0, -1] + disco = [1, 0, -1, 0] + + for edx in range(2*size - 1): + for _ in range((2*size - edx) // 2): + idx += digital[edx % 4] + jdx += disco[edx % 4] + matrix[idx][jdx] = element + element += 1 + return matrix diff --git a/test/practice-square-root/.meta/config.json b/test/practice-square-root/.meta/config.json new file mode 100644 index 0000000..b1b9630 --- /dev/null +++ b/test/practice-square-root/.meta/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "meatball133", + "Bethanyg" + ], + "contributors": [], + "files": { + "solution": [ + "square_root.py" + ], + "test": [ + "square_root_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a natural radicand, return its square root.", + "source": "wolf99", + "source_url": "https://github.com/exercism/problem-specifications/pull/1582" +} diff --git a/test/practice-square-root/mapping.json b/test/practice-square-root/mapping.json new file mode 100644 index 0000000..542bb3d --- /dev/null +++ b/test/practice-square-root/mapping.json @@ -0,0 +1,5 @@ +{ + "placeholder_0": "square_root", + "placeholder_1": "number", + "placeholder_2": "n" +} \ No newline at end of file diff --git a/test/practice-square-root/representation.json b/test/practice-square-root/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-square-root/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-square-root/representation.out b/test/practice-square-root/representation.out new file mode 100644 index 0000000..205e039 --- /dev/null +++ b/test/practice-square-root/representation.out @@ -0,0 +1,242 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = 0 + while placeholder_2**2 != placeholder_1: + placeholder_2 += 1 + return placeholder_2 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'square_root', + arguments( + [], + [ + arg( + 'number', + lineno=1, + col_offset=16, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'n', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=5)], + Constant( + 0, + lineno=2, + col_offset=8, + end_lineno=2, + end_col_offset=9), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9), + While( + Compare( + BinOp( + Name( + 'n', + Load(), + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=11), + Pow(), + Constant( + 2, + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=16), + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=16), + [ + NotEq()], + [ + Name( + 'number', + Load(), + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=26)], + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=26), + [ + AugAssign( + Name( + 'n', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=9), + Add(), + Constant( + 1, + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=14), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=14)], + [], + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=14), + Return( + Name( + 'n', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=12), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=12)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=16, + end_lineno=1, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=5)], + Constant( + 0, + lineno=2, + col_offset=8, + end_lineno=2, + end_col_offset=9), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=9), + While( + Compare( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=11), + Pow(), + Constant( + 2, + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=16), + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=16), + [ + NotEq()], + [ + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=20, + end_lineno=3, + end_col_offset=26)], + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=26), + [ + AugAssign( + Name( + 'placeholder_2', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=9), + Add(), + Constant( + 1, + lineno=4, + col_offset=13, + end_lineno=4, + end_col_offset=14), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=14)], + [], + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=14), + Return( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=12), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=12)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=12)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-square-root/representation.txt b/test/practice-square-root/representation.txt new file mode 100644 index 0000000..c4d509b --- /dev/null +++ b/test/practice-square-root/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=16, end_lineno=1, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=5)], Constant(0, lineno=2, col_offset=8, end_lineno=2, end_col_offset=9), lineno=2, col_offset=4, end_lineno=2, end_col_offset=9), While(Compare(BinOp(Name('placeholder_2', Load(), lineno=3, col_offset=10, end_lineno=3, end_col_offset=11), Pow(), Constant(2, lineno=3, col_offset=15, end_lineno=3, end_col_offset=16), lineno=3, col_offset=10, end_lineno=3, end_col_offset=16), [NotEq()], [Name('placeholder_1', Load(), lineno=3, col_offset=20, end_lineno=3, end_col_offset=26)], lineno=3, col_offset=10, end_lineno=3, end_col_offset=26), [AugAssign(Name('placeholder_2', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=9), Add(), Constant(1, lineno=4, col_offset=13, end_lineno=4, end_col_offset=14), lineno=4, col_offset=8, end_lineno=4, end_col_offset=14)], [], lineno=3, col_offset=4, end_lineno=4, end_col_offset=14), Return(Name('placeholder_2', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=12), lineno=5, col_offset=4, end_lineno=5, end_col_offset=12)], [], lineno=1, col_offset=0, end_lineno=5, end_col_offset=12)], []) \ No newline at end of file diff --git a/test/practice-square-root/square_root.py b/test/practice-square-root/square_root.py new file mode 100644 index 0000000..94cd0fd --- /dev/null +++ b/test/practice-square-root/square_root.py @@ -0,0 +1,5 @@ +def square_root(number): + n = 0 + while n ** 2 != number: + n += 1 + return n diff --git a/test/practice-strain/.meta/config.json b/test/practice-strain/.meta/config.json new file mode 100644 index 0000000..17a715c --- /dev/null +++ b/test/practice-strain/.meta/config.json @@ -0,0 +1,29 @@ +{ + "blurb": "Implement the `keep` and `discard` operation on collections. Given a collection and a predicate on the collection's elements, `keep` returns a new collection containing those elements where the predicate is true, while `discard` returns a new collection containing those elements where the predicate is false.", + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "jnaulty", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "strain.py" + ], + "test": [ + "strain_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "Conversation with James Edward Gray II", + "source_url": "https://twitter.com/jeg2" +} diff --git a/test/practice-strain/mapping.json b/test/practice-strain/mapping.json new file mode 100644 index 0000000..a7d0230 --- /dev/null +++ b/test/practice-strain/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "keep", + "placeholder_1": "sequence", + "placeholder_2": "predicate", + "placeholder_3": "element", + "placeholder_4": "discard" +} \ No newline at end of file diff --git a/test/practice-strain/representation.json b/test/practice-strain/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-strain/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-strain/representation.out b/test/practice-strain/representation.out new file mode 100644 index 0000000..9f6d696 --- /dev/null +++ b/test/practice-strain/representation.out @@ -0,0 +1,367 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return [ + placeholder_3 for placeholder_3 in placeholder_1 if placeholder_2(placeholder_3) + ] + + +def placeholder_4(placeholder_1, placeholder_2): + return [ + placeholder_3 + for placeholder_3 in placeholder_1 + if not placeholder_2(placeholder_3) + ] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'keep', + arguments( + [], + [ + arg( + 'sequence', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=17), + arg( + 'predicate', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'element', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=19), + [ + comprehension( + Name( + 'element', + Store(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=31), + Name( + 'sequence', + Load(), + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=43), + [ + Call( + Name( + 'predicate', + Load(), + lineno=2, + col_offset=47, + end_lineno=2, + end_col_offset=56), + [ + Name( + 'element', + Load(), + lineno=2, + col_offset=57, + end_lineno=2, + end_col_offset=64)], + [], + lineno=2, + col_offset=47, + end_lineno=2, + end_col_offset=65)], + 0)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=66), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=66)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=66), + FunctionDef( + 'discard', + arguments( + [], + [ + arg( + 'sequence', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=20), + arg( + 'predicate', + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'element', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=19), + [ + comprehension( + Name( + 'element', + Store(), + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=31), + Name( + 'sequence', + Load(), + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=43), + [ + UnaryOp( + Not(), + Call( + Name( + 'predicate', + Load(), + lineno=5, + col_offset=51, + end_lineno=5, + end_col_offset=60), + [ + Name( + 'element', + Load(), + lineno=5, + col_offset=61, + end_lineno=5, + end_col_offset=68)], + [], + lineno=5, + col_offset=51, + end_lineno=5, + end_col_offset=69), + lineno=5, + col_offset=47, + end_lineno=5, + end_col_offset=69)], + 0)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=70), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=70)], + [], + lineno=4, + col_offset=0, + end_lineno=5, + end_col_offset=70)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=17), + arg( + 'placeholder_2', + lineno=1, + col_offset=19, + end_lineno=1, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=19), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=31), + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=35, + end_lineno=2, + end_col_offset=43), + [ + Call( + Name( + 'placeholder_2', + Load(), + lineno=2, + col_offset=47, + end_lineno=2, + end_col_offset=56), + [ + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=57, + end_lineno=2, + end_col_offset=64)], + [], + lineno=2, + col_offset=47, + end_lineno=2, + end_col_offset=65)], + 0)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=66), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=66)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=66), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=20), + arg( + 'placeholder_2', + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=19), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=24, + end_lineno=5, + end_col_offset=31), + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=35, + end_lineno=5, + end_col_offset=43), + [ + UnaryOp( + Not(), + Call( + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=51, + end_lineno=5, + end_col_offset=60), + [ + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=61, + end_lineno=5, + end_col_offset=68)], + [], + lineno=5, + col_offset=51, + end_lineno=5, + end_col_offset=69), + lineno=5, + col_offset=47, + end_lineno=5, + end_col_offset=69)], + 0)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=70), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=70)], + [], + lineno=4, + col_offset=0, + end_lineno=5, + end_col_offset=70)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-strain/representation.txt b/test/practice-strain/representation.txt new file mode 100644 index 0000000..d39ca4b --- /dev/null +++ b/test/practice-strain/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=9, end_lineno=1, end_col_offset=17), arg('placeholder_2', lineno=1, col_offset=19, end_lineno=1, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Name('placeholder_3', Load(), lineno=2, col_offset=12, end_lineno=2, end_col_offset=19), [comprehension(Name('placeholder_3', Store(), lineno=2, col_offset=24, end_lineno=2, end_col_offset=31), Name('placeholder_1', Load(), lineno=2, col_offset=35, end_lineno=2, end_col_offset=43), [Call(Name('placeholder_2', Load(), lineno=2, col_offset=47, end_lineno=2, end_col_offset=56), [Name('placeholder_3', Load(), lineno=2, col_offset=57, end_lineno=2, end_col_offset=64)], [], lineno=2, col_offset=47, end_lineno=2, end_col_offset=65)], 0)], lineno=2, col_offset=11, end_lineno=2, end_col_offset=66), lineno=2, col_offset=4, end_lineno=2, end_col_offset=66)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=66), FunctionDef('placeholder_4', arguments([], [arg('placeholder_1', lineno=4, col_offset=12, end_lineno=4, end_col_offset=20), arg('placeholder_2', lineno=4, col_offset=22, end_lineno=4, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Name('placeholder_3', Load(), lineno=5, col_offset=12, end_lineno=5, end_col_offset=19), [comprehension(Name('placeholder_3', Store(), lineno=5, col_offset=24, end_lineno=5, end_col_offset=31), Name('placeholder_1', Load(), lineno=5, col_offset=35, end_lineno=5, end_col_offset=43), [UnaryOp(Not(), Call(Name('placeholder_2', Load(), lineno=5, col_offset=51, end_lineno=5, end_col_offset=60), [Name('placeholder_3', Load(), lineno=5, col_offset=61, end_lineno=5, end_col_offset=68)], [], lineno=5, col_offset=51, end_lineno=5, end_col_offset=69), lineno=5, col_offset=47, end_lineno=5, end_col_offset=69)], 0)], lineno=5, col_offset=11, end_lineno=5, end_col_offset=70), lineno=5, col_offset=4, end_lineno=5, end_col_offset=70)], [], lineno=4, col_offset=0, end_lineno=5, end_col_offset=70)], []) \ No newline at end of file diff --git a/test/practice-strain/strain.py b/test/practice-strain/strain.py new file mode 100644 index 0000000..6c4b3f8 --- /dev/null +++ b/test/practice-strain/strain.py @@ -0,0 +1,5 @@ +def keep(sequence, predicate): + return [element for element in sequence if predicate(element)] + +def discard(sequence, predicate): + return [element for element in sequence if not predicate(element)] diff --git a/test/practice-sublist/.meta/additional_tests.json b/test/practice-sublist/.meta/additional_tests.json new file mode 100644 index 0000000..d206a2e --- /dev/null +++ b/test/practice-sublist/.meta/additional_tests.json @@ -0,0 +1,31 @@ +{ + "cases": [ + { + "description": "inner spaces", + "property": "sublist", + "input": { + "listOne": ["a c"], + "listTwo": ["a", "c"] + }, + "expected": "unequal" + }, + { + "description": "large lists", + "property": "sublist", + "input": { + "listOne": "list(range(1000)) * 1000 + list(range(1000, 1100))", + "listTwo": "list(range(900, 1050))" + }, + "expected": "superlist" + }, + { + "description": "spread sublist", + "property": "sublist", + "input": { + "listOne": "list(range(3, 200, 3))", + "listTwo": "list(range(15, 200, 15))" + }, + "expected": "unequal" + } + ] +} \ No newline at end of file diff --git a/test/practice-sublist/.meta/config.json b/test/practice-sublist/.meta/config.json new file mode 100644 index 0000000..f4aeb47 --- /dev/null +++ b/test/practice-sublist/.meta/config.json @@ -0,0 +1,34 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "anunciado", + "behrtam", + "cmccandless", + "csabella", + "Dog", + "dvermd", + "Grociu", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "patricksjackson", + "Peque", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "sublist.py" + ], + "test": [ + "sublist_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Write a function to determine if a list is a sublist of another list." +} diff --git a/test/practice-sublist/mapping.json b/test/practice-sublist/mapping.json new file mode 100644 index 0000000..5178cda --- /dev/null +++ b/test/practice-sublist/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "SUBLIST", + "placeholder_1": "SUPERLIST", + "placeholder_2": "EQUAL", + "placeholder_3": "UNEQUAL", + "placeholder_4": "sublist", + "placeholder_5": "list_one", + "placeholder_6": "list_two", + "placeholder_7": "contains", + "placeholder_8": "idx", + "placeholder_9": "edx", + "placeholder_10": "_" +} \ No newline at end of file diff --git a/test/practice-sublist/representation.json b/test/practice-sublist/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-sublist/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-sublist/representation.out b/test/practice-sublist/representation.out new file mode 100644 index 0000000..f84a052 --- /dev/null +++ b/test/practice-sublist/representation.out @@ -0,0 +1,1378 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = 0 +placeholder_1 = 1 +placeholder_2 = 2 +placeholder_3 = 3 + + +def placeholder_4(placeholder_5, placeholder_6): + if placeholder_5 == placeholder_6: + return placeholder_2 + if contains(placeholder_5, placeholder_6): + return placeholder_1 + if contains(placeholder_6, placeholder_5): + return placeholder_0 + return placeholder_3 + + +def placeholder_7(placeholder_5, placeholder_6): + if not placeholder_6: + return True + if len(placeholder_6) > len(placeholder_5): + return False + for placeholder_8 in range(len(placeholder_5) - len(placeholder_6) + 1): + if placeholder_5[placeholder_8] != placeholder_6[0]: + continue + for placeholder_9, placeholder_10 in enumerate(placeholder_6): + if ( + placeholder_5[placeholder_8 + placeholder_9] + != placeholder_6[placeholder_9] + ): + break + else: + return True + return False + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'SUBLIST', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=7)], + Constant( + 0, + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=11), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + Assign( + [ + Name( + 'SUPERLIST', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=9)], + Constant( + 1, + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=13), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=13), + Assign( + [ + Name( + 'EQUAL', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=5)], + Constant( + 2, + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=9), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=9), + Assign( + [ + Name( + 'UNEQUAL', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=7)], + Constant( + 3, + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=11), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=11), + FunctionDef( + 'sublist', + arguments( + [], + [ + arg( + 'list_one', + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=20), + arg( + 'list_two', + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'list_one', + Load(), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=15), + [ + Eq()], + [ + Name( + 'list_two', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=27)], + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=27), + [ + Return( + Name( + 'EQUAL', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=20), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=20)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=20), + If( + Call( + Name( + 'contains', + Load(), + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=15), + [ + Name( + 'list_one', + Load(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=24), + Name( + 'list_two', + Load(), + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=34)], + [], + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=35), + [ + Return( + Name( + 'SUPERLIST', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=24)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=24), + If( + Call( + Name( + 'contains', + Load(), + lineno=12, + col_offset=7, + end_lineno=12, + end_col_offset=15), + [ + Name( + 'list_two', + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=24), + Name( + 'list_one', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=34)], + [], + lineno=12, + col_offset=7, + end_lineno=12, + end_col_offset=35), + [ + Return( + Name( + 'SUBLIST', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=22), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=22), + Return( + Name( + 'UNEQUAL', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=18), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=18)], + [], + lineno=7, + col_offset=0, + end_lineno=14, + end_col_offset=18), + FunctionDef( + 'contains', + arguments( + [], + [ + arg( + 'list_one', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=21), + arg( + 'list_two', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'list_two', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=19), + lineno=18, + col_offset=7, + end_lineno=18, + end_col_offset=19), + [ + Return( + Constant( + True, + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=19)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=19), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=10), + [ + Name( + 'list_two', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=19)], + [], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=20), + [ + Gt()], + [ + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=26), + [ + Name( + 'list_one', + Load(), + lineno=20, + col_offset=27, + end_lineno=20, + end_col_offset=35)], + [], + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=36)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=36), + [ + Return( + Constant( + False, + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=20), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=20)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=20), + For( + Name( + 'idx', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=20), + [ + BinOp( + BinOp( + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=24), + [ + Name( + 'list_one', + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=33)], + [], + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=34), + Sub(), + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=40), + [ + Name( + 'list_two', + Load(), + lineno=22, + col_offset=41, + end_lineno=22, + end_col_offset=49)], + [], + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=50), + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=50), + Add(), + Constant( + 1, + lineno=22, + col_offset=53, + end_lineno=22, + end_col_offset=54), + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=54)], + [], + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=55), + [ + If( + Compare( + Subscript( + Name( + 'list_one', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=19), + Name( + 'idx', + Load(), + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=23), + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=24), + [ + NotEq()], + [ + Subscript( + Name( + 'list_two', + Load(), + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=36), + Constant( + 0, + lineno=23, + col_offset=37, + end_lineno=23, + end_col_offset=38), + Load(), + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=39)], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=39), + [ + Continue( + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=20)], + [], + lineno=23, + col_offset=8, + end_lineno=24, + end_col_offset=20), + For( + Tuple( + [ + Name( + 'edx', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=15), + Name( + '_', + Store(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=18)], + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=18), + Call( + Name( + 'enumerate', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=31), + [ + Name( + 'list_two', + Load(), + lineno=25, + col_offset=32, + end_lineno=25, + end_col_offset=40)], + [], + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=41), + [ + If( + Compare( + Subscript( + Name( + 'list_one', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=23), + BinOp( + Name( + 'idx', + Load(), + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=27), + Add(), + Name( + 'edx', + Load(), + lineno=26, + col_offset=30, + end_lineno=26, + end_col_offset=33), + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=33), + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=34), + [ + NotEq()], + [ + Subscript( + Name( + 'list_two', + Load(), + lineno=26, + col_offset=38, + end_lineno=26, + end_col_offset=46), + Name( + 'edx', + Load(), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=50), + Load(), + lineno=26, + col_offset=38, + end_lineno=26, + end_col_offset=51)], + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=51), + [ + Break( + lineno=27, + col_offset=16, + end_lineno=27, + end_col_offset=21)], + [], + lineno=26, + col_offset=12, + end_lineno=27, + end_col_offset=21)], + [ + Return( + Constant( + True, + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=23), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=23)], + lineno=25, + col_offset=8, + end_lineno=29, + end_col_offset=23)], + [], + lineno=22, + col_offset=4, + end_lineno=29, + end_col_offset=23), + Return( + Constant( + False, + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=16), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=16)], + [], + lineno=17, + col_offset=0, + end_lineno=30, + end_col_offset=16)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=7)], + Constant( + 0, + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=11), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=9)], + Constant( + 1, + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=13), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=13), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=5)], + Constant( + 2, + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=9), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=9), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=7)], + Constant( + 3, + lineno=4, + col_offset=10, + end_lineno=4, + end_col_offset=11), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=11), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=7, + col_offset=12, + end_lineno=7, + end_col_offset=20), + arg( + 'placeholder_6', + lineno=7, + col_offset=22, + end_lineno=7, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=15), + [ + Eq()], + [ + Name( + 'placeholder_6', + Load(), + lineno=8, + col_offset=19, + end_lineno=8, + end_col_offset=27)], + lineno=8, + col_offset=7, + end_lineno=8, + end_col_offset=27), + [ + Return( + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=15, + end_lineno=9, + end_col_offset=20), + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=20)], + [], + lineno=8, + col_offset=4, + end_lineno=9, + end_col_offset=20), + If( + Call( + Name( + 'contains', + Load(), + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=15), + [ + Name( + 'placeholder_5', + Load(), + lineno=10, + col_offset=16, + end_lineno=10, + end_col_offset=24), + Name( + 'placeholder_6', + Load(), + lineno=10, + col_offset=26, + end_lineno=10, + end_col_offset=34)], + [], + lineno=10, + col_offset=7, + end_lineno=10, + end_col_offset=35), + [ + Return( + Name( + 'placeholder_1', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=24)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=24), + If( + Call( + Name( + 'contains', + Load(), + lineno=12, + col_offset=7, + end_lineno=12, + end_col_offset=15), + [ + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=24), + Name( + 'placeholder_5', + Load(), + lineno=12, + col_offset=26, + end_lineno=12, + end_col_offset=34)], + [], + lineno=12, + col_offset=7, + end_lineno=12, + end_col_offset=35), + [ + Return( + Name( + 'placeholder_0', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=22), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=22)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=22), + Return( + Name( + 'placeholder_3', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=18), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=18)], + [], + lineno=7, + col_offset=0, + end_lineno=14, + end_col_offset=18), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=21), + arg( + 'placeholder_6', + lineno=17, + col_offset=23, + end_lineno=17, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Name( + 'placeholder_6', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=19), + lineno=18, + col_offset=7, + end_lineno=18, + end_col_offset=19), + [ + Return( + Constant( + True, + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=19)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=19), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=10), + [ + Name( + 'placeholder_6', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=19)], + [], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=20), + [ + Gt()], + [ + Call( + Name( + 'len', + Load(), + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=26), + [ + Name( + 'placeholder_5', + Load(), + lineno=20, + col_offset=27, + end_lineno=20, + end_col_offset=35)], + [], + lineno=20, + col_offset=23, + end_lineno=20, + end_col_offset=36)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=36), + [ + Return( + Constant( + False, + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=20), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=20)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=20), + For( + Name( + 'placeholder_8', + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=11), + Call( + Name( + 'range', + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=20), + [ + BinOp( + BinOp( + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=24), + [ + Name( + 'placeholder_5', + Load(), + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=33)], + [], + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=34), + Sub(), + Call( + Name( + 'len', + Load(), + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=40), + [ + Name( + 'placeholder_6', + Load(), + lineno=22, + col_offset=41, + end_lineno=22, + end_col_offset=49)], + [], + lineno=22, + col_offset=37, + end_lineno=22, + end_col_offset=50), + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=50), + Add(), + Constant( + 1, + lineno=22, + col_offset=53, + end_lineno=22, + end_col_offset=54), + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=54)], + [], + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=55), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=19), + Name( + 'placeholder_8', + Load(), + lineno=23, + col_offset=20, + end_lineno=23, + end_col_offset=23), + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=24), + [ + NotEq()], + [ + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=36), + Constant( + 0, + lineno=23, + col_offset=37, + end_lineno=23, + end_col_offset=38), + Load(), + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=39)], + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=39), + [ + Continue( + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=20)], + [], + lineno=23, + col_offset=8, + end_lineno=24, + end_col_offset=20), + For( + Tuple( + [ + Name( + 'placeholder_9', + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=15), + Name( + 'placeholder_10', + Store(), + lineno=25, + col_offset=17, + end_lineno=25, + end_col_offset=18)], + Store(), + lineno=25, + col_offset=12, + end_lineno=25, + end_col_offset=18), + Call( + Name( + 'enumerate', + Load(), + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=31), + [ + Name( + 'placeholder_6', + Load(), + lineno=25, + col_offset=32, + end_lineno=25, + end_col_offset=40)], + [], + lineno=25, + col_offset=22, + end_lineno=25, + end_col_offset=41), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=23), + BinOp( + Name( + 'placeholder_8', + Load(), + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=27), + Add(), + Name( + 'placeholder_9', + Load(), + lineno=26, + col_offset=30, + end_lineno=26, + end_col_offset=33), + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=33), + Load(), + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=34), + [ + NotEq()], + [ + Subscript( + Name( + 'placeholder_6', + Load(), + lineno=26, + col_offset=38, + end_lineno=26, + end_col_offset=46), + Name( + 'placeholder_9', + Load(), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=50), + Load(), + lineno=26, + col_offset=38, + end_lineno=26, + end_col_offset=51)], + lineno=26, + col_offset=15, + end_lineno=26, + end_col_offset=51), + [ + Break( + lineno=27, + col_offset=16, + end_lineno=27, + end_col_offset=21)], + [], + lineno=26, + col_offset=12, + end_lineno=27, + end_col_offset=21)], + [ + Return( + Constant( + True, + lineno=29, + col_offset=19, + end_lineno=29, + end_col_offset=23), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=23)], + lineno=25, + col_offset=8, + end_lineno=29, + end_col_offset=23)], + [], + lineno=22, + col_offset=4, + end_lineno=29, + end_col_offset=23), + Return( + Constant( + False, + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=16), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=16)], + [], + lineno=17, + col_offset=0, + end_lineno=30, + end_col_offset=16)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-sublist/representation.txt b/test/practice-sublist/representation.txt new file mode 100644 index 0000000..2d92b32 --- /dev/null +++ b/test/practice-sublist/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=7)], Constant(0, lineno=1, col_offset=10, end_lineno=1, end_col_offset=11), lineno=1, col_offset=0, end_lineno=1, end_col_offset=11), Assign([Name('placeholder_1', Store(), lineno=2, col_offset=0, end_lineno=2, end_col_offset=9)], Constant(1, lineno=2, col_offset=12, end_lineno=2, end_col_offset=13), lineno=2, col_offset=0, end_lineno=2, end_col_offset=13), Assign([Name('placeholder_2', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=5)], Constant(2, lineno=3, col_offset=8, end_lineno=3, end_col_offset=9), lineno=3, col_offset=0, end_lineno=3, end_col_offset=9), Assign([Name('placeholder_3', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=7)], Constant(3, lineno=4, col_offset=10, end_lineno=4, end_col_offset=11), lineno=4, col_offset=0, end_lineno=4, end_col_offset=11), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=7, col_offset=12, end_lineno=7, end_col_offset=20), arg('placeholder_6', lineno=7, col_offset=22, end_lineno=7, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_5', Load(), lineno=8, col_offset=7, end_lineno=8, end_col_offset=15), [Eq()], [Name('placeholder_6', Load(), lineno=8, col_offset=19, end_lineno=8, end_col_offset=27)], lineno=8, col_offset=7, end_lineno=8, end_col_offset=27), [Return(Name('placeholder_2', Load(), lineno=9, col_offset=15, end_lineno=9, end_col_offset=20), lineno=9, col_offset=8, end_lineno=9, end_col_offset=20)], [], lineno=8, col_offset=4, end_lineno=9, end_col_offset=20), If(Call(Name('contains', Load(), lineno=10, col_offset=7, end_lineno=10, end_col_offset=15), [Name('placeholder_5', Load(), lineno=10, col_offset=16, end_lineno=10, end_col_offset=24), Name('placeholder_6', Load(), lineno=10, col_offset=26, end_lineno=10, end_col_offset=34)], [], lineno=10, col_offset=7, end_lineno=10, end_col_offset=35), [Return(Name('placeholder_1', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=24), lineno=11, col_offset=8, end_lineno=11, end_col_offset=24)], [], lineno=10, col_offset=4, end_lineno=11, end_col_offset=24), If(Call(Name('contains', Load(), lineno=12, col_offset=7, end_lineno=12, end_col_offset=15), [Name('placeholder_6', Load(), lineno=12, col_offset=16, end_lineno=12, end_col_offset=24), Name('placeholder_5', Load(), lineno=12, col_offset=26, end_lineno=12, end_col_offset=34)], [], lineno=12, col_offset=7, end_lineno=12, end_col_offset=35), [Return(Name('placeholder_0', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=22), lineno=13, col_offset=8, end_lineno=13, end_col_offset=22)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=22), Return(Name('placeholder_3', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=18), lineno=14, col_offset=4, end_lineno=14, end_col_offset=18)], [], lineno=7, col_offset=0, end_lineno=14, end_col_offset=18), FunctionDef('placeholder_7', arguments([], [arg('placeholder_5', lineno=17, col_offset=13, end_lineno=17, end_col_offset=21), arg('placeholder_6', lineno=17, col_offset=23, end_lineno=17, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Name('placeholder_6', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=19), lineno=18, col_offset=7, end_lineno=18, end_col_offset=19), [Return(Constant(True, lineno=19, col_offset=15, end_lineno=19, end_col_offset=19), lineno=19, col_offset=8, end_lineno=19, end_col_offset=19)], [], lineno=18, col_offset=4, end_lineno=19, end_col_offset=19), If(Compare(Call(Name('len', Load(), lineno=20, col_offset=7, end_lineno=20, end_col_offset=10), [Name('placeholder_6', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=19)], [], lineno=20, col_offset=7, end_lineno=20, end_col_offset=20), [Gt()], [Call(Name('len', Load(), lineno=20, col_offset=23, end_lineno=20, end_col_offset=26), [Name('placeholder_5', Load(), lineno=20, col_offset=27, end_lineno=20, end_col_offset=35)], [], lineno=20, col_offset=23, end_lineno=20, end_col_offset=36)], lineno=20, col_offset=7, end_lineno=20, end_col_offset=36), [Return(Constant(False, lineno=21, col_offset=15, end_lineno=21, end_col_offset=20), lineno=21, col_offset=8, end_lineno=21, end_col_offset=20)], [], lineno=20, col_offset=4, end_lineno=21, end_col_offset=20), For(Name('placeholder_8', Store(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=11), Call(Name('range', Load(), lineno=22, col_offset=15, end_lineno=22, end_col_offset=20), [BinOp(BinOp(Call(Name('len', Load(), lineno=22, col_offset=21, end_lineno=22, end_col_offset=24), [Name('placeholder_5', Load(), lineno=22, col_offset=25, end_lineno=22, end_col_offset=33)], [], lineno=22, col_offset=21, end_lineno=22, end_col_offset=34), Sub(), Call(Name('len', Load(), lineno=22, col_offset=37, end_lineno=22, end_col_offset=40), [Name('placeholder_6', Load(), lineno=22, col_offset=41, end_lineno=22, end_col_offset=49)], [], lineno=22, col_offset=37, end_lineno=22, end_col_offset=50), lineno=22, col_offset=21, end_lineno=22, end_col_offset=50), Add(), Constant(1, lineno=22, col_offset=53, end_lineno=22, end_col_offset=54), lineno=22, col_offset=21, end_lineno=22, end_col_offset=54)], [], lineno=22, col_offset=15, end_lineno=22, end_col_offset=55), [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=19), Name('placeholder_8', Load(), lineno=23, col_offset=20, end_lineno=23, end_col_offset=23), Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=24), [NotEq()], [Subscript(Name('placeholder_6', Load(), lineno=23, col_offset=28, end_lineno=23, end_col_offset=36), Constant(0, lineno=23, col_offset=37, end_lineno=23, end_col_offset=38), Load(), lineno=23, col_offset=28, end_lineno=23, end_col_offset=39)], lineno=23, col_offset=11, end_lineno=23, end_col_offset=39), [Continue(lineno=24, col_offset=12, end_lineno=24, end_col_offset=20)], [], lineno=23, col_offset=8, end_lineno=24, end_col_offset=20), For(Tuple([Name('placeholder_9', Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=15), Name('placeholder_10', Store(), lineno=25, col_offset=17, end_lineno=25, end_col_offset=18)], Store(), lineno=25, col_offset=12, end_lineno=25, end_col_offset=18), Call(Name('enumerate', Load(), lineno=25, col_offset=22, end_lineno=25, end_col_offset=31), [Name('placeholder_6', Load(), lineno=25, col_offset=32, end_lineno=25, end_col_offset=40)], [], lineno=25, col_offset=22, end_lineno=25, end_col_offset=41), [If(Compare(Subscript(Name('placeholder_5', Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=23), BinOp(Name('placeholder_8', Load(), lineno=26, col_offset=24, end_lineno=26, end_col_offset=27), Add(), Name('placeholder_9', Load(), lineno=26, col_offset=30, end_lineno=26, end_col_offset=33), lineno=26, col_offset=24, end_lineno=26, end_col_offset=33), Load(), lineno=26, col_offset=15, end_lineno=26, end_col_offset=34), [NotEq()], [Subscript(Name('placeholder_6', Load(), lineno=26, col_offset=38, end_lineno=26, end_col_offset=46), Name('placeholder_9', Load(), lineno=26, col_offset=47, end_lineno=26, end_col_offset=50), Load(), lineno=26, col_offset=38, end_lineno=26, end_col_offset=51)], lineno=26, col_offset=15, end_lineno=26, end_col_offset=51), [Break(lineno=27, col_offset=16, end_lineno=27, end_col_offset=21)], [], lineno=26, col_offset=12, end_lineno=27, end_col_offset=21)], [Return(Constant(True, lineno=29, col_offset=19, end_lineno=29, end_col_offset=23), lineno=29, col_offset=12, end_lineno=29, end_col_offset=23)], lineno=25, col_offset=8, end_lineno=29, end_col_offset=23)], [], lineno=22, col_offset=4, end_lineno=29, end_col_offset=23), Return(Constant(False, lineno=30, col_offset=11, end_lineno=30, end_col_offset=16), lineno=30, col_offset=4, end_lineno=30, end_col_offset=16)], [], lineno=17, col_offset=0, end_lineno=30, end_col_offset=16)], []) \ No newline at end of file diff --git a/test/practice-sublist/sublist.py b/test/practice-sublist/sublist.py new file mode 100644 index 0000000..93c909b --- /dev/null +++ b/test/practice-sublist/sublist.py @@ -0,0 +1,30 @@ +SUBLIST = 0 +SUPERLIST = 1 +EQUAL = 2 +UNEQUAL = 3 + + +def sublist(list_one, list_two): + if list_one == list_two: + return EQUAL + if contains(list_one, list_two): + return SUPERLIST + if contains(list_two, list_one): + return SUBLIST + return UNEQUAL + + +def contains(list_one, list_two): + if not list_two: + return True + if len(list_two) > len(list_one): + return False + for idx in range(len(list_one) - len(list_two) + 1): + if list_one[idx] != list_two[0]: + continue + for edx, _ in enumerate(list_two): + if list_one[idx + edx] != list_two[edx]: + break + else: + return True + return False diff --git a/test/practice-sum-of-multiples/.meta/config.json b/test/practice-sum-of-multiples/.meta/config.json new file mode 100644 index 0000000..cc5f1ce --- /dev/null +++ b/test/practice-sum-of-multiples/.meta/config.json @@ -0,0 +1,36 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "ackerleytng", + "behrtam", + "bsoyka", + "cmccandless", + "Dog", + "etmoore", + "GascaK", + "ikhadykin", + "julianandrews", + "kotp", + "kytrinyx", + "lekum", + "N-Parsons", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "sum_of_multiples.py" + ], + "test": [ + "sum_of_multiples_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a number, find the sum of all the multiples of particular numbers up to but not including that number.", + "source": "A variation on Problem 1 at Project Euler", + "source_url": "https://projecteuler.net/problem=1" +} diff --git a/test/practice-sum-of-multiples/mapping.json b/test/practice-sum-of-multiples/mapping.json new file mode 100644 index 0000000..b23edae --- /dev/null +++ b/test/practice-sum-of-multiples/mapping.json @@ -0,0 +1,7 @@ +{ + "placeholder_0": "sum_of_multiples", + "placeholder_1": "limit", + "placeholder_2": "multiples", + "placeholder_3": "value", + "placeholder_4": "multiple" +} \ No newline at end of file diff --git a/test/practice-sum-of-multiples/representation.json b/test/practice-sum-of-multiples/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-sum-of-multiples/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-sum-of-multiples/representation.out b/test/practice-sum-of-multiples/representation.out new file mode 100644 index 0000000..c664b09 --- /dev/null +++ b/test/practice-sum-of-multiples/representation.out @@ -0,0 +1,391 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2): + return sum( + ( + placeholder_3 + for placeholder_3 in range(placeholder_1) + if any( + ( + placeholder_3 % placeholder_4 == 0 + for placeholder_4 in placeholder_2 + if placeholder_4 > 0 + ) + ) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'sum_of_multiples', + arguments( + [], + [ + arg( + 'limit', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=26), + arg( + 'multiples', + lineno=1, + col_offset=28, + end_lineno=1, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + GeneratorExp( + Name( + 'value', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=20), + [ + comprehension( + Name( + 'value', + Store(), + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=30), + Call( + Name( + 'range', + Load(), + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=39), + [ + Name( + 'limit', + Load(), + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=45)], + [], + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=46), + [ + Call( + Name( + 'any', + Load(), + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=21), + [ + GeneratorExp( + Compare( + BinOp( + Name( + 'value', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=27), + Mod(), + Name( + 'multiple', + Load(), + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=38), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 0, + lineno=3, + col_offset=42, + end_lineno=3, + end_col_offset=43)], + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=43), + [ + comprehension( + Name( + 'multiple', + Store(), + lineno=4, + col_offset=26, + end_lineno=4, + end_col_offset=34), + Name( + 'multiples', + Load(), + lineno=4, + col_offset=38, + end_lineno=4, + end_col_offset=47), + [ + Compare( + Name( + 'multiple', + Load(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=33), + [ + Gt()], + [ + Constant( + 0, + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=37)], + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=37)], + 0)], + lineno=3, + col_offset=21, + end_lineno=5, + end_col_offset=38)], + [], + lineno=3, + col_offset=18, + end_lineno=5, + end_col_offset=38)], + 0)], + lineno=2, + col_offset=14, + end_lineno=5, + end_col_offset=39)], + [], + lineno=2, + col_offset=11, + end_lineno=5, + end_col_offset=39), + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=39)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=39)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=26), + arg( + 'placeholder_2', + lineno=1, + col_offset=28, + end_lineno=1, + end_col_offset=37)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + GeneratorExp( + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=20), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=25, + end_lineno=2, + end_col_offset=30), + Call( + Name( + 'range', + Load(), + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=39), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=40, + end_lineno=2, + end_col_offset=45)], + [], + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=46), + [ + Call( + Name( + 'any', + Load(), + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=21), + [ + GeneratorExp( + Compare( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=27), + Mod(), + Name( + 'placeholder_4', + Load(), + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=38), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 0, + lineno=3, + col_offset=42, + end_lineno=3, + end_col_offset=43)], + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=43), + [ + comprehension( + Name( + 'placeholder_4', + Store(), + lineno=4, + col_offset=26, + end_lineno=4, + end_col_offset=34), + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=38, + end_lineno=4, + end_col_offset=47), + [ + Compare( + Name( + 'placeholder_4', + Load(), + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=33), + [ + Gt()], + [ + Constant( + 0, + lineno=5, + col_offset=36, + end_lineno=5, + end_col_offset=37)], + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=37)], + 0)], + lineno=3, + col_offset=21, + end_lineno=5, + end_col_offset=38)], + [], + lineno=3, + col_offset=18, + end_lineno=5, + end_col_offset=38)], + 0)], + lineno=2, + col_offset=14, + end_lineno=5, + end_col_offset=39)], + [], + lineno=2, + col_offset=11, + end_lineno=5, + end_col_offset=39), + lineno=2, + col_offset=4, + end_lineno=5, + end_col_offset=39)], + [], + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=39)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-sum-of-multiples/representation.txt b/test/practice-sum-of-multiples/representation.txt new file mode 100644 index 0000000..b919594 --- /dev/null +++ b/test/practice-sum-of-multiples/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=21, end_lineno=1, end_col_offset=26), arg('placeholder_2', lineno=1, col_offset=28, end_lineno=1, end_col_offset=37)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sum', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=14), [GeneratorExp(Name('placeholder_3', Load(), lineno=2, col_offset=15, end_lineno=2, end_col_offset=20), [comprehension(Name('placeholder_3', Store(), lineno=2, col_offset=25, end_lineno=2, end_col_offset=30), Call(Name('range', Load(), lineno=2, col_offset=34, end_lineno=2, end_col_offset=39), [Name('placeholder_1', Load(), lineno=2, col_offset=40, end_lineno=2, end_col_offset=45)], [], lineno=2, col_offset=34, end_lineno=2, end_col_offset=46), [Call(Name('any', Load(), lineno=3, col_offset=18, end_lineno=3, end_col_offset=21), [GeneratorExp(Compare(BinOp(Name('placeholder_3', Load(), lineno=3, col_offset=22, end_lineno=3, end_col_offset=27), Mod(), Name('placeholder_4', Load(), lineno=3, col_offset=30, end_lineno=3, end_col_offset=38), lineno=3, col_offset=22, end_lineno=3, end_col_offset=38), [Eq()], [Constant(0, lineno=3, col_offset=42, end_lineno=3, end_col_offset=43)], lineno=3, col_offset=22, end_lineno=3, end_col_offset=43), [comprehension(Name('placeholder_4', Store(), lineno=4, col_offset=26, end_lineno=4, end_col_offset=34), Name('placeholder_2', Load(), lineno=4, col_offset=38, end_lineno=4, end_col_offset=47), [Compare(Name('placeholder_4', Load(), lineno=5, col_offset=25, end_lineno=5, end_col_offset=33), [Gt()], [Constant(0, lineno=5, col_offset=36, end_lineno=5, end_col_offset=37)], lineno=5, col_offset=25, end_lineno=5, end_col_offset=37)], 0)], lineno=3, col_offset=21, end_lineno=5, end_col_offset=38)], [], lineno=3, col_offset=18, end_lineno=5, end_col_offset=38)], 0)], lineno=2, col_offset=14, end_lineno=5, end_col_offset=39)], [], lineno=2, col_offset=11, end_lineno=5, end_col_offset=39), lineno=2, col_offset=4, end_lineno=5, end_col_offset=39)], [], lineno=1, col_offset=0, end_lineno=5, end_col_offset=39)], []) \ No newline at end of file diff --git a/test/practice-sum-of-multiples/sum_of_multiples.py b/test/practice-sum-of-multiples/sum_of_multiples.py new file mode 100644 index 0000000..55e1682 --- /dev/null +++ b/test/practice-sum-of-multiples/sum_of_multiples.py @@ -0,0 +1,5 @@ +def sum_of_multiples(limit, multiples): + return sum(value for value in range(limit) + if any(value % multiple == 0 + for multiple in multiples + if multiple > 0)) diff --git a/test/practice-tournament/.meta/config.json b/test/practice-tournament/.meta/config.json new file mode 100644 index 0000000..8f7263e --- /dev/null +++ b/test/practice-tournament/.meta/config.json @@ -0,0 +1,28 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "BethanyG", + "cmccandless", + "Dog", + "Grociu", + "ikhadykin", + "mikeyny", + "N-Parsons", + "spencer51324312", + "tqa236" + ], + "files": { + "solution": [ + "tournament.py" + ], + "test": [ + "tournament_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Tally the results of a small football competition." +} diff --git a/test/practice-tournament/mapping.json b/test/practice-tournament/mapping.json new file mode 100644 index 0000000..997ea08 --- /dev/null +++ b/test/practice-tournament/mapping.json @@ -0,0 +1,24 @@ +{ + "placeholder_0": "RESULTS", + "placeholder_1": "win", + "placeholder_2": "draw", + "placeholder_3": "loss", + "placeholder_4": "invert_result", + "placeholder_5": "result", + "placeholder_6": "parse_game", + "placeholder_7": "game_line", + "placeholder_8": "game", + "placeholder_9": "calculate_points", + "placeholder_10": "stats", + "placeholder_11": "format_table", + "placeholder_12": "results", + "placeholder_13": "table", + "placeholder_14": "team", + "placeholder_15": "games", + "placeholder_16": "key", + "placeholder_17": "group", + "placeholder_18": "team_fmt", + "placeholder_19": "tally", + "placeholder_20": "data", + "placeholder_21": "line" +} \ No newline at end of file diff --git a/test/practice-tournament/representation.json b/test/practice-tournament/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-tournament/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-tournament/representation.out b/test/practice-tournament/representation.out new file mode 100644 index 0000000..0f0de5a --- /dev/null +++ b/test/practice-tournament/representation.out @@ -0,0 +1,2312 @@ +## BEGIN NORMALIZED CODE ## +from collections import defaultdict + +placeholder_0 = dict(placeholder_1=0, placeholder_2=1, placeholder_3=2) + + +def placeholder_4(placeholder_5): + if placeholder_5 == 0: + return 2 + elif placeholder_5 == 2: + return 0 + return placeholder_5 + + +def placeholder_6(placeholder_7): + placeholder_8 = placeholder_7.split(";") + if len(placeholder_8) == 3 and placeholder_8[2] in placeholder_0: + placeholder_5 = placeholder_0[placeholder_8[2]] + return ( + (placeholder_8[0], placeholder_5), + (placeholder_8[1], placeholder_4(placeholder_5)), + ) + return [] + + +def placeholder_9(placeholder_10): + return placeholder_10[0] * 3 + placeholder_10[1] + + +def placeholder_11(placeholder_12): + placeholder_13 = ["Team | MP | W | D | L | P"] + for placeholder_14, placeholder_15 in sorted( + placeholder_12.items(), + placeholder_16=lambda placeholder_17: ( + -placeholder_9(placeholder_17[1]), + placeholder_17[0], + ), + ): + placeholder_18 = "{0:30} | {1:2} | {3:2} | {4:2} | {5:2} | {2:2}" + placeholder_13.append( + placeholder_18.format( + placeholder_14, + sum(placeholder_15), + placeholder_9(placeholder_15), + *placeholder_15 + ) + ) + return placeholder_13 + + +def placeholder_19(placeholder_20): + placeholder_13 = defaultdict(lambda: [0, 0, 0]) + for placeholder_21 in placeholder_20: + for placeholder_14, placeholder_5 in placeholder_6(placeholder_21): + placeholder_13[placeholder_14][placeholder_5] += 1 + return placeholder_11(placeholder_13) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'defaultdict', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=35)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=35), + Assign( + [ + Name( + 'RESULTS', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=7)], + Call( + Name( + 'dict', + Load(), + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=14), + [], + [ + keyword( + 'win', + Constant( + 0, + lineno=3, + col_offset=19, + end_lineno=3, + end_col_offset=20), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + keyword( + 'draw', + Constant( + 1, + lineno=3, + col_offset=27, + end_lineno=3, + end_col_offset=28), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=28), + keyword( + 'loss', + Constant( + 2, + lineno=3, + col_offset=35, + end_lineno=3, + end_col_offset=36), + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=36)], + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=37), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=37), + FunctionDef( + 'invert_result', + arguments( + [], + [ + arg( + 'result', + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'result', + Load(), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 0, + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=18)], + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=18), + [ + Return( + Constant( + 2, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=16), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=16)], + [ + If( + Compare( + Name( + 'result', + Load(), + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 2, + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=20)], + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=20), + [ + Return( + Constant( + 0, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=16), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=16)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=16)], + lineno=7, + col_offset=4, + end_lineno=10, + end_col_offset=16), + Return( + Name( + 'result', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=17), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=17)], + [], + lineno=6, + col_offset=0, + end_lineno=11, + end_col_offset=17), + FunctionDef( + 'parse_game', + arguments( + [], + [ + arg( + 'game_line', + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'game', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=8)], + Call( + Attribute( + Name( + 'game_line', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=20), + 'split', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=26), + [ + Constant( + ';', + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=30)], + [], + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=31), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=31), + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=10), + [ + Name( + 'game', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=15)], + [], + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 3, + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=21)], + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=21), + Compare( + Subscript( + Name( + 'game', + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=30), + Constant( + 2, + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=32), + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=33), + [ + In()], + [ + Name( + 'RESULTS', + Load(), + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=44)], + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=44)], + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=44), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=14)], + Subscript( + Name( + 'RESULTS', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=24), + Subscript( + Name( + 'game', + Load(), + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=29), + Constant( + 2, + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=31), + Load(), + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=32), + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=33), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=33), + Return( + Tuple( + [ + Tuple( + [ + Subscript( + Name( + 'game', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=20), + Constant( + 0, + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=22), + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=23), + Name( + 'result', + Load(), + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=31)], + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=32), + Tuple( + [ + Subscript( + Name( + 'game', + Load(), + lineno=18, + col_offset=35, + end_lineno=18, + end_col_offset=39), + Constant( + 1, + lineno=18, + col_offset=40, + end_lineno=18, + end_col_offset=41), + Load(), + lineno=18, + col_offset=35, + end_lineno=18, + end_col_offset=42), + Call( + Name( + 'invert_result', + Load(), + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=57), + [ + Name( + 'result', + Load(), + lineno=18, + col_offset=58, + end_lineno=18, + end_col_offset=64)], + [], + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=65)], + Load(), + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=66)], + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=66), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=66)], + [], + lineno=16, + col_offset=4, + end_lineno=18, + end_col_offset=66), + Return( + List( + [], + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=13), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=13)], + [], + lineno=14, + col_offset=0, + end_lineno=19, + end_col_offset=13), + FunctionDef( + 'calculate_points', + arguments( + [], + [ + arg( + 'stats', + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + Subscript( + Name( + 'stats', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=16), + Constant( + 0, + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=18), + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=19), + Mult(), + Constant( + 3, + lineno=23, + col_offset=22, + end_lineno=23, + end_col_offset=23), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=23), + Add(), + Subscript( + Name( + 'stats', + Load(), + lineno=23, + col_offset=26, + end_lineno=23, + end_col_offset=31), + Constant( + 1, + lineno=23, + col_offset=32, + end_lineno=23, + end_col_offset=33), + Load(), + lineno=23, + col_offset=26, + end_lineno=23, + end_col_offset=34), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=34), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=34)], + [], + lineno=22, + col_offset=0, + end_lineno=23, + end_col_offset=34), + FunctionDef( + 'format_table', + arguments( + [], + [ + arg( + 'results', + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'table', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=9)], + List( + [ + Constant( + 'Team | MP | W | D | L | P', + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=70)], + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=71), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=71), + For( + Tuple( + [ + Name( + 'team', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=12), + Name( + 'games', + Store(), + lineno=29, + col_offset=14, + end_lineno=29, + end_col_offset=19)], + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=19), + Call( + Name( + 'sorted', + Load(), + lineno=29, + col_offset=23, + end_lineno=29, + end_col_offset=29), + [ + Call( + Attribute( + Name( + 'results', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=19), + 'items', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=25), + [], + [], + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=27)], + [ + keyword( + 'key', + Lambda( + arguments( + [], + [ + arg( + 'group', + lineno=30, + col_offset=40, + end_lineno=30, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Tuple( + [ + UnaryOp( + USub(), + Call( + Name( + 'calculate_points', + Load(), + lineno=30, + col_offset=49, + end_lineno=30, + end_col_offset=65), + [ + Subscript( + Name( + 'group', + Load(), + lineno=30, + col_offset=66, + end_lineno=30, + end_col_offset=71), + Constant( + 1, + lineno=30, + col_offset=72, + end_lineno=30, + end_col_offset=73), + Load(), + lineno=30, + col_offset=66, + end_lineno=30, + end_col_offset=74)], + [], + lineno=30, + col_offset=49, + end_lineno=30, + end_col_offset=75), + lineno=30, + col_offset=48, + end_lineno=30, + end_col_offset=75), + Subscript( + Name( + 'group', + Load(), + lineno=30, + col_offset=77, + end_lineno=30, + end_col_offset=82), + Constant( + 0, + lineno=30, + col_offset=83, + end_lineno=30, + end_col_offset=84), + Load(), + lineno=30, + col_offset=77, + end_lineno=30, + end_col_offset=85)], + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=86), + lineno=30, + col_offset=33, + end_lineno=30, + end_col_offset=86), + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=86)], + lineno=29, + col_offset=23, + end_lineno=30, + end_col_offset=87), + [ + Assign( + [ + Name( + 'team_fmt', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=16)], + Constant( + '{0:30} | {1:2} | {3:2} | {4:2} | {5:2} | {2:2}', + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=67), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=67), + Expr( + Call( + Attribute( + Name( + 'table', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=13), + 'append', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=20), + [ + Call( + Attribute( + Name( + 'team_fmt', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=20), + 'format', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=27), + [ + Name( + 'team', + Load(), + lineno=33, + col_offset=28, + end_lineno=33, + end_col_offset=32), + Call( + Name( + 'sum', + Load(), + lineno=33, + col_offset=34, + end_lineno=33, + end_col_offset=37), + [ + Name( + 'games', + Load(), + lineno=33, + col_offset=38, + end_lineno=33, + end_col_offset=43)], + [], + lineno=33, + col_offset=34, + end_lineno=33, + end_col_offset=44), + Call( + Name( + 'calculate_points', + Load(), + lineno=33, + col_offset=46, + end_lineno=33, + end_col_offset=62), + [ + Name( + 'games', + Load(), + lineno=33, + col_offset=63, + end_lineno=33, + end_col_offset=68)], + [], + lineno=33, + col_offset=46, + end_lineno=33, + end_col_offset=69), + Starred( + Name( + 'games', + Load(), + lineno=33, + col_offset=72, + end_lineno=33, + end_col_offset=77), + Load(), + lineno=33, + col_offset=71, + end_lineno=33, + end_col_offset=77)], + [], + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=78)], + [], + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=79), + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=79)], + [], + lineno=29, + col_offset=4, + end_lineno=33, + end_col_offset=79), + Return( + Name( + 'table', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=16), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=16)], + [], + lineno=26, + col_offset=0, + end_lineno=34, + end_col_offset=16), + FunctionDef( + 'tally', + arguments( + [], + [ + arg( + 'data', + lineno=37, + col_offset=10, + end_lineno=37, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'table', + Store(), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=9)], + Call( + Name( + 'defaultdict', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=23), + [ + Lambda( + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + List( + [ + Constant( + 0, + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=34), + Constant( + 0, + lineno=38, + col_offset=36, + end_lineno=38, + end_col_offset=37), + Constant( + 0, + lineno=38, + col_offset=39, + end_lineno=38, + end_col_offset=40)], + Load(), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=41), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=41)], + [], + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=42), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=42), + For( + Name( + 'line', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=12), + Name( + 'data', + Load(), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=20), + [ + For( + Tuple( + [ + Name( + 'team', + Store(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=16), + Name( + 'result', + Store(), + lineno=41, + col_offset=18, + end_lineno=41, + end_col_offset=24)], + Store(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=24), + Call( + Name( + 'parse_game', + Load(), + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=38), + [ + Name( + 'line', + Load(), + lineno=41, + col_offset=39, + end_lineno=41, + end_col_offset=43)], + [], + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=44), + [ + AugAssign( + Subscript( + Subscript( + Name( + 'table', + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=17), + Name( + 'team', + Load(), + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=22), + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=23), + Name( + 'result', + Load(), + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=30), + Store(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=31), + Add(), + Constant( + 1, + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=36), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=36)], + [], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=36)], + [], + lineno=40, + col_offset=4, + end_lineno=42, + end_col_offset=36), + Return( + Call( + Name( + 'format_table', + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=23), + [ + Name( + 'table', + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=29)], + [], + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=30), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=30)], + [], + lineno=37, + col_offset=0, + end_lineno=44, + end_col_offset=30)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'defaultdict', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=35)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=35), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=7)], + Call( + Name( + 'dict', + Load(), + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=14), + [], + [ + keyword( + 'placeholder_1', + Constant( + 0, + lineno=3, + col_offset=19, + end_lineno=3, + end_col_offset=20), + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=20), + keyword( + 'placeholder_2', + Constant( + 1, + lineno=3, + col_offset=27, + end_lineno=3, + end_col_offset=28), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=28), + keyword( + 'placeholder_3', + Constant( + 2, + lineno=3, + col_offset=35, + end_lineno=3, + end_col_offset=36), + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=36)], + lineno=3, + col_offset=10, + end_lineno=3, + end_col_offset=37), + lineno=3, + col_offset=0, + end_lineno=3, + end_col_offset=37), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_5', + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=13), + [ + Eq()], + [ + Constant( + 0, + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=18)], + lineno=7, + col_offset=7, + end_lineno=7, + end_col_offset=18), + [ + Return( + Constant( + 2, + lineno=8, + col_offset=15, + end_lineno=8, + end_col_offset=16), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=16)], + [ + If( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=15), + [ + Eq()], + [ + Constant( + 2, + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=20)], + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=20), + [ + Return( + Constant( + 0, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=16), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=16)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=16)], + lineno=7, + col_offset=4, + end_lineno=10, + end_col_offset=16), + Return( + Name( + 'placeholder_5', + Load(), + lineno=11, + col_offset=11, + end_lineno=11, + end_col_offset=17), + lineno=11, + col_offset=4, + end_lineno=11, + end_col_offset=17)], + [], + lineno=6, + col_offset=0, + end_lineno=11, + end_col_offset=17), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'placeholder_7', + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=8)], + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=20), + 'split', + Load(), + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=26), + [ + Constant( + ';', + lineno=15, + col_offset=27, + end_lineno=15, + end_col_offset=30)], + [], + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=31), + lineno=15, + col_offset=4, + end_lineno=15, + end_col_offset=31), + If( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'len', + Load(), + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=10), + [ + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=15)], + [], + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=16), + [ + Eq()], + [ + Constant( + 3, + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=21)], + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=21), + Compare( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=30), + Constant( + 2, + lineno=16, + col_offset=31, + end_lineno=16, + end_col_offset=32), + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=33), + [ + In()], + [ + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=37, + end_lineno=16, + end_col_offset=44)], + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=44)], + lineno=16, + col_offset=7, + end_lineno=16, + end_col_offset=44), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=14)], + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=24), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=29), + Constant( + 2, + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=31), + Load(), + lineno=17, + col_offset=25, + end_lineno=17, + end_col_offset=32), + Load(), + lineno=17, + col_offset=17, + end_lineno=17, + end_col_offset=33), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=33), + Return( + Tuple( + [ + Tuple( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=20), + Constant( + 0, + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=22), + Load(), + lineno=18, + col_offset=16, + end_lineno=18, + end_col_offset=23), + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=31)], + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=32), + Tuple( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=18, + col_offset=35, + end_lineno=18, + end_col_offset=39), + Constant( + 1, + lineno=18, + col_offset=40, + end_lineno=18, + end_col_offset=41), + Load(), + lineno=18, + col_offset=35, + end_lineno=18, + end_col_offset=42), + Call( + Name( + 'placeholder_4', + Load(), + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=57), + [ + Name( + 'placeholder_5', + Load(), + lineno=18, + col_offset=58, + end_lineno=18, + end_col_offset=64)], + [], + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=65)], + Load(), + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=66)], + Load(), + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=66), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=66)], + [], + lineno=16, + col_offset=4, + end_lineno=18, + end_col_offset=66), + Return( + List( + [], + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=13), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=13)], + [], + lineno=14, + col_offset=0, + end_lineno=19, + end_col_offset=13), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'placeholder_10', + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BinOp( + BinOp( + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=16), + Constant( + 0, + lineno=23, + col_offset=17, + end_lineno=23, + end_col_offset=18), + Load(), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=19), + Mult(), + Constant( + 3, + lineno=23, + col_offset=22, + end_lineno=23, + end_col_offset=23), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=23), + Add(), + Subscript( + Name( + 'placeholder_10', + Load(), + lineno=23, + col_offset=26, + end_lineno=23, + end_col_offset=31), + Constant( + 1, + lineno=23, + col_offset=32, + end_lineno=23, + end_col_offset=33), + Load(), + lineno=23, + col_offset=26, + end_lineno=23, + end_col_offset=34), + lineno=23, + col_offset=11, + end_lineno=23, + end_col_offset=34), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=34)], + [], + lineno=22, + col_offset=0, + end_lineno=23, + end_col_offset=34), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_12', + lineno=26, + col_offset=17, + end_lineno=26, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=9)], + List( + [ + Constant( + 'Team | MP | W | D | L | P', + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=70)], + Load(), + lineno=27, + col_offset=12, + end_lineno=27, + end_col_offset=71), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=71), + For( + Tuple( + [ + Name( + 'placeholder_14', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=12), + Name( + 'placeholder_15', + Store(), + lineno=29, + col_offset=14, + end_lineno=29, + end_col_offset=19)], + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=19), + Call( + Name( + 'sorted', + Load(), + lineno=29, + col_offset=23, + end_lineno=29, + end_col_offset=29), + [ + Call( + Attribute( + Name( + 'placeholder_12', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=19), + 'items', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=25), + [], + [], + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=27)], + [ + keyword( + 'placeholder_16', + Lambda( + arguments( + [], + [ + arg( + 'placeholder_17', + lineno=30, + col_offset=40, + end_lineno=30, + end_col_offset=45)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + Tuple( + [ + UnaryOp( + USub(), + Call( + Name( + 'placeholder_9', + Load(), + lineno=30, + col_offset=49, + end_lineno=30, + end_col_offset=65), + [ + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=30, + col_offset=66, + end_lineno=30, + end_col_offset=71), + Constant( + 1, + lineno=30, + col_offset=72, + end_lineno=30, + end_col_offset=73), + Load(), + lineno=30, + col_offset=66, + end_lineno=30, + end_col_offset=74)], + [], + lineno=30, + col_offset=49, + end_lineno=30, + end_col_offset=75), + lineno=30, + col_offset=48, + end_lineno=30, + end_col_offset=75), + Subscript( + Name( + 'placeholder_17', + Load(), + lineno=30, + col_offset=77, + end_lineno=30, + end_col_offset=82), + Constant( + 0, + lineno=30, + col_offset=83, + end_lineno=30, + end_col_offset=84), + Load(), + lineno=30, + col_offset=77, + end_lineno=30, + end_col_offset=85)], + Load(), + lineno=30, + col_offset=47, + end_lineno=30, + end_col_offset=86), + lineno=30, + col_offset=33, + end_lineno=30, + end_col_offset=86), + lineno=30, + col_offset=29, + end_lineno=30, + end_col_offset=86)], + lineno=29, + col_offset=23, + end_lineno=30, + end_col_offset=87), + [ + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=16)], + Constant( + '{0:30} | {1:2} | {3:2} | {4:2} | {5:2} | {2:2}', + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=67), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=67), + Expr( + Call( + Attribute( + Name( + 'placeholder_13', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=13), + 'append', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=20), + [ + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=20), + 'format', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=27), + [ + Name( + 'placeholder_14', + Load(), + lineno=33, + col_offset=28, + end_lineno=33, + end_col_offset=32), + Call( + Name( + 'sum', + Load(), + lineno=33, + col_offset=34, + end_lineno=33, + end_col_offset=37), + [ + Name( + 'placeholder_15', + Load(), + lineno=33, + col_offset=38, + end_lineno=33, + end_col_offset=43)], + [], + lineno=33, + col_offset=34, + end_lineno=33, + end_col_offset=44), + Call( + Name( + 'placeholder_9', + Load(), + lineno=33, + col_offset=46, + end_lineno=33, + end_col_offset=62), + [ + Name( + 'placeholder_15', + Load(), + lineno=33, + col_offset=63, + end_lineno=33, + end_col_offset=68)], + [], + lineno=33, + col_offset=46, + end_lineno=33, + end_col_offset=69), + Starred( + Name( + 'placeholder_15', + Load(), + lineno=33, + col_offset=72, + end_lineno=33, + end_col_offset=77), + Load(), + lineno=33, + col_offset=71, + end_lineno=33, + end_col_offset=77)], + [], + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=78)], + [], + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=79), + lineno=32, + col_offset=8, + end_lineno=33, + end_col_offset=79)], + [], + lineno=29, + col_offset=4, + end_lineno=33, + end_col_offset=79), + Return( + Name( + 'placeholder_13', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=16), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=16)], + [], + lineno=26, + col_offset=0, + end_lineno=34, + end_col_offset=16), + FunctionDef( + 'placeholder_19', + arguments( + [], + [ + arg( + 'placeholder_20', + lineno=37, + col_offset=10, + end_lineno=37, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=9)], + Call( + Name( + 'defaultdict', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=23), + [ + Lambda( + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + List( + [ + Constant( + 0, + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=34), + Constant( + 0, + lineno=38, + col_offset=36, + end_lineno=38, + end_col_offset=37), + Constant( + 0, + lineno=38, + col_offset=39, + end_lineno=38, + end_col_offset=40)], + Load(), + lineno=38, + col_offset=32, + end_lineno=38, + end_col_offset=41), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=41)], + [], + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=42), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=42), + For( + Name( + 'placeholder_21', + Store(), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=12), + Name( + 'placeholder_20', + Load(), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=20), + [ + For( + Tuple( + [ + Name( + 'placeholder_14', + Store(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=16), + Name( + 'placeholder_5', + Store(), + lineno=41, + col_offset=18, + end_lineno=41, + end_col_offset=24)], + Store(), + lineno=41, + col_offset=12, + end_lineno=41, + end_col_offset=24), + Call( + Name( + 'placeholder_6', + Load(), + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=38), + [ + Name( + 'placeholder_21', + Load(), + lineno=41, + col_offset=39, + end_lineno=41, + end_col_offset=43)], + [], + lineno=41, + col_offset=28, + end_lineno=41, + end_col_offset=44), + [ + AugAssign( + Subscript( + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=17), + Name( + 'placeholder_14', + Load(), + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=22), + Load(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=23), + Name( + 'placeholder_5', + Load(), + lineno=42, + col_offset=24, + end_lineno=42, + end_col_offset=30), + Store(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=31), + Add(), + Constant( + 1, + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=36), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=36)], + [], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=36)], + [], + lineno=40, + col_offset=4, + end_lineno=42, + end_col_offset=36), + Return( + Call( + Name( + 'placeholder_11', + Load(), + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=23), + [ + Name( + 'placeholder_13', + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=29)], + [], + lineno=44, + col_offset=11, + end_lineno=44, + end_col_offset=30), + lineno=44, + col_offset=4, + end_lineno=44, + end_col_offset=30)], + [], + lineno=37, + col_offset=0, + end_lineno=44, + end_col_offset=30)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-tournament/representation.txt b/test/practice-tournament/representation.txt new file mode 100644 index 0000000..fd5ba20 --- /dev/null +++ b/test/practice-tournament/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('collections', [alias('defaultdict', lineno=1, col_offset=24, end_lineno=1, end_col_offset=35)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=35), Assign([Name('placeholder_0', Store(), lineno=3, col_offset=0, end_lineno=3, end_col_offset=7)], Call(Name('dict', Load(), lineno=3, col_offset=10, end_lineno=3, end_col_offset=14), [], [keyword('placeholder_1', Constant(0, lineno=3, col_offset=19, end_lineno=3, end_col_offset=20), lineno=3, col_offset=15, end_lineno=3, end_col_offset=20), keyword('placeholder_2', Constant(1, lineno=3, col_offset=27, end_lineno=3, end_col_offset=28), lineno=3, col_offset=22, end_lineno=3, end_col_offset=28), keyword('placeholder_3', Constant(2, lineno=3, col_offset=35, end_lineno=3, end_col_offset=36), lineno=3, col_offset=30, end_lineno=3, end_col_offset=36)], lineno=3, col_offset=10, end_lineno=3, end_col_offset=37), lineno=3, col_offset=0, end_lineno=3, end_col_offset=37), FunctionDef('placeholder_4', arguments([], [arg('placeholder_5', lineno=6, col_offset=18, end_lineno=6, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Name('placeholder_5', Load(), lineno=7, col_offset=7, end_lineno=7, end_col_offset=13), [Eq()], [Constant(0, lineno=7, col_offset=17, end_lineno=7, end_col_offset=18)], lineno=7, col_offset=7, end_lineno=7, end_col_offset=18), [Return(Constant(2, lineno=8, col_offset=15, end_lineno=8, end_col_offset=16), lineno=8, col_offset=8, end_lineno=8, end_col_offset=16)], [If(Compare(Name('placeholder_5', Load(), lineno=9, col_offset=9, end_lineno=9, end_col_offset=15), [Eq()], [Constant(2, lineno=9, col_offset=19, end_lineno=9, end_col_offset=20)], lineno=9, col_offset=9, end_lineno=9, end_col_offset=20), [Return(Constant(0, lineno=10, col_offset=15, end_lineno=10, end_col_offset=16), lineno=10, col_offset=8, end_lineno=10, end_col_offset=16)], [], lineno=9, col_offset=4, end_lineno=10, end_col_offset=16)], lineno=7, col_offset=4, end_lineno=10, end_col_offset=16), Return(Name('placeholder_5', Load(), lineno=11, col_offset=11, end_lineno=11, end_col_offset=17), lineno=11, col_offset=4, end_lineno=11, end_col_offset=17)], [], lineno=6, col_offset=0, end_lineno=11, end_col_offset=17), FunctionDef('placeholder_6', arguments([], [arg('placeholder_7', lineno=14, col_offset=15, end_lineno=14, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=15, col_offset=4, end_lineno=15, end_col_offset=8)], Call(Attribute(Name('placeholder_7', Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=20), 'split', Load(), lineno=15, col_offset=11, end_lineno=15, end_col_offset=26), [Constant(';', lineno=15, col_offset=27, end_lineno=15, end_col_offset=30)], [], lineno=15, col_offset=11, end_lineno=15, end_col_offset=31), lineno=15, col_offset=4, end_lineno=15, end_col_offset=31), If(BoolOp(And(), [Compare(Call(Name('len', Load(), lineno=16, col_offset=7, end_lineno=16, end_col_offset=10), [Name('placeholder_8', Load(), lineno=16, col_offset=11, end_lineno=16, end_col_offset=15)], [], lineno=16, col_offset=7, end_lineno=16, end_col_offset=16), [Eq()], [Constant(3, lineno=16, col_offset=20, end_lineno=16, end_col_offset=21)], lineno=16, col_offset=7, end_lineno=16, end_col_offset=21), Compare(Subscript(Name('placeholder_8', Load(), lineno=16, col_offset=26, end_lineno=16, end_col_offset=30), Constant(2, lineno=16, col_offset=31, end_lineno=16, end_col_offset=32), Load(), lineno=16, col_offset=26, end_lineno=16, end_col_offset=33), [In()], [Name('placeholder_0', Load(), lineno=16, col_offset=37, end_lineno=16, end_col_offset=44)], lineno=16, col_offset=26, end_lineno=16, end_col_offset=44)], lineno=16, col_offset=7, end_lineno=16, end_col_offset=44), [Assign([Name('placeholder_5', Store(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=14)], Subscript(Name('placeholder_0', Load(), lineno=17, col_offset=17, end_lineno=17, end_col_offset=24), Subscript(Name('placeholder_8', Load(), lineno=17, col_offset=25, end_lineno=17, end_col_offset=29), Constant(2, lineno=17, col_offset=30, end_lineno=17, end_col_offset=31), Load(), lineno=17, col_offset=25, end_lineno=17, end_col_offset=32), Load(), lineno=17, col_offset=17, end_lineno=17, end_col_offset=33), lineno=17, col_offset=8, end_lineno=17, end_col_offset=33), Return(Tuple([Tuple([Subscript(Name('placeholder_8', Load(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=20), Constant(0, lineno=18, col_offset=21, end_lineno=18, end_col_offset=22), Load(), lineno=18, col_offset=16, end_lineno=18, end_col_offset=23), Name('placeholder_5', Load(), lineno=18, col_offset=25, end_lineno=18, end_col_offset=31)], Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=32), Tuple([Subscript(Name('placeholder_8', Load(), lineno=18, col_offset=35, end_lineno=18, end_col_offset=39), Constant(1, lineno=18, col_offset=40, end_lineno=18, end_col_offset=41), Load(), lineno=18, col_offset=35, end_lineno=18, end_col_offset=42), Call(Name('placeholder_4', Load(), lineno=18, col_offset=44, end_lineno=18, end_col_offset=57), [Name('placeholder_5', Load(), lineno=18, col_offset=58, end_lineno=18, end_col_offset=64)], [], lineno=18, col_offset=44, end_lineno=18, end_col_offset=65)], Load(), lineno=18, col_offset=34, end_lineno=18, end_col_offset=66)], Load(), lineno=18, col_offset=15, end_lineno=18, end_col_offset=66), lineno=18, col_offset=8, end_lineno=18, end_col_offset=66)], [], lineno=16, col_offset=4, end_lineno=18, end_col_offset=66), Return(List([], Load(), lineno=19, col_offset=11, end_lineno=19, end_col_offset=13), lineno=19, col_offset=4, end_lineno=19, end_col_offset=13)], [], lineno=14, col_offset=0, end_lineno=19, end_col_offset=13), FunctionDef('placeholder_9', arguments([], [arg('placeholder_10', lineno=22, col_offset=21, end_lineno=22, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BinOp(BinOp(Subscript(Name('placeholder_10', Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=16), Constant(0, lineno=23, col_offset=17, end_lineno=23, end_col_offset=18), Load(), lineno=23, col_offset=11, end_lineno=23, end_col_offset=19), Mult(), Constant(3, lineno=23, col_offset=22, end_lineno=23, end_col_offset=23), lineno=23, col_offset=11, end_lineno=23, end_col_offset=23), Add(), Subscript(Name('placeholder_10', Load(), lineno=23, col_offset=26, end_lineno=23, end_col_offset=31), Constant(1, lineno=23, col_offset=32, end_lineno=23, end_col_offset=33), Load(), lineno=23, col_offset=26, end_lineno=23, end_col_offset=34), lineno=23, col_offset=11, end_lineno=23, end_col_offset=34), lineno=23, col_offset=4, end_lineno=23, end_col_offset=34)], [], lineno=22, col_offset=0, end_lineno=23, end_col_offset=34), FunctionDef('placeholder_11', arguments([], [arg('placeholder_12', lineno=26, col_offset=17, end_lineno=26, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_13', Store(), lineno=27, col_offset=4, end_lineno=27, end_col_offset=9)], List([Constant('Team | MP | W | D | L | P', lineno=27, col_offset=13, end_lineno=27, end_col_offset=70)], Load(), lineno=27, col_offset=12, end_lineno=27, end_col_offset=71), lineno=27, col_offset=4, end_lineno=27, end_col_offset=71), For(Tuple([Name('placeholder_14', Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=12), Name('placeholder_15', Store(), lineno=29, col_offset=14, end_lineno=29, end_col_offset=19)], Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=19), Call(Name('sorted', Load(), lineno=29, col_offset=23, end_lineno=29, end_col_offset=29), [Call(Attribute(Name('placeholder_12', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=19), 'items', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=25), [], [], lineno=30, col_offset=12, end_lineno=30, end_col_offset=27)], [keyword('placeholder_16', Lambda(arguments([], [arg('placeholder_17', lineno=30, col_offset=40, end_lineno=30, end_col_offset=45)], kwonlyargs=[], kw_defaults=[], defaults=[]), Tuple([UnaryOp(USub(), Call(Name('placeholder_9', Load(), lineno=30, col_offset=49, end_lineno=30, end_col_offset=65), [Subscript(Name('placeholder_17', Load(), lineno=30, col_offset=66, end_lineno=30, end_col_offset=71), Constant(1, lineno=30, col_offset=72, end_lineno=30, end_col_offset=73), Load(), lineno=30, col_offset=66, end_lineno=30, end_col_offset=74)], [], lineno=30, col_offset=49, end_lineno=30, end_col_offset=75), lineno=30, col_offset=48, end_lineno=30, end_col_offset=75), Subscript(Name('placeholder_17', Load(), lineno=30, col_offset=77, end_lineno=30, end_col_offset=82), Constant(0, lineno=30, col_offset=83, end_lineno=30, end_col_offset=84), Load(), lineno=30, col_offset=77, end_lineno=30, end_col_offset=85)], Load(), lineno=30, col_offset=47, end_lineno=30, end_col_offset=86), lineno=30, col_offset=33, end_lineno=30, end_col_offset=86), lineno=30, col_offset=29, end_lineno=30, end_col_offset=86)], lineno=29, col_offset=23, end_lineno=30, end_col_offset=87), [Assign([Name('placeholder_18', Store(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=16)], Constant('{0:30} | {1:2} | {3:2} | {4:2} | {5:2} | {2:2}', lineno=31, col_offset=19, end_lineno=31, end_col_offset=67), lineno=31, col_offset=8, end_lineno=31, end_col_offset=67), Expr(Call(Attribute(Name('placeholder_13', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=13), 'append', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=20), [Call(Attribute(Name('placeholder_18', Load(), lineno=33, col_offset=12, end_lineno=33, end_col_offset=20), 'format', Load(), lineno=33, col_offset=12, end_lineno=33, end_col_offset=27), [Name('placeholder_14', Load(), lineno=33, col_offset=28, end_lineno=33, end_col_offset=32), Call(Name('sum', Load(), lineno=33, col_offset=34, end_lineno=33, end_col_offset=37), [Name('placeholder_15', Load(), lineno=33, col_offset=38, end_lineno=33, end_col_offset=43)], [], lineno=33, col_offset=34, end_lineno=33, end_col_offset=44), Call(Name('placeholder_9', Load(), lineno=33, col_offset=46, end_lineno=33, end_col_offset=62), [Name('placeholder_15', Load(), lineno=33, col_offset=63, end_lineno=33, end_col_offset=68)], [], lineno=33, col_offset=46, end_lineno=33, end_col_offset=69), Starred(Name('placeholder_15', Load(), lineno=33, col_offset=72, end_lineno=33, end_col_offset=77), Load(), lineno=33, col_offset=71, end_lineno=33, end_col_offset=77)], [], lineno=33, col_offset=12, end_lineno=33, end_col_offset=78)], [], lineno=32, col_offset=8, end_lineno=33, end_col_offset=79), lineno=32, col_offset=8, end_lineno=33, end_col_offset=79)], [], lineno=29, col_offset=4, end_lineno=33, end_col_offset=79), Return(Name('placeholder_13', Load(), lineno=34, col_offset=11, end_lineno=34, end_col_offset=16), lineno=34, col_offset=4, end_lineno=34, end_col_offset=16)], [], lineno=26, col_offset=0, end_lineno=34, end_col_offset=16), FunctionDef('placeholder_19', arguments([], [arg('placeholder_20', lineno=37, col_offset=10, end_lineno=37, end_col_offset=14)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_13', Store(), lineno=38, col_offset=4, end_lineno=38, end_col_offset=9)], Call(Name('defaultdict', Load(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=23), [Lambda(arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), List([Constant(0, lineno=38, col_offset=33, end_lineno=38, end_col_offset=34), Constant(0, lineno=38, col_offset=36, end_lineno=38, end_col_offset=37), Constant(0, lineno=38, col_offset=39, end_lineno=38, end_col_offset=40)], Load(), lineno=38, col_offset=32, end_lineno=38, end_col_offset=41), lineno=38, col_offset=24, end_lineno=38, end_col_offset=41)], [], lineno=38, col_offset=12, end_lineno=38, end_col_offset=42), lineno=38, col_offset=4, end_lineno=38, end_col_offset=42), For(Name('placeholder_21', Store(), lineno=40, col_offset=8, end_lineno=40, end_col_offset=12), Name('placeholder_20', Load(), lineno=40, col_offset=16, end_lineno=40, end_col_offset=20), [For(Tuple([Name('placeholder_14', Store(), lineno=41, col_offset=12, end_lineno=41, end_col_offset=16), Name('placeholder_5', Store(), lineno=41, col_offset=18, end_lineno=41, end_col_offset=24)], Store(), lineno=41, col_offset=12, end_lineno=41, end_col_offset=24), Call(Name('placeholder_6', Load(), lineno=41, col_offset=28, end_lineno=41, end_col_offset=38), [Name('placeholder_21', Load(), lineno=41, col_offset=39, end_lineno=41, end_col_offset=43)], [], lineno=41, col_offset=28, end_lineno=41, end_col_offset=44), [AugAssign(Subscript(Subscript(Name('placeholder_13', Load(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=17), Name('placeholder_14', Load(), lineno=42, col_offset=18, end_lineno=42, end_col_offset=22), Load(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=23), Name('placeholder_5', Load(), lineno=42, col_offset=24, end_lineno=42, end_col_offset=30), Store(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=31), Add(), Constant(1, lineno=42, col_offset=35, end_lineno=42, end_col_offset=36), lineno=42, col_offset=12, end_lineno=42, end_col_offset=36)], [], lineno=41, col_offset=8, end_lineno=42, end_col_offset=36)], [], lineno=40, col_offset=4, end_lineno=42, end_col_offset=36), Return(Call(Name('placeholder_11', Load(), lineno=44, col_offset=11, end_lineno=44, end_col_offset=23), [Name('placeholder_13', Load(), lineno=44, col_offset=24, end_lineno=44, end_col_offset=29)], [], lineno=44, col_offset=11, end_lineno=44, end_col_offset=30), lineno=44, col_offset=4, end_lineno=44, end_col_offset=30)], [], lineno=37, col_offset=0, end_lineno=44, end_col_offset=30)], []) \ No newline at end of file diff --git a/test/practice-tournament/tournament.py b/test/practice-tournament/tournament.py new file mode 100644 index 0000000..e711468 --- /dev/null +++ b/test/practice-tournament/tournament.py @@ -0,0 +1,44 @@ +from collections import defaultdict + +RESULTS = dict(win=0, draw=1, loss=2) + + +def invert_result(result): + if result == 0: + return 2 + elif result == 2: + return 0 + return result + + +def parse_game(game_line): + game = game_line.split(';') + if len(game) == 3 and game[2] in RESULTS: + result = RESULTS[game[2]] + return (game[0], result), (game[1], invert_result(result)) + return [] + + +def calculate_points(stats): + return stats[0] * 3 + stats[1] + + +def format_table(results): + table = ['Team | MP | W | D | L | P'] + + for team, games in sorted( + results.items(), key=lambda group: (-calculate_points(group[1]), group[0])): + team_fmt = '{0:30} | {1:2} | {3:2} | {4:2} | {5:2} | {2:2}' + table.append( + team_fmt.format(team, sum(games), calculate_points(games), *games)) + return table + + +def tally(data): + table = defaultdict(lambda: [0, 0, 0]) + + for line in data: + for team, result in parse_game(line): + table[team][result] += 1 + + return format_table(table) diff --git a/test/practice-transpose/.meta/config.json b/test/practice-transpose/.meta/config.json new file mode 100644 index 0000000..5eb2b08 --- /dev/null +++ b/test/practice-transpose/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "nithin-vijayan" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "dvermd", + "Grociu", + "ikhadykin", + "N-Parsons", + "parinporecha", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "transpose.py" + ], + "test": [ + "transpose_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Take input text and output it transposed.", + "source": "Reddit r/dailyprogrammer challenge #270 [Easy].", + "source_url": "https://www.reddit.com/r/dailyprogrammer/comments/4msu2x/challenge_270_easy_transpose_the_input_text" +} diff --git a/test/practice-transpose/mapping.json b/test/practice-transpose/mapping.json new file mode 100644 index 0000000..c070ea1 --- /dev/null +++ b/test/practice-transpose/mapping.json @@ -0,0 +1,8 @@ +{ + "placeholder_0": "transpose", + "placeholder_1": "lines", + "placeholder_2": "rows", + "placeholder_3": "row", + "placeholder_4": "key", + "placeholder_5": "placeholder_4" +} \ No newline at end of file diff --git a/test/practice-transpose/representation.json b/test/practice-transpose/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-transpose/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-transpose/representation.out b/test/practice-transpose/representation.out new file mode 100644 index 0000000..bf57684 --- /dev/null +++ b/test/practice-transpose/representation.out @@ -0,0 +1,840 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + placeholder_2 = [ + placeholder_3.replace(" ", "_") for placeholder_3 in placeholder_1.splitlines() + ] + placeholder_2 = [ + placeholder_3.ljust(len(max(placeholder_2, placeholder_5=len))) + for placeholder_3 in placeholder_2 + ] + placeholder_2 = ["".join(placeholder_3) for placeholder_3 in zip(*placeholder_2)] + placeholder_2 = [ + placeholder_3.rstrip().replace("_", " ") for placeholder_3 in placeholder_2 + ] + return "\n".join(placeholder_2) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'transpose', + arguments( + [], + [ + arg( + 'lines', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'rows', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=8)], + ListComp( + Call( + Attribute( + Name( + 'row', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=15), + 'replace', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=23), + [ + Constant( + ' ', + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=27), + Constant( + '_', + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=32)], + [], + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=33), + [ + comprehension( + Name( + 'row', + Store(), + lineno=2, + col_offset=38, + end_lineno=2, + end_col_offset=41), + Call( + Attribute( + Name( + 'lines', + Load(), + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=50), + 'splitlines', + Load(), + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=61), + [], + [], + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=63), + [], + 0)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=64), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=64), + Assign( + [ + Name( + 'rows', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=8)], + ListComp( + Call( + Attribute( + Name( + 'row', + Load(), + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=15), + 'ljust', + Load(), + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=21), + [ + Call( + Name( + 'len', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=25), + [ + Call( + Name( + 'max', + Load(), + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=29), + [ + Name( + 'rows', + Load(), + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=34)], + [ + keyword( + 'key', + Name( + 'len', + Load(), + lineno=3, + col_offset=40, + end_lineno=3, + end_col_offset=43), + lineno=3, + col_offset=36, + end_lineno=3, + end_col_offset=43)], + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=44)], + [], + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=45)], + [], + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=46), + [ + comprehension( + Name( + 'row', + Store(), + lineno=3, + col_offset=51, + end_lineno=3, + end_col_offset=54), + Name( + 'rows', + Load(), + lineno=3, + col_offset=58, + end_lineno=3, + end_col_offset=62), + [], + 0)], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=63), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=63), + Assign( + [ + Name( + 'rows', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=8)], + ListComp( + Call( + Attribute( + Constant( + '', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=14), + 'join', + Load(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=19), + [ + Name( + 'row', + Load(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=23)], + [], + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=24), + [ + comprehension( + Name( + 'row', + Store(), + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=32), + Call( + Name( + 'zip', + Load(), + lineno=4, + col_offset=36, + end_lineno=4, + end_col_offset=39), + [ + Starred( + Name( + 'rows', + Load(), + lineno=4, + col_offset=41, + end_lineno=4, + end_col_offset=45), + Load(), + lineno=4, + col_offset=40, + end_lineno=4, + end_col_offset=45)], + [], + lineno=4, + col_offset=36, + end_lineno=4, + end_col_offset=46), + [], + 0)], + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=47), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=47), + Assign( + [ + Name( + 'rows', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=8)], + ListComp( + Call( + Attribute( + Call( + Attribute( + Name( + 'row', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=15), + 'rstrip', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=22), + [], + [], + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=24), + 'replace', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=32), + [ + Constant( + '_', + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=36), + Constant( + ' ', + lineno=5, + col_offset=38, + end_lineno=5, + end_col_offset=41)], + [], + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=42), + [ + comprehension( + Name( + 'row', + Store(), + lineno=5, + col_offset=47, + end_lineno=5, + end_col_offset=50), + Name( + 'rows', + Load(), + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=58), + [], + 0)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=59), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=59), + Return( + Call( + Attribute( + Constant( + '\n', + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=15), + 'join', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=20), + [ + Name( + 'rows', + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=25)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=26), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=26)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=14, + end_lineno=1, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=8)], + ListComp( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=15), + 'replace', + Load(), + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=23), + [ + Constant( + ' ', + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=27), + Constant( + '_', + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=32)], + [], + lineno=2, + col_offset=12, + end_lineno=2, + end_col_offset=33), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=2, + col_offset=38, + end_lineno=2, + end_col_offset=41), + Call( + Attribute( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=50), + 'splitlines', + Load(), + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=61), + [], + [], + lineno=2, + col_offset=45, + end_lineno=2, + end_col_offset=63), + [], + 0)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=64), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=64), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=8)], + ListComp( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=15), + 'ljust', + Load(), + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=21), + [ + Call( + Name( + 'len', + Load(), + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=25), + [ + Call( + Name( + 'max', + Load(), + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=29), + [ + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=30, + end_lineno=3, + end_col_offset=34)], + [ + keyword( + 'placeholder_5', + Name( + 'len', + Load(), + lineno=3, + col_offset=40, + end_lineno=3, + end_col_offset=43), + lineno=3, + col_offset=36, + end_lineno=3, + end_col_offset=43)], + lineno=3, + col_offset=26, + end_lineno=3, + end_col_offset=44)], + [], + lineno=3, + col_offset=22, + end_lineno=3, + end_col_offset=45)], + [], + lineno=3, + col_offset=12, + end_lineno=3, + end_col_offset=46), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=3, + col_offset=51, + end_lineno=3, + end_col_offset=54), + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=58, + end_lineno=3, + end_col_offset=62), + [], + 0)], + lineno=3, + col_offset=11, + end_lineno=3, + end_col_offset=63), + lineno=3, + col_offset=4, + end_lineno=3, + end_col_offset=63), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=8)], + ListComp( + Call( + Attribute( + Constant( + '', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=14), + 'join', + Load(), + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=19), + [ + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=20, + end_lineno=4, + end_col_offset=23)], + [], + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=24), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=4, + col_offset=29, + end_lineno=4, + end_col_offset=32), + Call( + Name( + 'zip', + Load(), + lineno=4, + col_offset=36, + end_lineno=4, + end_col_offset=39), + [ + Starred( + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=41, + end_lineno=4, + end_col_offset=45), + Load(), + lineno=4, + col_offset=40, + end_lineno=4, + end_col_offset=45)], + [], + lineno=4, + col_offset=36, + end_lineno=4, + end_col_offset=46), + [], + 0)], + lineno=4, + col_offset=11, + end_lineno=4, + end_col_offset=47), + lineno=4, + col_offset=4, + end_lineno=4, + end_col_offset=47), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=8)], + ListComp( + Call( + Attribute( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=15), + 'rstrip', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=22), + [], + [], + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=24), + 'replace', + Load(), + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=32), + [ + Constant( + '_', + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=36), + Constant( + ' ', + lineno=5, + col_offset=38, + end_lineno=5, + end_col_offset=41)], + [], + lineno=5, + col_offset=12, + end_lineno=5, + end_col_offset=42), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=5, + col_offset=47, + end_lineno=5, + end_col_offset=50), + Name( + 'placeholder_2', + Load(), + lineno=5, + col_offset=54, + end_lineno=5, + end_col_offset=58), + [], + 0)], + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=59), + lineno=5, + col_offset=4, + end_lineno=5, + end_col_offset=59), + Return( + Call( + Attribute( + Constant( + '\n', + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=15), + 'join', + Load(), + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=20), + [ + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=21, + end_lineno=6, + end_col_offset=25)], + [], + lineno=6, + col_offset=11, + end_lineno=6, + end_col_offset=26), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=26)], + [], + lineno=1, + col_offset=0, + end_lineno=6, + end_col_offset=26)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-transpose/representation.txt b/test/practice-transpose/representation.txt new file mode 100644 index 0000000..3c0a175 --- /dev/null +++ b/test/practice-transpose/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=14, end_lineno=1, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_2', Store(), lineno=2, col_offset=4, end_lineno=2, end_col_offset=8)], ListComp(Call(Attribute(Name('placeholder_3', Load(), lineno=2, col_offset=12, end_lineno=2, end_col_offset=15), 'replace', Load(), lineno=2, col_offset=12, end_lineno=2, end_col_offset=23), [Constant(' ', lineno=2, col_offset=24, end_lineno=2, end_col_offset=27), Constant('_', lineno=2, col_offset=29, end_lineno=2, end_col_offset=32)], [], lineno=2, col_offset=12, end_lineno=2, end_col_offset=33), [comprehension(Name('placeholder_3', Store(), lineno=2, col_offset=38, end_lineno=2, end_col_offset=41), Call(Attribute(Name('placeholder_1', Load(), lineno=2, col_offset=45, end_lineno=2, end_col_offset=50), 'splitlines', Load(), lineno=2, col_offset=45, end_lineno=2, end_col_offset=61), [], [], lineno=2, col_offset=45, end_lineno=2, end_col_offset=63), [], 0)], lineno=2, col_offset=11, end_lineno=2, end_col_offset=64), lineno=2, col_offset=4, end_lineno=2, end_col_offset=64), Assign([Name('placeholder_2', Store(), lineno=3, col_offset=4, end_lineno=3, end_col_offset=8)], ListComp(Call(Attribute(Name('placeholder_3', Load(), lineno=3, col_offset=12, end_lineno=3, end_col_offset=15), 'ljust', Load(), lineno=3, col_offset=12, end_lineno=3, end_col_offset=21), [Call(Name('len', Load(), lineno=3, col_offset=22, end_lineno=3, end_col_offset=25), [Call(Name('max', Load(), lineno=3, col_offset=26, end_lineno=3, end_col_offset=29), [Name('placeholder_2', Load(), lineno=3, col_offset=30, end_lineno=3, end_col_offset=34)], [keyword('placeholder_5', Name('len', Load(), lineno=3, col_offset=40, end_lineno=3, end_col_offset=43), lineno=3, col_offset=36, end_lineno=3, end_col_offset=43)], lineno=3, col_offset=26, end_lineno=3, end_col_offset=44)], [], lineno=3, col_offset=22, end_lineno=3, end_col_offset=45)], [], lineno=3, col_offset=12, end_lineno=3, end_col_offset=46), [comprehension(Name('placeholder_3', Store(), lineno=3, col_offset=51, end_lineno=3, end_col_offset=54), Name('placeholder_2', Load(), lineno=3, col_offset=58, end_lineno=3, end_col_offset=62), [], 0)], lineno=3, col_offset=11, end_lineno=3, end_col_offset=63), lineno=3, col_offset=4, end_lineno=3, end_col_offset=63), Assign([Name('placeholder_2', Store(), lineno=4, col_offset=4, end_lineno=4, end_col_offset=8)], ListComp(Call(Attribute(Constant('', lineno=4, col_offset=12, end_lineno=4, end_col_offset=14), 'join', Load(), lineno=4, col_offset=12, end_lineno=4, end_col_offset=19), [Name('placeholder_3', Load(), lineno=4, col_offset=20, end_lineno=4, end_col_offset=23)], [], lineno=4, col_offset=12, end_lineno=4, end_col_offset=24), [comprehension(Name('placeholder_3', Store(), lineno=4, col_offset=29, end_lineno=4, end_col_offset=32), Call(Name('zip', Load(), lineno=4, col_offset=36, end_lineno=4, end_col_offset=39), [Starred(Name('placeholder_2', Load(), lineno=4, col_offset=41, end_lineno=4, end_col_offset=45), Load(), lineno=4, col_offset=40, end_lineno=4, end_col_offset=45)], [], lineno=4, col_offset=36, end_lineno=4, end_col_offset=46), [], 0)], lineno=4, col_offset=11, end_lineno=4, end_col_offset=47), lineno=4, col_offset=4, end_lineno=4, end_col_offset=47), Assign([Name('placeholder_2', Store(), lineno=5, col_offset=4, end_lineno=5, end_col_offset=8)], ListComp(Call(Attribute(Call(Attribute(Name('placeholder_3', Load(), lineno=5, col_offset=12, end_lineno=5, end_col_offset=15), 'rstrip', Load(), lineno=5, col_offset=12, end_lineno=5, end_col_offset=22), [], [], lineno=5, col_offset=12, end_lineno=5, end_col_offset=24), 'replace', Load(), lineno=5, col_offset=12, end_lineno=5, end_col_offset=32), [Constant('_', lineno=5, col_offset=33, end_lineno=5, end_col_offset=36), Constant(' ', lineno=5, col_offset=38, end_lineno=5, end_col_offset=41)], [], lineno=5, col_offset=12, end_lineno=5, end_col_offset=42), [comprehension(Name('placeholder_3', Store(), lineno=5, col_offset=47, end_lineno=5, end_col_offset=50), Name('placeholder_2', Load(), lineno=5, col_offset=54, end_lineno=5, end_col_offset=58), [], 0)], lineno=5, col_offset=11, end_lineno=5, end_col_offset=59), lineno=5, col_offset=4, end_lineno=5, end_col_offset=59), Return(Call(Attribute(Constant('\n', lineno=6, col_offset=11, end_lineno=6, end_col_offset=15), 'join', Load(), lineno=6, col_offset=11, end_lineno=6, end_col_offset=20), [Name('placeholder_2', Load(), lineno=6, col_offset=21, end_lineno=6, end_col_offset=25)], [], lineno=6, col_offset=11, end_lineno=6, end_col_offset=26), lineno=6, col_offset=4, end_lineno=6, end_col_offset=26)], [], lineno=1, col_offset=0, end_lineno=6, end_col_offset=26)], []) \ No newline at end of file diff --git a/test/practice-transpose/transpose.py b/test/practice-transpose/transpose.py new file mode 100644 index 0000000..cbb8e5f --- /dev/null +++ b/test/practice-transpose/transpose.py @@ -0,0 +1,6 @@ +def transpose(lines): + rows = [row.replace(' ', '_') for row in lines.splitlines()] + rows = [row.ljust(len(max(rows, key=len))) for row in rows] + rows = [''.join(row) for row in zip(*rows)] + rows = [row.rstrip().replace('_', ' ') for row in rows] + return '\n'.join(rows) diff --git a/test/practice-tree-building/.meta/config.json b/test/practice-tree-building/.meta/config.json new file mode 100644 index 0000000..00d1da4 --- /dev/null +++ b/test/practice-tree-building/.meta/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "clapmyhands" + ], + "contributors": [ + "cmccandless", + "Dog", + "N-Parsons", + "tqa236" + ], + "files": { + "solution": [ + "tree_building.py" + ], + "test": [ + "tree_building_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Refactor a tree building algorithm." +} diff --git a/test/practice-tree-building/mapping.json b/test/practice-tree-building/mapping.json new file mode 100644 index 0000000..d7b37a4 --- /dev/null +++ b/test/practice-tree-building/mapping.json @@ -0,0 +1,21 @@ +{ + "placeholder_0": "Record", + "placeholder_1": "__init__", + "placeholder_2": "record_id", + "placeholder_3": "parent_id", + "placeholder_4": "equal_id", + "placeholder_5": "Node", + "placeholder_6": "node_id", + "placeholder_7": "children", + "placeholder_8": "validate_record", + "placeholder_9": "record", + "placeholder_10": "BuildTree", + "placeholder_11": "records", + "placeholder_12": "parent_dict", + "placeholder_13": "node_dict", + "placeholder_14": "ordered_id", + "placeholder_15": "idx", + "placeholder_16": "root_id", + "placeholder_17": "root", + "placeholder_18": "index" +} \ No newline at end of file diff --git a/test/practice-tree-building/representation.json b/test/practice-tree-building/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-tree-building/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-tree-building/representation.out b/test/practice-tree-building/representation.out new file mode 100644 index 0000000..eebe690 --- /dev/null +++ b/test/practice-tree-building/representation.out @@ -0,0 +1,2165 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 + + def placeholder_4(self): + return self.placeholder_2 == self.placeholder_3 + + +class placeholder_5: + def placeholder_1(self, placeholder_6): + self.placeholder_6 = placeholder_6 + self.placeholder_7 = [] + + +def placeholder_8(placeholder_9): + if placeholder_9.placeholder_4() and placeholder_9.placeholder_2 != 0: + raise ValueError("Only root should have equal record and parent id.") + if ( + not placeholder_9.placeholder_4() + and placeholder_9.placeholder_3 >= placeholder_9.placeholder_2 + ): + raise ValueError("Node parent_id should be smaller than it's record_id.") + + +def placeholder_10(placeholder_11): + placeholder_12 = {} + placeholder_13 = {} + placeholder_14 = sorted( + (placeholder_15.placeholder_2 for placeholder_15 in placeholder_11) + ) + for placeholder_9 in placeholder_11: + placeholder_8(placeholder_9) + placeholder_12[placeholder_9.placeholder_2] = placeholder_9.placeholder_3 + placeholder_13[placeholder_9.placeholder_2] = placeholder_5( + placeholder_9.placeholder_2 + ) + placeholder_16 = 0 + placeholder_17 = None + for placeholder_18, placeholder_2 in enumerate(placeholder_14): + if placeholder_18 != placeholder_2: + raise ValueError("Record id is invalid or out of order.") + if placeholder_2 == placeholder_16: + placeholder_17 = placeholder_13[placeholder_2] + else: + placeholder_3 = placeholder_12[placeholder_2] + placeholder_13[placeholder_3].placeholder_7.append( + placeholder_13[placeholder_2] + ) + return placeholder_17 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Record', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'record_id', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=32), + arg( + 'parent_id', + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'record_id', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=22)], + Name( + 'record_id', + Load(), + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=34), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'parent_id', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=22)], + Name( + 'parent_id', + Load(), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=34), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=34)], + [], + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=34), + FunctionDef( + 'equal_id', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=19), + 'record_id', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=29), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=37), + 'parent_id', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=47)], + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=47), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=47)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=47)], + [], + lineno=1, + col_offset=0, + end_lineno=7, + end_col_offset=47), + ClassDef( + 'Node', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=21), + arg( + 'node_id', + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'node_id', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=20)], + Name( + 'node_id', + Load(), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=30), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=30), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'children', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=21)], + List( + [], + Load(), + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=26), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=26)], + [], + lineno=11, + col_offset=4, + end_lineno=13, + end_col_offset=26)], + [], + lineno=10, + col_offset=0, + end_lineno=13, + end_col_offset=26), + FunctionDef( + 'validate_record', + arguments( + [], + [ + arg( + 'record', + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'record', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=13), + 'equal_id', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=22), + [], + [], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=24), + Compare( + Attribute( + Name( + 'record', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=35), + 'record_id', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=45), + [ + NotEq()], + [ + Constant( + 0, + lineno=17, + col_offset=49, + end_lineno=17, + end_col_offset=50)], + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=50)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=50), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + Constant( + 'Only root should have equal record and parent id.', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=76)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=77), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=77)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=77), + If( + BoolOp( + And(), + [ + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'record', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=17), + 'equal_id', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=26), + [], + [], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=28), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=28), + Compare( + Attribute( + Name( + 'record', + Load(), + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=39), + 'parent_id', + Load(), + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=49), + [ + GtE()], + [ + Attribute( + Name( + 'record', + Load(), + lineno=20, + col_offset=53, + end_lineno=20, + end_col_offset=59), + 'record_id', + Load(), + lineno=20, + col_offset=53, + end_lineno=20, + end_col_offset=69)], + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=69)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=69), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=21, + col_offset=14, + end_lineno=21, + end_col_offset=24), + [ + Constant( + "Node parent_id should be smaller than it's record_id.", + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=80)], + [], + lineno=21, + col_offset=14, + end_lineno=21, + end_col_offset=81), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=81)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=81)], + [], + lineno=16, + col_offset=0, + end_lineno=21, + end_col_offset=81), + FunctionDef( + 'BuildTree', + arguments( + [], + [ + arg( + 'records', + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'parent_dict', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=15)], + Dict( + [], + [], + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=20), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=20), + Assign( + [ + Name( + 'node_dict', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=13)], + Dict( + [], + [], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=18), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=18), + Assign( + [ + Name( + 'ordered_id', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=14)], + Call( + Name( + 'sorted', + Load(), + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=23), + [ + GeneratorExp( + Attribute( + Name( + 'idx', + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=27), + 'record_id', + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=37), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=27, + col_offset=42, + end_lineno=27, + end_col_offset=45), + Name( + 'records', + Load(), + lineno=27, + col_offset=49, + end_lineno=27, + end_col_offset=56), + [], + 0)], + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=57)], + [], + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=57), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=57), + For( + Name( + 'record', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=14), + Name( + 'records', + Load(), + lineno=29, + col_offset=18, + end_lineno=29, + end_col_offset=25), + [ + Expr( + Call( + Name( + 'validate_record', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=23), + [ + Name( + 'record', + Load(), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=30)], + [], + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=31), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=31), + Assign( + [ + Subscript( + Name( + 'parent_dict', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=19), + Attribute( + Name( + 'record', + Load(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=26), + 'record_id', + Load(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=36), + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=37)], + Attribute( + Name( + 'record', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=46), + 'parent_id', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=56), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=56), + Assign( + [ + Subscript( + Name( + 'node_dict', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=17), + Attribute( + Name( + 'record', + Load(), + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=24), + 'record_id', + Load(), + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=34), + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=35)], + Call( + Name( + 'Node', + Load(), + lineno=32, + col_offset=38, + end_lineno=32, + end_col_offset=42), + [ + Attribute( + Name( + 'record', + Load(), + lineno=32, + col_offset=43, + end_lineno=32, + end_col_offset=49), + 'record_id', + Load(), + lineno=32, + col_offset=43, + end_lineno=32, + end_col_offset=59)], + [], + lineno=32, + col_offset=38, + end_lineno=32, + end_col_offset=60), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=60)], + [], + lineno=29, + col_offset=4, + end_lineno=32, + end_col_offset=60), + Assign( + [ + Name( + 'root_id', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=11)], + Constant( + 0, + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=15), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=15), + Assign( + [ + Name( + 'root', + Store(), + lineno=35, + col_offset=4, + end_lineno=35, + end_col_offset=8)], + Constant( + None, + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=15), + lineno=35, + col_offset=4, + end_lineno=35, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'index', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=13), + Name( + 'record_id', + Store(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=24)], + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=24), + Call( + Name( + 'enumerate', + Load(), + lineno=37, + col_offset=28, + end_lineno=37, + end_col_offset=37), + [ + Name( + 'ordered_id', + Load(), + lineno=37, + col_offset=38, + end_lineno=37, + end_col_offset=48)], + [], + lineno=37, + col_offset=28, + end_lineno=37, + end_col_offset=49), + [ + If( + Compare( + Name( + 'index', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=16), + [ + NotEq()], + [ + Name( + 'record_id', + Load(), + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=29)], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=29), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=39, + col_offset=18, + end_lineno=39, + end_col_offset=28), + [ + Constant( + 'Record id is invalid or out of order.', + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=68)], + [], + lineno=39, + col_offset=18, + end_lineno=39, + end_col_offset=69), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=69)], + [], + lineno=38, + col_offset=8, + end_lineno=39, + end_col_offset=69), + If( + Compare( + Name( + 'record_id', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=20), + [ + Eq()], + [ + Name( + 'root_id', + Load(), + lineno=41, + col_offset=24, + end_lineno=41, + end_col_offset=31)], + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=31), + [ + Assign( + [ + Name( + 'root', + Store(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=16)], + Subscript( + Name( + 'node_dict', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=28), + Name( + 'record_id', + Load(), + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=38), + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=39), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=39)], + [ + Assign( + [ + Name( + 'parent_id', + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=21)], + Subscript( + Name( + 'parent_dict', + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=35), + Name( + 'record_id', + Load(), + lineno=44, + col_offset=36, + end_lineno=44, + end_col_offset=45), + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=46), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=46), + Expr( + Call( + Attribute( + Attribute( + Subscript( + Name( + 'node_dict', + Load(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=21), + Name( + 'parent_id', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=31), + Load(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=32), + 'children', + Load(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=41), + 'append', + Load(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=48), + [ + Subscript( + Name( + 'node_dict', + Load(), + lineno=45, + col_offset=49, + end_lineno=45, + end_col_offset=58), + Name( + 'record_id', + Load(), + lineno=45, + col_offset=59, + end_lineno=45, + end_col_offset=68), + Load(), + lineno=45, + col_offset=49, + end_lineno=45, + end_col_offset=69)], + [], + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=70), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=70)], + lineno=41, + col_offset=8, + end_lineno=45, + end_col_offset=70)], + [], + lineno=37, + col_offset=4, + end_lineno=45, + end_col_offset=70), + Return( + Name( + 'root', + Load(), + lineno=47, + col_offset=11, + end_lineno=47, + end_col_offset=15), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=15)], + [], + lineno=24, + col_offset=0, + end_lineno=47, + end_col_offset=15)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=2, + col_offset=23, + end_lineno=2, + end_col_offset=32), + arg( + 'placeholder_3', + lineno=2, + col_offset=34, + end_lineno=2, + end_col_offset=43)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=22)], + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=25, + end_lineno=3, + end_col_offset=34), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=34), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=22)], + Name( + 'placeholder_3', + Load(), + lineno=4, + col_offset=25, + end_lineno=4, + end_col_offset=34), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=34)], + [], + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=34), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=29), + [ + Eq()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=37), + 'placeholder_3', + Load(), + lineno=7, + col_offset=33, + end_lineno=7, + end_col_offset=47)], + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=47), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=47)], + [], + lineno=6, + col_offset=4, + end_lineno=7, + end_col_offset=47)], + [], + lineno=1, + col_offset=0, + end_lineno=7, + end_col_offset=47), + ClassDef( + 'placeholder_5', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=11, + col_offset=17, + end_lineno=11, + end_col_offset=21), + arg( + 'placeholder_6', + lineno=11, + col_offset=23, + end_lineno=11, + end_col_offset=30)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=12), + 'placeholder_6', + Store(), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=20)], + Name( + 'placeholder_6', + Load(), + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=30), + lineno=12, + col_offset=8, + end_lineno=12, + end_col_offset=30), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=12), + 'placeholder_7', + Store(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=21)], + List( + [], + Load(), + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=26), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=26)], + [], + lineno=11, + col_offset=4, + end_lineno=13, + end_col_offset=26)], + [], + lineno=10, + col_offset=0, + end_lineno=13, + end_col_offset=26), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'placeholder_9', + lineno=16, + col_offset=20, + end_lineno=16, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BoolOp( + And(), + [ + Call( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=13), + 'placeholder_4', + Load(), + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=22), + [], + [], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=24), + Compare( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=35), + 'placeholder_2', + Load(), + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=45), + [ + NotEq()], + [ + Constant( + 0, + lineno=17, + col_offset=49, + end_lineno=17, + end_col_offset=50)], + lineno=17, + col_offset=29, + end_lineno=17, + end_col_offset=50)], + lineno=17, + col_offset=7, + end_lineno=17, + end_col_offset=50), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=24), + [ + Constant( + 'Only root should have equal record and parent id.', + lineno=18, + col_offset=25, + end_lineno=18, + end_col_offset=76)], + [], + lineno=18, + col_offset=14, + end_lineno=18, + end_col_offset=77), + lineno=18, + col_offset=8, + end_lineno=18, + end_col_offset=77)], + [], + lineno=17, + col_offset=4, + end_lineno=18, + end_col_offset=77), + If( + BoolOp( + And(), + [ + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=17), + 'placeholder_4', + Load(), + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=26), + [], + [], + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=28), + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=28), + Compare( + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=39), + 'placeholder_3', + Load(), + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=49), + [ + GtE()], + [ + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=20, + col_offset=53, + end_lineno=20, + end_col_offset=59), + 'placeholder_2', + Load(), + lineno=20, + col_offset=53, + end_lineno=20, + end_col_offset=69)], + lineno=20, + col_offset=33, + end_lineno=20, + end_col_offset=69)], + lineno=20, + col_offset=7, + end_lineno=20, + end_col_offset=69), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=21, + col_offset=14, + end_lineno=21, + end_col_offset=24), + [ + Constant( + "Node parent_id should be smaller than it's record_id.", + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=80)], + [], + lineno=21, + col_offset=14, + end_lineno=21, + end_col_offset=81), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=81)], + [], + lineno=20, + col_offset=4, + end_lineno=21, + end_col_offset=81)], + [], + lineno=16, + col_offset=0, + end_lineno=21, + end_col_offset=81), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_11', + lineno=24, + col_offset=14, + end_lineno=24, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=15)], + Dict( + [], + [], + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=20), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=20), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=13)], + Dict( + [], + [], + lineno=26, + col_offset=16, + end_lineno=26, + end_col_offset=18), + lineno=26, + col_offset=4, + end_lineno=26, + end_col_offset=18), + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=14)], + Call( + Name( + 'sorted', + Load(), + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=23), + [ + GeneratorExp( + Attribute( + Name( + 'placeholder_15', + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=27), + 'placeholder_2', + Load(), + lineno=27, + col_offset=24, + end_lineno=27, + end_col_offset=37), + [ + comprehension( + Name( + 'placeholder_15', + Store(), + lineno=27, + col_offset=42, + end_lineno=27, + end_col_offset=45), + Name( + 'placeholder_11', + Load(), + lineno=27, + col_offset=49, + end_lineno=27, + end_col_offset=56), + [], + 0)], + lineno=27, + col_offset=23, + end_lineno=27, + end_col_offset=57)], + [], + lineno=27, + col_offset=17, + end_lineno=27, + end_col_offset=57), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=57), + For( + Name( + 'placeholder_9', + Store(), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=14), + Name( + 'placeholder_11', + Load(), + lineno=29, + col_offset=18, + end_lineno=29, + end_col_offset=25), + [ + Expr( + Call( + Name( + 'placeholder_8', + Load(), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=23), + [ + Name( + 'placeholder_9', + Load(), + lineno=30, + col_offset=24, + end_lineno=30, + end_col_offset=30)], + [], + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=31), + lineno=30, + col_offset=8, + end_lineno=30, + end_col_offset=31), + Assign( + [ + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=19), + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=26), + 'placeholder_2', + Load(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=36), + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=37)], + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=46), + 'placeholder_3', + Load(), + lineno=31, + col_offset=40, + end_lineno=31, + end_col_offset=56), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=56), + Assign( + [ + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=17), + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=24), + 'placeholder_2', + Load(), + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=34), + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=35)], + Call( + Name( + 'placeholder_5', + Load(), + lineno=32, + col_offset=38, + end_lineno=32, + end_col_offset=42), + [ + Attribute( + Name( + 'placeholder_9', + Load(), + lineno=32, + col_offset=43, + end_lineno=32, + end_col_offset=49), + 'placeholder_2', + Load(), + lineno=32, + col_offset=43, + end_lineno=32, + end_col_offset=59)], + [], + lineno=32, + col_offset=38, + end_lineno=32, + end_col_offset=60), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=60)], + [], + lineno=29, + col_offset=4, + end_lineno=32, + end_col_offset=60), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=11)], + Constant( + 0, + lineno=34, + col_offset=14, + end_lineno=34, + end_col_offset=15), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=15), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=35, + col_offset=4, + end_lineno=35, + end_col_offset=8)], + Constant( + None, + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=15), + lineno=35, + col_offset=4, + end_lineno=35, + end_col_offset=15), + For( + Tuple( + [ + Name( + 'placeholder_18', + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=13), + Name( + 'placeholder_2', + Store(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=24)], + Store(), + lineno=37, + col_offset=8, + end_lineno=37, + end_col_offset=24), + Call( + Name( + 'enumerate', + Load(), + lineno=37, + col_offset=28, + end_lineno=37, + end_col_offset=37), + [ + Name( + 'placeholder_14', + Load(), + lineno=37, + col_offset=38, + end_lineno=37, + end_col_offset=48)], + [], + lineno=37, + col_offset=28, + end_lineno=37, + end_col_offset=49), + [ + If( + Compare( + Name( + 'placeholder_18', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=16), + [ + NotEq()], + [ + Name( + 'placeholder_2', + Load(), + lineno=38, + col_offset=20, + end_lineno=38, + end_col_offset=29)], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=29), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=39, + col_offset=18, + end_lineno=39, + end_col_offset=28), + [ + Constant( + 'Record id is invalid or out of order.', + lineno=39, + col_offset=29, + end_lineno=39, + end_col_offset=68)], + [], + lineno=39, + col_offset=18, + end_lineno=39, + end_col_offset=69), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=69)], + [], + lineno=38, + col_offset=8, + end_lineno=39, + end_col_offset=69), + If( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=20), + [ + Eq()], + [ + Name( + 'placeholder_16', + Load(), + lineno=41, + col_offset=24, + end_lineno=41, + end_col_offset=31)], + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=31), + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=16)], + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=28), + Name( + 'placeholder_2', + Load(), + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=38), + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=39), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=39)], + [ + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=21)], + Subscript( + Name( + 'placeholder_12', + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=35), + Name( + 'placeholder_2', + Load(), + lineno=44, + col_offset=36, + end_lineno=44, + end_col_offset=45), + Load(), + lineno=44, + col_offset=24, + end_lineno=44, + end_col_offset=46), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=46), + Expr( + Call( + Attribute( + Attribute( + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=21), + Name( + 'placeholder_3', + Load(), + lineno=45, + col_offset=22, + end_lineno=45, + end_col_offset=31), + Load(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=32), + 'placeholder_7', + Load(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=41), + 'append', + Load(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=48), + [ + Subscript( + Name( + 'placeholder_13', + Load(), + lineno=45, + col_offset=49, + end_lineno=45, + end_col_offset=58), + Name( + 'placeholder_2', + Load(), + lineno=45, + col_offset=59, + end_lineno=45, + end_col_offset=68), + Load(), + lineno=45, + col_offset=49, + end_lineno=45, + end_col_offset=69)], + [], + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=70), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=70)], + lineno=41, + col_offset=8, + end_lineno=45, + end_col_offset=70)], + [], + lineno=37, + col_offset=4, + end_lineno=45, + end_col_offset=70), + Return( + Name( + 'placeholder_17', + Load(), + lineno=47, + col_offset=11, + end_lineno=47, + end_col_offset=15), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=15)], + [], + lineno=24, + col_offset=0, + end_lineno=47, + end_col_offset=15)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-tree-building/representation.txt b/test/practice-tree-building/representation.txt new file mode 100644 index 0000000..458e5ee --- /dev/null +++ b/test/practice-tree-building/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), arg('placeholder_2', lineno=2, col_offset=23, end_lineno=2, end_col_offset=32), arg('placeholder_3', lineno=2, col_offset=34, end_lineno=2, end_col_offset=43)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), 'placeholder_2', Store(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=22)], Name('placeholder_2', Load(), lineno=3, col_offset=25, end_lineno=3, end_col_offset=34), lineno=3, col_offset=8, end_lineno=3, end_col_offset=34), Assign([Attribute(Name('self', Load(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=12), 'placeholder_3', Store(), lineno=4, col_offset=8, end_lineno=4, end_col_offset=22)], Name('placeholder_3', Load(), lineno=4, col_offset=25, end_lineno=4, end_col_offset=34), lineno=4, col_offset=8, end_lineno=4, end_col_offset=34)], [], lineno=2, col_offset=4, end_lineno=4, end_col_offset=34), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=6, col_offset=17, end_lineno=6, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Attribute(Name('self', Load(), lineno=7, col_offset=15, end_lineno=7, end_col_offset=19), 'placeholder_2', Load(), lineno=7, col_offset=15, end_lineno=7, end_col_offset=29), [Eq()], [Attribute(Name('self', Load(), lineno=7, col_offset=33, end_lineno=7, end_col_offset=37), 'placeholder_3', Load(), lineno=7, col_offset=33, end_lineno=7, end_col_offset=47)], lineno=7, col_offset=15, end_lineno=7, end_col_offset=47), lineno=7, col_offset=8, end_lineno=7, end_col_offset=47)], [], lineno=6, col_offset=4, end_lineno=7, end_col_offset=47)], [], lineno=1, col_offset=0, end_lineno=7, end_col_offset=47), ClassDef('placeholder_5', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=11, col_offset=17, end_lineno=11, end_col_offset=21), arg('placeholder_6', lineno=11, col_offset=23, end_lineno=11, end_col_offset=30)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=12), 'placeholder_6', Store(), lineno=12, col_offset=8, end_lineno=12, end_col_offset=20)], Name('placeholder_6', Load(), lineno=12, col_offset=23, end_lineno=12, end_col_offset=30), lineno=12, col_offset=8, end_lineno=12, end_col_offset=30), Assign([Attribute(Name('self', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=12), 'placeholder_7', Store(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=21)], List([], Load(), lineno=13, col_offset=24, end_lineno=13, end_col_offset=26), lineno=13, col_offset=8, end_lineno=13, end_col_offset=26)], [], lineno=11, col_offset=4, end_lineno=13, end_col_offset=26)], [], lineno=10, col_offset=0, end_lineno=13, end_col_offset=26), FunctionDef('placeholder_8', arguments([], [arg('placeholder_9', lineno=16, col_offset=20, end_lineno=16, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(BoolOp(And(), [Call(Attribute(Name('placeholder_9', Load(), lineno=17, col_offset=7, end_lineno=17, end_col_offset=13), 'placeholder_4', Load(), lineno=17, col_offset=7, end_lineno=17, end_col_offset=22), [], [], lineno=17, col_offset=7, end_lineno=17, end_col_offset=24), Compare(Attribute(Name('placeholder_9', Load(), lineno=17, col_offset=29, end_lineno=17, end_col_offset=35), 'placeholder_2', Load(), lineno=17, col_offset=29, end_lineno=17, end_col_offset=45), [NotEq()], [Constant(0, lineno=17, col_offset=49, end_lineno=17, end_col_offset=50)], lineno=17, col_offset=29, end_lineno=17, end_col_offset=50)], lineno=17, col_offset=7, end_lineno=17, end_col_offset=50), [Raise(Call(Name('ValueError', Load(), lineno=18, col_offset=14, end_lineno=18, end_col_offset=24), [Constant('Only root should have equal record and parent id.', lineno=18, col_offset=25, end_lineno=18, end_col_offset=76)], [], lineno=18, col_offset=14, end_lineno=18, end_col_offset=77), lineno=18, col_offset=8, end_lineno=18, end_col_offset=77)], [], lineno=17, col_offset=4, end_lineno=18, end_col_offset=77), If(BoolOp(And(), [UnaryOp(Not(), Call(Attribute(Name('placeholder_9', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=17), 'placeholder_4', Load(), lineno=20, col_offset=11, end_lineno=20, end_col_offset=26), [], [], lineno=20, col_offset=11, end_lineno=20, end_col_offset=28), lineno=20, col_offset=7, end_lineno=20, end_col_offset=28), Compare(Attribute(Name('placeholder_9', Load(), lineno=20, col_offset=33, end_lineno=20, end_col_offset=39), 'placeholder_3', Load(), lineno=20, col_offset=33, end_lineno=20, end_col_offset=49), [GtE()], [Attribute(Name('placeholder_9', Load(), lineno=20, col_offset=53, end_lineno=20, end_col_offset=59), 'placeholder_2', Load(), lineno=20, col_offset=53, end_lineno=20, end_col_offset=69)], lineno=20, col_offset=33, end_lineno=20, end_col_offset=69)], lineno=20, col_offset=7, end_lineno=20, end_col_offset=69), [Raise(Call(Name('ValueError', Load(), lineno=21, col_offset=14, end_lineno=21, end_col_offset=24), [Constant("Node parent_id should be smaller than it's record_id.", lineno=21, col_offset=25, end_lineno=21, end_col_offset=80)], [], lineno=21, col_offset=14, end_lineno=21, end_col_offset=81), lineno=21, col_offset=8, end_lineno=21, end_col_offset=81)], [], lineno=20, col_offset=4, end_lineno=21, end_col_offset=81)], [], lineno=16, col_offset=0, end_lineno=21, end_col_offset=81), FunctionDef('placeholder_10', arguments([], [arg('placeholder_11', lineno=24, col_offset=14, end_lineno=24, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_12', Store(), lineno=25, col_offset=4, end_lineno=25, end_col_offset=15)], Dict([], [], lineno=25, col_offset=18, end_lineno=25, end_col_offset=20), lineno=25, col_offset=4, end_lineno=25, end_col_offset=20), Assign([Name('placeholder_13', Store(), lineno=26, col_offset=4, end_lineno=26, end_col_offset=13)], Dict([], [], lineno=26, col_offset=16, end_lineno=26, end_col_offset=18), lineno=26, col_offset=4, end_lineno=26, end_col_offset=18), Assign([Name('placeholder_14', Store(), lineno=27, col_offset=4, end_lineno=27, end_col_offset=14)], Call(Name('sorted', Load(), lineno=27, col_offset=17, end_lineno=27, end_col_offset=23), [GeneratorExp(Attribute(Name('placeholder_15', Load(), lineno=27, col_offset=24, end_lineno=27, end_col_offset=27), 'placeholder_2', Load(), lineno=27, col_offset=24, end_lineno=27, end_col_offset=37), [comprehension(Name('placeholder_15', Store(), lineno=27, col_offset=42, end_lineno=27, end_col_offset=45), Name('placeholder_11', Load(), lineno=27, col_offset=49, end_lineno=27, end_col_offset=56), [], 0)], lineno=27, col_offset=23, end_lineno=27, end_col_offset=57)], [], lineno=27, col_offset=17, end_lineno=27, end_col_offset=57), lineno=27, col_offset=4, end_lineno=27, end_col_offset=57), For(Name('placeholder_9', Store(), lineno=29, col_offset=8, end_lineno=29, end_col_offset=14), Name('placeholder_11', Load(), lineno=29, col_offset=18, end_lineno=29, end_col_offset=25), [Expr(Call(Name('placeholder_8', Load(), lineno=30, col_offset=8, end_lineno=30, end_col_offset=23), [Name('placeholder_9', Load(), lineno=30, col_offset=24, end_lineno=30, end_col_offset=30)], [], lineno=30, col_offset=8, end_lineno=30, end_col_offset=31), lineno=30, col_offset=8, end_lineno=30, end_col_offset=31), Assign([Subscript(Name('placeholder_12', Load(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=19), Attribute(Name('placeholder_9', Load(), lineno=31, col_offset=20, end_lineno=31, end_col_offset=26), 'placeholder_2', Load(), lineno=31, col_offset=20, end_lineno=31, end_col_offset=36), Store(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=37)], Attribute(Name('placeholder_9', Load(), lineno=31, col_offset=40, end_lineno=31, end_col_offset=46), 'placeholder_3', Load(), lineno=31, col_offset=40, end_lineno=31, end_col_offset=56), lineno=31, col_offset=8, end_lineno=31, end_col_offset=56), Assign([Subscript(Name('placeholder_13', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=17), Attribute(Name('placeholder_9', Load(), lineno=32, col_offset=18, end_lineno=32, end_col_offset=24), 'placeholder_2', Load(), lineno=32, col_offset=18, end_lineno=32, end_col_offset=34), Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=35)], Call(Name('placeholder_5', Load(), lineno=32, col_offset=38, end_lineno=32, end_col_offset=42), [Attribute(Name('placeholder_9', Load(), lineno=32, col_offset=43, end_lineno=32, end_col_offset=49), 'placeholder_2', Load(), lineno=32, col_offset=43, end_lineno=32, end_col_offset=59)], [], lineno=32, col_offset=38, end_lineno=32, end_col_offset=60), lineno=32, col_offset=8, end_lineno=32, end_col_offset=60)], [], lineno=29, col_offset=4, end_lineno=32, end_col_offset=60), Assign([Name('placeholder_16', Store(), lineno=34, col_offset=4, end_lineno=34, end_col_offset=11)], Constant(0, lineno=34, col_offset=14, end_lineno=34, end_col_offset=15), lineno=34, col_offset=4, end_lineno=34, end_col_offset=15), Assign([Name('placeholder_17', Store(), lineno=35, col_offset=4, end_lineno=35, end_col_offset=8)], Constant(None, lineno=35, col_offset=11, end_lineno=35, end_col_offset=15), lineno=35, col_offset=4, end_lineno=35, end_col_offset=15), For(Tuple([Name('placeholder_18', Store(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=13), Name('placeholder_2', Store(), lineno=37, col_offset=15, end_lineno=37, end_col_offset=24)], Store(), lineno=37, col_offset=8, end_lineno=37, end_col_offset=24), Call(Name('enumerate', Load(), lineno=37, col_offset=28, end_lineno=37, end_col_offset=37), [Name('placeholder_14', Load(), lineno=37, col_offset=38, end_lineno=37, end_col_offset=48)], [], lineno=37, col_offset=28, end_lineno=37, end_col_offset=49), [If(Compare(Name('placeholder_18', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=16), [NotEq()], [Name('placeholder_2', Load(), lineno=38, col_offset=20, end_lineno=38, end_col_offset=29)], lineno=38, col_offset=11, end_lineno=38, end_col_offset=29), [Raise(Call(Name('ValueError', Load(), lineno=39, col_offset=18, end_lineno=39, end_col_offset=28), [Constant('Record id is invalid or out of order.', lineno=39, col_offset=29, end_lineno=39, end_col_offset=68)], [], lineno=39, col_offset=18, end_lineno=39, end_col_offset=69), lineno=39, col_offset=12, end_lineno=39, end_col_offset=69)], [], lineno=38, col_offset=8, end_lineno=39, end_col_offset=69), If(Compare(Name('placeholder_2', Load(), lineno=41, col_offset=11, end_lineno=41, end_col_offset=20), [Eq()], [Name('placeholder_16', Load(), lineno=41, col_offset=24, end_lineno=41, end_col_offset=31)], lineno=41, col_offset=11, end_lineno=41, end_col_offset=31), [Assign([Name('placeholder_17', Store(), lineno=42, col_offset=12, end_lineno=42, end_col_offset=16)], Subscript(Name('placeholder_13', Load(), lineno=42, col_offset=19, end_lineno=42, end_col_offset=28), Name('placeholder_2', Load(), lineno=42, col_offset=29, end_lineno=42, end_col_offset=38), Load(), lineno=42, col_offset=19, end_lineno=42, end_col_offset=39), lineno=42, col_offset=12, end_lineno=42, end_col_offset=39)], [Assign([Name('placeholder_3', Store(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=21)], Subscript(Name('placeholder_12', Load(), lineno=44, col_offset=24, end_lineno=44, end_col_offset=35), Name('placeholder_2', Load(), lineno=44, col_offset=36, end_lineno=44, end_col_offset=45), Load(), lineno=44, col_offset=24, end_lineno=44, end_col_offset=46), lineno=44, col_offset=12, end_lineno=44, end_col_offset=46), Expr(Call(Attribute(Attribute(Subscript(Name('placeholder_13', Load(), lineno=45, col_offset=12, end_lineno=45, end_col_offset=21), Name('placeholder_3', Load(), lineno=45, col_offset=22, end_lineno=45, end_col_offset=31), Load(), lineno=45, col_offset=12, end_lineno=45, end_col_offset=32), 'placeholder_7', Load(), lineno=45, col_offset=12, end_lineno=45, end_col_offset=41), 'append', Load(), lineno=45, col_offset=12, end_lineno=45, end_col_offset=48), [Subscript(Name('placeholder_13', Load(), lineno=45, col_offset=49, end_lineno=45, end_col_offset=58), Name('placeholder_2', Load(), lineno=45, col_offset=59, end_lineno=45, end_col_offset=68), Load(), lineno=45, col_offset=49, end_lineno=45, end_col_offset=69)], [], lineno=45, col_offset=12, end_lineno=45, end_col_offset=70), lineno=45, col_offset=12, end_lineno=45, end_col_offset=70)], lineno=41, col_offset=8, end_lineno=45, end_col_offset=70)], [], lineno=37, col_offset=4, end_lineno=45, end_col_offset=70), Return(Name('placeholder_17', Load(), lineno=47, col_offset=11, end_lineno=47, end_col_offset=15), lineno=47, col_offset=4, end_lineno=47, end_col_offset=15)], [], lineno=24, col_offset=0, end_lineno=47, end_col_offset=15)], []) \ No newline at end of file diff --git a/test/practice-tree-building/tree_building.py b/test/practice-tree-building/tree_building.py new file mode 100644 index 0000000..e3929ea --- /dev/null +++ b/test/practice-tree-building/tree_building.py @@ -0,0 +1,47 @@ +class Record: + def __init__(self, record_id, parent_id): + self.record_id = record_id + self.parent_id = parent_id + + def equal_id(self): + return self.record_id == self.parent_id + + +class Node: + def __init__(self, node_id): + self.node_id = node_id + self.children = [] + + +def validate_record(record): + if record.equal_id() and record.record_id != 0: + raise ValueError('Only root should have equal record and parent id.') + + if not record.equal_id() and record.parent_id >= record.record_id: + raise ValueError("Node parent_id should be smaller than it's record_id.") + + +def BuildTree(records): + parent_dict = {} + node_dict = {} + ordered_id = sorted(idx.record_id for idx in records) + + for record in records: + validate_record(record) + parent_dict[record.record_id] = record.parent_id + node_dict[record.record_id] = Node(record.record_id) + + root_id = 0 + root = None + + for index, record_id in enumerate(ordered_id): + if index != record_id: + raise ValueError('Record id is invalid or out of order.') + + if record_id == root_id: + root = node_dict[record_id] + else: + parent_id = parent_dict[record_id] + node_dict[parent_id].children.append(node_dict[record_id]) + + return root diff --git a/test/practice-triangle/.meta/config.json b/test/practice-triangle/.meta/config.json new file mode 100644 index 0000000..041bf28 --- /dev/null +++ b/test/practice-triangle/.meta/config.json @@ -0,0 +1,36 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "lowks", + "mpatibandla", + "N-Parsons", + "Nishant23", + "pheanex", + "rozuur", + "sjakobi", + "Stigjb", + "tqa236", + "xitanggg", + "YuriyCherniy" + ], + "files": { + "solution": [ + "triangle.py" + ], + "test": [ + "triangle_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Determine if a triangle is equilateral, isosceles, or scalene.", + "source": "The Ruby Koans triangle project, parts 1 & 2", + "source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com" +} diff --git a/test/practice-triangle/mapping.json b/test/practice-triangle/mapping.json new file mode 100644 index 0000000..400db86 --- /dev/null +++ b/test/practice-triangle/mapping.json @@ -0,0 +1,10 @@ +{ + "placeholder_0": "valid", + "placeholder_1": "sides", + "placeholder_2": "side", + "placeholder_3": "equilateral", + "placeholder_4": "isosceles", + "placeholder_5": "side_1", + "placeholder_6": "side_2", + "placeholder_7": "scalene" +} \ No newline at end of file diff --git a/test/practice-triangle/representation.json b/test/practice-triangle/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-triangle/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-triangle/representation.out b/test/practice-triangle/representation.out new file mode 100644 index 0000000..dab8806 --- /dev/null +++ b/test/practice-triangle/representation.out @@ -0,0 +1,1198 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1): + return sum(sorted(placeholder_1)[:2]) >= sorted(placeholder_1)[2] and all( + (placeholder_2 > 0 for placeholder_2 in placeholder_1) + ) + + +def placeholder_3(placeholder_1): + return placeholder_0(placeholder_1) and all( + (placeholder_1[0] == placeholder_2 for placeholder_2 in placeholder_1) + ) + + +def placeholder_4(placeholder_1): + return placeholder_0(placeholder_1) and any( + ( + placeholder_5 == placeholder_6 + for placeholder_5, placeholder_6 in zip( + sorted(placeholder_1), sorted(placeholder_1)[1:] + ) + ) + ) + + +def placeholder_7(placeholder_1): + return placeholder_0(placeholder_1) and (not placeholder_4(placeholder_1)) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'valid', + arguments( + [], + [ + arg( + 'sides', + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + Subscript( + Call( + Name( + 'sorted', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=21), + [ + Name( + 'sides', + Load(), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=27)], + [], + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=28), + Slice( + upper=Constant( + 2, + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=31), + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=32)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=33), + [ + GtE()], + [ + Subscript( + Call( + Name( + 'sorted', + Load(), + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=43), + [ + Name( + 'sides', + Load(), + lineno=2, + col_offset=44, + end_lineno=2, + end_col_offset=49)], + [], + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=50), + Constant( + 2, + lineno=2, + col_offset=51, + end_lineno=2, + end_col_offset=52), + Load(), + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=53)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=53), + Call( + Name( + 'all', + Load(), + lineno=2, + col_offset=58, + end_lineno=2, + end_col_offset=61), + [ + GeneratorExp( + Compare( + Name( + 'side', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + [ + Gt()], + [ + Constant( + 0, + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=16)], + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=16), + [ + comprehension( + Name( + 'side', + Store(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=25), + Name( + 'sides', + Load(), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=34), + [], + 0)], + lineno=2, + col_offset=61, + end_lineno=4, + end_col_offset=5)], + [], + lineno=2, + col_offset=58, + end_lineno=4, + end_col_offset=5)], + lineno=2, + col_offset=11, + end_lineno=4, + end_col_offset=5), + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=5)], + [], + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=5), + FunctionDef( + 'equilateral', + arguments( + [], + [ + arg( + 'sides', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Call( + Name( + 'valid', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=16), + [ + Name( + 'sides', + Load(), + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=22)], + [], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=23), + Call( + Name( + 'all', + Load(), + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=31), + [ + GeneratorExp( + Compare( + Subscript( + Name( + 'sides', + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=37), + Constant( + 0, + lineno=8, + col_offset=38, + end_lineno=8, + end_col_offset=39), + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=40), + [ + Eq()], + [ + Name( + 'side', + Load(), + lineno=8, + col_offset=44, + end_lineno=8, + end_col_offset=48)], + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=48), + [ + comprehension( + Name( + 'side', + Store(), + lineno=8, + col_offset=53, + end_lineno=8, + end_col_offset=57), + Name( + 'sides', + Load(), + lineno=8, + col_offset=61, + end_lineno=8, + end_col_offset=66), + [], + 0)], + lineno=8, + col_offset=31, + end_lineno=8, + end_col_offset=67)], + [], + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=67)], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=67), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=67)], + [], + lineno=7, + col_offset=0, + end_lineno=8, + end_col_offset=67), + FunctionDef( + 'isosceles', + arguments( + [], + [ + arg( + 'sides', + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Call( + Name( + 'valid', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=16), + [ + Name( + 'sides', + Load(), + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=22)], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=23), + Call( + Name( + 'any', + Load(), + lineno=12, + col_offset=28, + end_lineno=12, + end_col_offset=31), + [ + GeneratorExp( + Compare( + Name( + 'side_1', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=14), + [ + Eq()], + [ + Name( + 'side_2', + Load(), + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=24)], + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=24), + [ + comprehension( + Tuple( + [ + Name( + 'side_1', + Store(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=35), + Name( + 'side_2', + Store(), + lineno=13, + col_offset=37, + end_lineno=13, + end_col_offset=43)], + Store(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=43), + Call( + Name( + 'zip', + Load(), + lineno=13, + col_offset=47, + end_lineno=13, + end_col_offset=50), + [ + Call( + Name( + 'sorted', + Load(), + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=57), + [ + Name( + 'sides', + Load(), + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=63)], + [], + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=64), + Subscript( + Call( + Name( + 'sorted', + Load(), + lineno=13, + col_offset=66, + end_lineno=13, + end_col_offset=72), + [ + Name( + 'sides', + Load(), + lineno=13, + col_offset=73, + end_lineno=13, + end_col_offset=78)], + [], + lineno=13, + col_offset=66, + end_lineno=13, + end_col_offset=79), + Slice( + Constant( + 1, + lineno=13, + col_offset=80, + end_lineno=13, + end_col_offset=81), + lineno=13, + col_offset=80, + end_lineno=13, + end_col_offset=82), + Load(), + lineno=13, + col_offset=66, + end_lineno=13, + end_col_offset=83)], + [], + lineno=13, + col_offset=47, + end_lineno=13, + end_col_offset=84), + [], + 0)], + lineno=12, + col_offset=31, + end_lineno=14, + end_col_offset=5)], + [], + lineno=12, + col_offset=28, + end_lineno=14, + end_col_offset=5)], + lineno=12, + col_offset=11, + end_lineno=14, + end_col_offset=5), + lineno=12, + col_offset=4, + end_lineno=14, + end_col_offset=5)], + [], + lineno=11, + col_offset=0, + end_lineno=14, + end_col_offset=5), + FunctionDef( + 'scalene', + arguments( + [], + [ + arg( + 'sides', + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Call( + Name( + 'valid', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=16), + [ + Name( + 'sides', + Load(), + lineno=18, + col_offset=17, + end_lineno=18, + end_col_offset=22)], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=23), + UnaryOp( + Not(), + Call( + Name( + 'isosceles', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=41), + [ + Name( + 'sides', + Load(), + lineno=18, + col_offset=42, + end_lineno=18, + end_col_offset=47)], + [], + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=48), + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=48)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=48), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=48)], + [], + lineno=17, + col_offset=0, + end_lineno=18, + end_col_offset=48)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=10, + end_lineno=1, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Call( + Name( + 'sum', + Load(), + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=14), + [ + Subscript( + Call( + Name( + 'sorted', + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=21), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=27)], + [], + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=28), + Slice( + upper=Constant( + 2, + lineno=2, + col_offset=30, + end_lineno=2, + end_col_offset=31), + lineno=2, + col_offset=29, + end_lineno=2, + end_col_offset=31), + Load(), + lineno=2, + col_offset=15, + end_lineno=2, + end_col_offset=32)], + [], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=33), + [ + GtE()], + [ + Subscript( + Call( + Name( + 'sorted', + Load(), + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=43), + [ + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=44, + end_lineno=2, + end_col_offset=49)], + [], + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=50), + Constant( + 2, + lineno=2, + col_offset=51, + end_lineno=2, + end_col_offset=52), + Load(), + lineno=2, + col_offset=37, + end_lineno=2, + end_col_offset=53)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=53), + Call( + Name( + 'all', + Load(), + lineno=2, + col_offset=58, + end_lineno=2, + end_col_offset=61), + [ + GeneratorExp( + Compare( + Name( + 'placeholder_2', + Load(), + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=12), + [ + Gt()], + [ + Constant( + 0, + lineno=3, + col_offset=15, + end_lineno=3, + end_col_offset=16)], + lineno=3, + col_offset=8, + end_lineno=3, + end_col_offset=16), + [ + comprehension( + Name( + 'placeholder_2', + Store(), + lineno=3, + col_offset=21, + end_lineno=3, + end_col_offset=25), + Name( + 'placeholder_1', + Load(), + lineno=3, + col_offset=29, + end_lineno=3, + end_col_offset=34), + [], + 0)], + lineno=2, + col_offset=61, + end_lineno=4, + end_col_offset=5)], + [], + lineno=2, + col_offset=58, + end_lineno=4, + end_col_offset=5)], + lineno=2, + col_offset=11, + end_lineno=4, + end_col_offset=5), + lineno=2, + col_offset=4, + end_lineno=4, + end_col_offset=5)], + [], + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=5), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=7, + col_offset=16, + end_lineno=7, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=16), + [ + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=17, + end_lineno=8, + end_col_offset=22)], + [], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=23), + Call( + Name( + 'all', + Load(), + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=31), + [ + GeneratorExp( + Compare( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=37), + Constant( + 0, + lineno=8, + col_offset=38, + end_lineno=8, + end_col_offset=39), + Load(), + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=40), + [ + Eq()], + [ + Name( + 'placeholder_2', + Load(), + lineno=8, + col_offset=44, + end_lineno=8, + end_col_offset=48)], + lineno=8, + col_offset=32, + end_lineno=8, + end_col_offset=48), + [ + comprehension( + Name( + 'placeholder_2', + Store(), + lineno=8, + col_offset=53, + end_lineno=8, + end_col_offset=57), + Name( + 'placeholder_1', + Load(), + lineno=8, + col_offset=61, + end_lineno=8, + end_col_offset=66), + [], + 0)], + lineno=8, + col_offset=31, + end_lineno=8, + end_col_offset=67)], + [], + lineno=8, + col_offset=28, + end_lineno=8, + end_col_offset=67)], + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=67), + lineno=8, + col_offset=4, + end_lineno=8, + end_col_offset=67)], + [], + lineno=7, + col_offset=0, + end_lineno=8, + end_col_offset=67), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=11, + col_offset=14, + end_lineno=11, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=16), + [ + Name( + 'placeholder_1', + Load(), + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=22)], + [], + lineno=12, + col_offset=11, + end_lineno=12, + end_col_offset=23), + Call( + Name( + 'any', + Load(), + lineno=12, + col_offset=28, + end_lineno=12, + end_col_offset=31), + [ + GeneratorExp( + Compare( + Name( + 'placeholder_5', + Load(), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=14), + [ + Eq()], + [ + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=24)], + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=24), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_5', + Store(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=35), + Name( + 'placeholder_6', + Store(), + lineno=13, + col_offset=37, + end_lineno=13, + end_col_offset=43)], + Store(), + lineno=13, + col_offset=29, + end_lineno=13, + end_col_offset=43), + Call( + Name( + 'zip', + Load(), + lineno=13, + col_offset=47, + end_lineno=13, + end_col_offset=50), + [ + Call( + Name( + 'sorted', + Load(), + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=57), + [ + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=58, + end_lineno=13, + end_col_offset=63)], + [], + lineno=13, + col_offset=51, + end_lineno=13, + end_col_offset=64), + Subscript( + Call( + Name( + 'sorted', + Load(), + lineno=13, + col_offset=66, + end_lineno=13, + end_col_offset=72), + [ + Name( + 'placeholder_1', + Load(), + lineno=13, + col_offset=73, + end_lineno=13, + end_col_offset=78)], + [], + lineno=13, + col_offset=66, + end_lineno=13, + end_col_offset=79), + Slice( + Constant( + 1, + lineno=13, + col_offset=80, + end_lineno=13, + end_col_offset=81), + lineno=13, + col_offset=80, + end_lineno=13, + end_col_offset=82), + Load(), + lineno=13, + col_offset=66, + end_lineno=13, + end_col_offset=83)], + [], + lineno=13, + col_offset=47, + end_lineno=13, + end_col_offset=84), + [], + 0)], + lineno=12, + col_offset=31, + end_lineno=14, + end_col_offset=5)], + [], + lineno=12, + col_offset=28, + end_lineno=14, + end_col_offset=5)], + lineno=12, + col_offset=11, + end_lineno=14, + end_col_offset=5), + lineno=12, + col_offset=4, + end_lineno=14, + end_col_offset=5)], + [], + lineno=11, + col_offset=0, + end_lineno=14, + end_col_offset=5), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=17, + col_offset=12, + end_lineno=17, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=16), + [ + Name( + 'placeholder_1', + Load(), + lineno=18, + col_offset=17, + end_lineno=18, + end_col_offset=22)], + [], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=23), + UnaryOp( + Not(), + Call( + Name( + 'placeholder_4', + Load(), + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=41), + [ + Name( + 'placeholder_1', + Load(), + lineno=18, + col_offset=42, + end_lineno=18, + end_col_offset=47)], + [], + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=48), + lineno=18, + col_offset=28, + end_lineno=18, + end_col_offset=48)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=48), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=48)], + [], + lineno=17, + col_offset=0, + end_lineno=18, + end_col_offset=48)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-triangle/representation.txt b/test/practice-triangle/representation.txt new file mode 100644 index 0000000..1bf7a8d --- /dev/null +++ b/test/practice-triangle/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=10, end_lineno=1, end_col_offset=15)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Call(Name('sum', Load(), lineno=2, col_offset=11, end_lineno=2, end_col_offset=14), [Subscript(Call(Name('sorted', Load(), lineno=2, col_offset=15, end_lineno=2, end_col_offset=21), [Name('placeholder_1', Load(), lineno=2, col_offset=22, end_lineno=2, end_col_offset=27)], [], lineno=2, col_offset=15, end_lineno=2, end_col_offset=28), Slice(upper=Constant(2, lineno=2, col_offset=30, end_lineno=2, end_col_offset=31), lineno=2, col_offset=29, end_lineno=2, end_col_offset=31), Load(), lineno=2, col_offset=15, end_lineno=2, end_col_offset=32)], [], lineno=2, col_offset=11, end_lineno=2, end_col_offset=33), [GtE()], [Subscript(Call(Name('sorted', Load(), lineno=2, col_offset=37, end_lineno=2, end_col_offset=43), [Name('placeholder_1', Load(), lineno=2, col_offset=44, end_lineno=2, end_col_offset=49)], [], lineno=2, col_offset=37, end_lineno=2, end_col_offset=50), Constant(2, lineno=2, col_offset=51, end_lineno=2, end_col_offset=52), Load(), lineno=2, col_offset=37, end_lineno=2, end_col_offset=53)], lineno=2, col_offset=11, end_lineno=2, end_col_offset=53), Call(Name('all', Load(), lineno=2, col_offset=58, end_lineno=2, end_col_offset=61), [GeneratorExp(Compare(Name('placeholder_2', Load(), lineno=3, col_offset=8, end_lineno=3, end_col_offset=12), [Gt()], [Constant(0, lineno=3, col_offset=15, end_lineno=3, end_col_offset=16)], lineno=3, col_offset=8, end_lineno=3, end_col_offset=16), [comprehension(Name('placeholder_2', Store(), lineno=3, col_offset=21, end_lineno=3, end_col_offset=25), Name('placeholder_1', Load(), lineno=3, col_offset=29, end_lineno=3, end_col_offset=34), [], 0)], lineno=2, col_offset=61, end_lineno=4, end_col_offset=5)], [], lineno=2, col_offset=58, end_lineno=4, end_col_offset=5)], lineno=2, col_offset=11, end_lineno=4, end_col_offset=5), lineno=2, col_offset=4, end_lineno=4, end_col_offset=5)], [], lineno=1, col_offset=0, end_lineno=4, end_col_offset=5), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=7, col_offset=16, end_lineno=7, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Call(Name('placeholder_0', Load(), lineno=8, col_offset=11, end_lineno=8, end_col_offset=16), [Name('placeholder_1', Load(), lineno=8, col_offset=17, end_lineno=8, end_col_offset=22)], [], lineno=8, col_offset=11, end_lineno=8, end_col_offset=23), Call(Name('all', Load(), lineno=8, col_offset=28, end_lineno=8, end_col_offset=31), [GeneratorExp(Compare(Subscript(Name('placeholder_1', Load(), lineno=8, col_offset=32, end_lineno=8, end_col_offset=37), Constant(0, lineno=8, col_offset=38, end_lineno=8, end_col_offset=39), Load(), lineno=8, col_offset=32, end_lineno=8, end_col_offset=40), [Eq()], [Name('placeholder_2', Load(), lineno=8, col_offset=44, end_lineno=8, end_col_offset=48)], lineno=8, col_offset=32, end_lineno=8, end_col_offset=48), [comprehension(Name('placeholder_2', Store(), lineno=8, col_offset=53, end_lineno=8, end_col_offset=57), Name('placeholder_1', Load(), lineno=8, col_offset=61, end_lineno=8, end_col_offset=66), [], 0)], lineno=8, col_offset=31, end_lineno=8, end_col_offset=67)], [], lineno=8, col_offset=28, end_lineno=8, end_col_offset=67)], lineno=8, col_offset=11, end_lineno=8, end_col_offset=67), lineno=8, col_offset=4, end_lineno=8, end_col_offset=67)], [], lineno=7, col_offset=0, end_lineno=8, end_col_offset=67), FunctionDef('placeholder_4', arguments([], [arg('placeholder_1', lineno=11, col_offset=14, end_lineno=11, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Call(Name('placeholder_0', Load(), lineno=12, col_offset=11, end_lineno=12, end_col_offset=16), [Name('placeholder_1', Load(), lineno=12, col_offset=17, end_lineno=12, end_col_offset=22)], [], lineno=12, col_offset=11, end_lineno=12, end_col_offset=23), Call(Name('any', Load(), lineno=12, col_offset=28, end_lineno=12, end_col_offset=31), [GeneratorExp(Compare(Name('placeholder_5', Load(), lineno=13, col_offset=8, end_lineno=13, end_col_offset=14), [Eq()], [Name('placeholder_6', Load(), lineno=13, col_offset=18, end_lineno=13, end_col_offset=24)], lineno=13, col_offset=8, end_lineno=13, end_col_offset=24), [comprehension(Tuple([Name('placeholder_5', Store(), lineno=13, col_offset=29, end_lineno=13, end_col_offset=35), Name('placeholder_6', Store(), lineno=13, col_offset=37, end_lineno=13, end_col_offset=43)], Store(), lineno=13, col_offset=29, end_lineno=13, end_col_offset=43), Call(Name('zip', Load(), lineno=13, col_offset=47, end_lineno=13, end_col_offset=50), [Call(Name('sorted', Load(), lineno=13, col_offset=51, end_lineno=13, end_col_offset=57), [Name('placeholder_1', Load(), lineno=13, col_offset=58, end_lineno=13, end_col_offset=63)], [], lineno=13, col_offset=51, end_lineno=13, end_col_offset=64), Subscript(Call(Name('sorted', Load(), lineno=13, col_offset=66, end_lineno=13, end_col_offset=72), [Name('placeholder_1', Load(), lineno=13, col_offset=73, end_lineno=13, end_col_offset=78)], [], lineno=13, col_offset=66, end_lineno=13, end_col_offset=79), Slice(Constant(1, lineno=13, col_offset=80, end_lineno=13, end_col_offset=81), lineno=13, col_offset=80, end_lineno=13, end_col_offset=82), Load(), lineno=13, col_offset=66, end_lineno=13, end_col_offset=83)], [], lineno=13, col_offset=47, end_lineno=13, end_col_offset=84), [], 0)], lineno=12, col_offset=31, end_lineno=14, end_col_offset=5)], [], lineno=12, col_offset=28, end_lineno=14, end_col_offset=5)], lineno=12, col_offset=11, end_lineno=14, end_col_offset=5), lineno=12, col_offset=4, end_lineno=14, end_col_offset=5)], [], lineno=11, col_offset=0, end_lineno=14, end_col_offset=5), FunctionDef('placeholder_7', arguments([], [arg('placeholder_1', lineno=17, col_offset=12, end_lineno=17, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Call(Name('placeholder_0', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=16), [Name('placeholder_1', Load(), lineno=18, col_offset=17, end_lineno=18, end_col_offset=22)], [], lineno=18, col_offset=11, end_lineno=18, end_col_offset=23), UnaryOp(Not(), Call(Name('placeholder_4', Load(), lineno=18, col_offset=32, end_lineno=18, end_col_offset=41), [Name('placeholder_1', Load(), lineno=18, col_offset=42, end_lineno=18, end_col_offset=47)], [], lineno=18, col_offset=32, end_lineno=18, end_col_offset=48), lineno=18, col_offset=28, end_lineno=18, end_col_offset=48)], lineno=18, col_offset=11, end_lineno=18, end_col_offset=48), lineno=18, col_offset=4, end_lineno=18, end_col_offset=48)], [], lineno=17, col_offset=0, end_lineno=18, end_col_offset=48)], []) \ No newline at end of file diff --git a/test/practice-triangle/triangle.py b/test/practice-triangle/triangle.py new file mode 100644 index 0000000..10c0646 --- /dev/null +++ b/test/practice-triangle/triangle.py @@ -0,0 +1,18 @@ +def valid(sides): + return sum(sorted(sides)[:2]) >= sorted(sides)[2] and all( + side > 0 for side in sides + ) + + +def equilateral(sides): + return valid(sides) and all(sides[0] == side for side in sides) + + +def isosceles(sides): + return valid(sides) and any( + side_1 == side_2 for side_1, side_2 in zip(sorted(sides), sorted(sides)[1:]) + ) + + +def scalene(sides): + return valid(sides) and not isosceles(sides) diff --git a/test/practice-trinary/.meta/config.json b/test/practice-trinary/.meta/config.json new file mode 100644 index 0000000..da59ec6 --- /dev/null +++ b/test/practice-trinary/.meta/config.json @@ -0,0 +1,30 @@ +{ + "blurb": "Convert a trinary number, represented as a string (e.g. '102012'), to its decimal equivalent using first principles.", + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "cmccandless", + "Dog", + "ikhadykin", + "kytrinyx", + "N-Parsons", + "pheanex", + "sjakobi", + "tqa236" + ], + "files": { + "solution": [ + "trinary.py" + ], + "test": [ + "trinary_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "source": "All of Computer Science", + "source_url": "https://www.wolframalpha.com/examples/mathematics/numbers/base-conversions" +} diff --git a/test/practice-trinary/mapping.json b/test/practice-trinary/mapping.json new file mode 100644 index 0000000..0f5f4a8 --- /dev/null +++ b/test/practice-trinary/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "trinary", + "placeholder_1": "string", + "placeholder_2": "idx", + "placeholder_3": "edx" +} \ No newline at end of file diff --git a/test/practice-trinary/representation.json b/test/practice-trinary/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-trinary/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-trinary/representation.out b/test/practice-trinary/representation.out new file mode 100644 index 0000000..7317235 --- /dev/null +++ b/test/practice-trinary/representation.out @@ -0,0 +1,426 @@ +## BEGIN NORMALIZED CODE ## +from functools import reduce + + +def placeholder_0(placeholder_1): + if set(placeholder_1) - set("012"): + return 0 + return reduce( + lambda placeholder_2, placeholder_3: placeholder_2 * 3 + int(placeholder_3), + placeholder_1, + 0, + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'functools', + [ + alias( + 'reduce', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=28)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=28), + FunctionDef( + 'trinary', + arguments( + [], + [ + arg( + 'string', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BinOp( + Call( + Name( + 'set', + Load(), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=10), + [ + Name( + 'string', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17)], + [], + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=18), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + [ + Constant( + '012', + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=30)], + [], + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=31), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=31), + [ + Return( + Constant( + 0, + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=16), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=16)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=16), + Return( + Call( + Name( + 'reduce', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=17), + [ + Lambda( + arguments( + [], + [ + arg( + 'idx', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=28), + arg( + 'edx', + lineno=7, + col_offset=30, + end_lineno=7, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + BinOp( + BinOp( + Name( + 'idx', + Load(), + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=38), + Mult(), + Constant( + 3, + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=42), + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=42), + Add(), + Call( + Name( + 'int', + Load(), + lineno=7, + col_offset=45, + end_lineno=7, + end_col_offset=48), + [ + Name( + 'edx', + Load(), + lineno=7, + col_offset=49, + end_lineno=7, + end_col_offset=52)], + [], + lineno=7, + col_offset=45, + end_lineno=7, + end_col_offset=53), + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=53), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=53), + Name( + 'string', + Load(), + lineno=7, + col_offset=55, + end_lineno=7, + end_col_offset=61), + Constant( + 0, + lineno=7, + col_offset=63, + end_lineno=7, + end_col_offset=64)], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=65), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=65)], + [], + lineno=4, + col_offset=0, + end_lineno=7, + end_col_offset=65)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'functools', + [ + alias( + 'reduce', + lineno=1, + col_offset=22, + end_lineno=1, + end_col_offset=28)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=28), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=4, + col_offset=12, + end_lineno=4, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BinOp( + Call( + Name( + 'set', + Load(), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=10), + [ + Name( + 'placeholder_1', + Load(), + lineno=5, + col_offset=11, + end_lineno=5, + end_col_offset=17)], + [], + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=18), + Sub(), + Call( + Name( + 'set', + Load(), + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=24), + [ + Constant( + '012', + lineno=5, + col_offset=25, + end_lineno=5, + end_col_offset=30)], + [], + lineno=5, + col_offset=21, + end_lineno=5, + end_col_offset=31), + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=31), + [ + Return( + Constant( + 0, + lineno=6, + col_offset=15, + end_lineno=6, + end_col_offset=16), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=16)], + [], + lineno=5, + col_offset=4, + end_lineno=6, + end_col_offset=16), + Return( + Call( + Name( + 'reduce', + Load(), + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=17), + [ + Lambda( + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=7, + col_offset=25, + end_lineno=7, + end_col_offset=28), + arg( + 'placeholder_3', + lineno=7, + col_offset=30, + end_lineno=7, + end_col_offset=33)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + BinOp( + BinOp( + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=38), + Mult(), + Constant( + 3, + lineno=7, + col_offset=41, + end_lineno=7, + end_col_offset=42), + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=42), + Add(), + Call( + Name( + 'int', + Load(), + lineno=7, + col_offset=45, + end_lineno=7, + end_col_offset=48), + [ + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=49, + end_lineno=7, + end_col_offset=52)], + [], + lineno=7, + col_offset=45, + end_lineno=7, + end_col_offset=53), + lineno=7, + col_offset=35, + end_lineno=7, + end_col_offset=53), + lineno=7, + col_offset=18, + end_lineno=7, + end_col_offset=53), + Name( + 'placeholder_1', + Load(), + lineno=7, + col_offset=55, + end_lineno=7, + end_col_offset=61), + Constant( + 0, + lineno=7, + col_offset=63, + end_lineno=7, + end_col_offset=64)], + [], + lineno=7, + col_offset=11, + end_lineno=7, + end_col_offset=65), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=65)], + [], + lineno=4, + col_offset=0, + end_lineno=7, + end_col_offset=65)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-trinary/representation.txt b/test/practice-trinary/representation.txt new file mode 100644 index 0000000..287493c --- /dev/null +++ b/test/practice-trinary/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('functools', [alias('reduce', lineno=1, col_offset=22, end_lineno=1, end_col_offset=28)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=28), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=4, col_offset=12, end_lineno=4, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(BinOp(Call(Name('set', Load(), lineno=5, col_offset=7, end_lineno=5, end_col_offset=10), [Name('placeholder_1', Load(), lineno=5, col_offset=11, end_lineno=5, end_col_offset=17)], [], lineno=5, col_offset=7, end_lineno=5, end_col_offset=18), Sub(), Call(Name('set', Load(), lineno=5, col_offset=21, end_lineno=5, end_col_offset=24), [Constant('012', lineno=5, col_offset=25, end_lineno=5, end_col_offset=30)], [], lineno=5, col_offset=21, end_lineno=5, end_col_offset=31), lineno=5, col_offset=7, end_lineno=5, end_col_offset=31), [Return(Constant(0, lineno=6, col_offset=15, end_lineno=6, end_col_offset=16), lineno=6, col_offset=8, end_lineno=6, end_col_offset=16)], [], lineno=5, col_offset=4, end_lineno=6, end_col_offset=16), Return(Call(Name('reduce', Load(), lineno=7, col_offset=11, end_lineno=7, end_col_offset=17), [Lambda(arguments([], [arg('placeholder_2', lineno=7, col_offset=25, end_lineno=7, end_col_offset=28), arg('placeholder_3', lineno=7, col_offset=30, end_lineno=7, end_col_offset=33)], kwonlyargs=[], kw_defaults=[], defaults=[]), BinOp(BinOp(Name('placeholder_2', Load(), lineno=7, col_offset=35, end_lineno=7, end_col_offset=38), Mult(), Constant(3, lineno=7, col_offset=41, end_lineno=7, end_col_offset=42), lineno=7, col_offset=35, end_lineno=7, end_col_offset=42), Add(), Call(Name('int', Load(), lineno=7, col_offset=45, end_lineno=7, end_col_offset=48), [Name('placeholder_3', Load(), lineno=7, col_offset=49, end_lineno=7, end_col_offset=52)], [], lineno=7, col_offset=45, end_lineno=7, end_col_offset=53), lineno=7, col_offset=35, end_lineno=7, end_col_offset=53), lineno=7, col_offset=18, end_lineno=7, end_col_offset=53), Name('placeholder_1', Load(), lineno=7, col_offset=55, end_lineno=7, end_col_offset=61), Constant(0, lineno=7, col_offset=63, end_lineno=7, end_col_offset=64)], [], lineno=7, col_offset=11, end_lineno=7, end_col_offset=65), lineno=7, col_offset=4, end_lineno=7, end_col_offset=65)], [], lineno=4, col_offset=0, end_lineno=7, end_col_offset=65)], []) \ No newline at end of file diff --git a/test/practice-trinary/trinary.py b/test/practice-trinary/trinary.py new file mode 100644 index 0000000..48074c0 --- /dev/null +++ b/test/practice-trinary/trinary.py @@ -0,0 +1,7 @@ +from functools import reduce + + +def trinary(string): + if set(string) - set('012'): + return 0 + return reduce(lambda idx, edx: idx * 3 + int(edx), string, 0) diff --git a/test/practice-twelve-days/.meta/config.json b/test/practice-twelve-days/.meta/config.json new file mode 100644 index 0000000..06c0b70 --- /dev/null +++ b/test/practice-twelve-days/.meta/config.json @@ -0,0 +1,31 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "ackerleytng", + "behrtam", + "cmccandless", + "Dog", + "kytrinyx", + "N-Parsons", + "PatrickMcSweeny", + "pheanex", + "rootulp", + "tqa236" + ], + "files": { + "solution": [ + "twelve_days.py" + ], + "test": [ + "twelve_days_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Output the lyrics to 'The Twelve Days of Christmas'.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/The_Twelve_Days_of_Christmas_(song)" +} diff --git a/test/practice-twelve-days/mapping.json b/test/practice-twelve-days/mapping.json new file mode 100644 index 0000000..c036c23 --- /dev/null +++ b/test/practice-twelve-days/mapping.json @@ -0,0 +1,11 @@ +{ + "placeholder_0": "GIFTS", + "placeholder_1": "ORDINAL", + "placeholder_2": "verse", + "placeholder_3": "day_number", + "placeholder_4": "gifts", + "placeholder_5": "recite", + "placeholder_6": "start", + "placeholder_7": "end", + "placeholder_8": "number" +} \ No newline at end of file diff --git a/test/practice-twelve-days/representation.json b/test/practice-twelve-days/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-twelve-days/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-twelve-days/representation.out b/test/practice-twelve-days/representation.out new file mode 100644 index 0000000..a025328 --- /dev/null +++ b/test/practice-twelve-days/representation.out @@ -0,0 +1,1269 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = [ + "twelve Drummers Drumming", + "eleven Pipers Piping", + "ten Lords-a-Leaping", + "nine Ladies Dancing", + "eight Maids-a-Milking", + "seven Swans-a-Swimming", + "six Geese-a-Laying", + "five Gold Rings", + "four Calling Birds", + "three French Hens", + "two Turtle Doves", + "a Partridge in a Pear Tree", +] +placeholder_1 = [ + None, + "first", + "second", + "third", + "fourth", + "fifth", + "sixth", + "seventh", + "eighth", + "ninth", + "tenth", + "eleventh", + "twelfth", +] + + +def placeholder_2(placeholder_3): + placeholder_4 = placeholder_0[-placeholder_3:] + if len(placeholder_4) > 1: + placeholder_4[:-1] = [", ".join(placeholder_4[:-1])] + placeholder_4 = ", and ".join(placeholder_4) + return f"On the {placeholder_1[placeholder_3]} day of Christmas my true love gave to me: {placeholder_4}." + + +def placeholder_5(placeholder_6, placeholder_7): + return [ + placeholder_2(placeholder_8) + for placeholder_8 in range(placeholder_6, placeholder_7 + 1) + ] + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'GIFTS', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=5)], + List( + [ + Constant( + 'twelve Drummers Drumming', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=35), + Constant( + 'eleven Pipers Piping', + lineno=2, + col_offset=9, + end_lineno=2, + end_col_offset=31), + Constant( + 'ten Lords-a-Leaping', + lineno=3, + col_offset=9, + end_lineno=3, + end_col_offset=30), + Constant( + 'nine Ladies Dancing', + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=30), + Constant( + 'eight Maids-a-Milking', + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=32), + Constant( + 'seven Swans-a-Swimming', + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=33), + Constant( + 'six Geese-a-Laying', + lineno=7, + col_offset=9, + end_lineno=7, + end_col_offset=29), + Constant( + 'five Gold Rings', + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=26), + Constant( + 'four Calling Birds', + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=29), + Constant( + 'three French Hens', + lineno=10, + col_offset=9, + end_lineno=10, + end_col_offset=28), + Constant( + 'two Turtle Doves', + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=27), + Constant( + 'a Partridge in a Pear Tree', + lineno=12, + col_offset=9, + end_lineno=12, + end_col_offset=37)], + Load(), + lineno=1, + col_offset=8, + end_lineno=12, + end_col_offset=38), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=38), + Assign( + [ + Name( + 'ORDINAL', + Store(), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=7)], + List( + [ + Constant( + None, + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=15), + Constant( + 'first', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=24), + Constant( + 'second', + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=34), + Constant( + 'third', + lineno=14, + col_offset=36, + end_lineno=14, + end_col_offset=43), + Constant( + 'fourth', + lineno=14, + col_offset=45, + end_lineno=14, + end_col_offset=53), + Constant( + 'fifth', + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=62), + Constant( + 'sixth', + lineno=14, + col_offset=64, + end_lineno=14, + end_col_offset=71), + Constant( + 'seventh', + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=20), + Constant( + 'eighth', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=30), + Constant( + 'ninth', + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=39), + Constant( + 'tenth', + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=48), + Constant( + 'eleventh', + lineno=15, + col_offset=50, + end_lineno=15, + end_col_offset=60), + Constant( + 'twelfth', + lineno=15, + col_offset=62, + end_lineno=15, + end_col_offset=71)], + Load(), + lineno=14, + col_offset=10, + end_lineno=15, + end_col_offset=72), + lineno=14, + col_offset=0, + end_lineno=15, + end_col_offset=72), + FunctionDef( + 'verse', + arguments( + [], + [ + arg( + 'day_number', + lineno=18, + col_offset=10, + end_lineno=18, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'gifts', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=9)], + Subscript( + Name( + 'GIFTS', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=17), + Slice( + UnaryOp( + USub(), + Name( + 'day_number', + Load(), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=29), + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=29), + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=30), + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=31), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=31), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=10), + [ + Name( + 'gifts', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=16)], + [], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=17), + [ + Gt()], + [ + Constant( + 1, + lineno=21, + col_offset=20, + end_lineno=21, + end_col_offset=21)], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=21), + [ + Assign( + [ + Subscript( + Name( + 'gifts', + Load(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=13), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=17), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=17), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=17), + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=18)], + List( + [ + Call( + Attribute( + Constant( + ', ', + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=26), + 'join', + Load(), + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=31), + [ + Subscript( + Name( + 'gifts', + Load(), + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=37), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=22, + col_offset=40, + end_lineno=22, + end_col_offset=41), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=41), + lineno=22, + col_offset=38, + end_lineno=22, + end_col_offset=41), + Load(), + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=42)], + [], + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=43)], + Load(), + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=44), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=44)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=44), + Assign( + [ + Name( + 'gifts', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=9)], + Call( + Attribute( + Constant( + ', and ', + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=20), + 'join', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=25), + [ + Name( + 'gifts', + Load(), + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=31)], + [], + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=32), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=32), + Return( + JoinedStr( + [ + Constant( + 'On the ', + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + FormattedValue( + Subscript( + Name( + 'ORDINAL', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=28), + Name( + 'day_number', + Load(), + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=39), + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=40), + -1, + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + Constant( + ' day of Christmas my true love gave to me: ', + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + FormattedValue( + Name( + 'gifts', + Load(), + lineno=25, + col_offset=85, + end_lineno=25, + end_col_offset=90), + -1, + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + Constant( + '.', + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93)], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=93)], + [], + lineno=18, + col_offset=0, + end_lineno=25, + end_col_offset=93), + FunctionDef( + 'recite', + arguments( + [], + [ + arg( + 'start', + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=16), + arg( + 'end', + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'verse', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=17), + [ + Name( + 'number', + Load(), + lineno=29, + col_offset=18, + end_lineno=29, + end_col_offset=24)], + [], + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=25), + [ + comprehension( + Name( + 'number', + Store(), + lineno=29, + col_offset=30, + end_lineno=29, + end_col_offset=36), + Call( + Name( + 'range', + Load(), + lineno=29, + col_offset=40, + end_lineno=29, + end_col_offset=45), + [ + Name( + 'start', + Load(), + lineno=29, + col_offset=46, + end_lineno=29, + end_col_offset=51), + BinOp( + Name( + 'end', + Load(), + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=56), + Add(), + Constant( + 1, + lineno=29, + col_offset=59, + end_lineno=29, + end_col_offset=60), + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=60)], + [], + lineno=29, + col_offset=40, + end_lineno=29, + end_col_offset=61), + [], + 0)], + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=62), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=62)], + [], + lineno=28, + col_offset=0, + end_lineno=29, + end_col_offset=62)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=5)], + List( + [ + Constant( + 'twelve Drummers Drumming', + lineno=1, + col_offset=9, + end_lineno=1, + end_col_offset=35), + Constant( + 'eleven Pipers Piping', + lineno=2, + col_offset=9, + end_lineno=2, + end_col_offset=31), + Constant( + 'ten Lords-a-Leaping', + lineno=3, + col_offset=9, + end_lineno=3, + end_col_offset=30), + Constant( + 'nine Ladies Dancing', + lineno=4, + col_offset=9, + end_lineno=4, + end_col_offset=30), + Constant( + 'eight Maids-a-Milking', + lineno=5, + col_offset=9, + end_lineno=5, + end_col_offset=32), + Constant( + 'seven Swans-a-Swimming', + lineno=6, + col_offset=9, + end_lineno=6, + end_col_offset=33), + Constant( + 'six Geese-a-Laying', + lineno=7, + col_offset=9, + end_lineno=7, + end_col_offset=29), + Constant( + 'five Gold Rings', + lineno=8, + col_offset=9, + end_lineno=8, + end_col_offset=26), + Constant( + 'four Calling Birds', + lineno=9, + col_offset=9, + end_lineno=9, + end_col_offset=29), + Constant( + 'three French Hens', + lineno=10, + col_offset=9, + end_lineno=10, + end_col_offset=28), + Constant( + 'two Turtle Doves', + lineno=11, + col_offset=9, + end_lineno=11, + end_col_offset=27), + Constant( + 'a Partridge in a Pear Tree', + lineno=12, + col_offset=9, + end_lineno=12, + end_col_offset=37)], + Load(), + lineno=1, + col_offset=8, + end_lineno=12, + end_col_offset=38), + lineno=1, + col_offset=0, + end_lineno=12, + end_col_offset=38), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=7)], + List( + [ + Constant( + None, + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=15), + Constant( + 'first', + lineno=14, + col_offset=17, + end_lineno=14, + end_col_offset=24), + Constant( + 'second', + lineno=14, + col_offset=26, + end_lineno=14, + end_col_offset=34), + Constant( + 'third', + lineno=14, + col_offset=36, + end_lineno=14, + end_col_offset=43), + Constant( + 'fourth', + lineno=14, + col_offset=45, + end_lineno=14, + end_col_offset=53), + Constant( + 'fifth', + lineno=14, + col_offset=55, + end_lineno=14, + end_col_offset=62), + Constant( + 'sixth', + lineno=14, + col_offset=64, + end_lineno=14, + end_col_offset=71), + Constant( + 'seventh', + lineno=15, + col_offset=11, + end_lineno=15, + end_col_offset=20), + Constant( + 'eighth', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=30), + Constant( + 'ninth', + lineno=15, + col_offset=32, + end_lineno=15, + end_col_offset=39), + Constant( + 'tenth', + lineno=15, + col_offset=41, + end_lineno=15, + end_col_offset=48), + Constant( + 'eleventh', + lineno=15, + col_offset=50, + end_lineno=15, + end_col_offset=60), + Constant( + 'twelfth', + lineno=15, + col_offset=62, + end_lineno=15, + end_col_offset=71)], + Load(), + lineno=14, + col_offset=10, + end_lineno=15, + end_col_offset=72), + lineno=14, + col_offset=0, + end_lineno=15, + end_col_offset=72), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=18, + col_offset=10, + end_lineno=18, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=9)], + Subscript( + Name( + 'placeholder_0', + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=17), + Slice( + UnaryOp( + USub(), + Name( + 'placeholder_3', + Load(), + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=29), + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=29), + lineno=19, + col_offset=18, + end_lineno=19, + end_col_offset=30), + Load(), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=31), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=31), + If( + Compare( + Call( + Name( + 'len', + Load(), + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=10), + [ + Name( + 'placeholder_4', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=16)], + [], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=17), + [ + Gt()], + [ + Constant( + 1, + lineno=21, + col_offset=20, + end_lineno=21, + end_col_offset=21)], + lineno=21, + col_offset=7, + end_lineno=21, + end_col_offset=21), + [ + Assign( + [ + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=13), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=17), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=17), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=17), + Store(), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=18)], + List( + [ + Call( + Attribute( + Constant( + ', ', + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=26), + 'join', + Load(), + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=31), + [ + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=37), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=22, + col_offset=40, + end_lineno=22, + end_col_offset=41), + lineno=22, + col_offset=39, + end_lineno=22, + end_col_offset=41), + lineno=22, + col_offset=38, + end_lineno=22, + end_col_offset=41), + Load(), + lineno=22, + col_offset=32, + end_lineno=22, + end_col_offset=42)], + [], + lineno=22, + col_offset=22, + end_lineno=22, + end_col_offset=43)], + Load(), + lineno=22, + col_offset=21, + end_lineno=22, + end_col_offset=44), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=44)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=9)], + Call( + Attribute( + Constant( + ', and ', + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=20), + 'join', + Load(), + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=25), + [ + Name( + 'placeholder_4', + Load(), + lineno=24, + col_offset=26, + end_lineno=24, + end_col_offset=31)], + [], + lineno=24, + col_offset=12, + end_lineno=24, + end_col_offset=32), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=32), + Return( + JoinedStr( + [ + Constant( + 'On the ', + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + FormattedValue( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=28), + Name( + 'placeholder_3', + Load(), + lineno=25, + col_offset=29, + end_lineno=25, + end_col_offset=39), + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=40), + -1, + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + Constant( + ' day of Christmas my true love gave to me: ', + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + FormattedValue( + Name( + 'placeholder_4', + Load(), + lineno=25, + col_offset=85, + end_lineno=25, + end_col_offset=90), + -1, + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + Constant( + '.', + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93)], + lineno=25, + col_offset=11, + end_lineno=25, + end_col_offset=93), + lineno=25, + col_offset=4, + end_lineno=25, + end_col_offset=93)], + [], + lineno=18, + col_offset=0, + end_lineno=25, + end_col_offset=93), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=16), + arg( + 'placeholder_7', + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + ListComp( + Call( + Name( + 'placeholder_2', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=17), + [ + Name( + 'placeholder_8', + Load(), + lineno=29, + col_offset=18, + end_lineno=29, + end_col_offset=24)], + [], + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=25), + [ + comprehension( + Name( + 'placeholder_8', + Store(), + lineno=29, + col_offset=30, + end_lineno=29, + end_col_offset=36), + Call( + Name( + 'range', + Load(), + lineno=29, + col_offset=40, + end_lineno=29, + end_col_offset=45), + [ + Name( + 'placeholder_6', + Load(), + lineno=29, + col_offset=46, + end_lineno=29, + end_col_offset=51), + BinOp( + Name( + 'placeholder_7', + Load(), + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=56), + Add(), + Constant( + 1, + lineno=29, + col_offset=59, + end_lineno=29, + end_col_offset=60), + lineno=29, + col_offset=53, + end_lineno=29, + end_col_offset=60)], + [], + lineno=29, + col_offset=40, + end_lineno=29, + end_col_offset=61), + [], + 0)], + lineno=29, + col_offset=11, + end_lineno=29, + end_col_offset=62), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=62)], + [], + lineno=28, + col_offset=0, + end_lineno=29, + end_col_offset=62)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-twelve-days/representation.txt b/test/practice-twelve-days/representation.txt new file mode 100644 index 0000000..adc725a --- /dev/null +++ b/test/practice-twelve-days/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=5)], List([Constant('twelve Drummers Drumming', lineno=1, col_offset=9, end_lineno=1, end_col_offset=35), Constant('eleven Pipers Piping', lineno=2, col_offset=9, end_lineno=2, end_col_offset=31), Constant('ten Lords-a-Leaping', lineno=3, col_offset=9, end_lineno=3, end_col_offset=30), Constant('nine Ladies Dancing', lineno=4, col_offset=9, end_lineno=4, end_col_offset=30), Constant('eight Maids-a-Milking', lineno=5, col_offset=9, end_lineno=5, end_col_offset=32), Constant('seven Swans-a-Swimming', lineno=6, col_offset=9, end_lineno=6, end_col_offset=33), Constant('six Geese-a-Laying', lineno=7, col_offset=9, end_lineno=7, end_col_offset=29), Constant('five Gold Rings', lineno=8, col_offset=9, end_lineno=8, end_col_offset=26), Constant('four Calling Birds', lineno=9, col_offset=9, end_lineno=9, end_col_offset=29), Constant('three French Hens', lineno=10, col_offset=9, end_lineno=10, end_col_offset=28), Constant('two Turtle Doves', lineno=11, col_offset=9, end_lineno=11, end_col_offset=27), Constant('a Partridge in a Pear Tree', lineno=12, col_offset=9, end_lineno=12, end_col_offset=37)], Load(), lineno=1, col_offset=8, end_lineno=12, end_col_offset=38), lineno=1, col_offset=0, end_lineno=12, end_col_offset=38), Assign([Name('placeholder_1', Store(), lineno=14, col_offset=0, end_lineno=14, end_col_offset=7)], List([Constant(None, lineno=14, col_offset=11, end_lineno=14, end_col_offset=15), Constant('first', lineno=14, col_offset=17, end_lineno=14, end_col_offset=24), Constant('second', lineno=14, col_offset=26, end_lineno=14, end_col_offset=34), Constant('third', lineno=14, col_offset=36, end_lineno=14, end_col_offset=43), Constant('fourth', lineno=14, col_offset=45, end_lineno=14, end_col_offset=53), Constant('fifth', lineno=14, col_offset=55, end_lineno=14, end_col_offset=62), Constant('sixth', lineno=14, col_offset=64, end_lineno=14, end_col_offset=71), Constant('seventh', lineno=15, col_offset=11, end_lineno=15, end_col_offset=20), Constant('eighth', lineno=15, col_offset=22, end_lineno=15, end_col_offset=30), Constant('ninth', lineno=15, col_offset=32, end_lineno=15, end_col_offset=39), Constant('tenth', lineno=15, col_offset=41, end_lineno=15, end_col_offset=48), Constant('eleventh', lineno=15, col_offset=50, end_lineno=15, end_col_offset=60), Constant('twelfth', lineno=15, col_offset=62, end_lineno=15, end_col_offset=71)], Load(), lineno=14, col_offset=10, end_lineno=15, end_col_offset=72), lineno=14, col_offset=0, end_lineno=15, end_col_offset=72), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=18, col_offset=10, end_lineno=18, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=19, col_offset=4, end_lineno=19, end_col_offset=9)], Subscript(Name('placeholder_0', Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=17), Slice(UnaryOp(USub(), Name('placeholder_3', Load(), lineno=19, col_offset=19, end_lineno=19, end_col_offset=29), lineno=19, col_offset=18, end_lineno=19, end_col_offset=29), lineno=19, col_offset=18, end_lineno=19, end_col_offset=30), Load(), lineno=19, col_offset=12, end_lineno=19, end_col_offset=31), lineno=19, col_offset=4, end_lineno=19, end_col_offset=31), If(Compare(Call(Name('len', Load(), lineno=21, col_offset=7, end_lineno=21, end_col_offset=10), [Name('placeholder_4', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=16)], [], lineno=21, col_offset=7, end_lineno=21, end_col_offset=17), [Gt()], [Constant(1, lineno=21, col_offset=20, end_lineno=21, end_col_offset=21)], lineno=21, col_offset=7, end_lineno=21, end_col_offset=21), [Assign([Subscript(Name('placeholder_4', Load(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=13), Slice(upper=UnaryOp(USub(), Constant(1, lineno=22, col_offset=16, end_lineno=22, end_col_offset=17), lineno=22, col_offset=15, end_lineno=22, end_col_offset=17), lineno=22, col_offset=14, end_lineno=22, end_col_offset=17), Store(), lineno=22, col_offset=8, end_lineno=22, end_col_offset=18)], List([Call(Attribute(Constant(', ', lineno=22, col_offset=22, end_lineno=22, end_col_offset=26), 'join', Load(), lineno=22, col_offset=22, end_lineno=22, end_col_offset=31), [Subscript(Name('placeholder_4', Load(), lineno=22, col_offset=32, end_lineno=22, end_col_offset=37), Slice(upper=UnaryOp(USub(), Constant(1, lineno=22, col_offset=40, end_lineno=22, end_col_offset=41), lineno=22, col_offset=39, end_lineno=22, end_col_offset=41), lineno=22, col_offset=38, end_lineno=22, end_col_offset=41), Load(), lineno=22, col_offset=32, end_lineno=22, end_col_offset=42)], [], lineno=22, col_offset=22, end_lineno=22, end_col_offset=43)], Load(), lineno=22, col_offset=21, end_lineno=22, end_col_offset=44), lineno=22, col_offset=8, end_lineno=22, end_col_offset=44)], [], lineno=21, col_offset=4, end_lineno=22, end_col_offset=44), Assign([Name('placeholder_4', Store(), lineno=24, col_offset=4, end_lineno=24, end_col_offset=9)], Call(Attribute(Constant(', and ', lineno=24, col_offset=12, end_lineno=24, end_col_offset=20), 'join', Load(), lineno=24, col_offset=12, end_lineno=24, end_col_offset=25), [Name('placeholder_4', Load(), lineno=24, col_offset=26, end_lineno=24, end_col_offset=31)], [], lineno=24, col_offset=12, end_lineno=24, end_col_offset=32), lineno=24, col_offset=4, end_lineno=24, end_col_offset=32), Return(JoinedStr([Constant('On the ', lineno=25, col_offset=11, end_lineno=25, end_col_offset=93), FormattedValue(Subscript(Name('placeholder_1', Load(), lineno=25, col_offset=21, end_lineno=25, end_col_offset=28), Name('placeholder_3', Load(), lineno=25, col_offset=29, end_lineno=25, end_col_offset=39), Load(), lineno=25, col_offset=21, end_lineno=25, end_col_offset=40), -1, lineno=25, col_offset=11, end_lineno=25, end_col_offset=93), Constant(' day of Christmas my true love gave to me: ', lineno=25, col_offset=11, end_lineno=25, end_col_offset=93), FormattedValue(Name('placeholder_4', Load(), lineno=25, col_offset=85, end_lineno=25, end_col_offset=90), -1, lineno=25, col_offset=11, end_lineno=25, end_col_offset=93), Constant('.', lineno=25, col_offset=11, end_lineno=25, end_col_offset=93)], lineno=25, col_offset=11, end_lineno=25, end_col_offset=93), lineno=25, col_offset=4, end_lineno=25, end_col_offset=93)], [], lineno=18, col_offset=0, end_lineno=25, end_col_offset=93), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=28, col_offset=11, end_lineno=28, end_col_offset=16), arg('placeholder_7', lineno=28, col_offset=18, end_lineno=28, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(ListComp(Call(Name('placeholder_2', Load(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=17), [Name('placeholder_8', Load(), lineno=29, col_offset=18, end_lineno=29, end_col_offset=24)], [], lineno=29, col_offset=12, end_lineno=29, end_col_offset=25), [comprehension(Name('placeholder_8', Store(), lineno=29, col_offset=30, end_lineno=29, end_col_offset=36), Call(Name('range', Load(), lineno=29, col_offset=40, end_lineno=29, end_col_offset=45), [Name('placeholder_6', Load(), lineno=29, col_offset=46, end_lineno=29, end_col_offset=51), BinOp(Name('placeholder_7', Load(), lineno=29, col_offset=53, end_lineno=29, end_col_offset=56), Add(), Constant(1, lineno=29, col_offset=59, end_lineno=29, end_col_offset=60), lineno=29, col_offset=53, end_lineno=29, end_col_offset=60)], [], lineno=29, col_offset=40, end_lineno=29, end_col_offset=61), [], 0)], lineno=29, col_offset=11, end_lineno=29, end_col_offset=62), lineno=29, col_offset=4, end_lineno=29, end_col_offset=62)], [], lineno=28, col_offset=0, end_lineno=29, end_col_offset=62)], []) \ No newline at end of file diff --git a/test/practice-twelve-days/twelve_days.py b/test/practice-twelve-days/twelve_days.py new file mode 100644 index 0000000..6b24c65 --- /dev/null +++ b/test/practice-twelve-days/twelve_days.py @@ -0,0 +1,29 @@ +GIFTS = ['twelve Drummers Drumming', + 'eleven Pipers Piping', + 'ten Lords-a-Leaping', + 'nine Ladies Dancing', + 'eight Maids-a-Milking', + 'seven Swans-a-Swimming', + 'six Geese-a-Laying', + 'five Gold Rings', + 'four Calling Birds', + 'three French Hens', + 'two Turtle Doves', + 'a Partridge in a Pear Tree'] + +ORDINAL = [None, 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', + 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth'] + + +def verse(day_number): + gifts = GIFTS[-day_number:] + + if len(gifts) > 1: + gifts[:-1] = [', '.join(gifts[:-1])] + + gifts = ', and '.join(gifts) + return f'On the {ORDINAL[day_number]} day of Christmas my true love gave to me: {gifts}.' + + +def recite(start, end): + return [verse(number) for number in range(start, end + 1)] diff --git a/test/practice-two-bucket/.meta/config.json b/test/practice-two-bucket/.meta/config.json new file mode 100644 index 0000000..9934289 --- /dev/null +++ b/test/practice-two-bucket/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "parthsharma2" + ], + "contributors": [ + "cmccandless", + "Dog", + "dvermd", + "guaneec", + "ikhadykin", + "N-Parsons", + "tqa236", + "yawpitch", + "mhorod" + ], + "files": { + "solution": [ + "two_bucket.py" + ], + "test": [ + "two_bucket_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given two buckets of different size, demonstrate how to measure an exact number of liters.", + "source": "Water Pouring Problem", + "source_url": "https://demonstrations.wolfram.com/WaterPouringProblem/" +} diff --git a/test/practice-two-bucket/mapping.json b/test/practice-two-bucket/mapping.json new file mode 100644 index 0000000..62012fb --- /dev/null +++ b/test/practice-two-bucket/mapping.json @@ -0,0 +1,27 @@ +{ + "placeholder_0": "measure", + "placeholder_1": "bucket_one", + "placeholder_2": "bucket_two", + "placeholder_3": "goal", + "placeholder_4": "start_bucket", + "placeholder_5": "sizes", + "placeholder_6": "goal_index", + "placeholder_7": "empty", + "placeholder_8": "buckets", + "placeholder_9": "idx", + "placeholder_10": "fill", + "placeholder_11": "consolidate", + "placeholder_12": "amount", + "placeholder_13": "target", + "placeholder_14": "source", + "placeholder_15": "bucket_str", + "placeholder_16": "invalid", + "placeholder_17": "invalid_string", + "placeholder_18": "to_visit", + "placeholder_19": "visited", + "placeholder_20": "count", + "placeholder_21": "key", + "placeholder_22": "number_count", + "placeholder_23": "goal_bucket", + "placeholder_24": "other_bucket" +} \ No newline at end of file diff --git a/test/practice-two-bucket/representation.json b/test/practice-two-bucket/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-two-bucket/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-two-bucket/representation.out b/test/practice-two-bucket/representation.out new file mode 100644 index 0000000..56eb0d1 --- /dev/null +++ b/test/practice-two-bucket/representation.out @@ -0,0 +1,3814 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1, placeholder_2, placeholder_3, placeholder_4): + placeholder_5 = [placeholder_1, placeholder_2] + placeholder_6 = 0 if placeholder_4 == "one" else 1 + + def placeholder_7(placeholder_8, placeholder_9): + return [0, placeholder_8[1]] if placeholder_9 == 0 else [placeholder_8[0], 0] + + def placeholder_10(placeholder_8, placeholder_9): + return ( + [placeholder_5[0], placeholder_8[1]] + if placeholder_9 == 0 + else [placeholder_8[0], placeholder_5[1]] + ) + + def placeholder_11(placeholder_8, placeholder_9): + placeholder_12 = min( + placeholder_8[1 - placeholder_9], + placeholder_5[placeholder_9] - placeholder_8[placeholder_9], + ) + placeholder_13 = placeholder_8[placeholder_9] + placeholder_12 + placeholder_14 = placeholder_8[1 - placeholder_9] - placeholder_12 + return ( + [placeholder_13, placeholder_14] + if placeholder_9 == 0 + else [placeholder_14, placeholder_13] + ) + + def placeholder_15(placeholder_8): + return f"{placeholder_8[0]},{placeholder_8[1]}" + + placeholder_16 = [0, 0] + placeholder_16[1 - placeholder_6] = placeholder_5[1 - placeholder_6] + placeholder_17 = placeholder_15(placeholder_16) + placeholder_8 = [0, 0] + placeholder_8[placeholder_6] = placeholder_5[placeholder_6] + placeholder_18 = [] + placeholder_19 = set() + placeholder_20 = 1 + while placeholder_3 not in placeholder_8: + placeholder_21 = placeholder_15(placeholder_8) + if placeholder_21 != placeholder_17 and placeholder_21 not in placeholder_19: + placeholder_19.add(placeholder_21) + placeholder_22 = placeholder_20 + 1 + for placeholder_9 in range(2): + if placeholder_8[placeholder_9] != 0: + placeholder_18.append( + (placeholder_7(placeholder_8, placeholder_9), placeholder_22) + ) + if placeholder_8[placeholder_9] != placeholder_5[placeholder_9]: + placeholder_18.append( + (placeholder_10(placeholder_8, placeholder_9), placeholder_22) + ) + placeholder_18.append( + (placeholder_11(placeholder_8, placeholder_9), placeholder_22) + ) + if not any(placeholder_18): + raise ValueError("No more moves!") + placeholder_8, placeholder_20 = placeholder_18.pop(0) + placeholder_6 = placeholder_8.index(placeholder_3) + placeholder_23 = ["one", "two"][placeholder_6] + placeholder_24 = placeholder_8[1 - placeholder_6] + return (placeholder_20, placeholder_23, placeholder_24) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + '\n This solution implements a breadth-first search of the graph\n of possible valid states for the two buckets until it reaches a state\n in which one of the two buckets contains the goal amount\n', + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=5, + end_col_offset=3), + FunctionDef( + 'measure', + arguments( + [], + [ + arg( + 'bucket_one', + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=22), + arg( + 'bucket_two', + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=34), + arg( + 'goal', + lineno=8, + col_offset=36, + end_lineno=8, + end_col_offset=40), + arg( + 'start_bucket', + lineno=8, + col_offset=42, + end_lineno=8, + end_col_offset=54)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'sizes', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=9)], + List( + [ + Name( + 'bucket_one', + Load(), + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=23), + Name( + 'bucket_two', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=35)], + Load(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=36), + Assign( + [ + Name( + 'goal_index', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14)], + IfExp( + Compare( + Name( + 'start_bucket', + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=34), + [ + Eq()], + [ + Constant( + 'one', + lineno=10, + col_offset=38, + end_lineno=10, + end_col_offset=43)], + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=43), + Constant( + 0, + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=18), + Constant( + 1, + lineno=10, + col_offset=49, + end_lineno=10, + end_col_offset=50), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=50), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=50), + FunctionDef( + 'empty', + arguments( + [], + [ + arg( + 'buckets', + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=21), + arg( + 'idx', + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Name( + 'idx', + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=37), + [ + Eq()], + [ + Constant( + 0, + lineno=13, + col_offset=41, + end_lineno=13, + end_col_offset=42)], + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=42), + List( + [ + Constant( + 0, + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=17), + Subscript( + Name( + 'buckets', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=26), + Constant( + 1, + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=28), + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=29)], + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=30), + List( + [ + Subscript( + Name( + 'buckets', + Load(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=56), + Constant( + 0, + lineno=13, + col_offset=57, + end_lineno=13, + end_col_offset=58), + Load(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=59), + Constant( + 0, + lineno=13, + col_offset=61, + end_lineno=13, + end_col_offset=62)], + Load(), + lineno=13, + col_offset=48, + end_lineno=13, + end_col_offset=63), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=63), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=63)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=63), + FunctionDef( + 'fill', + arguments( + [], + [ + arg( + 'buckets', + lineno=15, + col_offset=13, + end_lineno=15, + end_col_offset=20), + arg( + 'idx', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Name( + 'idx', + Load(), + lineno=16, + col_offset=41, + end_lineno=16, + end_col_offset=44), + [ + Eq()], + [ + Constant( + 0, + lineno=16, + col_offset=48, + end_lineno=16, + end_col_offset=49)], + lineno=16, + col_offset=41, + end_lineno=16, + end_col_offset=49), + List( + [ + Subscript( + Name( + 'sizes', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=21), + Constant( + 0, + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=23), + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=24), + Subscript( + Name( + 'buckets', + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=33), + Constant( + 1, + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=35), + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=36)], + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=37), + List( + [ + Subscript( + Name( + 'buckets', + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=63), + Constant( + 0, + lineno=16, + col_offset=64, + end_lineno=16, + end_col_offset=65), + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=66), + Subscript( + Name( + 'sizes', + Load(), + lineno=16, + col_offset=68, + end_lineno=16, + end_col_offset=73), + Constant( + 1, + lineno=16, + col_offset=74, + end_lineno=16, + end_col_offset=75), + Load(), + lineno=16, + col_offset=68, + end_lineno=16, + end_col_offset=76)], + Load(), + lineno=16, + col_offset=55, + end_lineno=16, + end_col_offset=77), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=77), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=77)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=77), + FunctionDef( + 'consolidate', + arguments( + [], + [ + arg( + 'buckets', + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=27), + arg( + 'idx', + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'amount', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=14)], + Call( + Name( + 'min', + Load(), + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=20), + [ + Subscript( + Name( + 'buckets', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=28), + BinOp( + Constant( + 1, + lineno=19, + col_offset=29, + end_lineno=19, + end_col_offset=30), + Sub(), + Name( + 'idx', + Load(), + lineno=19, + col_offset=33, + end_lineno=19, + end_col_offset=36), + lineno=19, + col_offset=29, + end_lineno=19, + end_col_offset=36), + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=37), + BinOp( + Subscript( + Name( + 'sizes', + Load(), + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=44), + Name( + 'idx', + Load(), + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=48), + Load(), + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=49), + Sub(), + Subscript( + Name( + 'buckets', + Load(), + lineno=19, + col_offset=52, + end_lineno=19, + end_col_offset=59), + Name( + 'idx', + Load(), + lineno=19, + col_offset=60, + end_lineno=19, + end_col_offset=63), + Load(), + lineno=19, + col_offset=52, + end_lineno=19, + end_col_offset=64), + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=64)], + [], + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=65), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=65), + Assign( + [ + Name( + 'target', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=14)], + BinOp( + Subscript( + Name( + 'buckets', + Load(), + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=24), + Name( + 'idx', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=28), + Load(), + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=29), + Add(), + Name( + 'amount', + Load(), + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=38), + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=38), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=38), + Assign( + [ + Name( + 'source', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=14)], + BinOp( + Subscript( + Name( + 'buckets', + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=24), + BinOp( + Constant( + 1, + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=26), + Sub(), + Name( + 'idx', + Load(), + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=32), + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=32), + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=33), + Sub(), + Name( + 'amount', + Load(), + lineno=21, + col_offset=36, + end_lineno=21, + end_col_offset=42), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=42), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=42), + Return( + IfExp( + Compare( + Name( + 'idx', + Load(), + lineno=22, + col_offset=35, + end_lineno=22, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 0, + lineno=22, + col_offset=42, + end_lineno=22, + end_col_offset=43)], + lineno=22, + col_offset=35, + end_lineno=22, + end_col_offset=43), + List( + [ + Name( + 'target', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=22), + Name( + 'source', + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=30)], + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=31), + List( + [ + Name( + 'source', + Load(), + lineno=22, + col_offset=50, + end_lineno=22, + end_col_offset=56), + Name( + 'target', + Load(), + lineno=22, + col_offset=58, + end_lineno=22, + end_col_offset=64)], + Load(), + lineno=22, + col_offset=49, + end_lineno=22, + end_col_offset=65), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=65), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=65)], + [], + lineno=18, + col_offset=4, + end_lineno=22, + end_col_offset=65), + FunctionDef( + 'bucket_str', + arguments( + [], + [ + arg( + 'buckets', + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + FormattedValue( + Subscript( + Name( + 'buckets', + Load(), + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=25), + Constant( + 0, + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=27), + Load(), + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=28), + -1, + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=43), + Constant( + ',', + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=43), + FormattedValue( + Subscript( + Name( + 'buckets', + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=38), + Constant( + 1, + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=40), + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=41), + -1, + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=43)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=43), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=43)], + [], + lineno=24, + col_offset=4, + end_lineno=25, + end_col_offset=43), + Assign( + [ + Name( + 'invalid', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=11)], + List( + [ + Constant( + 0, + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=16), + Constant( + 0, + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=19)], + Load(), + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=20), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=20), + Assign( + [ + Subscript( + Name( + 'invalid', + Load(), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=11), + BinOp( + Constant( + 1, + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=13), + Sub(), + Name( + 'goal_index', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=26), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=26), + Store(), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=27)], + Subscript( + Name( + 'sizes', + Load(), + lineno=28, + col_offset=30, + end_lineno=28, + end_col_offset=35), + BinOp( + Constant( + 1, + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=37), + Sub(), + Name( + 'goal_index', + Load(), + lineno=28, + col_offset=40, + end_lineno=28, + end_col_offset=50), + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=50), + Load(), + lineno=28, + col_offset=30, + end_lineno=28, + end_col_offset=51), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=51), + Assign( + [ + Name( + 'invalid_string', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=18)], + Call( + Name( + 'bucket_str', + Load(), + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=31), + [ + Name( + 'invalid', + Load(), + lineno=29, + col_offset=32, + end_lineno=29, + end_col_offset=39)], + [], + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=40), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=40), + Assign( + [ + Name( + 'buckets', + Store(), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=11)], + List( + [ + Constant( + 0, + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=16), + Constant( + 0, + lineno=30, + col_offset=18, + end_lineno=30, + end_col_offset=19)], + Load(), + lineno=30, + col_offset=14, + end_lineno=30, + end_col_offset=20), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=20), + Assign( + [ + Subscript( + Name( + 'buckets', + Load(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=11), + Name( + 'goal_index', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=22), + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=23)], + Subscript( + Name( + 'sizes', + Load(), + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=31), + Name( + 'goal_index', + Load(), + lineno=31, + col_offset=32, + end_lineno=31, + end_col_offset=42), + Load(), + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=43), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=43), + Assign( + [ + Name( + 'to_visit', + Store(), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=12)], + List( + [], + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=17), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=17), + Assign( + [ + Name( + 'visited', + Store(), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=11)], + Call( + Name( + 'set', + Load(), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=17), + [], + [], + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=19), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=19), + Assign( + [ + Name( + 'count', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=9)], + Constant( + 1, + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=13), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=13), + While( + Compare( + Name( + 'goal', + Load(), + lineno=35, + col_offset=10, + end_lineno=35, + end_col_offset=14), + [ + NotIn()], + [ + Name( + 'buckets', + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=29)], + lineno=35, + col_offset=10, + end_lineno=35, + end_col_offset=29), + [ + Assign( + [ + Name( + 'key', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=11)], + Call( + Name( + 'bucket_str', + Load(), + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=24), + [ + Name( + 'buckets', + Load(), + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=32)], + [], + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=33), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=33), + If( + BoolOp( + And(), + [ + Compare( + Name( + 'key', + Load(), + lineno=37, + col_offset=11, + end_lineno=37, + end_col_offset=14), + [ + NotEq()], + [ + Name( + 'invalid_string', + Load(), + lineno=37, + col_offset=18, + end_lineno=37, + end_col_offset=32)], + lineno=37, + col_offset=11, + end_lineno=37, + end_col_offset=32), + Compare( + Name( + 'key', + Load(), + lineno=37, + col_offset=37, + end_lineno=37, + end_col_offset=40), + [ + NotIn()], + [ + Name( + 'visited', + Load(), + lineno=37, + col_offset=48, + end_lineno=37, + end_col_offset=55)], + lineno=37, + col_offset=37, + end_lineno=37, + end_col_offset=55)], + lineno=37, + col_offset=11, + end_lineno=37, + end_col_offset=55), + [ + Expr( + Call( + Attribute( + Name( + 'visited', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=19), + 'add', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=23), + [ + Name( + 'key', + Load(), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=27)], + [], + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=28), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=28), + Assign( + [ + Name( + 'number_count', + Store(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=24)], + BinOp( + Name( + 'count', + Load(), + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=32), + Add(), + Constant( + 1, + lineno=39, + col_offset=35, + end_lineno=39, + end_col_offset=36), + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=36), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=36), + For( + Name( + 'idx', + Store(), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=40, + col_offset=23, + end_lineno=40, + end_col_offset=28), + [ + Constant( + 2, + lineno=40, + col_offset=29, + end_lineno=40, + end_col_offset=30)], + [], + lineno=40, + col_offset=23, + end_lineno=40, + end_col_offset=31), + [ + If( + Compare( + Subscript( + Name( + 'buckets', + Load(), + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=26), + Name( + 'idx', + Load(), + lineno=41, + col_offset=27, + end_lineno=41, + end_col_offset=30), + Load(), + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=31), + [ + NotEq()], + [ + Constant( + 0, + lineno=41, + col_offset=35, + end_lineno=41, + end_col_offset=36)], + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=36), + [ + Expr( + Call( + Attribute( + Name( + 'to_visit', + Load(), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=28), + 'append', + Load(), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=35), + [ + Tuple( + [ + Call( + Name( + 'empty', + Load(), + lineno=42, + col_offset=37, + end_lineno=42, + end_col_offset=42), + [ + Name( + 'buckets', + Load(), + lineno=42, + col_offset=43, + end_lineno=42, + end_col_offset=50), + Name( + 'idx', + Load(), + lineno=42, + col_offset=52, + end_lineno=42, + end_col_offset=55)], + [], + lineno=42, + col_offset=37, + end_lineno=42, + end_col_offset=56), + Name( + 'number_count', + Load(), + lineno=42, + col_offset=58, + end_lineno=42, + end_col_offset=70)], + Load(), + lineno=42, + col_offset=36, + end_lineno=42, + end_col_offset=71)], + [], + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=72), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=72)], + [], + lineno=41, + col_offset=16, + end_lineno=42, + end_col_offset=72), + If( + Compare( + Subscript( + Name( + 'buckets', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=26), + Name( + 'idx', + Load(), + lineno=43, + col_offset=27, + end_lineno=43, + end_col_offset=30), + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=31), + [ + NotEq()], + [ + Subscript( + Name( + 'sizes', + Load(), + lineno=43, + col_offset=35, + end_lineno=43, + end_col_offset=40), + Name( + 'idx', + Load(), + lineno=43, + col_offset=41, + end_lineno=43, + end_col_offset=44), + Load(), + lineno=43, + col_offset=35, + end_lineno=43, + end_col_offset=45)], + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=45), + [ + Expr( + Call( + Attribute( + Name( + 'to_visit', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=28), + 'append', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=35), + [ + Tuple( + [ + Call( + Name( + 'fill', + Load(), + lineno=44, + col_offset=37, + end_lineno=44, + end_col_offset=41), + [ + Name( + 'buckets', + Load(), + lineno=44, + col_offset=42, + end_lineno=44, + end_col_offset=49), + Name( + 'idx', + Load(), + lineno=44, + col_offset=51, + end_lineno=44, + end_col_offset=54)], + [], + lineno=44, + col_offset=37, + end_lineno=44, + end_col_offset=55), + Name( + 'number_count', + Load(), + lineno=44, + col_offset=57, + end_lineno=44, + end_col_offset=69)], + Load(), + lineno=44, + col_offset=36, + end_lineno=44, + end_col_offset=70)], + [], + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=71), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=71), + Expr( + Call( + Attribute( + Name( + 'to_visit', + Load(), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=28), + 'append', + Load(), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=35), + [ + Tuple( + [ + Call( + Name( + 'consolidate', + Load(), + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=48), + [ + Name( + 'buckets', + Load(), + lineno=45, + col_offset=49, + end_lineno=45, + end_col_offset=56), + Name( + 'idx', + Load(), + lineno=45, + col_offset=58, + end_lineno=45, + end_col_offset=61)], + [], + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=62), + Name( + 'number_count', + Load(), + lineno=45, + col_offset=64, + end_lineno=45, + end_col_offset=76)], + Load(), + lineno=45, + col_offset=36, + end_lineno=45, + end_col_offset=77)], + [], + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=78), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=78)], + [], + lineno=43, + col_offset=16, + end_lineno=45, + end_col_offset=78)], + [], + lineno=40, + col_offset=12, + end_lineno=45, + end_col_offset=78)], + [], + lineno=37, + col_offset=8, + end_lineno=45, + end_col_offset=78), + If( + UnaryOp( + Not(), + Call( + Name( + 'any', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=18), + [ + Name( + 'to_visit', + Load(), + lineno=46, + col_offset=19, + end_lineno=46, + end_col_offset=27)], + [], + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=28), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=28), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=28), + [ + Constant( + 'No more moves!', + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=45)], + [], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=46), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=46)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=46), + Assign( + [ + Tuple( + [ + Name( + 'buckets', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=15), + Name( + 'count', + Store(), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=22)], + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=22)], + Call( + Attribute( + Name( + 'to_visit', + Load(), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=33), + 'pop', + Load(), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=37), + [ + Constant( + 0, + lineno=48, + col_offset=38, + end_lineno=48, + end_col_offset=39)], + [], + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=40), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=40)], + [], + lineno=35, + col_offset=4, + end_lineno=48, + end_col_offset=40), + Assign( + [ + Name( + 'goal_index', + Store(), + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=14)], + Call( + Attribute( + Name( + 'buckets', + Load(), + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=24), + 'index', + Load(), + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=30), + [ + Name( + 'goal', + Load(), + lineno=50, + col_offset=31, + end_lineno=50, + end_col_offset=35)], + [], + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=36), + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=36), + Assign( + [ + Name( + 'goal_bucket', + Store(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=15)], + Subscript( + List( + [ + Constant( + 'one', + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=24), + Constant( + 'two', + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=31)], + Load(), + lineno=51, + col_offset=18, + end_lineno=51, + end_col_offset=32), + Name( + 'goal_index', + Load(), + lineno=51, + col_offset=33, + end_lineno=51, + end_col_offset=43), + Load(), + lineno=51, + col_offset=18, + end_lineno=51, + end_col_offset=44), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=44), + Assign( + [ + Name( + 'other_bucket', + Store(), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=16)], + Subscript( + Name( + 'buckets', + Load(), + lineno=52, + col_offset=19, + end_lineno=52, + end_col_offset=26), + BinOp( + Constant( + 1, + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=28), + Sub(), + Name( + 'goal_index', + Load(), + lineno=52, + col_offset=31, + end_lineno=52, + end_col_offset=41), + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=41), + Load(), + lineno=52, + col_offset=19, + end_lineno=52, + end_col_offset=42), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=42), + Return( + Tuple( + [ + Name( + 'count', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=17), + Name( + 'goal_bucket', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=30), + Name( + 'other_bucket', + Load(), + lineno=53, + col_offset=32, + end_lineno=53, + end_col_offset=44)], + Load(), + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=45), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=45)], + [], + lineno=8, + col_offset=0, + end_lineno=53, + end_col_offset=45)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=8, + col_offset=12, + end_lineno=8, + end_col_offset=22), + arg( + 'placeholder_2', + lineno=8, + col_offset=24, + end_lineno=8, + end_col_offset=34), + arg( + 'placeholder_3', + lineno=8, + col_offset=36, + end_lineno=8, + end_col_offset=40), + arg( + 'placeholder_4', + lineno=8, + col_offset=42, + end_lineno=8, + end_col_offset=54)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=9)], + List( + [ + Name( + 'placeholder_1', + Load(), + lineno=9, + col_offset=13, + end_lineno=9, + end_col_offset=23), + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=35)], + Load(), + lineno=9, + col_offset=12, + end_lineno=9, + end_col_offset=36), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=36), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=14)], + IfExp( + Compare( + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=34), + [ + Eq()], + [ + Constant( + 'one', + lineno=10, + col_offset=38, + end_lineno=10, + end_col_offset=43)], + lineno=10, + col_offset=22, + end_lineno=10, + end_col_offset=43), + Constant( + 0, + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=18), + Constant( + 1, + lineno=10, + col_offset=49, + end_lineno=10, + end_col_offset=50), + lineno=10, + col_offset=17, + end_lineno=10, + end_col_offset=50), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=50), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=12, + col_offset=14, + end_lineno=12, + end_col_offset=21), + arg( + 'placeholder_9', + lineno=12, + col_offset=23, + end_lineno=12, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=37), + [ + Eq()], + [ + Constant( + 0, + lineno=13, + col_offset=41, + end_lineno=13, + end_col_offset=42)], + lineno=13, + col_offset=34, + end_lineno=13, + end_col_offset=42), + List( + [ + Constant( + 0, + lineno=13, + col_offset=16, + end_lineno=13, + end_col_offset=17), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=26), + Constant( + 1, + lineno=13, + col_offset=27, + end_lineno=13, + end_col_offset=28), + Load(), + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=29)], + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=30), + List( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=56), + Constant( + 0, + lineno=13, + col_offset=57, + end_lineno=13, + end_col_offset=58), + Load(), + lineno=13, + col_offset=49, + end_lineno=13, + end_col_offset=59), + Constant( + 0, + lineno=13, + col_offset=61, + end_lineno=13, + end_col_offset=62)], + Load(), + lineno=13, + col_offset=48, + end_lineno=13, + end_col_offset=63), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=63), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=63)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=63), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=15, + col_offset=13, + end_lineno=15, + end_col_offset=20), + arg( + 'placeholder_9', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=16, + col_offset=41, + end_lineno=16, + end_col_offset=44), + [ + Eq()], + [ + Constant( + 0, + lineno=16, + col_offset=48, + end_lineno=16, + end_col_offset=49)], + lineno=16, + col_offset=41, + end_lineno=16, + end_col_offset=49), + List( + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=21), + Constant( + 0, + lineno=16, + col_offset=22, + end_lineno=16, + end_col_offset=23), + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=24), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=33), + Constant( + 1, + lineno=16, + col_offset=34, + end_lineno=16, + end_col_offset=35), + Load(), + lineno=16, + col_offset=26, + end_lineno=16, + end_col_offset=36)], + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=37), + List( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=63), + Constant( + 0, + lineno=16, + col_offset=64, + end_lineno=16, + end_col_offset=65), + Load(), + lineno=16, + col_offset=56, + end_lineno=16, + end_col_offset=66), + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=16, + col_offset=68, + end_lineno=16, + end_col_offset=73), + Constant( + 1, + lineno=16, + col_offset=74, + end_lineno=16, + end_col_offset=75), + Load(), + lineno=16, + col_offset=68, + end_lineno=16, + end_col_offset=76)], + Load(), + lineno=16, + col_offset=55, + end_lineno=16, + end_col_offset=77), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=77), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=77)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=77), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=27), + arg( + 'placeholder_9', + lineno=18, + col_offset=29, + end_lineno=18, + end_col_offset=32)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_12', + Store(), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=14)], + Call( + Name( + 'min', + Load(), + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=20), + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=28), + BinOp( + Constant( + 1, + lineno=19, + col_offset=29, + end_lineno=19, + end_col_offset=30), + Sub(), + Name( + 'placeholder_9', + Load(), + lineno=19, + col_offset=33, + end_lineno=19, + end_col_offset=36), + lineno=19, + col_offset=29, + end_lineno=19, + end_col_offset=36), + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=37), + BinOp( + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=44), + Name( + 'placeholder_9', + Load(), + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=48), + Load(), + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=49), + Sub(), + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=19, + col_offset=52, + end_lineno=19, + end_col_offset=59), + Name( + 'placeholder_9', + Load(), + lineno=19, + col_offset=60, + end_lineno=19, + end_col_offset=63), + Load(), + lineno=19, + col_offset=52, + end_lineno=19, + end_col_offset=64), + lineno=19, + col_offset=39, + end_lineno=19, + end_col_offset=64)], + [], + lineno=19, + col_offset=17, + end_lineno=19, + end_col_offset=65), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=65), + Assign( + [ + Name( + 'placeholder_13', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=14)], + BinOp( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=24), + Name( + 'placeholder_9', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=28), + Load(), + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=29), + Add(), + Name( + 'placeholder_12', + Load(), + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=38), + lineno=20, + col_offset=17, + end_lineno=20, + end_col_offset=38), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=38), + Assign( + [ + Name( + 'placeholder_14', + Store(), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=14)], + BinOp( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=24), + BinOp( + Constant( + 1, + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=26), + Sub(), + Name( + 'placeholder_9', + Load(), + lineno=21, + col_offset=29, + end_lineno=21, + end_col_offset=32), + lineno=21, + col_offset=25, + end_lineno=21, + end_col_offset=32), + Load(), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=33), + Sub(), + Name( + 'placeholder_12', + Load(), + lineno=21, + col_offset=36, + end_lineno=21, + end_col_offset=42), + lineno=21, + col_offset=17, + end_lineno=21, + end_col_offset=42), + lineno=21, + col_offset=8, + end_lineno=21, + end_col_offset=42), + Return( + IfExp( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=22, + col_offset=35, + end_lineno=22, + end_col_offset=38), + [ + Eq()], + [ + Constant( + 0, + lineno=22, + col_offset=42, + end_lineno=22, + end_col_offset=43)], + lineno=22, + col_offset=35, + end_lineno=22, + end_col_offset=43), + List( + [ + Name( + 'placeholder_13', + Load(), + lineno=22, + col_offset=16, + end_lineno=22, + end_col_offset=22), + Name( + 'placeholder_14', + Load(), + lineno=22, + col_offset=24, + end_lineno=22, + end_col_offset=30)], + Load(), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=31), + List( + [ + Name( + 'placeholder_14', + Load(), + lineno=22, + col_offset=50, + end_lineno=22, + end_col_offset=56), + Name( + 'placeholder_13', + Load(), + lineno=22, + col_offset=58, + end_lineno=22, + end_col_offset=64)], + Load(), + lineno=22, + col_offset=49, + end_lineno=22, + end_col_offset=65), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=65), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=65)], + [], + lineno=18, + col_offset=4, + end_lineno=22, + end_col_offset=65), + FunctionDef( + 'placeholder_15', + arguments( + [], + [ + arg( + 'placeholder_8', + lineno=24, + col_offset=19, + end_lineno=24, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + FormattedValue( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=25), + Constant( + 0, + lineno=25, + col_offset=26, + end_lineno=25, + end_col_offset=27), + Load(), + lineno=25, + col_offset=18, + end_lineno=25, + end_col_offset=28), + -1, + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=43), + Constant( + ',', + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=43), + FormattedValue( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=38), + Constant( + 1, + lineno=25, + col_offset=39, + end_lineno=25, + end_col_offset=40), + Load(), + lineno=25, + col_offset=31, + end_lineno=25, + end_col_offset=41), + -1, + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=43)], + lineno=25, + col_offset=15, + end_lineno=25, + end_col_offset=43), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=43)], + [], + lineno=24, + col_offset=4, + end_lineno=25, + end_col_offset=43), + Assign( + [ + Name( + 'placeholder_16', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=11)], + List( + [ + Constant( + 0, + lineno=27, + col_offset=15, + end_lineno=27, + end_col_offset=16), + Constant( + 0, + lineno=27, + col_offset=18, + end_lineno=27, + end_col_offset=19)], + Load(), + lineno=27, + col_offset=14, + end_lineno=27, + end_col_offset=20), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=20), + Assign( + [ + Subscript( + Name( + 'placeholder_16', + Load(), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=11), + BinOp( + Constant( + 1, + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=13), + Sub(), + Name( + 'placeholder_6', + Load(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=26), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=26), + Store(), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=27)], + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=28, + col_offset=30, + end_lineno=28, + end_col_offset=35), + BinOp( + Constant( + 1, + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=37), + Sub(), + Name( + 'placeholder_6', + Load(), + lineno=28, + col_offset=40, + end_lineno=28, + end_col_offset=50), + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=50), + Load(), + lineno=28, + col_offset=30, + end_lineno=28, + end_col_offset=51), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=51), + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=18)], + Call( + Name( + 'placeholder_15', + Load(), + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=31), + [ + Name( + 'placeholder_16', + Load(), + lineno=29, + col_offset=32, + end_lineno=29, + end_col_offset=39)], + [], + lineno=29, + col_offset=21, + end_lineno=29, + end_col_offset=40), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=11)], + List( + [ + Constant( + 0, + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=16), + Constant( + 0, + lineno=30, + col_offset=18, + end_lineno=30, + end_col_offset=19)], + Load(), + lineno=30, + col_offset=14, + end_lineno=30, + end_col_offset=20), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=20), + Assign( + [ + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=11), + Name( + 'placeholder_6', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=22), + Store(), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=23)], + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=31), + Name( + 'placeholder_6', + Load(), + lineno=31, + col_offset=32, + end_lineno=31, + end_col_offset=42), + Load(), + lineno=31, + col_offset=26, + end_lineno=31, + end_col_offset=43), + lineno=31, + col_offset=4, + end_lineno=31, + end_col_offset=43), + Assign( + [ + Name( + 'placeholder_18', + Store(), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=12)], + List( + [], + Load(), + lineno=32, + col_offset=15, + end_lineno=32, + end_col_offset=17), + lineno=32, + col_offset=4, + end_lineno=32, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_19', + Store(), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=11)], + Call( + Name( + 'set', + Load(), + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=17), + [], + [], + lineno=33, + col_offset=14, + end_lineno=33, + end_col_offset=19), + lineno=33, + col_offset=4, + end_lineno=33, + end_col_offset=19), + Assign( + [ + Name( + 'placeholder_20', + Store(), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=9)], + Constant( + 1, + lineno=34, + col_offset=12, + end_lineno=34, + end_col_offset=13), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=13), + While( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=35, + col_offset=10, + end_lineno=35, + end_col_offset=14), + [ + NotIn()], + [ + Name( + 'placeholder_8', + Load(), + lineno=35, + col_offset=22, + end_lineno=35, + end_col_offset=29)], + lineno=35, + col_offset=10, + end_lineno=35, + end_col_offset=29), + [ + Assign( + [ + Name( + 'placeholder_21', + Store(), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=11)], + Call( + Name( + 'placeholder_15', + Load(), + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=24), + [ + Name( + 'placeholder_8', + Load(), + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=32)], + [], + lineno=36, + col_offset=14, + end_lineno=36, + end_col_offset=33), + lineno=36, + col_offset=8, + end_lineno=36, + end_col_offset=33), + If( + BoolOp( + And(), + [ + Compare( + Name( + 'placeholder_21', + Load(), + lineno=37, + col_offset=11, + end_lineno=37, + end_col_offset=14), + [ + NotEq()], + [ + Name( + 'placeholder_17', + Load(), + lineno=37, + col_offset=18, + end_lineno=37, + end_col_offset=32)], + lineno=37, + col_offset=11, + end_lineno=37, + end_col_offset=32), + Compare( + Name( + 'placeholder_21', + Load(), + lineno=37, + col_offset=37, + end_lineno=37, + end_col_offset=40), + [ + NotIn()], + [ + Name( + 'placeholder_19', + Load(), + lineno=37, + col_offset=48, + end_lineno=37, + end_col_offset=55)], + lineno=37, + col_offset=37, + end_lineno=37, + end_col_offset=55)], + lineno=37, + col_offset=11, + end_lineno=37, + end_col_offset=55), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_19', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=19), + 'add', + Load(), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=23), + [ + Name( + 'placeholder_21', + Load(), + lineno=38, + col_offset=24, + end_lineno=38, + end_col_offset=27)], + [], + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=28), + lineno=38, + col_offset=12, + end_lineno=38, + end_col_offset=28), + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=24)], + BinOp( + Name( + 'placeholder_20', + Load(), + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=32), + Add(), + Constant( + 1, + lineno=39, + col_offset=35, + end_lineno=39, + end_col_offset=36), + lineno=39, + col_offset=27, + end_lineno=39, + end_col_offset=36), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=36), + For( + Name( + 'placeholder_9', + Store(), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=19), + Call( + Name( + 'range', + Load(), + lineno=40, + col_offset=23, + end_lineno=40, + end_col_offset=28), + [ + Constant( + 2, + lineno=40, + col_offset=29, + end_lineno=40, + end_col_offset=30)], + [], + lineno=40, + col_offset=23, + end_lineno=40, + end_col_offset=31), + [ + If( + Compare( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=26), + Name( + 'placeholder_9', + Load(), + lineno=41, + col_offset=27, + end_lineno=41, + end_col_offset=30), + Load(), + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=31), + [ + NotEq()], + [ + Constant( + 0, + lineno=41, + col_offset=35, + end_lineno=41, + end_col_offset=36)], + lineno=41, + col_offset=19, + end_lineno=41, + end_col_offset=36), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=28), + 'append', + Load(), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=35), + [ + Tuple( + [ + Call( + Name( + 'placeholder_7', + Load(), + lineno=42, + col_offset=37, + end_lineno=42, + end_col_offset=42), + [ + Name( + 'placeholder_8', + Load(), + lineno=42, + col_offset=43, + end_lineno=42, + end_col_offset=50), + Name( + 'placeholder_9', + Load(), + lineno=42, + col_offset=52, + end_lineno=42, + end_col_offset=55)], + [], + lineno=42, + col_offset=37, + end_lineno=42, + end_col_offset=56), + Name( + 'placeholder_22', + Load(), + lineno=42, + col_offset=58, + end_lineno=42, + end_col_offset=70)], + Load(), + lineno=42, + col_offset=36, + end_lineno=42, + end_col_offset=71)], + [], + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=72), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=72)], + [], + lineno=41, + col_offset=16, + end_lineno=42, + end_col_offset=72), + If( + Compare( + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=26), + Name( + 'placeholder_9', + Load(), + lineno=43, + col_offset=27, + end_lineno=43, + end_col_offset=30), + Load(), + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=31), + [ + NotEq()], + [ + Subscript( + Name( + 'placeholder_5', + Load(), + lineno=43, + col_offset=35, + end_lineno=43, + end_col_offset=40), + Name( + 'placeholder_9', + Load(), + lineno=43, + col_offset=41, + end_lineno=43, + end_col_offset=44), + Load(), + lineno=43, + col_offset=35, + end_lineno=43, + end_col_offset=45)], + lineno=43, + col_offset=19, + end_lineno=43, + end_col_offset=45), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=28), + 'append', + Load(), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=35), + [ + Tuple( + [ + Call( + Name( + 'placeholder_10', + Load(), + lineno=44, + col_offset=37, + end_lineno=44, + end_col_offset=41), + [ + Name( + 'placeholder_8', + Load(), + lineno=44, + col_offset=42, + end_lineno=44, + end_col_offset=49), + Name( + 'placeholder_9', + Load(), + lineno=44, + col_offset=51, + end_lineno=44, + end_col_offset=54)], + [], + lineno=44, + col_offset=37, + end_lineno=44, + end_col_offset=55), + Name( + 'placeholder_22', + Load(), + lineno=44, + col_offset=57, + end_lineno=44, + end_col_offset=69)], + Load(), + lineno=44, + col_offset=36, + end_lineno=44, + end_col_offset=70)], + [], + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=71), + lineno=44, + col_offset=20, + end_lineno=44, + end_col_offset=71), + Expr( + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=28), + 'append', + Load(), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=35), + [ + Tuple( + [ + Call( + Name( + 'placeholder_11', + Load(), + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=48), + [ + Name( + 'placeholder_8', + Load(), + lineno=45, + col_offset=49, + end_lineno=45, + end_col_offset=56), + Name( + 'placeholder_9', + Load(), + lineno=45, + col_offset=58, + end_lineno=45, + end_col_offset=61)], + [], + lineno=45, + col_offset=37, + end_lineno=45, + end_col_offset=62), + Name( + 'placeholder_22', + Load(), + lineno=45, + col_offset=64, + end_lineno=45, + end_col_offset=76)], + Load(), + lineno=45, + col_offset=36, + end_lineno=45, + end_col_offset=77)], + [], + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=78), + lineno=45, + col_offset=20, + end_lineno=45, + end_col_offset=78)], + [], + lineno=43, + col_offset=16, + end_lineno=45, + end_col_offset=78)], + [], + lineno=40, + col_offset=12, + end_lineno=45, + end_col_offset=78)], + [], + lineno=37, + col_offset=8, + end_lineno=45, + end_col_offset=78), + If( + UnaryOp( + Not(), + Call( + Name( + 'any', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=18), + [ + Name( + 'placeholder_18', + Load(), + lineno=46, + col_offset=19, + end_lineno=46, + end_col_offset=27)], + [], + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=28), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=28), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=28), + [ + Constant( + 'No more moves!', + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=45)], + [], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=46), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=46)], + [], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=46), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_8', + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=15), + Name( + 'placeholder_20', + Store(), + lineno=48, + col_offset=17, + end_lineno=48, + end_col_offset=22)], + Store(), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=22)], + Call( + Attribute( + Name( + 'placeholder_18', + Load(), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=33), + 'pop', + Load(), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=37), + [ + Constant( + 0, + lineno=48, + col_offset=38, + end_lineno=48, + end_col_offset=39)], + [], + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=40), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=40)], + [], + lineno=35, + col_offset=4, + end_lineno=48, + end_col_offset=40), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=14)], + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=24), + 'index', + Load(), + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=30), + [ + Name( + 'placeholder_3', + Load(), + lineno=50, + col_offset=31, + end_lineno=50, + end_col_offset=35)], + [], + lineno=50, + col_offset=17, + end_lineno=50, + end_col_offset=36), + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=36), + Assign( + [ + Name( + 'placeholder_23', + Store(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=15)], + Subscript( + List( + [ + Constant( + 'one', + lineno=51, + col_offset=19, + end_lineno=51, + end_col_offset=24), + Constant( + 'two', + lineno=51, + col_offset=26, + end_lineno=51, + end_col_offset=31)], + Load(), + lineno=51, + col_offset=18, + end_lineno=51, + end_col_offset=32), + Name( + 'placeholder_6', + Load(), + lineno=51, + col_offset=33, + end_lineno=51, + end_col_offset=43), + Load(), + lineno=51, + col_offset=18, + end_lineno=51, + end_col_offset=44), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=44), + Assign( + [ + Name( + 'placeholder_24', + Store(), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=16)], + Subscript( + Name( + 'placeholder_8', + Load(), + lineno=52, + col_offset=19, + end_lineno=52, + end_col_offset=26), + BinOp( + Constant( + 1, + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=28), + Sub(), + Name( + 'placeholder_6', + Load(), + lineno=52, + col_offset=31, + end_lineno=52, + end_col_offset=41), + lineno=52, + col_offset=27, + end_lineno=52, + end_col_offset=41), + Load(), + lineno=52, + col_offset=19, + end_lineno=52, + end_col_offset=42), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=42), + Return( + Tuple( + [ + Name( + 'placeholder_20', + Load(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=17), + Name( + 'placeholder_23', + Load(), + lineno=53, + col_offset=19, + end_lineno=53, + end_col_offset=30), + Name( + 'placeholder_24', + Load(), + lineno=53, + col_offset=32, + end_lineno=53, + end_col_offset=44)], + Load(), + lineno=53, + col_offset=11, + end_lineno=53, + end_col_offset=45), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=45)], + [], + lineno=8, + col_offset=0, + end_lineno=53, + end_col_offset=45)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-two-bucket/representation.txt b/test/practice-two-bucket/representation.txt new file mode 100644 index 0000000..8a70692 --- /dev/null +++ b/test/practice-two-bucket/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=8, col_offset=12, end_lineno=8, end_col_offset=22), arg('placeholder_2', lineno=8, col_offset=24, end_lineno=8, end_col_offset=34), arg('placeholder_3', lineno=8, col_offset=36, end_lineno=8, end_col_offset=40), arg('placeholder_4', lineno=8, col_offset=42, end_lineno=8, end_col_offset=54)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_5', Store(), lineno=9, col_offset=4, end_lineno=9, end_col_offset=9)], List([Name('placeholder_1', Load(), lineno=9, col_offset=13, end_lineno=9, end_col_offset=23), Name('placeholder_2', Load(), lineno=9, col_offset=25, end_lineno=9, end_col_offset=35)], Load(), lineno=9, col_offset=12, end_lineno=9, end_col_offset=36), lineno=9, col_offset=4, end_lineno=9, end_col_offset=36), Assign([Name('placeholder_6', Store(), lineno=10, col_offset=4, end_lineno=10, end_col_offset=14)], IfExp(Compare(Name('placeholder_4', Load(), lineno=10, col_offset=22, end_lineno=10, end_col_offset=34), [Eq()], [Constant('one', lineno=10, col_offset=38, end_lineno=10, end_col_offset=43)], lineno=10, col_offset=22, end_lineno=10, end_col_offset=43), Constant(0, lineno=10, col_offset=17, end_lineno=10, end_col_offset=18), Constant(1, lineno=10, col_offset=49, end_lineno=10, end_col_offset=50), lineno=10, col_offset=17, end_lineno=10, end_col_offset=50), lineno=10, col_offset=4, end_lineno=10, end_col_offset=50), FunctionDef('placeholder_7', arguments([], [arg('placeholder_8', lineno=12, col_offset=14, end_lineno=12, end_col_offset=21), arg('placeholder_9', lineno=12, col_offset=23, end_lineno=12, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(IfExp(Compare(Name('placeholder_9', Load(), lineno=13, col_offset=34, end_lineno=13, end_col_offset=37), [Eq()], [Constant(0, lineno=13, col_offset=41, end_lineno=13, end_col_offset=42)], lineno=13, col_offset=34, end_lineno=13, end_col_offset=42), List([Constant(0, lineno=13, col_offset=16, end_lineno=13, end_col_offset=17), Subscript(Name('placeholder_8', Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=26), Constant(1, lineno=13, col_offset=27, end_lineno=13, end_col_offset=28), Load(), lineno=13, col_offset=19, end_lineno=13, end_col_offset=29)], Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=30), List([Subscript(Name('placeholder_8', Load(), lineno=13, col_offset=49, end_lineno=13, end_col_offset=56), Constant(0, lineno=13, col_offset=57, end_lineno=13, end_col_offset=58), Load(), lineno=13, col_offset=49, end_lineno=13, end_col_offset=59), Constant(0, lineno=13, col_offset=61, end_lineno=13, end_col_offset=62)], Load(), lineno=13, col_offset=48, end_lineno=13, end_col_offset=63), lineno=13, col_offset=15, end_lineno=13, end_col_offset=63), lineno=13, col_offset=8, end_lineno=13, end_col_offset=63)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=63), FunctionDef('placeholder_10', arguments([], [arg('placeholder_8', lineno=15, col_offset=13, end_lineno=15, end_col_offset=20), arg('placeholder_9', lineno=15, col_offset=22, end_lineno=15, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(IfExp(Compare(Name('placeholder_9', Load(), lineno=16, col_offset=41, end_lineno=16, end_col_offset=44), [Eq()], [Constant(0, lineno=16, col_offset=48, end_lineno=16, end_col_offset=49)], lineno=16, col_offset=41, end_lineno=16, end_col_offset=49), List([Subscript(Name('placeholder_5', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=21), Constant(0, lineno=16, col_offset=22, end_lineno=16, end_col_offset=23), Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=24), Subscript(Name('placeholder_8', Load(), lineno=16, col_offset=26, end_lineno=16, end_col_offset=33), Constant(1, lineno=16, col_offset=34, end_lineno=16, end_col_offset=35), Load(), lineno=16, col_offset=26, end_lineno=16, end_col_offset=36)], Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=37), List([Subscript(Name('placeholder_8', Load(), lineno=16, col_offset=56, end_lineno=16, end_col_offset=63), Constant(0, lineno=16, col_offset=64, end_lineno=16, end_col_offset=65), Load(), lineno=16, col_offset=56, end_lineno=16, end_col_offset=66), Subscript(Name('placeholder_5', Load(), lineno=16, col_offset=68, end_lineno=16, end_col_offset=73), Constant(1, lineno=16, col_offset=74, end_lineno=16, end_col_offset=75), Load(), lineno=16, col_offset=68, end_lineno=16, end_col_offset=76)], Load(), lineno=16, col_offset=55, end_lineno=16, end_col_offset=77), lineno=16, col_offset=15, end_lineno=16, end_col_offset=77), lineno=16, col_offset=8, end_lineno=16, end_col_offset=77)], [], lineno=15, col_offset=4, end_lineno=16, end_col_offset=77), FunctionDef('placeholder_11', arguments([], [arg('placeholder_8', lineno=18, col_offset=20, end_lineno=18, end_col_offset=27), arg('placeholder_9', lineno=18, col_offset=29, end_lineno=18, end_col_offset=32)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_12', Store(), lineno=19, col_offset=8, end_lineno=19, end_col_offset=14)], Call(Name('min', Load(), lineno=19, col_offset=17, end_lineno=19, end_col_offset=20), [Subscript(Name('placeholder_8', Load(), lineno=19, col_offset=21, end_lineno=19, end_col_offset=28), BinOp(Constant(1, lineno=19, col_offset=29, end_lineno=19, end_col_offset=30), Sub(), Name('placeholder_9', Load(), lineno=19, col_offset=33, end_lineno=19, end_col_offset=36), lineno=19, col_offset=29, end_lineno=19, end_col_offset=36), Load(), lineno=19, col_offset=21, end_lineno=19, end_col_offset=37), BinOp(Subscript(Name('placeholder_5', Load(), lineno=19, col_offset=39, end_lineno=19, end_col_offset=44), Name('placeholder_9', Load(), lineno=19, col_offset=45, end_lineno=19, end_col_offset=48), Load(), lineno=19, col_offset=39, end_lineno=19, end_col_offset=49), Sub(), Subscript(Name('placeholder_8', Load(), lineno=19, col_offset=52, end_lineno=19, end_col_offset=59), Name('placeholder_9', Load(), lineno=19, col_offset=60, end_lineno=19, end_col_offset=63), Load(), lineno=19, col_offset=52, end_lineno=19, end_col_offset=64), lineno=19, col_offset=39, end_lineno=19, end_col_offset=64)], [], lineno=19, col_offset=17, end_lineno=19, end_col_offset=65), lineno=19, col_offset=8, end_lineno=19, end_col_offset=65), Assign([Name('placeholder_13', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=14)], BinOp(Subscript(Name('placeholder_8', Load(), lineno=20, col_offset=17, end_lineno=20, end_col_offset=24), Name('placeholder_9', Load(), lineno=20, col_offset=25, end_lineno=20, end_col_offset=28), Load(), lineno=20, col_offset=17, end_lineno=20, end_col_offset=29), Add(), Name('placeholder_12', Load(), lineno=20, col_offset=32, end_lineno=20, end_col_offset=38), lineno=20, col_offset=17, end_lineno=20, end_col_offset=38), lineno=20, col_offset=8, end_lineno=20, end_col_offset=38), Assign([Name('placeholder_14', Store(), lineno=21, col_offset=8, end_lineno=21, end_col_offset=14)], BinOp(Subscript(Name('placeholder_8', Load(), lineno=21, col_offset=17, end_lineno=21, end_col_offset=24), BinOp(Constant(1, lineno=21, col_offset=25, end_lineno=21, end_col_offset=26), Sub(), Name('placeholder_9', Load(), lineno=21, col_offset=29, end_lineno=21, end_col_offset=32), lineno=21, col_offset=25, end_lineno=21, end_col_offset=32), Load(), lineno=21, col_offset=17, end_lineno=21, end_col_offset=33), Sub(), Name('placeholder_12', Load(), lineno=21, col_offset=36, end_lineno=21, end_col_offset=42), lineno=21, col_offset=17, end_lineno=21, end_col_offset=42), lineno=21, col_offset=8, end_lineno=21, end_col_offset=42), Return(IfExp(Compare(Name('placeholder_9', Load(), lineno=22, col_offset=35, end_lineno=22, end_col_offset=38), [Eq()], [Constant(0, lineno=22, col_offset=42, end_lineno=22, end_col_offset=43)], lineno=22, col_offset=35, end_lineno=22, end_col_offset=43), List([Name('placeholder_13', Load(), lineno=22, col_offset=16, end_lineno=22, end_col_offset=22), Name('placeholder_14', Load(), lineno=22, col_offset=24, end_lineno=22, end_col_offset=30)], Load(), lineno=22, col_offset=15, end_lineno=22, end_col_offset=31), List([Name('placeholder_14', Load(), lineno=22, col_offset=50, end_lineno=22, end_col_offset=56), Name('placeholder_13', Load(), lineno=22, col_offset=58, end_lineno=22, end_col_offset=64)], Load(), lineno=22, col_offset=49, end_lineno=22, end_col_offset=65), lineno=22, col_offset=15, end_lineno=22, end_col_offset=65), lineno=22, col_offset=8, end_lineno=22, end_col_offset=65)], [], lineno=18, col_offset=4, end_lineno=22, end_col_offset=65), FunctionDef('placeholder_15', arguments([], [arg('placeholder_8', lineno=24, col_offset=19, end_lineno=24, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(JoinedStr([FormattedValue(Subscript(Name('placeholder_8', Load(), lineno=25, col_offset=18, end_lineno=25, end_col_offset=25), Constant(0, lineno=25, col_offset=26, end_lineno=25, end_col_offset=27), Load(), lineno=25, col_offset=18, end_lineno=25, end_col_offset=28), -1, lineno=25, col_offset=15, end_lineno=25, end_col_offset=43), Constant(',', lineno=25, col_offset=15, end_lineno=25, end_col_offset=43), FormattedValue(Subscript(Name('placeholder_8', Load(), lineno=25, col_offset=31, end_lineno=25, end_col_offset=38), Constant(1, lineno=25, col_offset=39, end_lineno=25, end_col_offset=40), Load(), lineno=25, col_offset=31, end_lineno=25, end_col_offset=41), -1, lineno=25, col_offset=15, end_lineno=25, end_col_offset=43)], lineno=25, col_offset=15, end_lineno=25, end_col_offset=43), lineno=25, col_offset=8, end_lineno=25, end_col_offset=43)], [], lineno=24, col_offset=4, end_lineno=25, end_col_offset=43), Assign([Name('placeholder_16', Store(), lineno=27, col_offset=4, end_lineno=27, end_col_offset=11)], List([Constant(0, lineno=27, col_offset=15, end_lineno=27, end_col_offset=16), Constant(0, lineno=27, col_offset=18, end_lineno=27, end_col_offset=19)], Load(), lineno=27, col_offset=14, end_lineno=27, end_col_offset=20), lineno=27, col_offset=4, end_lineno=27, end_col_offset=20), Assign([Subscript(Name('placeholder_16', Load(), lineno=28, col_offset=4, end_lineno=28, end_col_offset=11), BinOp(Constant(1, lineno=28, col_offset=12, end_lineno=28, end_col_offset=13), Sub(), Name('placeholder_6', Load(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=26), lineno=28, col_offset=12, end_lineno=28, end_col_offset=26), Store(), lineno=28, col_offset=4, end_lineno=28, end_col_offset=27)], Subscript(Name('placeholder_5', Load(), lineno=28, col_offset=30, end_lineno=28, end_col_offset=35), BinOp(Constant(1, lineno=28, col_offset=36, end_lineno=28, end_col_offset=37), Sub(), Name('placeholder_6', Load(), lineno=28, col_offset=40, end_lineno=28, end_col_offset=50), lineno=28, col_offset=36, end_lineno=28, end_col_offset=50), Load(), lineno=28, col_offset=30, end_lineno=28, end_col_offset=51), lineno=28, col_offset=4, end_lineno=28, end_col_offset=51), Assign([Name('placeholder_17', Store(), lineno=29, col_offset=4, end_lineno=29, end_col_offset=18)], Call(Name('placeholder_15', Load(), lineno=29, col_offset=21, end_lineno=29, end_col_offset=31), [Name('placeholder_16', Load(), lineno=29, col_offset=32, end_lineno=29, end_col_offset=39)], [], lineno=29, col_offset=21, end_lineno=29, end_col_offset=40), lineno=29, col_offset=4, end_lineno=29, end_col_offset=40), Assign([Name('placeholder_8', Store(), lineno=30, col_offset=4, end_lineno=30, end_col_offset=11)], List([Constant(0, lineno=30, col_offset=15, end_lineno=30, end_col_offset=16), Constant(0, lineno=30, col_offset=18, end_lineno=30, end_col_offset=19)], Load(), lineno=30, col_offset=14, end_lineno=30, end_col_offset=20), lineno=30, col_offset=4, end_lineno=30, end_col_offset=20), Assign([Subscript(Name('placeholder_8', Load(), lineno=31, col_offset=4, end_lineno=31, end_col_offset=11), Name('placeholder_6', Load(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=22), Store(), lineno=31, col_offset=4, end_lineno=31, end_col_offset=23)], Subscript(Name('placeholder_5', Load(), lineno=31, col_offset=26, end_lineno=31, end_col_offset=31), Name('placeholder_6', Load(), lineno=31, col_offset=32, end_lineno=31, end_col_offset=42), Load(), lineno=31, col_offset=26, end_lineno=31, end_col_offset=43), lineno=31, col_offset=4, end_lineno=31, end_col_offset=43), Assign([Name('placeholder_18', Store(), lineno=32, col_offset=4, end_lineno=32, end_col_offset=12)], List([], Load(), lineno=32, col_offset=15, end_lineno=32, end_col_offset=17), lineno=32, col_offset=4, end_lineno=32, end_col_offset=17), Assign([Name('placeholder_19', Store(), lineno=33, col_offset=4, end_lineno=33, end_col_offset=11)], Call(Name('set', Load(), lineno=33, col_offset=14, end_lineno=33, end_col_offset=17), [], [], lineno=33, col_offset=14, end_lineno=33, end_col_offset=19), lineno=33, col_offset=4, end_lineno=33, end_col_offset=19), Assign([Name('placeholder_20', Store(), lineno=34, col_offset=4, end_lineno=34, end_col_offset=9)], Constant(1, lineno=34, col_offset=12, end_lineno=34, end_col_offset=13), lineno=34, col_offset=4, end_lineno=34, end_col_offset=13), While(Compare(Name('placeholder_3', Load(), lineno=35, col_offset=10, end_lineno=35, end_col_offset=14), [NotIn()], [Name('placeholder_8', Load(), lineno=35, col_offset=22, end_lineno=35, end_col_offset=29)], lineno=35, col_offset=10, end_lineno=35, end_col_offset=29), [Assign([Name('placeholder_21', Store(), lineno=36, col_offset=8, end_lineno=36, end_col_offset=11)], Call(Name('placeholder_15', Load(), lineno=36, col_offset=14, end_lineno=36, end_col_offset=24), [Name('placeholder_8', Load(), lineno=36, col_offset=25, end_lineno=36, end_col_offset=32)], [], lineno=36, col_offset=14, end_lineno=36, end_col_offset=33), lineno=36, col_offset=8, end_lineno=36, end_col_offset=33), If(BoolOp(And(), [Compare(Name('placeholder_21', Load(), lineno=37, col_offset=11, end_lineno=37, end_col_offset=14), [NotEq()], [Name('placeholder_17', Load(), lineno=37, col_offset=18, end_lineno=37, end_col_offset=32)], lineno=37, col_offset=11, end_lineno=37, end_col_offset=32), Compare(Name('placeholder_21', Load(), lineno=37, col_offset=37, end_lineno=37, end_col_offset=40), [NotIn()], [Name('placeholder_19', Load(), lineno=37, col_offset=48, end_lineno=37, end_col_offset=55)], lineno=37, col_offset=37, end_lineno=37, end_col_offset=55)], lineno=37, col_offset=11, end_lineno=37, end_col_offset=55), [Expr(Call(Attribute(Name('placeholder_19', Load(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=19), 'add', Load(), lineno=38, col_offset=12, end_lineno=38, end_col_offset=23), [Name('placeholder_21', Load(), lineno=38, col_offset=24, end_lineno=38, end_col_offset=27)], [], lineno=38, col_offset=12, end_lineno=38, end_col_offset=28), lineno=38, col_offset=12, end_lineno=38, end_col_offset=28), Assign([Name('placeholder_22', Store(), lineno=39, col_offset=12, end_lineno=39, end_col_offset=24)], BinOp(Name('placeholder_20', Load(), lineno=39, col_offset=27, end_lineno=39, end_col_offset=32), Add(), Constant(1, lineno=39, col_offset=35, end_lineno=39, end_col_offset=36), lineno=39, col_offset=27, end_lineno=39, end_col_offset=36), lineno=39, col_offset=12, end_lineno=39, end_col_offset=36), For(Name('placeholder_9', Store(), lineno=40, col_offset=16, end_lineno=40, end_col_offset=19), Call(Name('range', Load(), lineno=40, col_offset=23, end_lineno=40, end_col_offset=28), [Constant(2, lineno=40, col_offset=29, end_lineno=40, end_col_offset=30)], [], lineno=40, col_offset=23, end_lineno=40, end_col_offset=31), [If(Compare(Subscript(Name('placeholder_8', Load(), lineno=41, col_offset=19, end_lineno=41, end_col_offset=26), Name('placeholder_9', Load(), lineno=41, col_offset=27, end_lineno=41, end_col_offset=30), Load(), lineno=41, col_offset=19, end_lineno=41, end_col_offset=31), [NotEq()], [Constant(0, lineno=41, col_offset=35, end_lineno=41, end_col_offset=36)], lineno=41, col_offset=19, end_lineno=41, end_col_offset=36), [Expr(Call(Attribute(Name('placeholder_18', Load(), lineno=42, col_offset=20, end_lineno=42, end_col_offset=28), 'append', Load(), lineno=42, col_offset=20, end_lineno=42, end_col_offset=35), [Tuple([Call(Name('placeholder_7', Load(), lineno=42, col_offset=37, end_lineno=42, end_col_offset=42), [Name('placeholder_8', Load(), lineno=42, col_offset=43, end_lineno=42, end_col_offset=50), Name('placeholder_9', Load(), lineno=42, col_offset=52, end_lineno=42, end_col_offset=55)], [], lineno=42, col_offset=37, end_lineno=42, end_col_offset=56), Name('placeholder_22', Load(), lineno=42, col_offset=58, end_lineno=42, end_col_offset=70)], Load(), lineno=42, col_offset=36, end_lineno=42, end_col_offset=71)], [], lineno=42, col_offset=20, end_lineno=42, end_col_offset=72), lineno=42, col_offset=20, end_lineno=42, end_col_offset=72)], [], lineno=41, col_offset=16, end_lineno=42, end_col_offset=72), If(Compare(Subscript(Name('placeholder_8', Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=26), Name('placeholder_9', Load(), lineno=43, col_offset=27, end_lineno=43, end_col_offset=30), Load(), lineno=43, col_offset=19, end_lineno=43, end_col_offset=31), [NotEq()], [Subscript(Name('placeholder_5', Load(), lineno=43, col_offset=35, end_lineno=43, end_col_offset=40), Name('placeholder_9', Load(), lineno=43, col_offset=41, end_lineno=43, end_col_offset=44), Load(), lineno=43, col_offset=35, end_lineno=43, end_col_offset=45)], lineno=43, col_offset=19, end_lineno=43, end_col_offset=45), [Expr(Call(Attribute(Name('placeholder_18', Load(), lineno=44, col_offset=20, end_lineno=44, end_col_offset=28), 'append', Load(), lineno=44, col_offset=20, end_lineno=44, end_col_offset=35), [Tuple([Call(Name('placeholder_10', Load(), lineno=44, col_offset=37, end_lineno=44, end_col_offset=41), [Name('placeholder_8', Load(), lineno=44, col_offset=42, end_lineno=44, end_col_offset=49), Name('placeholder_9', Load(), lineno=44, col_offset=51, end_lineno=44, end_col_offset=54)], [], lineno=44, col_offset=37, end_lineno=44, end_col_offset=55), Name('placeholder_22', Load(), lineno=44, col_offset=57, end_lineno=44, end_col_offset=69)], Load(), lineno=44, col_offset=36, end_lineno=44, end_col_offset=70)], [], lineno=44, col_offset=20, end_lineno=44, end_col_offset=71), lineno=44, col_offset=20, end_lineno=44, end_col_offset=71), Expr(Call(Attribute(Name('placeholder_18', Load(), lineno=45, col_offset=20, end_lineno=45, end_col_offset=28), 'append', Load(), lineno=45, col_offset=20, end_lineno=45, end_col_offset=35), [Tuple([Call(Name('placeholder_11', Load(), lineno=45, col_offset=37, end_lineno=45, end_col_offset=48), [Name('placeholder_8', Load(), lineno=45, col_offset=49, end_lineno=45, end_col_offset=56), Name('placeholder_9', Load(), lineno=45, col_offset=58, end_lineno=45, end_col_offset=61)], [], lineno=45, col_offset=37, end_lineno=45, end_col_offset=62), Name('placeholder_22', Load(), lineno=45, col_offset=64, end_lineno=45, end_col_offset=76)], Load(), lineno=45, col_offset=36, end_lineno=45, end_col_offset=77)], [], lineno=45, col_offset=20, end_lineno=45, end_col_offset=78), lineno=45, col_offset=20, end_lineno=45, end_col_offset=78)], [], lineno=43, col_offset=16, end_lineno=45, end_col_offset=78)], [], lineno=40, col_offset=12, end_lineno=45, end_col_offset=78)], [], lineno=37, col_offset=8, end_lineno=45, end_col_offset=78), If(UnaryOp(Not(), Call(Name('any', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=18), [Name('placeholder_18', Load(), lineno=46, col_offset=19, end_lineno=46, end_col_offset=27)], [], lineno=46, col_offset=15, end_lineno=46, end_col_offset=28), lineno=46, col_offset=11, end_lineno=46, end_col_offset=28), [Raise(Call(Name('ValueError', Load(), lineno=47, col_offset=18, end_lineno=47, end_col_offset=28), [Constant('No more moves!', lineno=47, col_offset=29, end_lineno=47, end_col_offset=45)], [], lineno=47, col_offset=18, end_lineno=47, end_col_offset=46), lineno=47, col_offset=12, end_lineno=47, end_col_offset=46)], [], lineno=46, col_offset=8, end_lineno=47, end_col_offset=46), Assign([Tuple([Name('placeholder_8', Store(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=15), Name('placeholder_20', Store(), lineno=48, col_offset=17, end_lineno=48, end_col_offset=22)], Store(), lineno=48, col_offset=8, end_lineno=48, end_col_offset=22)], Call(Attribute(Name('placeholder_18', Load(), lineno=48, col_offset=25, end_lineno=48, end_col_offset=33), 'pop', Load(), lineno=48, col_offset=25, end_lineno=48, end_col_offset=37), [Constant(0, lineno=48, col_offset=38, end_lineno=48, end_col_offset=39)], [], lineno=48, col_offset=25, end_lineno=48, end_col_offset=40), lineno=48, col_offset=8, end_lineno=48, end_col_offset=40)], [], lineno=35, col_offset=4, end_lineno=48, end_col_offset=40), Assign([Name('placeholder_6', Store(), lineno=50, col_offset=4, end_lineno=50, end_col_offset=14)], Call(Attribute(Name('placeholder_8', Load(), lineno=50, col_offset=17, end_lineno=50, end_col_offset=24), 'index', Load(), lineno=50, col_offset=17, end_lineno=50, end_col_offset=30), [Name('placeholder_3', Load(), lineno=50, col_offset=31, end_lineno=50, end_col_offset=35)], [], lineno=50, col_offset=17, end_lineno=50, end_col_offset=36), lineno=50, col_offset=4, end_lineno=50, end_col_offset=36), Assign([Name('placeholder_23', Store(), lineno=51, col_offset=4, end_lineno=51, end_col_offset=15)], Subscript(List([Constant('one', lineno=51, col_offset=19, end_lineno=51, end_col_offset=24), Constant('two', lineno=51, col_offset=26, end_lineno=51, end_col_offset=31)], Load(), lineno=51, col_offset=18, end_lineno=51, end_col_offset=32), Name('placeholder_6', Load(), lineno=51, col_offset=33, end_lineno=51, end_col_offset=43), Load(), lineno=51, col_offset=18, end_lineno=51, end_col_offset=44), lineno=51, col_offset=4, end_lineno=51, end_col_offset=44), Assign([Name('placeholder_24', Store(), lineno=52, col_offset=4, end_lineno=52, end_col_offset=16)], Subscript(Name('placeholder_8', Load(), lineno=52, col_offset=19, end_lineno=52, end_col_offset=26), BinOp(Constant(1, lineno=52, col_offset=27, end_lineno=52, end_col_offset=28), Sub(), Name('placeholder_6', Load(), lineno=52, col_offset=31, end_lineno=52, end_col_offset=41), lineno=52, col_offset=27, end_lineno=52, end_col_offset=41), Load(), lineno=52, col_offset=19, end_lineno=52, end_col_offset=42), lineno=52, col_offset=4, end_lineno=52, end_col_offset=42), Return(Tuple([Name('placeholder_20', Load(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=17), Name('placeholder_23', Load(), lineno=53, col_offset=19, end_lineno=53, end_col_offset=30), Name('placeholder_24', Load(), lineno=53, col_offset=32, end_lineno=53, end_col_offset=44)], Load(), lineno=53, col_offset=11, end_lineno=53, end_col_offset=45), lineno=53, col_offset=4, end_lineno=53, end_col_offset=45)], [], lineno=8, col_offset=0, end_lineno=53, end_col_offset=45)], []) \ No newline at end of file diff --git a/test/practice-two-bucket/two_bucket.py b/test/practice-two-bucket/two_bucket.py new file mode 100644 index 0000000..83077eb --- /dev/null +++ b/test/practice-two-bucket/two_bucket.py @@ -0,0 +1,53 @@ +''' + This solution implements a breadth-first search of the graph + of possible valid states for the two buckets until it reaches a state + in which one of the two buckets contains the goal amount +''' + + +def measure(bucket_one, bucket_two, goal, start_bucket): + sizes = [bucket_one, bucket_two] + goal_index = 0 if start_bucket == 'one' else 1 + + def empty(buckets, idx): + return [0, buckets[1]] if idx == 0 else [buckets[0], 0] + + def fill(buckets, idx): + return [sizes[0], buckets[1]] if idx == 0 else [buckets[0], sizes[1]] + + def consolidate(buckets, idx): + amount = min(buckets[1 - idx], sizes[idx] - buckets[idx]) + target = buckets[idx] + amount + source = buckets[1 - idx] - amount + return [target, source] if idx == 0 else [source, target] + + def bucket_str(buckets): + return f'{buckets[0]},{buckets[1]}' + + invalid = [0, 0] + invalid[1 - goal_index] = sizes[1 - goal_index] + invalid_string = bucket_str(invalid) + buckets = [0, 0] + buckets[goal_index] = sizes[goal_index] + to_visit = [] + visited = set() + count = 1 + while goal not in buckets: + key = bucket_str(buckets) + if key != invalid_string and key not in visited: + visited.add(key) + number_count = count + 1 + for idx in range(2): + if buckets[idx] != 0: + to_visit.append((empty(buckets, idx), number_count)) + if buckets[idx] != sizes[idx]: + to_visit.append((fill(buckets, idx), number_count)) + to_visit.append((consolidate(buckets, idx), number_count)) + if not any(to_visit): + raise ValueError('No more moves!') + buckets, count = to_visit.pop(0) + + goal_index = buckets.index(goal) + goal_bucket = ['one', 'two'][goal_index] + other_bucket = buckets[1 - goal_index] + return (count, goal_bucket, other_bucket) diff --git a/test/practice-two-fer/.meta/config.json b/test/practice-two-fer/.meta/config.json new file mode 100644 index 0000000..24e71e7 --- /dev/null +++ b/test/practice-two-fer/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "samwincott" + ], + "contributors": [ + "cmccandless", + "denislooby", + "Dog", + "Grociu", + "ikhadykin", + "mikeyny", + "N-Parsons", + "tqa236", + "xarxziux", + "yawpitch" + ], + "files": { + "solution": [ + "two_fer.py" + ], + "test": [ + "two_fer_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Create a sentence of the form \"One for X, one for me.\".", + "source_url": "https://github.com/exercism/problem-specifications/issues/757" +} diff --git a/test/practice-two-fer/mapping.json b/test/practice-two-fer/mapping.json new file mode 100644 index 0000000..d2f2ce0 --- /dev/null +++ b/test/practice-two-fer/mapping.json @@ -0,0 +1,4 @@ +{ + "placeholder_0": "two_fer", + "placeholder_1": "name" +} \ No newline at end of file diff --git a/test/practice-two-fer/representation.json b/test/practice-two-fer/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-two-fer/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-two-fer/representation.out b/test/practice-two-fer/representation.out new file mode 100644 index 0000000..bd33c1b --- /dev/null +++ b/test/practice-two-fer/representation.out @@ -0,0 +1,141 @@ +## BEGIN NORMALIZED CODE ## +def placeholder_0(placeholder_1="you"): + return f"One for {placeholder_1}, one for me." + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + FunctionDef( + 'two_fer', + arguments( + [], + [ + arg( + 'name', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 'you', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=22)]), + [ + Return( + JoinedStr( + [ + Constant( + 'One for ', + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=41), + FormattedValue( + Name( + 'name', + Load(), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=26), + -1, + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=41), + Constant( + ', one for me.', + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=41)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=41), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=41)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=41)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=1, + col_offset=12, + end_lineno=1, + end_col_offset=16)], + kwonlyargs=[], + kw_defaults=[], + defaults=[ + Constant( + 'you', + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=22)]), + [ + Return( + JoinedStr( + [ + Constant( + 'One for ', + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=41), + FormattedValue( + Name( + 'placeholder_1', + Load(), + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=26), + -1, + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=41), + Constant( + ', one for me.', + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=41)], + lineno=2, + col_offset=11, + end_lineno=2, + end_col_offset=41), + lineno=2, + col_offset=4, + end_lineno=2, + end_col_offset=41)], + [], + lineno=1, + col_offset=0, + end_lineno=2, + end_col_offset=41)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-two-fer/representation.txt b/test/practice-two-fer/representation.txt new file mode 100644 index 0000000..c84b10c --- /dev/null +++ b/test/practice-two-fer/representation.txt @@ -0,0 +1 @@ +Module([FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=1, col_offset=12, end_lineno=1, end_col_offset=16)], kwonlyargs=[], kw_defaults=[], defaults=[Constant('you', lineno=1, col_offset=17, end_lineno=1, end_col_offset=22)]), [Return(JoinedStr([Constant('One for ', lineno=2, col_offset=11, end_lineno=2, end_col_offset=41), FormattedValue(Name('placeholder_1', Load(), lineno=2, col_offset=22, end_lineno=2, end_col_offset=26), -1, lineno=2, col_offset=11, end_lineno=2, end_col_offset=41), Constant(', one for me.', lineno=2, col_offset=11, end_lineno=2, end_col_offset=41)], lineno=2, col_offset=11, end_lineno=2, end_col_offset=41), lineno=2, col_offset=4, end_lineno=2, end_col_offset=41)], [], lineno=1, col_offset=0, end_lineno=2, end_col_offset=41)], []) \ No newline at end of file diff --git a/test/practice-two-fer/two_fer.py b/test/practice-two-fer/two_fer.py new file mode 100644 index 0000000..425d236 --- /dev/null +++ b/test/practice-two-fer/two_fer.py @@ -0,0 +1,2 @@ +def two_fer(name='you'): + return f'One for {name}, one for me.' diff --git a/test/practice-variable-length-quantity/.meta/config.json b/test/practice-variable-length-quantity/.meta/config.json new file mode 100644 index 0000000..dc5843a --- /dev/null +++ b/test/practice-variable-length-quantity/.meta/config.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "ackerleytng", + "cmccandless", + "Dog", + "dvermd", + "ikhadykin", + "N-Parsons", + "siejqa", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "variable_length_quantity.py" + ], + "test": [ + "variable_length_quantity_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Implement variable length quantity encoding and decoding.", + "source": "A poor Splice developer having to implement MIDI encoding/decoding.", + "source_url": "https://splice.com" +} diff --git a/test/practice-variable-length-quantity/mapping.json b/test/practice-variable-length-quantity/mapping.json new file mode 100644 index 0000000..fc4b05b --- /dev/null +++ b/test/practice-variable-length-quantity/mapping.json @@ -0,0 +1,13 @@ +{ + "placeholder_0": "EIGHT_BIT_MASK", + "placeholder_1": "SEVEN_BIT_MASK", + "placeholder_2": "encode_single", + "placeholder_3": "number", + "placeholder_4": "byte_string", + "placeholder_5": "encode", + "placeholder_6": "numbers", + "placeholder_7": "decode", + "placeholder_8": "values", + "placeholder_9": "idx", + "placeholder_10": "byte" +} \ No newline at end of file diff --git a/test/practice-variable-length-quantity/representation.json b/test/practice-variable-length-quantity/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-variable-length-quantity/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-variable-length-quantity/representation.out b/test/practice-variable-length-quantity/representation.out new file mode 100644 index 0000000..8e43010 --- /dev/null +++ b/test/practice-variable-length-quantity/representation.out @@ -0,0 +1,1430 @@ +## BEGIN NORMALIZED CODE ## +placeholder_0 = 128 +placeholder_1 = 127 + + +def placeholder_2(placeholder_3): + placeholder_4 = [placeholder_3 & placeholder_1] + placeholder_3 >>= 7 + while placeholder_3 > 0: + placeholder_4.append(placeholder_3 & placeholder_1 | placeholder_0) + placeholder_3 >>= 7 + return placeholder_4[::-1] + + +def placeholder_5(placeholder_6): + return sum((placeholder_2(placeholder_3) for placeholder_3 in placeholder_6), []) + + +def placeholder_7(placeholder_4): + placeholder_8 = [] + placeholder_3 = 0 + for placeholder_9, placeholder_10 in enumerate(placeholder_4): + placeholder_3 <<= 7 + placeholder_3 += placeholder_10 & placeholder_1 + if placeholder_10 & placeholder_0 == 0: + placeholder_8.append(placeholder_3) + placeholder_3 = 0 + elif placeholder_9 == len(placeholder_4) - 1: + raise ValueError("incomplete sequence") + return placeholder_8 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Assign( + [ + Name( + 'EIGHT_BIT_MASK', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=14)], + Constant( + 128, + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=21), + Assign( + [ + Name( + 'SEVEN_BIT_MASK', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=14)], + Constant( + 127, + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=21), + FunctionDef( + 'encode_single', + arguments( + [], + [ + arg( + 'number', + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'byte_string', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15)], + List( + [ + BinOp( + Name( + 'number', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=25), + BitAnd(), + Name( + 'SEVEN_BIT_MASK', + Load(), + lineno=6, + col_offset=28, + end_lineno=6, + end_col_offset=42), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=42)], + Load(), + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=43), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=43), + AugAssign( + Name( + 'number', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=10), + RShift(), + Constant( + 7, + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=16), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=16), + While( + Compare( + Name( + 'number', + Load(), + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 0, + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=20)], + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=20), + [ + Expr( + Call( + Attribute( + Name( + 'byte_string', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=19), + 'append', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=26), + [ + BinOp( + BinOp( + Name( + 'number', + Load(), + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=33), + BitAnd(), + Name( + 'SEVEN_BIT_MASK', + Load(), + lineno=10, + col_offset=36, + end_lineno=10, + end_col_offset=50), + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=50), + BitOr(), + Name( + 'EIGHT_BIT_MASK', + Load(), + lineno=10, + col_offset=53, + end_lineno=10, + end_col_offset=67), + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=67)], + [], + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=68), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=68), + AugAssign( + Name( + 'number', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=14), + RShift(), + Constant( + 7, + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=20), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=20)], + [], + lineno=9, + col_offset=4, + end_lineno=11, + end_col_offset=20), + Return( + Subscript( + Name( + 'byte_string', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=22), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=27), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=27), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=27), + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=28)], + [], + lineno=5, + col_offset=0, + end_lineno=13, + end_col_offset=28), + FunctionDef( + 'encode', + arguments( + [], + [ + arg( + 'numbers', + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=14), + [ + GeneratorExp( + Call( + Name( + 'encode_single', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=29), + [ + Name( + 'number', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=36)], + [], + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=37), + [ + comprehension( + Name( + 'number', + Store(), + lineno=17, + col_offset=42, + end_lineno=17, + end_col_offset=48), + Name( + 'numbers', + Load(), + lineno=17, + col_offset=52, + end_lineno=17, + end_col_offset=59), + [], + 0)], + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=60), + List( + [], + Load(), + lineno=17, + col_offset=62, + end_lineno=17, + end_col_offset=64)], + [], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=65), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=65)], + [], + lineno=16, + col_offset=0, + end_lineno=17, + end_col_offset=65), + FunctionDef( + 'decode', + arguments( + [], + [ + arg( + 'byte_string', + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'values', + Store(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=10)], + List( + [], + Load(), + lineno=21, + col_offset=13, + end_lineno=21, + end_col_offset=15), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=15), + Assign( + [ + Name( + 'number', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=10)], + Constant( + 0, + lineno=22, + col_offset=13, + end_lineno=22, + end_col_offset=14), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=14), + For( + Tuple( + [ + Name( + 'idx', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=11), + Name( + 'byte', + Store(), + lineno=24, + col_offset=13, + end_lineno=24, + end_col_offset=17)], + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=17), + Call( + Name( + 'enumerate', + Load(), + lineno=24, + col_offset=21, + end_lineno=24, + end_col_offset=30), + [ + Name( + 'byte_string', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=42)], + [], + lineno=24, + col_offset=21, + end_lineno=24, + end_col_offset=43), + [ + AugAssign( + Name( + 'number', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=14), + LShift(), + Constant( + 7, + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=20), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=20), + AugAssign( + Name( + 'number', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=14), + Add(), + BinOp( + Name( + 'byte', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=23), + BitAnd(), + Name( + 'SEVEN_BIT_MASK', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=40), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=40), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=41), + If( + Compare( + BinOp( + Name( + 'byte', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=15), + BitAnd(), + Name( + 'EIGHT_BIT_MASK', + Load(), + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=32), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=32), + [ + Eq()], + [ + Constant( + 0, + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=37)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=37), + [ + Expr( + Call( + Attribute( + Name( + 'values', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=18), + 'append', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=25), + [ + Name( + 'number', + Load(), + lineno=29, + col_offset=26, + end_lineno=29, + end_col_offset=32)], + [], + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=33), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=33), + Assign( + [ + Name( + 'number', + Store(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=18)], + Constant( + 0, + lineno=30, + col_offset=21, + end_lineno=30, + end_col_offset=22), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=22)], + [ + If( + Compare( + Name( + 'idx', + Load(), + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=16), + [ + Eq()], + [ + BinOp( + Call( + Name( + 'len', + Load(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=23), + [ + Name( + 'byte_string', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=35)], + [], + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=36), + Sub(), + Constant( + 1, + lineno=31, + col_offset=39, + end_lineno=31, + end_col_offset=40), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=40)], + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=40), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=28), + [ + Constant( + 'incomplete sequence', + lineno=32, + col_offset=29, + end_lineno=32, + end_col_offset=50)], + [], + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=51), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=51)], + [], + lineno=31, + col_offset=8, + end_lineno=32, + end_col_offset=51)], + lineno=28, + col_offset=8, + end_lineno=32, + end_col_offset=51)], + [], + lineno=24, + col_offset=4, + end_lineno=32, + end_col_offset=51), + Return( + Name( + 'values', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=17), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=17)], + [], + lineno=20, + col_offset=0, + end_lineno=34, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=14)], + Constant( + 128, + lineno=1, + col_offset=17, + end_lineno=1, + end_col_offset=21), + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=21), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=14)], + Constant( + 127, + lineno=2, + col_offset=17, + end_lineno=2, + end_col_offset=21), + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=21), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=5, + col_offset=18, + end_lineno=5, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=15)], + List( + [ + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=25), + BitAnd(), + Name( + 'placeholder_1', + Load(), + lineno=6, + col_offset=28, + end_lineno=6, + end_col_offset=42), + lineno=6, + col_offset=19, + end_lineno=6, + end_col_offset=42)], + Load(), + lineno=6, + col_offset=18, + end_lineno=6, + end_col_offset=43), + lineno=6, + col_offset=4, + end_lineno=6, + end_col_offset=43), + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=10), + RShift(), + Constant( + 7, + lineno=7, + col_offset=15, + end_lineno=7, + end_col_offset=16), + lineno=7, + col_offset=4, + end_lineno=7, + end_col_offset=16), + While( + Compare( + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=16), + [ + Gt()], + [ + Constant( + 0, + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=20)], + lineno=9, + col_offset=10, + end_lineno=9, + end_col_offset=20), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=19), + 'append', + Load(), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=26), + [ + BinOp( + BinOp( + Name( + 'placeholder_3', + Load(), + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=33), + BitAnd(), + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=36, + end_lineno=10, + end_col_offset=50), + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=50), + BitOr(), + Name( + 'placeholder_0', + Load(), + lineno=10, + col_offset=53, + end_lineno=10, + end_col_offset=67), + lineno=10, + col_offset=27, + end_lineno=10, + end_col_offset=67)], + [], + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=68), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=68), + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=14), + RShift(), + Constant( + 7, + lineno=11, + col_offset=19, + end_lineno=11, + end_col_offset=20), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=20)], + [], + lineno=9, + col_offset=4, + end_lineno=11, + end_col_offset=20), + Return( + Subscript( + Name( + 'placeholder_4', + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=22), + Slice( + step=UnaryOp( + USub(), + Constant( + 1, + lineno=13, + col_offset=26, + end_lineno=13, + end_col_offset=27), + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=27), + lineno=13, + col_offset=23, + end_lineno=13, + end_col_offset=27), + Load(), + lineno=13, + col_offset=11, + end_lineno=13, + end_col_offset=28), + lineno=13, + col_offset=4, + end_lineno=13, + end_col_offset=28)], + [], + lineno=5, + col_offset=0, + end_lineno=13, + end_col_offset=28), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'placeholder_6', + lineno=16, + col_offset=11, + end_lineno=16, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=14), + [ + GeneratorExp( + Call( + Name( + 'placeholder_2', + Load(), + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=29), + [ + Name( + 'placeholder_3', + Load(), + lineno=17, + col_offset=30, + end_lineno=17, + end_col_offset=36)], + [], + lineno=17, + col_offset=16, + end_lineno=17, + end_col_offset=37), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=17, + col_offset=42, + end_lineno=17, + end_col_offset=48), + Name( + 'placeholder_6', + Load(), + lineno=17, + col_offset=52, + end_lineno=17, + end_col_offset=59), + [], + 0)], + lineno=17, + col_offset=15, + end_lineno=17, + end_col_offset=60), + List( + [], + Load(), + lineno=17, + col_offset=62, + end_lineno=17, + end_col_offset=64)], + [], + lineno=17, + col_offset=11, + end_lineno=17, + end_col_offset=65), + lineno=17, + col_offset=4, + end_lineno=17, + end_col_offset=65)], + [], + lineno=16, + col_offset=0, + end_lineno=17, + end_col_offset=65), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'placeholder_4', + lineno=20, + col_offset=11, + end_lineno=20, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=10)], + List( + [], + Load(), + lineno=21, + col_offset=13, + end_lineno=21, + end_col_offset=15), + lineno=21, + col_offset=4, + end_lineno=21, + end_col_offset=15), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=10)], + Constant( + 0, + lineno=22, + col_offset=13, + end_lineno=22, + end_col_offset=14), + lineno=22, + col_offset=4, + end_lineno=22, + end_col_offset=14), + For( + Tuple( + [ + Name( + 'placeholder_9', + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=11), + Name( + 'placeholder_10', + Store(), + lineno=24, + col_offset=13, + end_lineno=24, + end_col_offset=17)], + Store(), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=17), + Call( + Name( + 'enumerate', + Load(), + lineno=24, + col_offset=21, + end_lineno=24, + end_col_offset=30), + [ + Name( + 'placeholder_4', + Load(), + lineno=24, + col_offset=31, + end_lineno=24, + end_col_offset=42)], + [], + lineno=24, + col_offset=21, + end_lineno=24, + end_col_offset=43), + [ + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=14), + LShift(), + Constant( + 7, + lineno=25, + col_offset=19, + end_lineno=25, + end_col_offset=20), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=20), + AugAssign( + Name( + 'placeholder_3', + Store(), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=14), + Add(), + BinOp( + Name( + 'placeholder_10', + Load(), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=23), + BitAnd(), + Name( + 'placeholder_1', + Load(), + lineno=26, + col_offset=26, + end_lineno=26, + end_col_offset=40), + lineno=26, + col_offset=19, + end_lineno=26, + end_col_offset=40), + lineno=26, + col_offset=8, + end_lineno=26, + end_col_offset=41), + If( + Compare( + BinOp( + Name( + 'placeholder_10', + Load(), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=15), + BitAnd(), + Name( + 'placeholder_0', + Load(), + lineno=28, + col_offset=18, + end_lineno=28, + end_col_offset=32), + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=32), + [ + Eq()], + [ + Constant( + 0, + lineno=28, + col_offset=36, + end_lineno=28, + end_col_offset=37)], + lineno=28, + col_offset=11, + end_lineno=28, + end_col_offset=37), + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_8', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=18), + 'append', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=25), + [ + Name( + 'placeholder_3', + Load(), + lineno=29, + col_offset=26, + end_lineno=29, + end_col_offset=32)], + [], + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=33), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=33), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=18)], + Constant( + 0, + lineno=30, + col_offset=21, + end_lineno=30, + end_col_offset=22), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=22)], + [ + If( + Compare( + Name( + 'placeholder_9', + Load(), + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=16), + [ + Eq()], + [ + BinOp( + Call( + Name( + 'len', + Load(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=23), + [ + Name( + 'placeholder_4', + Load(), + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=35)], + [], + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=36), + Sub(), + Constant( + 1, + lineno=31, + col_offset=39, + end_lineno=31, + end_col_offset=40), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=40)], + lineno=31, + col_offset=13, + end_lineno=31, + end_col_offset=40), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=28), + [ + Constant( + 'incomplete sequence', + lineno=32, + col_offset=29, + end_lineno=32, + end_col_offset=50)], + [], + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=51), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=51)], + [], + lineno=31, + col_offset=8, + end_lineno=32, + end_col_offset=51)], + lineno=28, + col_offset=8, + end_lineno=32, + end_col_offset=51)], + [], + lineno=24, + col_offset=4, + end_lineno=32, + end_col_offset=51), + Return( + Name( + 'placeholder_8', + Load(), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=17), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=17)], + [], + lineno=20, + col_offset=0, + end_lineno=34, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-variable-length-quantity/representation.txt b/test/practice-variable-length-quantity/representation.txt new file mode 100644 index 0000000..005c268 --- /dev/null +++ b/test/practice-variable-length-quantity/representation.txt @@ -0,0 +1 @@ +Module([Assign([Name('placeholder_0', Store(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=14)], Constant(128, lineno=1, col_offset=17, end_lineno=1, end_col_offset=21), lineno=1, col_offset=0, end_lineno=1, end_col_offset=21), Assign([Name('placeholder_1', Store(), lineno=2, col_offset=0, end_lineno=2, end_col_offset=14)], Constant(127, lineno=2, col_offset=17, end_lineno=2, end_col_offset=21), lineno=2, col_offset=0, end_lineno=2, end_col_offset=21), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=5, col_offset=18, end_lineno=5, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_4', Store(), lineno=6, col_offset=4, end_lineno=6, end_col_offset=15)], List([BinOp(Name('placeholder_3', Load(), lineno=6, col_offset=19, end_lineno=6, end_col_offset=25), BitAnd(), Name('placeholder_1', Load(), lineno=6, col_offset=28, end_lineno=6, end_col_offset=42), lineno=6, col_offset=19, end_lineno=6, end_col_offset=42)], Load(), lineno=6, col_offset=18, end_lineno=6, end_col_offset=43), lineno=6, col_offset=4, end_lineno=6, end_col_offset=43), AugAssign(Name('placeholder_3', Store(), lineno=7, col_offset=4, end_lineno=7, end_col_offset=10), RShift(), Constant(7, lineno=7, col_offset=15, end_lineno=7, end_col_offset=16), lineno=7, col_offset=4, end_lineno=7, end_col_offset=16), While(Compare(Name('placeholder_3', Load(), lineno=9, col_offset=10, end_lineno=9, end_col_offset=16), [Gt()], [Constant(0, lineno=9, col_offset=19, end_lineno=9, end_col_offset=20)], lineno=9, col_offset=10, end_lineno=9, end_col_offset=20), [Expr(Call(Attribute(Name('placeholder_4', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=19), 'append', Load(), lineno=10, col_offset=8, end_lineno=10, end_col_offset=26), [BinOp(BinOp(Name('placeholder_3', Load(), lineno=10, col_offset=27, end_lineno=10, end_col_offset=33), BitAnd(), Name('placeholder_1', Load(), lineno=10, col_offset=36, end_lineno=10, end_col_offset=50), lineno=10, col_offset=27, end_lineno=10, end_col_offset=50), BitOr(), Name('placeholder_0', Load(), lineno=10, col_offset=53, end_lineno=10, end_col_offset=67), lineno=10, col_offset=27, end_lineno=10, end_col_offset=67)], [], lineno=10, col_offset=8, end_lineno=10, end_col_offset=68), lineno=10, col_offset=8, end_lineno=10, end_col_offset=68), AugAssign(Name('placeholder_3', Store(), lineno=11, col_offset=8, end_lineno=11, end_col_offset=14), RShift(), Constant(7, lineno=11, col_offset=19, end_lineno=11, end_col_offset=20), lineno=11, col_offset=8, end_lineno=11, end_col_offset=20)], [], lineno=9, col_offset=4, end_lineno=11, end_col_offset=20), Return(Subscript(Name('placeholder_4', Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=22), Slice(step=UnaryOp(USub(), Constant(1, lineno=13, col_offset=26, end_lineno=13, end_col_offset=27), lineno=13, col_offset=25, end_lineno=13, end_col_offset=27), lineno=13, col_offset=23, end_lineno=13, end_col_offset=27), Load(), lineno=13, col_offset=11, end_lineno=13, end_col_offset=28), lineno=13, col_offset=4, end_lineno=13, end_col_offset=28)], [], lineno=5, col_offset=0, end_lineno=13, end_col_offset=28), FunctionDef('placeholder_5', arguments([], [arg('placeholder_6', lineno=16, col_offset=11, end_lineno=16, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sum', Load(), lineno=17, col_offset=11, end_lineno=17, end_col_offset=14), [GeneratorExp(Call(Name('placeholder_2', Load(), lineno=17, col_offset=16, end_lineno=17, end_col_offset=29), [Name('placeholder_3', Load(), lineno=17, col_offset=30, end_lineno=17, end_col_offset=36)], [], lineno=17, col_offset=16, end_lineno=17, end_col_offset=37), [comprehension(Name('placeholder_3', Store(), lineno=17, col_offset=42, end_lineno=17, end_col_offset=48), Name('placeholder_6', Load(), lineno=17, col_offset=52, end_lineno=17, end_col_offset=59), [], 0)], lineno=17, col_offset=15, end_lineno=17, end_col_offset=60), List([], Load(), lineno=17, col_offset=62, end_lineno=17, end_col_offset=64)], [], lineno=17, col_offset=11, end_lineno=17, end_col_offset=65), lineno=17, col_offset=4, end_lineno=17, end_col_offset=65)], [], lineno=16, col_offset=0, end_lineno=17, end_col_offset=65), FunctionDef('placeholder_7', arguments([], [arg('placeholder_4', lineno=20, col_offset=11, end_lineno=20, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_8', Store(), lineno=21, col_offset=4, end_lineno=21, end_col_offset=10)], List([], Load(), lineno=21, col_offset=13, end_lineno=21, end_col_offset=15), lineno=21, col_offset=4, end_lineno=21, end_col_offset=15), Assign([Name('placeholder_3', Store(), lineno=22, col_offset=4, end_lineno=22, end_col_offset=10)], Constant(0, lineno=22, col_offset=13, end_lineno=22, end_col_offset=14), lineno=22, col_offset=4, end_lineno=22, end_col_offset=14), For(Tuple([Name('placeholder_9', Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=11), Name('placeholder_10', Store(), lineno=24, col_offset=13, end_lineno=24, end_col_offset=17)], Store(), lineno=24, col_offset=8, end_lineno=24, end_col_offset=17), Call(Name('enumerate', Load(), lineno=24, col_offset=21, end_lineno=24, end_col_offset=30), [Name('placeholder_4', Load(), lineno=24, col_offset=31, end_lineno=24, end_col_offset=42)], [], lineno=24, col_offset=21, end_lineno=24, end_col_offset=43), [AugAssign(Name('placeholder_3', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=14), LShift(), Constant(7, lineno=25, col_offset=19, end_lineno=25, end_col_offset=20), lineno=25, col_offset=8, end_lineno=25, end_col_offset=20), AugAssign(Name('placeholder_3', Store(), lineno=26, col_offset=8, end_lineno=26, end_col_offset=14), Add(), BinOp(Name('placeholder_10', Load(), lineno=26, col_offset=19, end_lineno=26, end_col_offset=23), BitAnd(), Name('placeholder_1', Load(), lineno=26, col_offset=26, end_lineno=26, end_col_offset=40), lineno=26, col_offset=19, end_lineno=26, end_col_offset=40), lineno=26, col_offset=8, end_lineno=26, end_col_offset=41), If(Compare(BinOp(Name('placeholder_10', Load(), lineno=28, col_offset=11, end_lineno=28, end_col_offset=15), BitAnd(), Name('placeholder_0', Load(), lineno=28, col_offset=18, end_lineno=28, end_col_offset=32), lineno=28, col_offset=11, end_lineno=28, end_col_offset=32), [Eq()], [Constant(0, lineno=28, col_offset=36, end_lineno=28, end_col_offset=37)], lineno=28, col_offset=11, end_lineno=28, end_col_offset=37), [Expr(Call(Attribute(Name('placeholder_8', Load(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=18), 'append', Load(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=25), [Name('placeholder_3', Load(), lineno=29, col_offset=26, end_lineno=29, end_col_offset=32)], [], lineno=29, col_offset=12, end_lineno=29, end_col_offset=33), lineno=29, col_offset=12, end_lineno=29, end_col_offset=33), Assign([Name('placeholder_3', Store(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=18)], Constant(0, lineno=30, col_offset=21, end_lineno=30, end_col_offset=22), lineno=30, col_offset=12, end_lineno=30, end_col_offset=22)], [If(Compare(Name('placeholder_9', Load(), lineno=31, col_offset=13, end_lineno=31, end_col_offset=16), [Eq()], [BinOp(Call(Name('len', Load(), lineno=31, col_offset=20, end_lineno=31, end_col_offset=23), [Name('placeholder_4', Load(), lineno=31, col_offset=24, end_lineno=31, end_col_offset=35)], [], lineno=31, col_offset=20, end_lineno=31, end_col_offset=36), Sub(), Constant(1, lineno=31, col_offset=39, end_lineno=31, end_col_offset=40), lineno=31, col_offset=20, end_lineno=31, end_col_offset=40)], lineno=31, col_offset=13, end_lineno=31, end_col_offset=40), [Raise(Call(Name('ValueError', Load(), lineno=32, col_offset=18, end_lineno=32, end_col_offset=28), [Constant('incomplete sequence', lineno=32, col_offset=29, end_lineno=32, end_col_offset=50)], [], lineno=32, col_offset=18, end_lineno=32, end_col_offset=51), lineno=32, col_offset=12, end_lineno=32, end_col_offset=51)], [], lineno=31, col_offset=8, end_lineno=32, end_col_offset=51)], lineno=28, col_offset=8, end_lineno=32, end_col_offset=51)], [], lineno=24, col_offset=4, end_lineno=32, end_col_offset=51), Return(Name('placeholder_8', Load(), lineno=34, col_offset=11, end_lineno=34, end_col_offset=17), lineno=34, col_offset=4, end_lineno=34, end_col_offset=17)], [], lineno=20, col_offset=0, end_lineno=34, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-variable-length-quantity/variable_length_quantity.py b/test/practice-variable-length-quantity/variable_length_quantity.py new file mode 100644 index 0000000..ed5a393 --- /dev/null +++ b/test/practice-variable-length-quantity/variable_length_quantity.py @@ -0,0 +1,34 @@ +EIGHT_BIT_MASK = 0x80 +SEVEN_BIT_MASK = 0x7f + + +def encode_single(number): + byte_string = [number & SEVEN_BIT_MASK] + number >>= 7 + + while number > 0: + byte_string.append(number & SEVEN_BIT_MASK | EIGHT_BIT_MASK) + number >>= 7 + + return byte_string[::-1] + + +def encode(numbers): + return sum((encode_single(number) for number in numbers), []) + + +def decode(byte_string): + values = [] + number = 0 + + for idx, byte in enumerate(byte_string): + number <<= 7 + number += (byte & SEVEN_BIT_MASK) + + if byte & EIGHT_BIT_MASK == 0: + values.append(number) + number = 0 + elif idx == len(byte_string) - 1: + raise ValueError('incomplete sequence') + + return values diff --git a/test/practice-word-count/.meta/additional_tests.json b/test/practice-word-count/.meta/additional_tests.json new file mode 100644 index 0000000..39c9d22 --- /dev/null +++ b/test/practice-word-count/.meta/additional_tests.json @@ -0,0 +1,48 @@ +{ + "cases": [ + { + "description": "tabs", + "property": "countWords", + "input": { + "sentence": "rah rah ah ah ah\troma roma ma\tga ga oh la la\twant your bad romance" + }, + "expected": { + "rah": 2, + "ah": 3, + "roma": 2, + "ma": 1, + "ga": 2, + "oh": 1, + "la": 2, + "want": 1, + "your": 1, + "bad": 1, + "romance": 1 + } + }, + { + "description": "non-alphanumeric", + "property": "countWords", + "input": { + "sentence": "hey,my_spacebar_is_broken" + }, + "expected": { + "hey": 1, + "my": 1, + "spacebar": 1, + "is": 1, + "broken": 1 + } + }, + { + "description": "multiple apostrophes ignored", + "property": "countWords", + "input": { + "sentence": "''hey''" + }, + "expected": { + "hey": 1 + } + } + ] +} diff --git a/test/practice-word-count/.meta/config.json b/test/practice-word-count/.meta/config.json new file mode 100644 index 0000000..c713447 --- /dev/null +++ b/test/practice-word-count/.meta/config.json @@ -0,0 +1,38 @@ +{ + "authors": [], + "contributors": [ + "behrtam", + "c4llmeco4ch", + "cmccandless", + "Dog", + "gabriel376", + "Grociu", + "guygastineau", + "ikhadykin", + "jackattack24", + "kytrinyx", + "lowks", + "N-Parsons", + "pheanex", + "rivergillis", + "samdec11", + "sjakobi", + "tqa236", + "wobh", + "yawpitch", + "ZacharyRSmith" + ], + "files": { + "solution": [ + "word_count.py" + ], + "test": [ + "word_count_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Given a phrase, count the occurrences of each word in that phrase.", + "source": "This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour." +} diff --git a/test/practice-word-count/mapping.json b/test/practice-word-count/mapping.json new file mode 100644 index 0000000..5f5b791 --- /dev/null +++ b/test/practice-word-count/mapping.json @@ -0,0 +1,6 @@ +{ + "placeholder_0": "WORDS", + "placeholder_1": "count_words", + "placeholder_2": "text", + "placeholder_3": "word" +} \ No newline at end of file diff --git a/test/practice-word-count/representation.json b/test/practice-word-count/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-word-count/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-word-count/representation.out b/test/practice-word-count/representation.out new file mode 100644 index 0000000..f828d7c --- /dev/null +++ b/test/practice-word-count/representation.out @@ -0,0 +1,408 @@ +## BEGIN NORMALIZED CODE ## +import re +from collections import Counter + +placeholder_0 = re.compile("[a-z0-9]+(['][a-z]+)?") + + +def placeholder_1(placeholder_2): + return Counter( + ( + placeholder_3.group(0) + for placeholder_3 in placeholder_0.finditer(placeholder_2.lower()) + ) + ) + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + ImportFrom( + 'collections', + [ + alias( + 'Counter', + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=31)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=31), + Assign( + [ + Name( + 'WORDS', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=5)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=10), + 'compile', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=18), + [ + Constant( + "[a-z0-9]+(['][a-z]+)?", + lineno=5, + col_offset=19, + end_lineno=5, + end_col_offset=42)], + [], + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=43), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=43), + FunctionDef( + 'count_words', + arguments( + [], + [ + arg( + 'text', + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Counter', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'word', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=23), + 'group', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=29), + [ + Constant( + 0, + lineno=9, + col_offset=30, + end_lineno=9, + end_col_offset=31)], + [], + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=32), + [ + comprehension( + Name( + 'word', + Store(), + lineno=9, + col_offset=37, + end_lineno=9, + end_col_offset=41), + Call( + Attribute( + Name( + 'WORDS', + Load(), + lineno=9, + col_offset=45, + end_lineno=9, + end_col_offset=50), + 'finditer', + Load(), + lineno=9, + col_offset=45, + end_lineno=9, + end_col_offset=59), + [ + Call( + Attribute( + Name( + 'text', + Load(), + lineno=9, + col_offset=60, + end_lineno=9, + end_col_offset=64), + 'lower', + Load(), + lineno=9, + col_offset=60, + end_lineno=9, + end_col_offset=70), + [], + [], + lineno=9, + col_offset=60, + end_lineno=9, + end_col_offset=72)], + [], + lineno=9, + col_offset=45, + end_lineno=9, + end_col_offset=73), + [], + 0)], + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=74)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=74), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=74)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=74)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 're', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=9)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=9), + ImportFrom( + 'collections', + [ + alias( + 'Counter', + lineno=2, + col_offset=24, + end_lineno=2, + end_col_offset=31)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=31), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=5)], + Call( + Attribute( + Name( + 're', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=10), + 'compile', + Load(), + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=18), + [ + Constant( + "[a-z0-9]+(['][a-z]+)?", + lineno=5, + col_offset=19, + end_lineno=5, + end_col_offset=42)], + [], + lineno=5, + col_offset=8, + end_lineno=5, + end_col_offset=43), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=43), + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=8, + col_offset=16, + end_lineno=8, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Counter', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=18), + [ + GeneratorExp( + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=23), + 'group', + Load(), + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=29), + [ + Constant( + 0, + lineno=9, + col_offset=30, + end_lineno=9, + end_col_offset=31)], + [], + lineno=9, + col_offset=19, + end_lineno=9, + end_col_offset=32), + [ + comprehension( + Name( + 'placeholder_3', + Store(), + lineno=9, + col_offset=37, + end_lineno=9, + end_col_offset=41), + Call( + Attribute( + Name( + 'placeholder_0', + Load(), + lineno=9, + col_offset=45, + end_lineno=9, + end_col_offset=50), + 'finditer', + Load(), + lineno=9, + col_offset=45, + end_lineno=9, + end_col_offset=59), + [ + Call( + Attribute( + Name( + 'placeholder_2', + Load(), + lineno=9, + col_offset=60, + end_lineno=9, + end_col_offset=64), + 'lower', + Load(), + lineno=9, + col_offset=60, + end_lineno=9, + end_col_offset=70), + [], + [], + lineno=9, + col_offset=60, + end_lineno=9, + end_col_offset=72)], + [], + lineno=9, + col_offset=45, + end_lineno=9, + end_col_offset=73), + [], + 0)], + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=74)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=74), + lineno=9, + col_offset=4, + end_lineno=9, + end_col_offset=74)], + [], + lineno=8, + col_offset=0, + end_lineno=9, + end_col_offset=74)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-word-count/representation.txt b/test/practice-word-count/representation.txt new file mode 100644 index 0000000..9893bf8 --- /dev/null +++ b/test/practice-word-count/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('re', lineno=1, col_offset=7, end_lineno=1, end_col_offset=9)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=9), ImportFrom('collections', [alias('Counter', lineno=2, col_offset=24, end_lineno=2, end_col_offset=31)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=31), Assign([Name('placeholder_0', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=5)], Call(Attribute(Name('re', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=10), 'compile', Load(), lineno=5, col_offset=8, end_lineno=5, end_col_offset=18), [Constant("[a-z0-9]+(['][a-z]+)?", lineno=5, col_offset=19, end_lineno=5, end_col_offset=42)], [], lineno=5, col_offset=8, end_lineno=5, end_col_offset=43), lineno=5, col_offset=0, end_lineno=5, end_col_offset=43), FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=8, col_offset=16, end_lineno=8, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('Counter', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=18), [GeneratorExp(Call(Attribute(Name('placeholder_3', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=23), 'group', Load(), lineno=9, col_offset=19, end_lineno=9, end_col_offset=29), [Constant(0, lineno=9, col_offset=30, end_lineno=9, end_col_offset=31)], [], lineno=9, col_offset=19, end_lineno=9, end_col_offset=32), [comprehension(Name('placeholder_3', Store(), lineno=9, col_offset=37, end_lineno=9, end_col_offset=41), Call(Attribute(Name('placeholder_0', Load(), lineno=9, col_offset=45, end_lineno=9, end_col_offset=50), 'finditer', Load(), lineno=9, col_offset=45, end_lineno=9, end_col_offset=59), [Call(Attribute(Name('placeholder_2', Load(), lineno=9, col_offset=60, end_lineno=9, end_col_offset=64), 'lower', Load(), lineno=9, col_offset=60, end_lineno=9, end_col_offset=70), [], [], lineno=9, col_offset=60, end_lineno=9, end_col_offset=72)], [], lineno=9, col_offset=45, end_lineno=9, end_col_offset=73), [], 0)], lineno=9, col_offset=18, end_lineno=9, end_col_offset=74)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=74), lineno=9, col_offset=4, end_lineno=9, end_col_offset=74)], [], lineno=8, col_offset=0, end_lineno=9, end_col_offset=74)], []) \ No newline at end of file diff --git a/test/practice-word-count/word_count.py b/test/practice-word-count/word_count.py new file mode 100644 index 0000000..03fb260 --- /dev/null +++ b/test/practice-word-count/word_count.py @@ -0,0 +1,9 @@ +import re +from collections import Counter + + +WORDS = re.compile("[a-z0-9]+(['][a-z]+)?") + + +def count_words(text): + return Counter(word.group(0) for word in WORDS.finditer(text.lower())) diff --git a/test/practice-word-search/.meta/config.json b/test/practice-word-search/.meta/config.json new file mode 100644 index 0000000..84c6ecd --- /dev/null +++ b/test/practice-word-search/.meta/config.json @@ -0,0 +1,27 @@ +{ + "authors": [ + "behrtam" + ], + "contributors": [ + "cmccandless", + "Dog", + "dvermd", + "josix", + "N-Parsons", + "pheanex", + "thomasjpfan", + "tqa236" + ], + "files": { + "solution": [ + "word_search.py" + ], + "test": [ + "word_search_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Create a program to solve a word search puzzle." +} diff --git a/test/practice-word-search/mapping.json b/test/practice-word-search/mapping.json new file mode 100644 index 0000000..3bbe5da --- /dev/null +++ b/test/practice-word-search/mapping.json @@ -0,0 +1,31 @@ +{ + "placeholder_0": "Point", + "placeholder_1": "__init__", + "placeholder_2": "x", + "placeholder_3": "y", + "placeholder_4": "__repr__", + "placeholder_5": "__add__", + "placeholder_6": "other", + "placeholder_7": "__sub__", + "placeholder_8": "__eq__", + "placeholder_9": "__ne__", + "placeholder_10": "DIRECTIONS", + "placeholder_11": "WordSearch", + "placeholder_12": "puzzle", + "placeholder_13": "rows", + "placeholder_14": "width", + "placeholder_15": "height", + "placeholder_16": "find_char", + "placeholder_17": "coordinate", + "placeholder_18": "find", + "placeholder_19": "word", + "placeholder_20": "position", + "placeholder_21": "direction", + "placeholder_22": "current", + "placeholder_23": "letter", + "placeholder_24": "search", + "placeholder_25": "positions", + "placeholder_26": "idx", + "placeholder_27": "edx", + "placeholder_28": "result" +} \ No newline at end of file diff --git a/test/practice-word-search/representation.json b/test/practice-word-search/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-word-search/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-word-search/representation.out b/test/practice-word-search/representation.out new file mode 100644 index 0000000..f617405 --- /dev/null +++ b/test/practice-word-search/representation.out @@ -0,0 +1,3689 @@ +## BEGIN NORMALIZED CODE ## +import copy + + +class placeholder_0: + def placeholder_1(self, placeholder_2, placeholder_3): + self.placeholder_2 = placeholder_2 + self.placeholder_3 = placeholder_3 + + def placeholder_4(self): + return f"Point({self.placeholder_2}:{self.placeholder_3})" + + def placeholder_5(self, placeholder_6): + return placeholder_0( + self.placeholder_2 + placeholder_6.placeholder_2, + self.placeholder_3 + placeholder_6.placeholder_3, + ) + + def placeholder_7(self, placeholder_6): + return placeholder_0( + self.placeholder_2 - placeholder_6.placeholder_2, + self.placeholder_3 - placeholder_6.placeholder_3, + ) + + def placeholder_8(self, placeholder_6): + return ( + self.placeholder_2 == placeholder_6.placeholder_2 + and self.placeholder_3 == placeholder_6.placeholder_3 + ) + + def placeholder_9(self, placeholder_6): + return not self == placeholder_6 + + +placeholder_10 = ( + placeholder_0(1, 0), + placeholder_0(1, -1), + placeholder_0(1, 1), + placeholder_0(-1, -1), + placeholder_0(0, -1), + placeholder_0(0, 1), + placeholder_0(-1, 1), + placeholder_0(-1, 0), +) + + +class placeholder_11: + def placeholder_1(self, placeholder_12): + self.placeholder_13 = placeholder_12 + self.placeholder_14 = len(self.placeholder_13[0]) + self.placeholder_15 = len(self.placeholder_13) + + def placeholder_16(self, placeholder_17): + if ( + placeholder_17.placeholder_2 < 0 + or placeholder_17.placeholder_2 >= self.placeholder_14 + ): + return None + if ( + placeholder_17.placeholder_3 < 0 + or placeholder_17.placeholder_3 >= self.placeholder_15 + ): + return None + return self.placeholder_13[placeholder_17.placeholder_3][ + placeholder_17.placeholder_2 + ] + + def placeholder_18(self, placeholder_19, placeholder_20, placeholder_21): + placeholder_22 = copy.copy(placeholder_20) + for placeholder_23 in placeholder_19: + if self.placeholder_16(placeholder_22) != placeholder_23: + return None + placeholder_22 += placeholder_21 + return (placeholder_20, placeholder_22 - placeholder_21) + + def placeholder_24(self, placeholder_19): + placeholder_25 = ( + placeholder_0(placeholder_26, placeholder_27) + for placeholder_26 in range(self.placeholder_14) + for placeholder_27 in range(self.placeholder_15) + ) + for placeholder_20 in placeholder_25: + for placeholder_21 in placeholder_10: + placeholder_28 = self.placeholder_18( + placeholder_19, placeholder_20, placeholder_21 + ) + if placeholder_28: + return placeholder_28 + return None + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Import( + [ + alias( + 'copy', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + ClassDef( + 'Point', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'x', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=24), + arg( + 'y', + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'x', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=14)], + Name( + 'x', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=18), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=18), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'y', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=14)], + Name( + 'y', + Load(), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=18), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=18)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=18), + FunctionDef( + '__repr__', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + Constant( + 'Point(', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=28), + 'x', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=30), + -1, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + Constant( + ':', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=37), + 'y', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=39), + -1, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + Constant( + ')', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=42)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=42), + FunctionDef( + '__add__', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=20), + arg( + 'other', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Point', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=20), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=25), + 'x', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=27), + Add(), + Attribute( + Name( + 'other', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=35), + 'x', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=37), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=37), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=43), + 'y', + Load(), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=45), + Add(), + Attribute( + Name( + 'other', + Load(), + lineno=13, + col_offset=48, + end_lineno=13, + end_col_offset=53), + 'y', + Load(), + lineno=13, + col_offset=48, + end_lineno=13, + end_col_offset=55), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=55)], + [], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=56), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=56)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=56), + FunctionDef( + '__sub__', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=20), + arg( + 'other', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Point', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=20), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=25), + 'x', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=27), + Sub(), + Attribute( + Name( + 'other', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=35), + 'x', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=37), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=37), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=43), + 'y', + Load(), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=45), + Sub(), + Attribute( + Name( + 'other', + Load(), + lineno=16, + col_offset=48, + end_lineno=16, + end_col_offset=53), + 'y', + Load(), + lineno=16, + col_offset=48, + end_lineno=16, + end_col_offset=55), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=55)], + [], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=56), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=56)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=56), + FunctionDef( + '__eq__', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + arg( + 'other', + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + 'x', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=21), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=30), + 'x', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=32)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=32), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=41), + 'y', + Load(), + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=43), + [ + Eq()], + [ + Attribute( + Name( + 'other', + Load(), + lineno=19, + col_offset=47, + end_lineno=19, + end_col_offset=52), + 'y', + Load(), + lineno=19, + col_offset=47, + end_lineno=19, + end_col_offset=54)], + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=54)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=54), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=54)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=54), + FunctionDef( + '__ne__', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + arg( + 'other', + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + UnaryOp( + Not(), + Compare( + Name( + 'self', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=23), + [ + Eq()], + [ + Name( + 'other', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=32)], + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=32), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=32), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=32)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=32)], + [], + lineno=4, + col_offset=0, + end_lineno=22, + end_col_offset=32), + Assign( + [ + Name( + 'DIRECTIONS', + Store(), + lineno=25, + col_offset=0, + end_lineno=25, + end_col_offset=10)], + Tuple( + [ + Call( + Name( + 'Point', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=19), + [ + Constant( + 1, + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=21), + Constant( + 0, + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=24)], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=25), + Call( + Name( + 'Point', + Load(), + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=32), + [ + Constant( + 1, + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 1, + lineno=25, + col_offset=37, + end_lineno=25, + end_col_offset=38), + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=38)], + [], + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=39), + Call( + Name( + 'Point', + Load(), + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=46), + [ + Constant( + 1, + lineno=25, + col_offset=47, + end_lineno=25, + end_col_offset=48), + Constant( + 1, + lineno=25, + col_offset=50, + end_lineno=25, + end_col_offset=51)], + [], + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=52), + Call( + Name( + 'Point', + Load(), + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=59), + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=25, + col_offset=61, + end_lineno=25, + end_col_offset=62), + lineno=25, + col_offset=60, + end_lineno=25, + end_col_offset=62), + UnaryOp( + USub(), + Constant( + 1, + lineno=25, + col_offset=65, + end_lineno=25, + end_col_offset=66), + lineno=25, + col_offset=64, + end_lineno=25, + end_col_offset=66)], + [], + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=67), + Call( + Name( + 'Point', + Load(), + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=19), + [ + Constant( + 0, + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=21), + UnaryOp( + USub(), + Constant( + 1, + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=25), + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=25)], + [], + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=26), + Call( + Name( + 'Point', + Load(), + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=33), + [ + Constant( + 0, + lineno=26, + col_offset=34, + end_lineno=26, + end_col_offset=35), + Constant( + 1, + lineno=26, + col_offset=37, + end_lineno=26, + end_col_offset=38)], + [], + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=39), + Call( + Name( + 'Point', + Load(), + lineno=26, + col_offset=41, + end_lineno=26, + end_col_offset=46), + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=26, + col_offset=48, + end_lineno=26, + end_col_offset=49), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=49), + Constant( + 1, + lineno=26, + col_offset=51, + end_lineno=26, + end_col_offset=52)], + [], + lineno=26, + col_offset=41, + end_lineno=26, + end_col_offset=53), + Call( + Name( + 'Point', + Load(), + lineno=26, + col_offset=55, + end_lineno=26, + end_col_offset=60), + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=26, + col_offset=62, + end_lineno=26, + end_col_offset=63), + lineno=26, + col_offset=61, + end_lineno=26, + end_col_offset=63), + Constant( + 0, + lineno=26, + col_offset=65, + end_lineno=26, + end_col_offset=66)], + [], + lineno=26, + col_offset=55, + end_lineno=26, + end_col_offset=67)], + Load(), + lineno=25, + col_offset=13, + end_lineno=26, + end_col_offset=68), + lineno=25, + col_offset=0, + end_lineno=26, + end_col_offset=68), + ClassDef( + 'WordSearch', + [], + [], + [ + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=30, + col_offset=17, + end_lineno=30, + end_col_offset=21), + arg( + 'puzzle', + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=12), + 'rows', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=17)], + Name( + 'puzzle', + Load(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=26), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'width', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=18)], + Call( + Name( + 'len', + Load(), + lineno=32, + col_offset=21, + end_lineno=32, + end_col_offset=24), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=29), + 'rows', + Load(), + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=34), + Constant( + 0, + lineno=32, + col_offset=35, + end_lineno=32, + end_col_offset=36), + Load(), + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=37)], + [], + lineno=32, + col_offset=21, + end_lineno=32, + end_col_offset=38), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=38), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=12), + 'height', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=19)], + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=25), + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=30), + 'rows', + Load(), + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=35)], + [], + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=36), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=36)], + [], + lineno=30, + col_offset=4, + end_lineno=33, + end_col_offset=36), + FunctionDef( + 'find_char', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=22), + arg( + 'coordinate', + lineno=35, + col_offset=24, + end_lineno=35, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BoolOp( + Or(), + [ + Compare( + Attribute( + Name( + 'coordinate', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=21), + 'x', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=23), + [ + Lt()], + [ + Constant( + 0, + lineno=36, + col_offset=26, + end_lineno=36, + end_col_offset=27)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=27), + Compare( + Attribute( + Name( + 'coordinate', + Load(), + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=41), + 'x', + Load(), + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=43), + [ + GtE()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=47, + end_lineno=36, + end_col_offset=51), + 'width', + Load(), + lineno=36, + col_offset=47, + end_lineno=36, + end_col_offset=57)], + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=57)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=57), + [ + Return( + Constant( + None, + lineno=37, + col_offset=19, + end_lineno=37, + end_col_offset=23), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=23)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=23), + If( + BoolOp( + Or(), + [ + Compare( + Attribute( + Name( + 'coordinate', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=21), + 'y', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=23), + [ + Lt()], + [ + Constant( + 0, + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=27)], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=27), + Compare( + Attribute( + Name( + 'coordinate', + Load(), + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=41), + 'y', + Load(), + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=43), + [ + GtE()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=47, + end_lineno=38, + end_col_offset=51), + 'height', + Load(), + lineno=38, + col_offset=47, + end_lineno=38, + end_col_offset=58)], + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=58)], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=58), + [ + Return( + Constant( + None, + lineno=39, + col_offset=19, + end_lineno=39, + end_col_offset=23), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=23)], + [], + lineno=38, + col_offset=8, + end_lineno=39, + end_col_offset=23), + Return( + Subscript( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=19), + 'rows', + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=24), + Attribute( + Name( + 'coordinate', + Load(), + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=35), + 'y', + Load(), + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=37), + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=38), + Attribute( + Name( + 'coordinate', + Load(), + lineno=40, + col_offset=39, + end_lineno=40, + end_col_offset=49), + 'x', + Load(), + lineno=40, + col_offset=39, + end_lineno=40, + end_col_offset=51), + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=52), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=52)], + [], + lineno=35, + col_offset=4, + end_lineno=40, + end_col_offset=52), + FunctionDef( + 'find', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=17), + arg( + 'word', + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=23), + arg( + 'position', + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=33), + arg( + 'direction', + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'current', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=15)], + Call( + Attribute( + Name( + 'copy', + Load(), + lineno=43, + col_offset=18, + end_lineno=43, + end_col_offset=22), + 'copy', + Load(), + lineno=43, + col_offset=18, + end_lineno=43, + end_col_offset=27), + [ + Name( + 'position', + Load(), + lineno=43, + col_offset=28, + end_lineno=43, + end_col_offset=36)], + [], + lineno=43, + col_offset=18, + end_lineno=43, + end_col_offset=37), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=37), + For( + Name( + 'letter', + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=18), + Name( + 'word', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=26), + [ + If( + Compare( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=19), + 'find_char', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=29), + [ + Name( + 'current', + Load(), + lineno=45, + col_offset=30, + end_lineno=45, + end_col_offset=37)], + [], + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=38), + [ + NotEq()], + [ + Name( + 'letter', + Load(), + lineno=45, + col_offset=42, + end_lineno=45, + end_col_offset=48)], + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=48), + [ + Return( + Constant( + None, + lineno=46, + col_offset=23, + end_lineno=46, + end_col_offset=27), + lineno=46, + col_offset=16, + end_lineno=46, + end_col_offset=27)], + [], + lineno=45, + col_offset=12, + end_lineno=46, + end_col_offset=27), + AugAssign( + Name( + 'current', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=19), + Add(), + Name( + 'direction', + Load(), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=32), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=32)], + [], + lineno=44, + col_offset=8, + end_lineno=47, + end_col_offset=32), + Return( + Tuple( + [ + Name( + 'position', + Load(), + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=23), + BinOp( + Name( + 'current', + Load(), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=32), + Sub(), + Name( + 'direction', + Load(), + lineno=48, + col_offset=35, + end_lineno=48, + end_col_offset=44), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=44)], + Load(), + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=44), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=44)], + [], + lineno=42, + col_offset=4, + end_lineno=48, + end_col_offset=44), + FunctionDef( + 'search', + arguments( + [], + [ + arg( + 'self', + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=19), + arg( + 'word', + lineno=50, + col_offset=21, + end_lineno=50, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'positions', + Store(), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=17)], + GeneratorExp( + Call( + Name( + 'Point', + Load(), + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=26), + [ + Name( + 'idx', + Load(), + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=30), + Name( + 'edx', + Load(), + lineno=51, + col_offset=32, + end_lineno=51, + end_col_offset=35)], + [], + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=36), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=52, + col_offset=25, + end_lineno=52, + end_col_offset=28), + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=37), + [ + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=38, + end_lineno=52, + end_col_offset=42), + 'width', + Load(), + lineno=52, + col_offset=38, + end_lineno=52, + end_col_offset=48)], + [], + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=49), + [], + 0), + comprehension( + Name( + 'edx', + Store(), + lineno=52, + col_offset=54, + end_lineno=52, + end_col_offset=57), + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=61, + end_lineno=52, + end_col_offset=66), + [ + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=67, + end_lineno=52, + end_col_offset=71), + 'height', + Load(), + lineno=52, + col_offset=67, + end_lineno=52, + end_col_offset=78)], + [], + lineno=52, + col_offset=61, + end_lineno=52, + end_col_offset=79), + [], + 0)], + lineno=51, + col_offset=20, + end_lineno=52, + end_col_offset=80), + lineno=51, + col_offset=8, + end_lineno=52, + end_col_offset=80), + For( + Name( + 'position', + Store(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=20), + Name( + 'positions', + Load(), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=33), + [ + For( + Name( + 'direction', + Store(), + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=25), + Name( + 'DIRECTIONS', + Load(), + lineno=54, + col_offset=29, + end_lineno=54, + end_col_offset=39), + [ + Assign( + [ + Name( + 'result', + Store(), + lineno=55, + col_offset=16, + end_lineno=55, + end_col_offset=22)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=29), + 'find', + Load(), + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=34), + [ + Name( + 'word', + Load(), + lineno=55, + col_offset=35, + end_lineno=55, + end_col_offset=39), + Name( + 'position', + Load(), + lineno=55, + col_offset=41, + end_lineno=55, + end_col_offset=49), + Name( + 'direction', + Load(), + lineno=55, + col_offset=51, + end_lineno=55, + end_col_offset=60)], + [], + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=61), + lineno=55, + col_offset=16, + end_lineno=55, + end_col_offset=61), + If( + Name( + 'result', + Load(), + lineno=56, + col_offset=19, + end_lineno=56, + end_col_offset=25), + [ + Return( + Name( + 'result', + Load(), + lineno=57, + col_offset=27, + end_lineno=57, + end_col_offset=33), + lineno=57, + col_offset=20, + end_lineno=57, + end_col_offset=33)], + [], + lineno=56, + col_offset=16, + end_lineno=57, + end_col_offset=33)], + [], + lineno=54, + col_offset=12, + end_lineno=57, + end_col_offset=33)], + [], + lineno=53, + col_offset=8, + end_lineno=57, + end_col_offset=33), + Return( + Constant( + None, + lineno=58, + col_offset=15, + end_lineno=58, + end_col_offset=19), + lineno=58, + col_offset=8, + end_lineno=58, + end_col_offset=19)], + [], + lineno=50, + col_offset=4, + end_lineno=58, + end_col_offset=19)], + [], + lineno=29, + col_offset=0, + end_lineno=58, + end_col_offset=19)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + Import( + [ + alias( + 'copy', + lineno=1, + col_offset=7, + end_lineno=1, + end_col_offset=11)], + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=11), + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=5, + col_offset=17, + end_lineno=5, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=5, + col_offset=23, + end_lineno=5, + end_col_offset=24), + arg( + 'placeholder_3', + lineno=5, + col_offset=26, + end_lineno=5, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=14)], + Name( + 'placeholder_2', + Load(), + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=18), + lineno=6, + col_offset=8, + end_lineno=6, + end_col_offset=18), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_3', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=14)], + Name( + 'placeholder_3', + Load(), + lineno=7, + col_offset=17, + end_lineno=7, + end_col_offset=18), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=18)], + [], + lineno=5, + col_offset=4, + end_lineno=7, + end_col_offset=18), + FunctionDef( + 'placeholder_4', + arguments( + [], + [ + arg( + 'self', + lineno=9, + col_offset=17, + end_lineno=9, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + JoinedStr( + [ + Constant( + 'Point(', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=28), + 'placeholder_2', + Load(), + lineno=10, + col_offset=24, + end_lineno=10, + end_col_offset=30), + -1, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + Constant( + ':', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + FormattedValue( + Attribute( + Name( + 'self', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=37), + 'placeholder_3', + Load(), + lineno=10, + col_offset=33, + end_lineno=10, + end_col_offset=39), + -1, + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + Constant( + ')', + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42)], + lineno=10, + col_offset=15, + end_lineno=10, + end_col_offset=42), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=42)], + [], + lineno=9, + col_offset=4, + end_lineno=10, + end_col_offset=42), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=12, + col_offset=16, + end_lineno=12, + end_col_offset=20), + arg( + 'placeholder_6', + lineno=12, + col_offset=22, + end_lineno=12, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=20), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=25), + 'placeholder_2', + Load(), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=27), + Add(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=35), + 'placeholder_2', + Load(), + lineno=13, + col_offset=30, + end_lineno=13, + end_col_offset=37), + lineno=13, + col_offset=21, + end_lineno=13, + end_col_offset=37), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=43), + 'placeholder_3', + Load(), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=45), + Add(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=13, + col_offset=48, + end_lineno=13, + end_col_offset=53), + 'placeholder_3', + Load(), + lineno=13, + col_offset=48, + end_lineno=13, + end_col_offset=55), + lineno=13, + col_offset=39, + end_lineno=13, + end_col_offset=55)], + [], + lineno=13, + col_offset=15, + end_lineno=13, + end_col_offset=56), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=56)], + [], + lineno=12, + col_offset=4, + end_lineno=13, + end_col_offset=56), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=15, + col_offset=16, + end_lineno=15, + end_col_offset=20), + arg( + 'placeholder_6', + lineno=15, + col_offset=22, + end_lineno=15, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=20), + [ + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=25), + 'placeholder_2', + Load(), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=27), + Sub(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=35), + 'placeholder_2', + Load(), + lineno=16, + col_offset=30, + end_lineno=16, + end_col_offset=37), + lineno=16, + col_offset=21, + end_lineno=16, + end_col_offset=37), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=43), + 'placeholder_3', + Load(), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=45), + Sub(), + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=16, + col_offset=48, + end_lineno=16, + end_col_offset=53), + 'placeholder_3', + Load(), + lineno=16, + col_offset=48, + end_lineno=16, + end_col_offset=55), + lineno=16, + col_offset=39, + end_lineno=16, + end_col_offset=55)], + [], + lineno=16, + col_offset=15, + end_lineno=16, + end_col_offset=56), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=56)], + [], + lineno=15, + col_offset=4, + end_lineno=16, + end_col_offset=56), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=18, + col_offset=15, + end_lineno=18, + end_col_offset=19), + arg( + 'placeholder_6', + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + BoolOp( + And(), + [ + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=21), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=30), + 'placeholder_2', + Load(), + lineno=19, + col_offset=25, + end_lineno=19, + end_col_offset=32)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=32), + Compare( + Attribute( + Name( + 'self', + Load(), + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=41), + 'placeholder_3', + Load(), + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=43), + [ + Eq()], + [ + Attribute( + Name( + 'placeholder_6', + Load(), + lineno=19, + col_offset=47, + end_lineno=19, + end_col_offset=52), + 'placeholder_3', + Load(), + lineno=19, + col_offset=47, + end_lineno=19, + end_col_offset=54)], + lineno=19, + col_offset=37, + end_lineno=19, + end_col_offset=54)], + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=54), + lineno=19, + col_offset=8, + end_lineno=19, + end_col_offset=54)], + [], + lineno=18, + col_offset=4, + end_lineno=19, + end_col_offset=54), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=21, + col_offset=15, + end_lineno=21, + end_col_offset=19), + arg( + 'placeholder_6', + lineno=21, + col_offset=21, + end_lineno=21, + end_col_offset=26)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + UnaryOp( + Not(), + Compare( + Name( + 'self', + Load(), + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=23), + [ + Eq()], + [ + Name( + 'placeholder_6', + Load(), + lineno=22, + col_offset=27, + end_lineno=22, + end_col_offset=32)], + lineno=22, + col_offset=19, + end_lineno=22, + end_col_offset=32), + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=32), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=32)], + [], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=32)], + [], + lineno=4, + col_offset=0, + end_lineno=22, + end_col_offset=32), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=25, + col_offset=0, + end_lineno=25, + end_col_offset=10)], + Tuple( + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=19), + [ + Constant( + 1, + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=21), + Constant( + 0, + lineno=25, + col_offset=23, + end_lineno=25, + end_col_offset=24)], + [], + lineno=25, + col_offset=14, + end_lineno=25, + end_col_offset=25), + Call( + Name( + 'placeholder_0', + Load(), + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=32), + [ + Constant( + 1, + lineno=25, + col_offset=33, + end_lineno=25, + end_col_offset=34), + UnaryOp( + USub(), + Constant( + 1, + lineno=25, + col_offset=37, + end_lineno=25, + end_col_offset=38), + lineno=25, + col_offset=36, + end_lineno=25, + end_col_offset=38)], + [], + lineno=25, + col_offset=27, + end_lineno=25, + end_col_offset=39), + Call( + Name( + 'placeholder_0', + Load(), + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=46), + [ + Constant( + 1, + lineno=25, + col_offset=47, + end_lineno=25, + end_col_offset=48), + Constant( + 1, + lineno=25, + col_offset=50, + end_lineno=25, + end_col_offset=51)], + [], + lineno=25, + col_offset=41, + end_lineno=25, + end_col_offset=52), + Call( + Name( + 'placeholder_0', + Load(), + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=59), + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=25, + col_offset=61, + end_lineno=25, + end_col_offset=62), + lineno=25, + col_offset=60, + end_lineno=25, + end_col_offset=62), + UnaryOp( + USub(), + Constant( + 1, + lineno=25, + col_offset=65, + end_lineno=25, + end_col_offset=66), + lineno=25, + col_offset=64, + end_lineno=25, + end_col_offset=66)], + [], + lineno=25, + col_offset=54, + end_lineno=25, + end_col_offset=67), + Call( + Name( + 'placeholder_0', + Load(), + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=19), + [ + Constant( + 0, + lineno=26, + col_offset=20, + end_lineno=26, + end_col_offset=21), + UnaryOp( + USub(), + Constant( + 1, + lineno=26, + col_offset=24, + end_lineno=26, + end_col_offset=25), + lineno=26, + col_offset=23, + end_lineno=26, + end_col_offset=25)], + [], + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=26), + Call( + Name( + 'placeholder_0', + Load(), + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=33), + [ + Constant( + 0, + lineno=26, + col_offset=34, + end_lineno=26, + end_col_offset=35), + Constant( + 1, + lineno=26, + col_offset=37, + end_lineno=26, + end_col_offset=38)], + [], + lineno=26, + col_offset=28, + end_lineno=26, + end_col_offset=39), + Call( + Name( + 'placeholder_0', + Load(), + lineno=26, + col_offset=41, + end_lineno=26, + end_col_offset=46), + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=26, + col_offset=48, + end_lineno=26, + end_col_offset=49), + lineno=26, + col_offset=47, + end_lineno=26, + end_col_offset=49), + Constant( + 1, + lineno=26, + col_offset=51, + end_lineno=26, + end_col_offset=52)], + [], + lineno=26, + col_offset=41, + end_lineno=26, + end_col_offset=53), + Call( + Name( + 'placeholder_0', + Load(), + lineno=26, + col_offset=55, + end_lineno=26, + end_col_offset=60), + [ + UnaryOp( + USub(), + Constant( + 1, + lineno=26, + col_offset=62, + end_lineno=26, + end_col_offset=63), + lineno=26, + col_offset=61, + end_lineno=26, + end_col_offset=63), + Constant( + 0, + lineno=26, + col_offset=65, + end_lineno=26, + end_col_offset=66)], + [], + lineno=26, + col_offset=55, + end_lineno=26, + end_col_offset=67)], + Load(), + lineno=25, + col_offset=13, + end_lineno=26, + end_col_offset=68), + lineno=25, + col_offset=0, + end_lineno=26, + end_col_offset=68), + ClassDef( + 'placeholder_11', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'self', + lineno=30, + col_offset=17, + end_lineno=30, + end_col_offset=21), + arg( + 'placeholder_12', + lineno=30, + col_offset=23, + end_lineno=30, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=12), + 'placeholder_13', + Store(), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=17)], + Name( + 'placeholder_12', + Load(), + lineno=31, + col_offset=20, + end_lineno=31, + end_col_offset=26), + lineno=31, + col_offset=8, + end_lineno=31, + end_col_offset=26), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'placeholder_14', + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=18)], + Call( + Name( + 'len', + Load(), + lineno=32, + col_offset=21, + end_lineno=32, + end_col_offset=24), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=29), + 'placeholder_13', + Load(), + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=34), + Constant( + 0, + lineno=32, + col_offset=35, + end_lineno=32, + end_col_offset=36), + Load(), + lineno=32, + col_offset=25, + end_lineno=32, + end_col_offset=37)], + [], + lineno=32, + col_offset=21, + end_lineno=32, + end_col_offset=38), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=38), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=12), + 'placeholder_15', + Store(), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=19)], + Call( + Name( + 'len', + Load(), + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=25), + [ + Attribute( + Name( + 'self', + Load(), + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=30), + 'placeholder_13', + Load(), + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=35)], + [], + lineno=33, + col_offset=22, + end_lineno=33, + end_col_offset=36), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=36)], + [], + lineno=30, + col_offset=4, + end_lineno=33, + end_col_offset=36), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=22), + arg( + 'placeholder_17', + lineno=35, + col_offset=24, + end_lineno=35, + end_col_offset=34)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + BoolOp( + Or(), + [ + Compare( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=21), + 'placeholder_2', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=23), + [ + Lt()], + [ + Constant( + 0, + lineno=36, + col_offset=26, + end_lineno=36, + end_col_offset=27)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=27), + Compare( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=41), + 'placeholder_2', + Load(), + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=43), + [ + GtE()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=47, + end_lineno=36, + end_col_offset=51), + 'placeholder_14', + Load(), + lineno=36, + col_offset=47, + end_lineno=36, + end_col_offset=57)], + lineno=36, + col_offset=31, + end_lineno=36, + end_col_offset=57)], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=57), + [ + Return( + Constant( + None, + lineno=37, + col_offset=19, + end_lineno=37, + end_col_offset=23), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=23)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=23), + If( + BoolOp( + Or(), + [ + Compare( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=21), + 'placeholder_3', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=23), + [ + Lt()], + [ + Constant( + 0, + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=27)], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=27), + Compare( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=41), + 'placeholder_3', + Load(), + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=43), + [ + GtE()], + [ + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=47, + end_lineno=38, + end_col_offset=51), + 'placeholder_15', + Load(), + lineno=38, + col_offset=47, + end_lineno=38, + end_col_offset=58)], + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=58)], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=58), + [ + Return( + Constant( + None, + lineno=39, + col_offset=19, + end_lineno=39, + end_col_offset=23), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=23)], + [], + lineno=38, + col_offset=8, + end_lineno=39, + end_col_offset=23), + Return( + Subscript( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=19), + 'placeholder_13', + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=24), + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=35), + 'placeholder_3', + Load(), + lineno=40, + col_offset=25, + end_lineno=40, + end_col_offset=37), + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=38), + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=40, + col_offset=39, + end_lineno=40, + end_col_offset=49), + 'placeholder_2', + Load(), + lineno=40, + col_offset=39, + end_lineno=40, + end_col_offset=51), + Load(), + lineno=40, + col_offset=15, + end_lineno=40, + end_col_offset=52), + lineno=40, + col_offset=8, + end_lineno=40, + end_col_offset=52)], + [], + lineno=35, + col_offset=4, + end_lineno=40, + end_col_offset=52), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'self', + lineno=42, + col_offset=13, + end_lineno=42, + end_col_offset=17), + arg( + 'placeholder_19', + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=23), + arg( + 'placeholder_20', + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=33), + arg( + 'placeholder_21', + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=44)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_22', + Store(), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=15)], + Call( + Attribute( + Name( + 'copy', + Load(), + lineno=43, + col_offset=18, + end_lineno=43, + end_col_offset=22), + 'copy', + Load(), + lineno=43, + col_offset=18, + end_lineno=43, + end_col_offset=27), + [ + Name( + 'placeholder_20', + Load(), + lineno=43, + col_offset=28, + end_lineno=43, + end_col_offset=36)], + [], + lineno=43, + col_offset=18, + end_lineno=43, + end_col_offset=37), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=37), + For( + Name( + 'placeholder_23', + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=18), + Name( + 'placeholder_19', + Load(), + lineno=44, + col_offset=22, + end_lineno=44, + end_col_offset=26), + [ + If( + Compare( + Call( + Attribute( + Name( + 'self', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=19), + 'placeholder_16', + Load(), + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=29), + [ + Name( + 'placeholder_22', + Load(), + lineno=45, + col_offset=30, + end_lineno=45, + end_col_offset=37)], + [], + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=38), + [ + NotEq()], + [ + Name( + 'placeholder_23', + Load(), + lineno=45, + col_offset=42, + end_lineno=45, + end_col_offset=48)], + lineno=45, + col_offset=15, + end_lineno=45, + end_col_offset=48), + [ + Return( + Constant( + None, + lineno=46, + col_offset=23, + end_lineno=46, + end_col_offset=27), + lineno=46, + col_offset=16, + end_lineno=46, + end_col_offset=27)], + [], + lineno=45, + col_offset=12, + end_lineno=46, + end_col_offset=27), + AugAssign( + Name( + 'placeholder_22', + Store(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=19), + Add(), + Name( + 'placeholder_21', + Load(), + lineno=47, + col_offset=23, + end_lineno=47, + end_col_offset=32), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=32)], + [], + lineno=44, + col_offset=8, + end_lineno=47, + end_col_offset=32), + Return( + Tuple( + [ + Name( + 'placeholder_20', + Load(), + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=23), + BinOp( + Name( + 'placeholder_22', + Load(), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=32), + Sub(), + Name( + 'placeholder_21', + Load(), + lineno=48, + col_offset=35, + end_lineno=48, + end_col_offset=44), + lineno=48, + col_offset=25, + end_lineno=48, + end_col_offset=44)], + Load(), + lineno=48, + col_offset=15, + end_lineno=48, + end_col_offset=44), + lineno=48, + col_offset=8, + end_lineno=48, + end_col_offset=44)], + [], + lineno=42, + col_offset=4, + end_lineno=48, + end_col_offset=44), + FunctionDef( + 'placeholder_24', + arguments( + [], + [ + arg( + 'self', + lineno=50, + col_offset=15, + end_lineno=50, + end_col_offset=19), + arg( + 'placeholder_19', + lineno=50, + col_offset=21, + end_lineno=50, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_25', + Store(), + lineno=51, + col_offset=8, + end_lineno=51, + end_col_offset=17)], + GeneratorExp( + Call( + Name( + 'placeholder_0', + Load(), + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=26), + [ + Name( + 'placeholder_26', + Load(), + lineno=51, + col_offset=27, + end_lineno=51, + end_col_offset=30), + Name( + 'placeholder_27', + Load(), + lineno=51, + col_offset=32, + end_lineno=51, + end_col_offset=35)], + [], + lineno=51, + col_offset=21, + end_lineno=51, + end_col_offset=36), + [ + comprehension( + Name( + 'placeholder_26', + Store(), + lineno=52, + col_offset=25, + end_lineno=52, + end_col_offset=28), + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=37), + [ + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=38, + end_lineno=52, + end_col_offset=42), + 'placeholder_14', + Load(), + lineno=52, + col_offset=38, + end_lineno=52, + end_col_offset=48)], + [], + lineno=52, + col_offset=32, + end_lineno=52, + end_col_offset=49), + [], + 0), + comprehension( + Name( + 'placeholder_27', + Store(), + lineno=52, + col_offset=54, + end_lineno=52, + end_col_offset=57), + Call( + Name( + 'range', + Load(), + lineno=52, + col_offset=61, + end_lineno=52, + end_col_offset=66), + [ + Attribute( + Name( + 'self', + Load(), + lineno=52, + col_offset=67, + end_lineno=52, + end_col_offset=71), + 'placeholder_15', + Load(), + lineno=52, + col_offset=67, + end_lineno=52, + end_col_offset=78)], + [], + lineno=52, + col_offset=61, + end_lineno=52, + end_col_offset=79), + [], + 0)], + lineno=51, + col_offset=20, + end_lineno=52, + end_col_offset=80), + lineno=51, + col_offset=8, + end_lineno=52, + end_col_offset=80), + For( + Name( + 'placeholder_20', + Store(), + lineno=53, + col_offset=12, + end_lineno=53, + end_col_offset=20), + Name( + 'placeholder_25', + Load(), + lineno=53, + col_offset=24, + end_lineno=53, + end_col_offset=33), + [ + For( + Name( + 'placeholder_21', + Store(), + lineno=54, + col_offset=16, + end_lineno=54, + end_col_offset=25), + Name( + 'placeholder_10', + Load(), + lineno=54, + col_offset=29, + end_lineno=54, + end_col_offset=39), + [ + Assign( + [ + Name( + 'placeholder_28', + Store(), + lineno=55, + col_offset=16, + end_lineno=55, + end_col_offset=22)], + Call( + Attribute( + Name( + 'self', + Load(), + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=29), + 'placeholder_18', + Load(), + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=34), + [ + Name( + 'placeholder_19', + Load(), + lineno=55, + col_offset=35, + end_lineno=55, + end_col_offset=39), + Name( + 'placeholder_20', + Load(), + lineno=55, + col_offset=41, + end_lineno=55, + end_col_offset=49), + Name( + 'placeholder_21', + Load(), + lineno=55, + col_offset=51, + end_lineno=55, + end_col_offset=60)], + [], + lineno=55, + col_offset=25, + end_lineno=55, + end_col_offset=61), + lineno=55, + col_offset=16, + end_lineno=55, + end_col_offset=61), + If( + Name( + 'placeholder_28', + Load(), + lineno=56, + col_offset=19, + end_lineno=56, + end_col_offset=25), + [ + Return( + Name( + 'placeholder_28', + Load(), + lineno=57, + col_offset=27, + end_lineno=57, + end_col_offset=33), + lineno=57, + col_offset=20, + end_lineno=57, + end_col_offset=33)], + [], + lineno=56, + col_offset=16, + end_lineno=57, + end_col_offset=33)], + [], + lineno=54, + col_offset=12, + end_lineno=57, + end_col_offset=33)], + [], + lineno=53, + col_offset=8, + end_lineno=57, + end_col_offset=33), + Return( + Constant( + None, + lineno=58, + col_offset=15, + end_lineno=58, + end_col_offset=19), + lineno=58, + col_offset=8, + end_lineno=58, + end_col_offset=19)], + [], + lineno=50, + col_offset=4, + end_lineno=58, + end_col_offset=19)], + [], + lineno=29, + col_offset=0, + end_lineno=58, + end_col_offset=19)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-word-search/representation.txt b/test/practice-word-search/representation.txt new file mode 100644 index 0000000..578d471 --- /dev/null +++ b/test/practice-word-search/representation.txt @@ -0,0 +1 @@ +Module([Import([alias('copy', lineno=1, col_offset=7, end_lineno=1, end_col_offset=11)], lineno=1, col_offset=0, end_lineno=1, end_col_offset=11), ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=5, col_offset=17, end_lineno=5, end_col_offset=21), arg('placeholder_2', lineno=5, col_offset=23, end_lineno=5, end_col_offset=24), arg('placeholder_3', lineno=5, col_offset=26, end_lineno=5, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=12), 'placeholder_2', Store(), lineno=6, col_offset=8, end_lineno=6, end_col_offset=14)], Name('placeholder_2', Load(), lineno=6, col_offset=17, end_lineno=6, end_col_offset=18), lineno=6, col_offset=8, end_lineno=6, end_col_offset=18), Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_3', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=14)], Name('placeholder_3', Load(), lineno=7, col_offset=17, end_lineno=7, end_col_offset=18), lineno=7, col_offset=8, end_lineno=7, end_col_offset=18)], [], lineno=5, col_offset=4, end_lineno=7, end_col_offset=18), FunctionDef('placeholder_4', arguments([], [arg('self', lineno=9, col_offset=17, end_lineno=9, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(JoinedStr([Constant('Point(', lineno=10, col_offset=15, end_lineno=10, end_col_offset=42), FormattedValue(Attribute(Name('self', Load(), lineno=10, col_offset=24, end_lineno=10, end_col_offset=28), 'placeholder_2', Load(), lineno=10, col_offset=24, end_lineno=10, end_col_offset=30), -1, lineno=10, col_offset=15, end_lineno=10, end_col_offset=42), Constant(':', lineno=10, col_offset=15, end_lineno=10, end_col_offset=42), FormattedValue(Attribute(Name('self', Load(), lineno=10, col_offset=33, end_lineno=10, end_col_offset=37), 'placeholder_3', Load(), lineno=10, col_offset=33, end_lineno=10, end_col_offset=39), -1, lineno=10, col_offset=15, end_lineno=10, end_col_offset=42), Constant(')', lineno=10, col_offset=15, end_lineno=10, end_col_offset=42)], lineno=10, col_offset=15, end_lineno=10, end_col_offset=42), lineno=10, col_offset=8, end_lineno=10, end_col_offset=42)], [], lineno=9, col_offset=4, end_lineno=10, end_col_offset=42), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=12, col_offset=16, end_lineno=12, end_col_offset=20), arg('placeholder_6', lineno=12, col_offset=22, end_lineno=12, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=13, col_offset=15, end_lineno=13, end_col_offset=20), [BinOp(Attribute(Name('self', Load(), lineno=13, col_offset=21, end_lineno=13, end_col_offset=25), 'placeholder_2', Load(), lineno=13, col_offset=21, end_lineno=13, end_col_offset=27), Add(), Attribute(Name('placeholder_6', Load(), lineno=13, col_offset=30, end_lineno=13, end_col_offset=35), 'placeholder_2', Load(), lineno=13, col_offset=30, end_lineno=13, end_col_offset=37), lineno=13, col_offset=21, end_lineno=13, end_col_offset=37), BinOp(Attribute(Name('self', Load(), lineno=13, col_offset=39, end_lineno=13, end_col_offset=43), 'placeholder_3', Load(), lineno=13, col_offset=39, end_lineno=13, end_col_offset=45), Add(), Attribute(Name('placeholder_6', Load(), lineno=13, col_offset=48, end_lineno=13, end_col_offset=53), 'placeholder_3', Load(), lineno=13, col_offset=48, end_lineno=13, end_col_offset=55), lineno=13, col_offset=39, end_lineno=13, end_col_offset=55)], [], lineno=13, col_offset=15, end_lineno=13, end_col_offset=56), lineno=13, col_offset=8, end_lineno=13, end_col_offset=56)], [], lineno=12, col_offset=4, end_lineno=13, end_col_offset=56), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=15, col_offset=16, end_lineno=15, end_col_offset=20), arg('placeholder_6', lineno=15, col_offset=22, end_lineno=15, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=16, col_offset=15, end_lineno=16, end_col_offset=20), [BinOp(Attribute(Name('self', Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=25), 'placeholder_2', Load(), lineno=16, col_offset=21, end_lineno=16, end_col_offset=27), Sub(), Attribute(Name('placeholder_6', Load(), lineno=16, col_offset=30, end_lineno=16, end_col_offset=35), 'placeholder_2', Load(), lineno=16, col_offset=30, end_lineno=16, end_col_offset=37), lineno=16, col_offset=21, end_lineno=16, end_col_offset=37), BinOp(Attribute(Name('self', Load(), lineno=16, col_offset=39, end_lineno=16, end_col_offset=43), 'placeholder_3', Load(), lineno=16, col_offset=39, end_lineno=16, end_col_offset=45), Sub(), Attribute(Name('placeholder_6', Load(), lineno=16, col_offset=48, end_lineno=16, end_col_offset=53), 'placeholder_3', Load(), lineno=16, col_offset=48, end_lineno=16, end_col_offset=55), lineno=16, col_offset=39, end_lineno=16, end_col_offset=55)], [], lineno=16, col_offset=15, end_lineno=16, end_col_offset=56), lineno=16, col_offset=8, end_lineno=16, end_col_offset=56)], [], lineno=15, col_offset=4, end_lineno=16, end_col_offset=56), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=18, col_offset=15, end_lineno=18, end_col_offset=19), arg('placeholder_6', lineno=18, col_offset=21, end_lineno=18, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(BoolOp(And(), [Compare(Attribute(Name('self', Load(), lineno=19, col_offset=15, end_lineno=19, end_col_offset=19), 'placeholder_2', Load(), lineno=19, col_offset=15, end_lineno=19, end_col_offset=21), [Eq()], [Attribute(Name('placeholder_6', Load(), lineno=19, col_offset=25, end_lineno=19, end_col_offset=30), 'placeholder_2', Load(), lineno=19, col_offset=25, end_lineno=19, end_col_offset=32)], lineno=19, col_offset=15, end_lineno=19, end_col_offset=32), Compare(Attribute(Name('self', Load(), lineno=19, col_offset=37, end_lineno=19, end_col_offset=41), 'placeholder_3', Load(), lineno=19, col_offset=37, end_lineno=19, end_col_offset=43), [Eq()], [Attribute(Name('placeholder_6', Load(), lineno=19, col_offset=47, end_lineno=19, end_col_offset=52), 'placeholder_3', Load(), lineno=19, col_offset=47, end_lineno=19, end_col_offset=54)], lineno=19, col_offset=37, end_lineno=19, end_col_offset=54)], lineno=19, col_offset=15, end_lineno=19, end_col_offset=54), lineno=19, col_offset=8, end_lineno=19, end_col_offset=54)], [], lineno=18, col_offset=4, end_lineno=19, end_col_offset=54), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=21, col_offset=15, end_lineno=21, end_col_offset=19), arg('placeholder_6', lineno=21, col_offset=21, end_lineno=21, end_col_offset=26)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(UnaryOp(Not(), Compare(Name('self', Load(), lineno=22, col_offset=19, end_lineno=22, end_col_offset=23), [Eq()], [Name('placeholder_6', Load(), lineno=22, col_offset=27, end_lineno=22, end_col_offset=32)], lineno=22, col_offset=19, end_lineno=22, end_col_offset=32), lineno=22, col_offset=15, end_lineno=22, end_col_offset=32), lineno=22, col_offset=8, end_lineno=22, end_col_offset=32)], [], lineno=21, col_offset=4, end_lineno=22, end_col_offset=32)], [], lineno=4, col_offset=0, end_lineno=22, end_col_offset=32), Assign([Name('placeholder_10', Store(), lineno=25, col_offset=0, end_lineno=25, end_col_offset=10)], Tuple([Call(Name('placeholder_0', Load(), lineno=25, col_offset=14, end_lineno=25, end_col_offset=19), [Constant(1, lineno=25, col_offset=20, end_lineno=25, end_col_offset=21), Constant(0, lineno=25, col_offset=23, end_lineno=25, end_col_offset=24)], [], lineno=25, col_offset=14, end_lineno=25, end_col_offset=25), Call(Name('placeholder_0', Load(), lineno=25, col_offset=27, end_lineno=25, end_col_offset=32), [Constant(1, lineno=25, col_offset=33, end_lineno=25, end_col_offset=34), UnaryOp(USub(), Constant(1, lineno=25, col_offset=37, end_lineno=25, end_col_offset=38), lineno=25, col_offset=36, end_lineno=25, end_col_offset=38)], [], lineno=25, col_offset=27, end_lineno=25, end_col_offset=39), Call(Name('placeholder_0', Load(), lineno=25, col_offset=41, end_lineno=25, end_col_offset=46), [Constant(1, lineno=25, col_offset=47, end_lineno=25, end_col_offset=48), Constant(1, lineno=25, col_offset=50, end_lineno=25, end_col_offset=51)], [], lineno=25, col_offset=41, end_lineno=25, end_col_offset=52), Call(Name('placeholder_0', Load(), lineno=25, col_offset=54, end_lineno=25, end_col_offset=59), [UnaryOp(USub(), Constant(1, lineno=25, col_offset=61, end_lineno=25, end_col_offset=62), lineno=25, col_offset=60, end_lineno=25, end_col_offset=62), UnaryOp(USub(), Constant(1, lineno=25, col_offset=65, end_lineno=25, end_col_offset=66), lineno=25, col_offset=64, end_lineno=25, end_col_offset=66)], [], lineno=25, col_offset=54, end_lineno=25, end_col_offset=67), Call(Name('placeholder_0', Load(), lineno=26, col_offset=14, end_lineno=26, end_col_offset=19), [Constant(0, lineno=26, col_offset=20, end_lineno=26, end_col_offset=21), UnaryOp(USub(), Constant(1, lineno=26, col_offset=24, end_lineno=26, end_col_offset=25), lineno=26, col_offset=23, end_lineno=26, end_col_offset=25)], [], lineno=26, col_offset=14, end_lineno=26, end_col_offset=26), Call(Name('placeholder_0', Load(), lineno=26, col_offset=28, end_lineno=26, end_col_offset=33), [Constant(0, lineno=26, col_offset=34, end_lineno=26, end_col_offset=35), Constant(1, lineno=26, col_offset=37, end_lineno=26, end_col_offset=38)], [], lineno=26, col_offset=28, end_lineno=26, end_col_offset=39), Call(Name('placeholder_0', Load(), lineno=26, col_offset=41, end_lineno=26, end_col_offset=46), [UnaryOp(USub(), Constant(1, lineno=26, col_offset=48, end_lineno=26, end_col_offset=49), lineno=26, col_offset=47, end_lineno=26, end_col_offset=49), Constant(1, lineno=26, col_offset=51, end_lineno=26, end_col_offset=52)], [], lineno=26, col_offset=41, end_lineno=26, end_col_offset=53), Call(Name('placeholder_0', Load(), lineno=26, col_offset=55, end_lineno=26, end_col_offset=60), [UnaryOp(USub(), Constant(1, lineno=26, col_offset=62, end_lineno=26, end_col_offset=63), lineno=26, col_offset=61, end_lineno=26, end_col_offset=63), Constant(0, lineno=26, col_offset=65, end_lineno=26, end_col_offset=66)], [], lineno=26, col_offset=55, end_lineno=26, end_col_offset=67)], Load(), lineno=25, col_offset=13, end_lineno=26, end_col_offset=68), lineno=25, col_offset=0, end_lineno=26, end_col_offset=68), ClassDef('placeholder_11', [], [], [FunctionDef('placeholder_1', arguments([], [arg('self', lineno=30, col_offset=17, end_lineno=30, end_col_offset=21), arg('placeholder_12', lineno=30, col_offset=23, end_lineno=30, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=12), 'placeholder_13', Store(), lineno=31, col_offset=8, end_lineno=31, end_col_offset=17)], Name('placeholder_12', Load(), lineno=31, col_offset=20, end_lineno=31, end_col_offset=26), lineno=31, col_offset=8, end_lineno=31, end_col_offset=26), Assign([Attribute(Name('self', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=12), 'placeholder_14', Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=18)], Call(Name('len', Load(), lineno=32, col_offset=21, end_lineno=32, end_col_offset=24), [Subscript(Attribute(Name('self', Load(), lineno=32, col_offset=25, end_lineno=32, end_col_offset=29), 'placeholder_13', Load(), lineno=32, col_offset=25, end_lineno=32, end_col_offset=34), Constant(0, lineno=32, col_offset=35, end_lineno=32, end_col_offset=36), Load(), lineno=32, col_offset=25, end_lineno=32, end_col_offset=37)], [], lineno=32, col_offset=21, end_lineno=32, end_col_offset=38), lineno=32, col_offset=8, end_lineno=32, end_col_offset=38), Assign([Attribute(Name('self', Load(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=12), 'placeholder_15', Store(), lineno=33, col_offset=8, end_lineno=33, end_col_offset=19)], Call(Name('len', Load(), lineno=33, col_offset=22, end_lineno=33, end_col_offset=25), [Attribute(Name('self', Load(), lineno=33, col_offset=26, end_lineno=33, end_col_offset=30), 'placeholder_13', Load(), lineno=33, col_offset=26, end_lineno=33, end_col_offset=35)], [], lineno=33, col_offset=22, end_lineno=33, end_col_offset=36), lineno=33, col_offset=8, end_lineno=33, end_col_offset=36)], [], lineno=30, col_offset=4, end_lineno=33, end_col_offset=36), FunctionDef('placeholder_16', arguments([], [arg('self', lineno=35, col_offset=18, end_lineno=35, end_col_offset=22), arg('placeholder_17', lineno=35, col_offset=24, end_lineno=35, end_col_offset=34)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(BoolOp(Or(), [Compare(Attribute(Name('placeholder_17', Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=21), 'placeholder_2', Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=23), [Lt()], [Constant(0, lineno=36, col_offset=26, end_lineno=36, end_col_offset=27)], lineno=36, col_offset=11, end_lineno=36, end_col_offset=27), Compare(Attribute(Name('placeholder_17', Load(), lineno=36, col_offset=31, end_lineno=36, end_col_offset=41), 'placeholder_2', Load(), lineno=36, col_offset=31, end_lineno=36, end_col_offset=43), [GtE()], [Attribute(Name('self', Load(), lineno=36, col_offset=47, end_lineno=36, end_col_offset=51), 'placeholder_14', Load(), lineno=36, col_offset=47, end_lineno=36, end_col_offset=57)], lineno=36, col_offset=31, end_lineno=36, end_col_offset=57)], lineno=36, col_offset=11, end_lineno=36, end_col_offset=57), [Return(Constant(None, lineno=37, col_offset=19, end_lineno=37, end_col_offset=23), lineno=37, col_offset=12, end_lineno=37, end_col_offset=23)], [], lineno=36, col_offset=8, end_lineno=37, end_col_offset=23), If(BoolOp(Or(), [Compare(Attribute(Name('placeholder_17', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=21), 'placeholder_3', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=23), [Lt()], [Constant(0, lineno=38, col_offset=26, end_lineno=38, end_col_offset=27)], lineno=38, col_offset=11, end_lineno=38, end_col_offset=27), Compare(Attribute(Name('placeholder_17', Load(), lineno=38, col_offset=31, end_lineno=38, end_col_offset=41), 'placeholder_3', Load(), lineno=38, col_offset=31, end_lineno=38, end_col_offset=43), [GtE()], [Attribute(Name('self', Load(), lineno=38, col_offset=47, end_lineno=38, end_col_offset=51), 'placeholder_15', Load(), lineno=38, col_offset=47, end_lineno=38, end_col_offset=58)], lineno=38, col_offset=31, end_lineno=38, end_col_offset=58)], lineno=38, col_offset=11, end_lineno=38, end_col_offset=58), [Return(Constant(None, lineno=39, col_offset=19, end_lineno=39, end_col_offset=23), lineno=39, col_offset=12, end_lineno=39, end_col_offset=23)], [], lineno=38, col_offset=8, end_lineno=39, end_col_offset=23), Return(Subscript(Subscript(Attribute(Name('self', Load(), lineno=40, col_offset=15, end_lineno=40, end_col_offset=19), 'placeholder_13', Load(), lineno=40, col_offset=15, end_lineno=40, end_col_offset=24), Attribute(Name('placeholder_17', Load(), lineno=40, col_offset=25, end_lineno=40, end_col_offset=35), 'placeholder_3', Load(), lineno=40, col_offset=25, end_lineno=40, end_col_offset=37), Load(), lineno=40, col_offset=15, end_lineno=40, end_col_offset=38), Attribute(Name('placeholder_17', Load(), lineno=40, col_offset=39, end_lineno=40, end_col_offset=49), 'placeholder_2', Load(), lineno=40, col_offset=39, end_lineno=40, end_col_offset=51), Load(), lineno=40, col_offset=15, end_lineno=40, end_col_offset=52), lineno=40, col_offset=8, end_lineno=40, end_col_offset=52)], [], lineno=35, col_offset=4, end_lineno=40, end_col_offset=52), FunctionDef('placeholder_18', arguments([], [arg('self', lineno=42, col_offset=13, end_lineno=42, end_col_offset=17), arg('placeholder_19', lineno=42, col_offset=19, end_lineno=42, end_col_offset=23), arg('placeholder_20', lineno=42, col_offset=25, end_lineno=42, end_col_offset=33), arg('placeholder_21', lineno=42, col_offset=35, end_lineno=42, end_col_offset=44)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_22', Store(), lineno=43, col_offset=8, end_lineno=43, end_col_offset=15)], Call(Attribute(Name('copy', Load(), lineno=43, col_offset=18, end_lineno=43, end_col_offset=22), 'copy', Load(), lineno=43, col_offset=18, end_lineno=43, end_col_offset=27), [Name('placeholder_20', Load(), lineno=43, col_offset=28, end_lineno=43, end_col_offset=36)], [], lineno=43, col_offset=18, end_lineno=43, end_col_offset=37), lineno=43, col_offset=8, end_lineno=43, end_col_offset=37), For(Name('placeholder_23', Store(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=18), Name('placeholder_19', Load(), lineno=44, col_offset=22, end_lineno=44, end_col_offset=26), [If(Compare(Call(Attribute(Name('self', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=19), 'placeholder_16', Load(), lineno=45, col_offset=15, end_lineno=45, end_col_offset=29), [Name('placeholder_22', Load(), lineno=45, col_offset=30, end_lineno=45, end_col_offset=37)], [], lineno=45, col_offset=15, end_lineno=45, end_col_offset=38), [NotEq()], [Name('placeholder_23', Load(), lineno=45, col_offset=42, end_lineno=45, end_col_offset=48)], lineno=45, col_offset=15, end_lineno=45, end_col_offset=48), [Return(Constant(None, lineno=46, col_offset=23, end_lineno=46, end_col_offset=27), lineno=46, col_offset=16, end_lineno=46, end_col_offset=27)], [], lineno=45, col_offset=12, end_lineno=46, end_col_offset=27), AugAssign(Name('placeholder_22', Store(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=19), Add(), Name('placeholder_21', Load(), lineno=47, col_offset=23, end_lineno=47, end_col_offset=32), lineno=47, col_offset=12, end_lineno=47, end_col_offset=32)], [], lineno=44, col_offset=8, end_lineno=47, end_col_offset=32), Return(Tuple([Name('placeholder_20', Load(), lineno=48, col_offset=15, end_lineno=48, end_col_offset=23), BinOp(Name('placeholder_22', Load(), lineno=48, col_offset=25, end_lineno=48, end_col_offset=32), Sub(), Name('placeholder_21', Load(), lineno=48, col_offset=35, end_lineno=48, end_col_offset=44), lineno=48, col_offset=25, end_lineno=48, end_col_offset=44)], Load(), lineno=48, col_offset=15, end_lineno=48, end_col_offset=44), lineno=48, col_offset=8, end_lineno=48, end_col_offset=44)], [], lineno=42, col_offset=4, end_lineno=48, end_col_offset=44), FunctionDef('placeholder_24', arguments([], [arg('self', lineno=50, col_offset=15, end_lineno=50, end_col_offset=19), arg('placeholder_19', lineno=50, col_offset=21, end_lineno=50, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_25', Store(), lineno=51, col_offset=8, end_lineno=51, end_col_offset=17)], GeneratorExp(Call(Name('placeholder_0', Load(), lineno=51, col_offset=21, end_lineno=51, end_col_offset=26), [Name('placeholder_26', Load(), lineno=51, col_offset=27, end_lineno=51, end_col_offset=30), Name('placeholder_27', Load(), lineno=51, col_offset=32, end_lineno=51, end_col_offset=35)], [], lineno=51, col_offset=21, end_lineno=51, end_col_offset=36), [comprehension(Name('placeholder_26', Store(), lineno=52, col_offset=25, end_lineno=52, end_col_offset=28), Call(Name('range', Load(), lineno=52, col_offset=32, end_lineno=52, end_col_offset=37), [Attribute(Name('self', Load(), lineno=52, col_offset=38, end_lineno=52, end_col_offset=42), 'placeholder_14', Load(), lineno=52, col_offset=38, end_lineno=52, end_col_offset=48)], [], lineno=52, col_offset=32, end_lineno=52, end_col_offset=49), [], 0), comprehension(Name('placeholder_27', Store(), lineno=52, col_offset=54, end_lineno=52, end_col_offset=57), Call(Name('range', Load(), lineno=52, col_offset=61, end_lineno=52, end_col_offset=66), [Attribute(Name('self', Load(), lineno=52, col_offset=67, end_lineno=52, end_col_offset=71), 'placeholder_15', Load(), lineno=52, col_offset=67, end_lineno=52, end_col_offset=78)], [], lineno=52, col_offset=61, end_lineno=52, end_col_offset=79), [], 0)], lineno=51, col_offset=20, end_lineno=52, end_col_offset=80), lineno=51, col_offset=8, end_lineno=52, end_col_offset=80), For(Name('placeholder_20', Store(), lineno=53, col_offset=12, end_lineno=53, end_col_offset=20), Name('placeholder_25', Load(), lineno=53, col_offset=24, end_lineno=53, end_col_offset=33), [For(Name('placeholder_21', Store(), lineno=54, col_offset=16, end_lineno=54, end_col_offset=25), Name('placeholder_10', Load(), lineno=54, col_offset=29, end_lineno=54, end_col_offset=39), [Assign([Name('placeholder_28', Store(), lineno=55, col_offset=16, end_lineno=55, end_col_offset=22)], Call(Attribute(Name('self', Load(), lineno=55, col_offset=25, end_lineno=55, end_col_offset=29), 'placeholder_18', Load(), lineno=55, col_offset=25, end_lineno=55, end_col_offset=34), [Name('placeholder_19', Load(), lineno=55, col_offset=35, end_lineno=55, end_col_offset=39), Name('placeholder_20', Load(), lineno=55, col_offset=41, end_lineno=55, end_col_offset=49), Name('placeholder_21', Load(), lineno=55, col_offset=51, end_lineno=55, end_col_offset=60)], [], lineno=55, col_offset=25, end_lineno=55, end_col_offset=61), lineno=55, col_offset=16, end_lineno=55, end_col_offset=61), If(Name('placeholder_28', Load(), lineno=56, col_offset=19, end_lineno=56, end_col_offset=25), [Return(Name('placeholder_28', Load(), lineno=57, col_offset=27, end_lineno=57, end_col_offset=33), lineno=57, col_offset=20, end_lineno=57, end_col_offset=33)], [], lineno=56, col_offset=16, end_lineno=57, end_col_offset=33)], [], lineno=54, col_offset=12, end_lineno=57, end_col_offset=33)], [], lineno=53, col_offset=8, end_lineno=57, end_col_offset=33), Return(Constant(None, lineno=58, col_offset=15, end_lineno=58, end_col_offset=19), lineno=58, col_offset=8, end_lineno=58, end_col_offset=19)], [], lineno=50, col_offset=4, end_lineno=58, end_col_offset=19)], [], lineno=29, col_offset=0, end_lineno=58, end_col_offset=19)], []) \ No newline at end of file diff --git a/test/practice-word-search/word_search.py b/test/practice-word-search/word_search.py new file mode 100644 index 0000000..fe2b9b6 --- /dev/null +++ b/test/practice-word-search/word_search.py @@ -0,0 +1,58 @@ +import copy + + +class Point: + def __init__(self, x, y): + self.x = x + self.y = y + + def __repr__(self): + return f'Point({self.x}:{self.y})' + + def __add__(self, other): + return Point(self.x + other.x, self.y + other.y) + + def __sub__(self, other): + return Point(self.x - other.x, self.y - other.y) + + def __eq__(self, other): + return self.x == other.x and self.y == other.y + + def __ne__(self, other): + return not self == other + + +DIRECTIONS = (Point(1, 0), Point(1, -1), Point(1, 1), Point(-1, -1), + Point(0, -1), Point(0, 1), Point(-1, 1), Point(-1, 0)) + + +class WordSearch: + def __init__(self, puzzle): + self.rows = puzzle + self.width = len(self.rows[0]) + self.height = len(self.rows) + + def find_char(self, coordinate): + if coordinate.x < 0 or coordinate.x >= self.width: + return None + if coordinate.y < 0 or coordinate.y >= self.height: + return None + return self.rows[coordinate.y][coordinate.x] + + def find(self, word, position, direction): + current = copy.copy(position) + for letter in word: + if self.find_char(current) != letter: + return None + current += direction + return position, current - direction + + def search(self, word): + positions = (Point(idx, edx) + for idx in range(self.width) for edx in range(self.height)) + for position in positions: + for direction in DIRECTIONS: + result = self.find(word, position, direction) + if result: + return result + return None diff --git a/test/practice-wordy/.meta/additional_tests.json b/test/practice-wordy/.meta/additional_tests.json new file mode 100644 index 0000000..089dd45 --- /dev/null +++ b/test/practice-wordy/.meta/additional_tests.json @@ -0,0 +1,20 @@ +{ + "cases": [ + { + "description": "Missing operation", + "property": "answer", + "input": { + "question": "What is 2 2 minus 3?" + }, + "expected": {"error": "syntax error"} + }, + { + "description": "Missing number", + "property": "answer", + "input": { + "question": "What is 7 plus multiplied by -2?" + }, + "expected": {"error": "syntax error"} + } + ] +} diff --git a/test/practice-wordy/.meta/config.json b/test/practice-wordy/.meta/config.json new file mode 100644 index 0000000..07c6341 --- /dev/null +++ b/test/practice-wordy/.meta/config.json @@ -0,0 +1,40 @@ +{ + "authors": [ + "betegelse" + ], + "contributors": [ + "behrtam", + "BethanyG", + "cmccandless", + "Dog", + "dvermd", + "fluxusfrequency", + "fortrieb", + "Grociu", + "ikhadykin", + "jackattack24", + "kytrinyx", + "N-Parsons", + "Nishant23", + "parinporecha", + "pheanex", + "rootulp", + "sjakobi", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "wordy.py" + ], + "test": [ + "wordy_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Parse and evaluate simple math word problems returning the answer as an integer.", + "source": "Inspired by one of the generated questions in the Extreme Startup game.", + "source_url": "https://github.com/rchatley/extreme_startup" +} diff --git a/test/practice-wordy/mapping.json b/test/practice-wordy/mapping.json new file mode 100644 index 0000000..54cebea --- /dev/null +++ b/test/practice-wordy/mapping.json @@ -0,0 +1,12 @@ +{ + "placeholder_0": "div", + "placeholder_1": "VALID_OPERATIONS", + "placeholder_2": "answer", + "placeholder_3": "question", + "placeholder_4": "words", + "placeholder_5": "main_value", + "placeholder_6": "error", + "placeholder_7": "operation", + "placeholder_8": "next_to_evaluate", + "placeholder_9": "second_value" +} \ No newline at end of file diff --git a/test/practice-wordy/representation.json b/test/practice-wordy/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-wordy/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-wordy/representation.out b/test/practice-wordy/representation.out new file mode 100644 index 0000000..30256aa --- /dev/null +++ b/test/practice-wordy/representation.out @@ -0,0 +1,2333 @@ +## BEGIN NORMALIZED CODE ## +from operator import add, mul, sub +from operator import floordiv as placeholder_0 + +placeholder_1 = { + "plus": add, + "minus": sub, + "multiplied by": mul, + "divided by": placeholder_0, +} + + +def placeholder_2(placeholder_3): + if not bool(placeholder_3[8:-1].strip().lower().split()): + raise ValueError("syntax error") + elif not placeholder_3.startswith("What is "): + raise ValueError("unknown operation") + else: + placeholder_4 = placeholder_3[8:-1].strip().lower().split() + placeholder_4.reverse() + try: + placeholder_5 = int(placeholder_4.pop()) + except ValueError as placeholder_6: + raise ValueError("syntax error") from placeholder_6 + while placeholder_4: + placeholder_7 = [placeholder_4.pop()] + while placeholder_4: + try: + placeholder_8 = placeholder_4.pop() + placeholder_9 = int(placeholder_8) + break + except ValueError as placeholder_6: + if placeholder_8 == placeholder_7[-1]: + raise ValueError("syntax error") from placeholder_6 + else: + placeholder_7.append(placeholder_8) + else: + if placeholder_7[-1] not in placeholder_1 and ( + not placeholder_7[-1].isdigit() + ): + raise ValueError("unknown operation") + else: + raise ValueError("syntax error") + placeholder_7 = " ".join(placeholder_7) + try: + placeholder_5 = placeholder_1[placeholder_7](placeholder_5, placeholder_9) + except KeyError as placeholder_6: + raise ValueError("syntax error") from placeholder_6 + return placeholder_5 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'operator', + [ + alias( + 'add', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=24), + alias( + 'mul', + lineno=1, + col_offset=26, + end_lineno=1, + end_col_offset=29), + alias( + 'sub', + lineno=1, + col_offset=31, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + ImportFrom( + 'operator', + [ + alias( + 'floordiv', + 'div', + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=36)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=36), + Assign( + [ + Name( + 'VALID_OPERATIONS', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=16)], + Dict( + [ + Constant( + 'plus', + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=26), + Constant( + 'minus', + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=40), + Constant( + 'multiplied by', + lineno=5, + col_offset=47, + end_lineno=5, + end_col_offset=62), + Constant( + 'divided by', + lineno=5, + col_offset=69, + end_lineno=5, + end_col_offset=81)], + [ + Name( + 'add', + Load(), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=31), + Name( + 'sub', + Load(), + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=45), + Name( + 'mul', + Load(), + lineno=5, + col_offset=64, + end_lineno=5, + end_col_offset=67), + Name( + 'div', + Load(), + lineno=5, + col_offset=83, + end_lineno=5, + end_col_offset=86)], + lineno=5, + col_offset=19, + end_lineno=5, + end_col_offset=87), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=87), + FunctionDef( + 'answer', + arguments( + [], + [ + arg( + 'question', + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'bool', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=15), + [ + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Subscript( + Name( + 'question', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=24), + Slice( + Constant( + 8, + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=26), + UnaryOp( + USub(), + Constant( + 1, + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=29), + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=29), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=29), + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=30), + 'strip', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=36), + [], + [], + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=38), + 'lower', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=44), + [], + [], + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=46), + 'split', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=52), + [], + [], + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=54)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=55), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=55), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=24), + [ + Constant( + 'syntax error', + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=39)], + [], + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=40), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=40)], + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'question', + Load(), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=21), + 'startswith', + Load(), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=32), + [ + Constant( + 'What is ', + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=43)], + [], + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=44), + lineno=12, + col_offset=9, + end_lineno=12, + end_col_offset=44), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=24), + [ + Constant( + 'unknown operation', + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=44)], + [], + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=45), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=45)], + [ + Assign( + [ + Name( + 'words', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=13)], + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Subscript( + Name( + 'question', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=24), + Slice( + Constant( + 8, + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=26), + UnaryOp( + USub(), + Constant( + 1, + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=29), + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=29), + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=29), + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=30), + 'strip', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=36), + [], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=38), + 'lower', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=44), + [], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=46), + 'split', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=52), + [], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=54), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=54), + Expr( + Call( + Attribute( + Name( + 'words', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=13), + 'reverse', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=21), + [], + [], + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=23), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=23)], + lineno=12, + col_offset=4, + end_lineno=17, + end_col_offset=23)], + lineno=9, + col_offset=4, + end_lineno=17, + end_col_offset=23), + Try( + [ + Assign( + [ + Name( + 'main_value', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=18)], + Call( + Name( + 'int', + Load(), + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=24), + [ + Call( + Attribute( + Name( + 'words', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=30), + 'pop', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=34), + [], + [], + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=36)], + [], + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=37), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=37)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=21), + 'error', + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=24), + [ + Constant( + 'syntax error', + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=39)], + [], + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=40), + Name( + 'error', + Load(), + lineno=22, + col_offset=46, + end_lineno=22, + end_col_offset=51), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=51)], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=51)], + [], + [], + lineno=19, + col_offset=4, + end_lineno=22, + end_col_offset=51), + While( + Name( + 'words', + Load(), + lineno=24, + col_offset=10, + end_lineno=24, + end_col_offset=15), + [ + Assign( + [ + Name( + 'operation', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=17)], + List( + [ + Call( + Attribute( + Name( + 'words', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=26), + 'pop', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=30), + [], + [], + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=32)], + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=33), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=33), + While( + Name( + 'words', + Load(), + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=19), + [ + Try( + [ + Assign( + [ + Name( + 'next_to_evaluate', + Store(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=32)], + Call( + Attribute( + Name( + 'words', + Load(), + lineno=28, + col_offset=35, + end_lineno=28, + end_col_offset=40), + 'pop', + Load(), + lineno=28, + col_offset=35, + end_lineno=28, + end_col_offset=44), + [], + [], + lineno=28, + col_offset=35, + end_lineno=28, + end_col_offset=46), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=46), + Assign( + [ + Name( + 'second_value', + Store(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=28)], + Call( + Name( + 'int', + Load(), + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=34), + [ + Name( + 'next_to_evaluate', + Load(), + lineno=29, + col_offset=35, + end_lineno=29, + end_col_offset=51)], + [], + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=52), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=52), + Break( + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=21)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=29), + 'error', + [ + If( + Compare( + Name( + 'next_to_evaluate', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=35), + [ + Eq()], + [ + Subscript( + Name( + 'operation', + Load(), + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=48), + UnaryOp( + USub(), + Constant( + 1, + lineno=32, + col_offset=50, + end_lineno=32, + end_col_offset=51), + lineno=32, + col_offset=49, + end_lineno=32, + end_col_offset=51), + Load(), + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=52)], + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=52), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=36), + [ + Constant( + 'syntax error', + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=51)], + [], + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=52), + Name( + 'error', + Load(), + lineno=33, + col_offset=58, + end_lineno=33, + end_col_offset=63), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=63)], + [ + Expr( + Call( + Attribute( + Name( + 'operation', + Load(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=29), + 'append', + Load(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=36), + [ + Name( + 'next_to_evaluate', + Load(), + lineno=35, + col_offset=37, + end_lineno=35, + end_col_offset=53)], + [], + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=54), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=54)], + lineno=32, + col_offset=16, + end_lineno=35, + end_col_offset=54)], + lineno=31, + col_offset=12, + end_lineno=35, + end_col_offset=54)], + [], + [], + lineno=27, + col_offset=12, + end_lineno=35, + end_col_offset=54)], + [ + If( + BoolOp( + And(), + [ + Compare( + Subscript( + Name( + 'operation', + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=24), + UnaryOp( + USub(), + Constant( + 1, + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=27), + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=27), + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=28), + [ + NotIn()], + [ + Name( + 'VALID_OPERATIONS', + Load(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=52)], + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=52), + UnaryOp( + Not(), + Call( + Attribute( + Subscript( + Name( + 'operation', + Load(), + lineno=37, + col_offset=61, + end_lineno=37, + end_col_offset=70), + UnaryOp( + USub(), + Constant( + 1, + lineno=37, + col_offset=72, + end_lineno=37, + end_col_offset=73), + lineno=37, + col_offset=71, + end_lineno=37, + end_col_offset=73), + Load(), + lineno=37, + col_offset=61, + end_lineno=37, + end_col_offset=74), + 'isdigit', + Load(), + lineno=37, + col_offset=61, + end_lineno=37, + end_col_offset=82), + [], + [], + lineno=37, + col_offset=61, + end_lineno=37, + end_col_offset=84), + lineno=37, + col_offset=57, + end_lineno=37, + end_col_offset=84)], + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=84), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=32), + [ + Constant( + 'unknown operation', + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=52)], + [], + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=53), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=53)], + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=32), + [ + Constant( + 'syntax error', + lineno=40, + col_offset=33, + end_lineno=40, + end_col_offset=47)], + [], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=48), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=48)], + lineno=37, + col_offset=12, + end_lineno=40, + end_col_offset=48)], + lineno=26, + col_offset=8, + end_lineno=40, + end_col_offset=48), + Assign( + [ + Name( + 'operation', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=17)], + Call( + Attribute( + Constant( + ' ', + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=23), + 'join', + Load(), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=28), + [ + Name( + 'operation', + Load(), + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=38)], + [], + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=39), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=39), + Try( + [ + Assign( + [ + Name( + 'main_value', + Store(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=22)], + Call( + Subscript( + Name( + 'VALID_OPERATIONS', + Load(), + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=41), + Name( + 'operation', + Load(), + lineno=45, + col_offset=42, + end_lineno=45, + end_col_offset=51), + Load(), + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=52), + [ + Name( + 'main_value', + Load(), + lineno=45, + col_offset=53, + end_lineno=45, + end_col_offset=63), + Name( + 'second_value', + Load(), + lineno=45, + col_offset=65, + end_lineno=45, + end_col_offset=77)], + [], + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=78), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=78)], + [ + ExceptHandler( + Name( + 'KeyError', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=23), + 'error', + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=28), + [ + Constant( + 'syntax error', + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=43)], + [], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=44), + Name( + 'error', + Load(), + lineno=47, + col_offset=50, + end_lineno=47, + end_col_offset=55), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=55)], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=55)], + [], + [], + lineno=44, + col_offset=8, + end_lineno=47, + end_col_offset=55)], + [], + lineno=24, + col_offset=4, + end_lineno=47, + end_col_offset=55), + Return( + Name( + 'main_value', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=21), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=21)], + [], + lineno=8, + col_offset=0, + end_lineno=49, + end_col_offset=21)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'operator', + [ + alias( + 'add', + lineno=1, + col_offset=21, + end_lineno=1, + end_col_offset=24), + alias( + 'mul', + lineno=1, + col_offset=26, + end_lineno=1, + end_col_offset=29), + alias( + 'sub', + lineno=1, + col_offset=31, + end_lineno=1, + end_col_offset=34)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=34), + ImportFrom( + 'operator', + [ + alias( + 'floordiv', + 'placeholder_0', + lineno=2, + col_offset=21, + end_lineno=2, + end_col_offset=36)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=36), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=16)], + Dict( + [ + Constant( + 'plus', + lineno=5, + col_offset=20, + end_lineno=5, + end_col_offset=26), + Constant( + 'minus', + lineno=5, + col_offset=33, + end_lineno=5, + end_col_offset=40), + Constant( + 'multiplied by', + lineno=5, + col_offset=47, + end_lineno=5, + end_col_offset=62), + Constant( + 'divided by', + lineno=5, + col_offset=69, + end_lineno=5, + end_col_offset=81)], + [ + Name( + 'add', + Load(), + lineno=5, + col_offset=28, + end_lineno=5, + end_col_offset=31), + Name( + 'sub', + Load(), + lineno=5, + col_offset=42, + end_lineno=5, + end_col_offset=45), + Name( + 'mul', + Load(), + lineno=5, + col_offset=64, + end_lineno=5, + end_col_offset=67), + Name( + 'placeholder_0', + Load(), + lineno=5, + col_offset=83, + end_lineno=5, + end_col_offset=86)], + lineno=5, + col_offset=19, + end_lineno=5, + end_col_offset=87), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=87), + FunctionDef( + 'placeholder_2', + arguments( + [], + [ + arg( + 'placeholder_3', + lineno=8, + col_offset=11, + end_lineno=8, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Call( + Name( + 'bool', + Load(), + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=15), + [ + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=24), + Slice( + Constant( + 8, + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=26), + UnaryOp( + USub(), + Constant( + 1, + lineno=9, + col_offset=28, + end_lineno=9, + end_col_offset=29), + lineno=9, + col_offset=27, + end_lineno=9, + end_col_offset=29), + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=29), + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=30), + 'strip', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=36), + [], + [], + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=38), + 'lower', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=44), + [], + [], + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=46), + 'split', + Load(), + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=52), + [], + [], + lineno=9, + col_offset=16, + end_lineno=9, + end_col_offset=54)], + [], + lineno=9, + col_offset=11, + end_lineno=9, + end_col_offset=55), + lineno=9, + col_offset=7, + end_lineno=9, + end_col_offset=55), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=24), + [ + Constant( + 'syntax error', + lineno=10, + col_offset=25, + end_lineno=10, + end_col_offset=39)], + [], + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=40), + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=40)], + [ + If( + UnaryOp( + Not(), + Call( + Attribute( + Name( + 'placeholder_3', + Load(), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=21), + 'startswith', + Load(), + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=32), + [ + Constant( + 'What is ', + lineno=12, + col_offset=33, + end_lineno=12, + end_col_offset=43)], + [], + lineno=12, + col_offset=13, + end_lineno=12, + end_col_offset=44), + lineno=12, + col_offset=9, + end_lineno=12, + end_col_offset=44), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=24), + [ + Constant( + 'unknown operation', + lineno=13, + col_offset=25, + end_lineno=13, + end_col_offset=44)], + [], + lineno=13, + col_offset=14, + end_lineno=13, + end_col_offset=45), + lineno=13, + col_offset=8, + end_lineno=13, + end_col_offset=45)], + [ + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=13)], + Call( + Attribute( + Call( + Attribute( + Call( + Attribute( + Subscript( + Name( + 'placeholder_3', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=24), + Slice( + Constant( + 8, + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=26), + UnaryOp( + USub(), + Constant( + 1, + lineno=16, + col_offset=28, + end_lineno=16, + end_col_offset=29), + lineno=16, + col_offset=27, + end_lineno=16, + end_col_offset=29), + lineno=16, + col_offset=25, + end_lineno=16, + end_col_offset=29), + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=30), + 'strip', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=36), + [], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=38), + 'lower', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=44), + [], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=46), + 'split', + Load(), + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=52), + [], + [], + lineno=16, + col_offset=16, + end_lineno=16, + end_col_offset=54), + lineno=16, + col_offset=8, + end_lineno=16, + end_col_offset=54), + Expr( + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=13), + 'reverse', + Load(), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=21), + [], + [], + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=23), + lineno=17, + col_offset=8, + end_lineno=17, + end_col_offset=23)], + lineno=12, + col_offset=4, + end_lineno=17, + end_col_offset=23)], + lineno=9, + col_offset=4, + end_lineno=17, + end_col_offset=23), + Try( + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=18)], + Call( + Name( + 'int', + Load(), + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=24), + [ + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=30), + 'pop', + Load(), + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=34), + [], + [], + lineno=20, + col_offset=25, + end_lineno=20, + end_col_offset=36)], + [], + lineno=20, + col_offset=21, + end_lineno=20, + end_col_offset=37), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=37)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=21, + col_offset=11, + end_lineno=21, + end_col_offset=21), + 'placeholder_6', + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=24), + [ + Constant( + 'syntax error', + lineno=22, + col_offset=25, + end_lineno=22, + end_col_offset=39)], + [], + lineno=22, + col_offset=14, + end_lineno=22, + end_col_offset=40), + Name( + 'placeholder_6', + Load(), + lineno=22, + col_offset=46, + end_lineno=22, + end_col_offset=51), + lineno=22, + col_offset=8, + end_lineno=22, + end_col_offset=51)], + lineno=21, + col_offset=4, + end_lineno=22, + end_col_offset=51)], + [], + [], + lineno=19, + col_offset=4, + end_lineno=22, + end_col_offset=51), + While( + Name( + 'placeholder_4', + Load(), + lineno=24, + col_offset=10, + end_lineno=24, + end_col_offset=15), + [ + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=17)], + List( + [ + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=26), + 'pop', + Load(), + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=30), + [], + [], + lineno=25, + col_offset=21, + end_lineno=25, + end_col_offset=32)], + Load(), + lineno=25, + col_offset=20, + end_lineno=25, + end_col_offset=33), + lineno=25, + col_offset=8, + end_lineno=25, + end_col_offset=33), + While( + Name( + 'placeholder_4', + Load(), + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=19), + [ + Try( + [ + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=32)], + Call( + Attribute( + Name( + 'placeholder_4', + Load(), + lineno=28, + col_offset=35, + end_lineno=28, + end_col_offset=40), + 'pop', + Load(), + lineno=28, + col_offset=35, + end_lineno=28, + end_col_offset=44), + [], + [], + lineno=28, + col_offset=35, + end_lineno=28, + end_col_offset=46), + lineno=28, + col_offset=16, + end_lineno=28, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=28)], + Call( + Name( + 'int', + Load(), + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=34), + [ + Name( + 'placeholder_8', + Load(), + lineno=29, + col_offset=35, + end_lineno=29, + end_col_offset=51)], + [], + lineno=29, + col_offset=31, + end_lineno=29, + end_col_offset=52), + lineno=29, + col_offset=16, + end_lineno=29, + end_col_offset=52), + Break( + lineno=30, + col_offset=16, + end_lineno=30, + end_col_offset=21)], + [ + ExceptHandler( + Name( + 'ValueError', + Load(), + lineno=31, + col_offset=19, + end_lineno=31, + end_col_offset=29), + 'placeholder_6', + [ + If( + Compare( + Name( + 'placeholder_8', + Load(), + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=35), + [ + Eq()], + [ + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=48), + UnaryOp( + USub(), + Constant( + 1, + lineno=32, + col_offset=50, + end_lineno=32, + end_col_offset=51), + lineno=32, + col_offset=49, + end_lineno=32, + end_col_offset=51), + Load(), + lineno=32, + col_offset=39, + end_lineno=32, + end_col_offset=52)], + lineno=32, + col_offset=19, + end_lineno=32, + end_col_offset=52), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=36), + [ + Constant( + 'syntax error', + lineno=33, + col_offset=37, + end_lineno=33, + end_col_offset=51)], + [], + lineno=33, + col_offset=26, + end_lineno=33, + end_col_offset=52), + Name( + 'placeholder_6', + Load(), + lineno=33, + col_offset=58, + end_lineno=33, + end_col_offset=63), + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=63)], + [ + Expr( + Call( + Attribute( + Name( + 'placeholder_7', + Load(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=29), + 'append', + Load(), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=36), + [ + Name( + 'placeholder_8', + Load(), + lineno=35, + col_offset=37, + end_lineno=35, + end_col_offset=53)], + [], + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=54), + lineno=35, + col_offset=20, + end_lineno=35, + end_col_offset=54)], + lineno=32, + col_offset=16, + end_lineno=35, + end_col_offset=54)], + lineno=31, + col_offset=12, + end_lineno=35, + end_col_offset=54)], + [], + [], + lineno=27, + col_offset=12, + end_lineno=35, + end_col_offset=54)], + [ + If( + BoolOp( + And(), + [ + Compare( + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=24), + UnaryOp( + USub(), + Constant( + 1, + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=27), + lineno=37, + col_offset=25, + end_lineno=37, + end_col_offset=27), + Load(), + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=28), + [ + NotIn()], + [ + Name( + 'placeholder_1', + Load(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=52)], + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=52), + UnaryOp( + Not(), + Call( + Attribute( + Subscript( + Name( + 'placeholder_7', + Load(), + lineno=37, + col_offset=61, + end_lineno=37, + end_col_offset=70), + UnaryOp( + USub(), + Constant( + 1, + lineno=37, + col_offset=72, + end_lineno=37, + end_col_offset=73), + lineno=37, + col_offset=71, + end_lineno=37, + end_col_offset=73), + Load(), + lineno=37, + col_offset=61, + end_lineno=37, + end_col_offset=74), + 'isdigit', + Load(), + lineno=37, + col_offset=61, + end_lineno=37, + end_col_offset=82), + [], + [], + lineno=37, + col_offset=61, + end_lineno=37, + end_col_offset=84), + lineno=37, + col_offset=57, + end_lineno=37, + end_col_offset=84)], + lineno=37, + col_offset=15, + end_lineno=37, + end_col_offset=84), + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=32), + [ + Constant( + 'unknown operation', + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=52)], + [], + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=53), + lineno=38, + col_offset=16, + end_lineno=38, + end_col_offset=53)], + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=32), + [ + Constant( + 'syntax error', + lineno=40, + col_offset=33, + end_lineno=40, + end_col_offset=47)], + [], + lineno=40, + col_offset=22, + end_lineno=40, + end_col_offset=48), + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=48)], + lineno=37, + col_offset=12, + end_lineno=40, + end_col_offset=48)], + lineno=26, + col_offset=8, + end_lineno=40, + end_col_offset=48), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=17)], + Call( + Attribute( + Constant( + ' ', + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=23), + 'join', + Load(), + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=28), + [ + Name( + 'placeholder_7', + Load(), + lineno=42, + col_offset=29, + end_lineno=42, + end_col_offset=38)], + [], + lineno=42, + col_offset=20, + end_lineno=42, + end_col_offset=39), + lineno=42, + col_offset=8, + end_lineno=42, + end_col_offset=39), + Try( + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=22)], + Call( + Subscript( + Name( + 'placeholder_1', + Load(), + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=41), + Name( + 'placeholder_7', + Load(), + lineno=45, + col_offset=42, + end_lineno=45, + end_col_offset=51), + Load(), + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=52), + [ + Name( + 'placeholder_5', + Load(), + lineno=45, + col_offset=53, + end_lineno=45, + end_col_offset=63), + Name( + 'placeholder_9', + Load(), + lineno=45, + col_offset=65, + end_lineno=45, + end_col_offset=77)], + [], + lineno=45, + col_offset=25, + end_lineno=45, + end_col_offset=78), + lineno=45, + col_offset=12, + end_lineno=45, + end_col_offset=78)], + [ + ExceptHandler( + Name( + 'KeyError', + Load(), + lineno=46, + col_offset=15, + end_lineno=46, + end_col_offset=23), + 'placeholder_6', + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=28), + [ + Constant( + 'syntax error', + lineno=47, + col_offset=29, + end_lineno=47, + end_col_offset=43)], + [], + lineno=47, + col_offset=18, + end_lineno=47, + end_col_offset=44), + Name( + 'placeholder_6', + Load(), + lineno=47, + col_offset=50, + end_lineno=47, + end_col_offset=55), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=55)], + lineno=46, + col_offset=8, + end_lineno=47, + end_col_offset=55)], + [], + [], + lineno=44, + col_offset=8, + end_lineno=47, + end_col_offset=55)], + [], + lineno=24, + col_offset=4, + end_lineno=47, + end_col_offset=55), + Return( + Name( + 'placeholder_5', + Load(), + lineno=49, + col_offset=11, + end_lineno=49, + end_col_offset=21), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=21)], + [], + lineno=8, + col_offset=0, + end_lineno=49, + end_col_offset=21)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-wordy/representation.txt b/test/practice-wordy/representation.txt new file mode 100644 index 0000000..e8da9a2 --- /dev/null +++ b/test/practice-wordy/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('operator', [alias('add', lineno=1, col_offset=21, end_lineno=1, end_col_offset=24), alias('mul', lineno=1, col_offset=26, end_lineno=1, end_col_offset=29), alias('sub', lineno=1, col_offset=31, end_lineno=1, end_col_offset=34)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=34), ImportFrom('operator', [alias('floordiv', 'placeholder_0', lineno=2, col_offset=21, end_lineno=2, end_col_offset=36)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=36), Assign([Name('placeholder_1', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=16)], Dict([Constant('plus', lineno=5, col_offset=20, end_lineno=5, end_col_offset=26), Constant('minus', lineno=5, col_offset=33, end_lineno=5, end_col_offset=40), Constant('multiplied by', lineno=5, col_offset=47, end_lineno=5, end_col_offset=62), Constant('divided by', lineno=5, col_offset=69, end_lineno=5, end_col_offset=81)], [Name('add', Load(), lineno=5, col_offset=28, end_lineno=5, end_col_offset=31), Name('sub', Load(), lineno=5, col_offset=42, end_lineno=5, end_col_offset=45), Name('mul', Load(), lineno=5, col_offset=64, end_lineno=5, end_col_offset=67), Name('placeholder_0', Load(), lineno=5, col_offset=83, end_lineno=5, end_col_offset=86)], lineno=5, col_offset=19, end_lineno=5, end_col_offset=87), lineno=5, col_offset=0, end_lineno=5, end_col_offset=87), FunctionDef('placeholder_2', arguments([], [arg('placeholder_3', lineno=8, col_offset=11, end_lineno=8, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Call(Name('bool', Load(), lineno=9, col_offset=11, end_lineno=9, end_col_offset=15), [Call(Attribute(Call(Attribute(Call(Attribute(Subscript(Name('placeholder_3', Load(), lineno=9, col_offset=16, end_lineno=9, end_col_offset=24), Slice(Constant(8, lineno=9, col_offset=25, end_lineno=9, end_col_offset=26), UnaryOp(USub(), Constant(1, lineno=9, col_offset=28, end_lineno=9, end_col_offset=29), lineno=9, col_offset=27, end_lineno=9, end_col_offset=29), lineno=9, col_offset=25, end_lineno=9, end_col_offset=29), Load(), lineno=9, col_offset=16, end_lineno=9, end_col_offset=30), 'strip', Load(), lineno=9, col_offset=16, end_lineno=9, end_col_offset=36), [], [], lineno=9, col_offset=16, end_lineno=9, end_col_offset=38), 'lower', Load(), lineno=9, col_offset=16, end_lineno=9, end_col_offset=44), [], [], lineno=9, col_offset=16, end_lineno=9, end_col_offset=46), 'split', Load(), lineno=9, col_offset=16, end_lineno=9, end_col_offset=52), [], [], lineno=9, col_offset=16, end_lineno=9, end_col_offset=54)], [], lineno=9, col_offset=11, end_lineno=9, end_col_offset=55), lineno=9, col_offset=7, end_lineno=9, end_col_offset=55), [Raise(Call(Name('ValueError', Load(), lineno=10, col_offset=14, end_lineno=10, end_col_offset=24), [Constant('syntax error', lineno=10, col_offset=25, end_lineno=10, end_col_offset=39)], [], lineno=10, col_offset=14, end_lineno=10, end_col_offset=40), lineno=10, col_offset=8, end_lineno=10, end_col_offset=40)], [If(UnaryOp(Not(), Call(Attribute(Name('placeholder_3', Load(), lineno=12, col_offset=13, end_lineno=12, end_col_offset=21), 'startswith', Load(), lineno=12, col_offset=13, end_lineno=12, end_col_offset=32), [Constant('What is ', lineno=12, col_offset=33, end_lineno=12, end_col_offset=43)], [], lineno=12, col_offset=13, end_lineno=12, end_col_offset=44), lineno=12, col_offset=9, end_lineno=12, end_col_offset=44), [Raise(Call(Name('ValueError', Load(), lineno=13, col_offset=14, end_lineno=13, end_col_offset=24), [Constant('unknown operation', lineno=13, col_offset=25, end_lineno=13, end_col_offset=44)], [], lineno=13, col_offset=14, end_lineno=13, end_col_offset=45), lineno=13, col_offset=8, end_lineno=13, end_col_offset=45)], [Assign([Name('placeholder_4', Store(), lineno=16, col_offset=8, end_lineno=16, end_col_offset=13)], Call(Attribute(Call(Attribute(Call(Attribute(Subscript(Name('placeholder_3', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=24), Slice(Constant(8, lineno=16, col_offset=25, end_lineno=16, end_col_offset=26), UnaryOp(USub(), Constant(1, lineno=16, col_offset=28, end_lineno=16, end_col_offset=29), lineno=16, col_offset=27, end_lineno=16, end_col_offset=29), lineno=16, col_offset=25, end_lineno=16, end_col_offset=29), Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=30), 'strip', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=36), [], [], lineno=16, col_offset=16, end_lineno=16, end_col_offset=38), 'lower', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=44), [], [], lineno=16, col_offset=16, end_lineno=16, end_col_offset=46), 'split', Load(), lineno=16, col_offset=16, end_lineno=16, end_col_offset=52), [], [], lineno=16, col_offset=16, end_lineno=16, end_col_offset=54), lineno=16, col_offset=8, end_lineno=16, end_col_offset=54), Expr(Call(Attribute(Name('placeholder_4', Load(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=13), 'reverse', Load(), lineno=17, col_offset=8, end_lineno=17, end_col_offset=21), [], [], lineno=17, col_offset=8, end_lineno=17, end_col_offset=23), lineno=17, col_offset=8, end_lineno=17, end_col_offset=23)], lineno=12, col_offset=4, end_lineno=17, end_col_offset=23)], lineno=9, col_offset=4, end_lineno=17, end_col_offset=23), Try([Assign([Name('placeholder_5', Store(), lineno=20, col_offset=8, end_lineno=20, end_col_offset=18)], Call(Name('int', Load(), lineno=20, col_offset=21, end_lineno=20, end_col_offset=24), [Call(Attribute(Name('placeholder_4', Load(), lineno=20, col_offset=25, end_lineno=20, end_col_offset=30), 'pop', Load(), lineno=20, col_offset=25, end_lineno=20, end_col_offset=34), [], [], lineno=20, col_offset=25, end_lineno=20, end_col_offset=36)], [], lineno=20, col_offset=21, end_lineno=20, end_col_offset=37), lineno=20, col_offset=8, end_lineno=20, end_col_offset=37)], [ExceptHandler(Name('ValueError', Load(), lineno=21, col_offset=11, end_lineno=21, end_col_offset=21), 'placeholder_6', [Raise(Call(Name('ValueError', Load(), lineno=22, col_offset=14, end_lineno=22, end_col_offset=24), [Constant('syntax error', lineno=22, col_offset=25, end_lineno=22, end_col_offset=39)], [], lineno=22, col_offset=14, end_lineno=22, end_col_offset=40), Name('placeholder_6', Load(), lineno=22, col_offset=46, end_lineno=22, end_col_offset=51), lineno=22, col_offset=8, end_lineno=22, end_col_offset=51)], lineno=21, col_offset=4, end_lineno=22, end_col_offset=51)], [], [], lineno=19, col_offset=4, end_lineno=22, end_col_offset=51), While(Name('placeholder_4', Load(), lineno=24, col_offset=10, end_lineno=24, end_col_offset=15), [Assign([Name('placeholder_7', Store(), lineno=25, col_offset=8, end_lineno=25, end_col_offset=17)], List([Call(Attribute(Name('placeholder_4', Load(), lineno=25, col_offset=21, end_lineno=25, end_col_offset=26), 'pop', Load(), lineno=25, col_offset=21, end_lineno=25, end_col_offset=30), [], [], lineno=25, col_offset=21, end_lineno=25, end_col_offset=32)], Load(), lineno=25, col_offset=20, end_lineno=25, end_col_offset=33), lineno=25, col_offset=8, end_lineno=25, end_col_offset=33), While(Name('placeholder_4', Load(), lineno=26, col_offset=14, end_lineno=26, end_col_offset=19), [Try([Assign([Name('placeholder_8', Store(), lineno=28, col_offset=16, end_lineno=28, end_col_offset=32)], Call(Attribute(Name('placeholder_4', Load(), lineno=28, col_offset=35, end_lineno=28, end_col_offset=40), 'pop', Load(), lineno=28, col_offset=35, end_lineno=28, end_col_offset=44), [], [], lineno=28, col_offset=35, end_lineno=28, end_col_offset=46), lineno=28, col_offset=16, end_lineno=28, end_col_offset=46), Assign([Name('placeholder_9', Store(), lineno=29, col_offset=16, end_lineno=29, end_col_offset=28)], Call(Name('int', Load(), lineno=29, col_offset=31, end_lineno=29, end_col_offset=34), [Name('placeholder_8', Load(), lineno=29, col_offset=35, end_lineno=29, end_col_offset=51)], [], lineno=29, col_offset=31, end_lineno=29, end_col_offset=52), lineno=29, col_offset=16, end_lineno=29, end_col_offset=52), Break(lineno=30, col_offset=16, end_lineno=30, end_col_offset=21)], [ExceptHandler(Name('ValueError', Load(), lineno=31, col_offset=19, end_lineno=31, end_col_offset=29), 'placeholder_6', [If(Compare(Name('placeholder_8', Load(), lineno=32, col_offset=19, end_lineno=32, end_col_offset=35), [Eq()], [Subscript(Name('placeholder_7', Load(), lineno=32, col_offset=39, end_lineno=32, end_col_offset=48), UnaryOp(USub(), Constant(1, lineno=32, col_offset=50, end_lineno=32, end_col_offset=51), lineno=32, col_offset=49, end_lineno=32, end_col_offset=51), Load(), lineno=32, col_offset=39, end_lineno=32, end_col_offset=52)], lineno=32, col_offset=19, end_lineno=32, end_col_offset=52), [Raise(Call(Name('ValueError', Load(), lineno=33, col_offset=26, end_lineno=33, end_col_offset=36), [Constant('syntax error', lineno=33, col_offset=37, end_lineno=33, end_col_offset=51)], [], lineno=33, col_offset=26, end_lineno=33, end_col_offset=52), Name('placeholder_6', Load(), lineno=33, col_offset=58, end_lineno=33, end_col_offset=63), lineno=33, col_offset=20, end_lineno=33, end_col_offset=63)], [Expr(Call(Attribute(Name('placeholder_7', Load(), lineno=35, col_offset=20, end_lineno=35, end_col_offset=29), 'append', Load(), lineno=35, col_offset=20, end_lineno=35, end_col_offset=36), [Name('placeholder_8', Load(), lineno=35, col_offset=37, end_lineno=35, end_col_offset=53)], [], lineno=35, col_offset=20, end_lineno=35, end_col_offset=54), lineno=35, col_offset=20, end_lineno=35, end_col_offset=54)], lineno=32, col_offset=16, end_lineno=35, end_col_offset=54)], lineno=31, col_offset=12, end_lineno=35, end_col_offset=54)], [], [], lineno=27, col_offset=12, end_lineno=35, end_col_offset=54)], [If(BoolOp(And(), [Compare(Subscript(Name('placeholder_7', Load(), lineno=37, col_offset=15, end_lineno=37, end_col_offset=24), UnaryOp(USub(), Constant(1, lineno=37, col_offset=26, end_lineno=37, end_col_offset=27), lineno=37, col_offset=25, end_lineno=37, end_col_offset=27), Load(), lineno=37, col_offset=15, end_lineno=37, end_col_offset=28), [NotIn()], [Name('placeholder_1', Load(), lineno=37, col_offset=36, end_lineno=37, end_col_offset=52)], lineno=37, col_offset=15, end_lineno=37, end_col_offset=52), UnaryOp(Not(), Call(Attribute(Subscript(Name('placeholder_7', Load(), lineno=37, col_offset=61, end_lineno=37, end_col_offset=70), UnaryOp(USub(), Constant(1, lineno=37, col_offset=72, end_lineno=37, end_col_offset=73), lineno=37, col_offset=71, end_lineno=37, end_col_offset=73), Load(), lineno=37, col_offset=61, end_lineno=37, end_col_offset=74), 'isdigit', Load(), lineno=37, col_offset=61, end_lineno=37, end_col_offset=82), [], [], lineno=37, col_offset=61, end_lineno=37, end_col_offset=84), lineno=37, col_offset=57, end_lineno=37, end_col_offset=84)], lineno=37, col_offset=15, end_lineno=37, end_col_offset=84), [Raise(Call(Name('ValueError', Load(), lineno=38, col_offset=22, end_lineno=38, end_col_offset=32), [Constant('unknown operation', lineno=38, col_offset=33, end_lineno=38, end_col_offset=52)], [], lineno=38, col_offset=22, end_lineno=38, end_col_offset=53), lineno=38, col_offset=16, end_lineno=38, end_col_offset=53)], [Raise(Call(Name('ValueError', Load(), lineno=40, col_offset=22, end_lineno=40, end_col_offset=32), [Constant('syntax error', lineno=40, col_offset=33, end_lineno=40, end_col_offset=47)], [], lineno=40, col_offset=22, end_lineno=40, end_col_offset=48), lineno=40, col_offset=16, end_lineno=40, end_col_offset=48)], lineno=37, col_offset=12, end_lineno=40, end_col_offset=48)], lineno=26, col_offset=8, end_lineno=40, end_col_offset=48), Assign([Name('placeholder_7', Store(), lineno=42, col_offset=8, end_lineno=42, end_col_offset=17)], Call(Attribute(Constant(' ', lineno=42, col_offset=20, end_lineno=42, end_col_offset=23), 'join', Load(), lineno=42, col_offset=20, end_lineno=42, end_col_offset=28), [Name('placeholder_7', Load(), lineno=42, col_offset=29, end_lineno=42, end_col_offset=38)], [], lineno=42, col_offset=20, end_lineno=42, end_col_offset=39), lineno=42, col_offset=8, end_lineno=42, end_col_offset=39), Try([Assign([Name('placeholder_5', Store(), lineno=45, col_offset=12, end_lineno=45, end_col_offset=22)], Call(Subscript(Name('placeholder_1', Load(), lineno=45, col_offset=25, end_lineno=45, end_col_offset=41), Name('placeholder_7', Load(), lineno=45, col_offset=42, end_lineno=45, end_col_offset=51), Load(), lineno=45, col_offset=25, end_lineno=45, end_col_offset=52), [Name('placeholder_5', Load(), lineno=45, col_offset=53, end_lineno=45, end_col_offset=63), Name('placeholder_9', Load(), lineno=45, col_offset=65, end_lineno=45, end_col_offset=77)], [], lineno=45, col_offset=25, end_lineno=45, end_col_offset=78), lineno=45, col_offset=12, end_lineno=45, end_col_offset=78)], [ExceptHandler(Name('KeyError', Load(), lineno=46, col_offset=15, end_lineno=46, end_col_offset=23), 'placeholder_6', [Raise(Call(Name('ValueError', Load(), lineno=47, col_offset=18, end_lineno=47, end_col_offset=28), [Constant('syntax error', lineno=47, col_offset=29, end_lineno=47, end_col_offset=43)], [], lineno=47, col_offset=18, end_lineno=47, end_col_offset=44), Name('placeholder_6', Load(), lineno=47, col_offset=50, end_lineno=47, end_col_offset=55), lineno=47, col_offset=12, end_lineno=47, end_col_offset=55)], lineno=46, col_offset=8, end_lineno=47, end_col_offset=55)], [], [], lineno=44, col_offset=8, end_lineno=47, end_col_offset=55)], [], lineno=24, col_offset=4, end_lineno=47, end_col_offset=55), Return(Name('placeholder_5', Load(), lineno=49, col_offset=11, end_lineno=49, end_col_offset=21), lineno=49, col_offset=4, end_lineno=49, end_col_offset=21)], [], lineno=8, col_offset=0, end_lineno=49, end_col_offset=21)], []) \ No newline at end of file diff --git a/test/practice-wordy/wordy.py b/test/practice-wordy/wordy.py new file mode 100644 index 0000000..2488153 --- /dev/null +++ b/test/practice-wordy/wordy.py @@ -0,0 +1,49 @@ +from operator import add, mul, sub +from operator import floordiv as div + + +VALID_OPERATIONS = {'plus': add, 'minus': sub, 'multiplied by': mul, 'divided by': div} + + +def answer(question): + if not bool(question[8:-1].strip().lower().split()): + raise ValueError('syntax error') + + elif not question.startswith('What is '): + raise ValueError('unknown operation') + + else: + words = question[8:-1].strip().lower().split() + words.reverse() + + try: + main_value = int(words.pop()) + except ValueError as error: + raise ValueError('syntax error') from error + + while words: + operation = [words.pop()] + while words: + try: + next_to_evaluate = words.pop() + second_value = int(next_to_evaluate) + break + except ValueError as error: + if next_to_evaluate == operation[-1]: + raise ValueError('syntax error') from error + else: + operation.append(next_to_evaluate) + else: + if operation[-1] not in VALID_OPERATIONS and not operation[-1].isdigit() : + raise ValueError('unknown operation') + else: + raise ValueError('syntax error') + + operation = ' '.join(operation) + + try: + main_value = VALID_OPERATIONS[operation](main_value, second_value) + except KeyError as error: + raise ValueError('syntax error') from error + + return main_value diff --git a/test/practice-yacht/.meta/config.json b/test/practice-yacht/.meta/config.json new file mode 100644 index 0000000..78c685c --- /dev/null +++ b/test/practice-yacht/.meta/config.json @@ -0,0 +1,25 @@ +{ + "authors": [], + "contributors": [ + "aaditkamat", + "cmccandless", + "Dog", + "Grociu", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "yacht.py" + ], + "test": [ + "yacht_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Score a single throw of dice in the game Yacht.", + "source": "James Kilfiger, using wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)" +} diff --git a/test/practice-yacht/mapping.json b/test/practice-yacht/mapping.json new file mode 100644 index 0000000..9f3b14c --- /dev/null +++ b/test/practice-yacht/mapping.json @@ -0,0 +1,29 @@ +{ + "placeholder_0": "YACHT", + "placeholder_1": "ONES", + "placeholder_2": "TWOS", + "placeholder_3": "THREES", + "placeholder_4": "FOURS", + "placeholder_5": "FIVES", + "placeholder_6": "SIXES", + "placeholder_7": "FULL_HOUSE", + "placeholder_8": "FOUR_OF_A_KIND", + "placeholder_9": "LITTLE_STRAIGHT", + "placeholder_10": "BIG_STRAIGHT", + "placeholder_11": "CHOICE", + "placeholder_12": "sum_of_numbers", + "placeholder_13": "number", + "placeholder_14": "dice", + "placeholder_15": "idx", + "placeholder_16": "full_house", + "placeholder_17": "counter", + "placeholder_18": "four_of_a_kind", + "placeholder_19": "count", + "placeholder_20": "little_straight", + "placeholder_21": "big_straight", + "placeholder_22": "yacht", + "placeholder_23": "functions", + "placeholder_24": "score", + "placeholder_25": "category", + "placeholder_26": "error" +} \ No newline at end of file diff --git a/test/practice-yacht/representation.json b/test/practice-yacht/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-yacht/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-yacht/representation.out b/test/practice-yacht/representation.out new file mode 100644 index 0000000..29510c8 --- /dev/null +++ b/test/practice-yacht/representation.out @@ -0,0 +1,2734 @@ +## BEGIN NORMALIZED CODE ## +from collections import Counter +from functools import partial + +placeholder_0 = 0 +placeholder_1 = 1 +placeholder_2 = 2 +placeholder_3 = 3 +placeholder_4 = 4 +placeholder_5 = 5 +placeholder_6 = 6 +placeholder_7 = 7 +placeholder_8 = 8 +placeholder_9 = 9 +placeholder_10 = 10 +placeholder_11 = 11 + + +def placeholder_12(placeholder_13, placeholder_14): + return sum( + ( + placeholder_15 + for placeholder_15 in placeholder_14 + if placeholder_15 == placeholder_13 + ) + ) + + +def placeholder_16(placeholder_14): + placeholder_17 = Counter(placeholder_14) + return sum(placeholder_14) if set(placeholder_17.values()) == {3, 2} else 0 + + +def placeholder_18(placeholder_14): + placeholder_17 = Counter(placeholder_14) + placeholder_13, placeholder_19 = placeholder_17.most_common()[0] + return 4 * placeholder_13 if placeholder_19 >= 4 else 0 + + +def placeholder_20(placeholder_14): + return 30 if set(placeholder_14) == {1, 2, 3, 4, 5} else 0 + + +def placeholder_21(placeholder_14): + return 30 if set(placeholder_14) == {2, 3, 4, 5, 6} else 0 + + +def placeholder_22(placeholder_14): + return 50 if len(set(placeholder_14)) == 1 else 0 + + +placeholder_23 = [ + placeholder_22, + partial(placeholder_12, 1), + partial(placeholder_12, 2), + partial(placeholder_12, 3), + partial(placeholder_12, 4), + partial(placeholder_12, 5), + partial(placeholder_12, 6), + placeholder_16, + placeholder_18, + placeholder_20, + placeholder_21, + sum, +] + + +def placeholder_24(placeholder_14, placeholder_25): + try: + return placeholder_23[placeholder_25](placeholder_14) + except IndexError as placeholder_26: + raise ValueError("No such category.") from placeholder_26 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'Counter', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=31)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=31), + ImportFrom( + 'functools', + [ + alias( + 'partial', + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=29)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=29), + Assign( + [ + Name( + 'YACHT', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=5)], + Constant( + 0, + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=9), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=9), + Assign( + [ + Name( + 'ONES', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=4)], + Constant( + 1, + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=8), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=8), + Assign( + [ + Name( + 'TWOS', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=4)], + Constant( + 2, + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=8), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=8), + Assign( + [ + Name( + 'THREES', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=6)], + Constant( + 3, + lineno=7, + col_offset=9, + end_lineno=7, + end_col_offset=10), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=10), + Assign( + [ + Name( + 'FOURS', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=5)], + Constant( + 4, + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=9), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=9), + Assign( + [ + Name( + 'FIVES', + Store(), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=5)], + Constant( + 5, + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=9), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=9), + Assign( + [ + Name( + 'SIXES', + Store(), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=5)], + Constant( + 6, + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=9), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=9), + Assign( + [ + Name( + 'FULL_HOUSE', + Store(), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=10)], + Constant( + 7, + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=14), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=14), + Assign( + [ + Name( + 'FOUR_OF_A_KIND', + Store(), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=14)], + Constant( + 8, + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=18), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=18), + Assign( + [ + Name( + 'LITTLE_STRAIGHT', + Store(), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=15)], + Constant( + 9, + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=19), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=19), + Assign( + [ + Name( + 'BIG_STRAIGHT', + Store(), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=12)], + Constant( + 10, + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=17), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=17), + Assign( + [ + Name( + 'CHOICE', + Store(), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=6)], + Constant( + 11, + lineno=15, + col_offset=9, + end_lineno=15, + end_col_offset=11), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=11), + FunctionDef( + 'sum_of_numbers', + arguments( + [], + [ + arg( + 'number', + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=25), + arg( + 'dice', + lineno=18, + col_offset=27, + end_lineno=18, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=14), + [ + GeneratorExp( + Name( + 'idx', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=18), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=26), + Name( + 'dice', + Load(), + lineno=19, + col_offset=30, + end_lineno=19, + end_col_offset=34), + [ + Compare( + Name( + 'idx', + Load(), + lineno=19, + col_offset=38, + end_lineno=19, + end_col_offset=41), + [ + Eq()], + [ + Name( + 'number', + Load(), + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=51)], + lineno=19, + col_offset=38, + end_lineno=19, + end_col_offset=51)], + 0)], + lineno=19, + col_offset=14, + end_lineno=19, + end_col_offset=52)], + [], + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=52), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=52)], + [], + lineno=18, + col_offset=0, + end_lineno=19, + end_col_offset=52), + FunctionDef( + 'full_house', + arguments( + [], + [ + arg( + 'dice', + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'counter', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=11)], + Call( + Name( + 'Counter', + Load(), + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=21), + [ + Name( + 'dice', + Load(), + lineno=23, + col_offset=22, + end_lineno=23, + end_col_offset=26)], + [], + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=27), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=27), + Return( + IfExp( + Compare( + Call( + Name( + 'set', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=27), + [ + Call( + Attribute( + Name( + 'counter', + Load(), + lineno=24, + col_offset=28, + end_lineno=24, + end_col_offset=35), + 'values', + Load(), + lineno=24, + col_offset=28, + end_lineno=24, + end_col_offset=42), + [], + [], + lineno=24, + col_offset=28, + end_lineno=24, + end_col_offset=44)], + [], + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=45), + [ + Eq()], + [ + Set( + [ + Constant( + 3, + lineno=24, + col_offset=50, + end_lineno=24, + end_col_offset=51), + Constant( + 2, + lineno=24, + col_offset=53, + end_lineno=24, + end_col_offset=54)], + lineno=24, + col_offset=49, + end_lineno=24, + end_col_offset=55)], + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=55), + Call( + Name( + 'sum', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=14), + [ + Name( + 'dice', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=19)], + [], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=20), + Constant( + 0, + lineno=24, + col_offset=61, + end_lineno=24, + end_col_offset=62), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=62), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=62)], + [], + lineno=22, + col_offset=0, + end_lineno=24, + end_col_offset=62), + FunctionDef( + 'four_of_a_kind', + arguments( + [], + [ + arg( + 'dice', + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'counter', + Store(), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=11)], + Call( + Name( + 'Counter', + Load(), + lineno=28, + col_offset=14, + end_lineno=28, + end_col_offset=21), + [ + Name( + 'dice', + Load(), + lineno=28, + col_offset=22, + end_lineno=28, + end_col_offset=26)], + [], + lineno=28, + col_offset=14, + end_lineno=28, + end_col_offset=27), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=27), + Assign( + [ + Tuple( + [ + Name( + 'number', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=10), + Name( + 'count', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=17)], + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=17)], + Subscript( + Call( + Attribute( + Name( + 'counter', + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=27), + 'most_common', + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=39), + [], + [], + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=41), + Constant( + 0, + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=43), + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=44), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=44), + Return( + IfExp( + Compare( + Name( + 'count', + Load(), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=30), + [ + GtE()], + [ + Constant( + 4, + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=35)], + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=35), + BinOp( + Constant( + 4, + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=12), + Mult(), + Name( + 'number', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=21), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=21), + Constant( + 0, + lineno=30, + col_offset=41, + end_lineno=30, + end_col_offset=42), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=42), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=42)], + [], + lineno=27, + col_offset=0, + end_lineno=30, + end_col_offset=42), + FunctionDef( + 'little_straight', + arguments( + [], + [ + arg( + 'dice', + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Call( + Name( + 'set', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=20), + [ + Name( + 'dice', + Load(), + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=25)], + [], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=26), + [ + Eq()], + [ + Set( + [ + Constant( + 1, + lineno=34, + col_offset=31, + end_lineno=34, + end_col_offset=32), + Constant( + 2, + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=35), + Constant( + 3, + lineno=34, + col_offset=37, + end_lineno=34, + end_col_offset=38), + Constant( + 4, + lineno=34, + col_offset=40, + end_lineno=34, + end_col_offset=41), + Constant( + 5, + lineno=34, + col_offset=43, + end_lineno=34, + end_col_offset=44)], + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=45)], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=45), + Constant( + 30, + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=13), + Constant( + 0, + lineno=34, + col_offset=51, + end_lineno=34, + end_col_offset=52), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=52), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=52)], + [], + lineno=33, + col_offset=0, + end_lineno=34, + end_col_offset=52), + FunctionDef( + 'big_straight', + arguments( + [], + [ + arg( + 'dice', + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Call( + Name( + 'set', + Load(), + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=20), + [ + Name( + 'dice', + Load(), + lineno=38, + col_offset=21, + end_lineno=38, + end_col_offset=25)], + [], + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=26), + [ + Eq()], + [ + Set( + [ + Constant( + 2, + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=32), + Constant( + 3, + lineno=38, + col_offset=34, + end_lineno=38, + end_col_offset=35), + Constant( + 4, + lineno=38, + col_offset=37, + end_lineno=38, + end_col_offset=38), + Constant( + 5, + lineno=38, + col_offset=40, + end_lineno=38, + end_col_offset=41), + Constant( + 6, + lineno=38, + col_offset=43, + end_lineno=38, + end_col_offset=44)], + lineno=38, + col_offset=30, + end_lineno=38, + end_col_offset=45)], + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=45), + Constant( + 30, + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=13), + Constant( + 0, + lineno=38, + col_offset=51, + end_lineno=38, + end_col_offset=52), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=52), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=52)], + [], + lineno=37, + col_offset=0, + end_lineno=38, + end_col_offset=52), + FunctionDef( + 'yacht', + arguments( + [], + [ + arg( + 'dice', + lineno=41, + col_offset=10, + end_lineno=41, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Call( + Name( + 'len', + Load(), + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=20), + [ + Call( + Name( + 'set', + Load(), + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=24), + [ + Name( + 'dice', + Load(), + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=29)], + [], + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=30)], + [], + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=31), + [ + Eq()], + [ + Constant( + 1, + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=36)], + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=36), + Constant( + 50, + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=13), + Constant( + 0, + lineno=42, + col_offset=42, + end_lineno=42, + end_col_offset=43), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=43), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=43)], + [], + lineno=41, + col_offset=0, + end_lineno=42, + end_col_offset=43), + Assign( + [ + Name( + 'functions', + Store(), + lineno=45, + col_offset=0, + end_lineno=45, + end_col_offset=9)], + List( + [ + Name( + 'yacht', + Load(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=9), + Call( + Name( + 'partial', + Load(), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=11), + [ + Name( + 'sum_of_numbers', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=26), + Constant( + 1, + lineno=47, + col_offset=28, + end_lineno=47, + end_col_offset=29)], + [], + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=11), + [ + Name( + 'sum_of_numbers', + Load(), + lineno=48, + col_offset=12, + end_lineno=48, + end_col_offset=26), + Constant( + 2, + lineno=48, + col_offset=28, + end_lineno=48, + end_col_offset=29)], + [], + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=11), + [ + Name( + 'sum_of_numbers', + Load(), + lineno=49, + col_offset=12, + end_lineno=49, + end_col_offset=26), + Constant( + 3, + lineno=49, + col_offset=28, + end_lineno=49, + end_col_offset=29)], + [], + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=11), + [ + Name( + 'sum_of_numbers', + Load(), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=26), + Constant( + 4, + lineno=50, + col_offset=28, + end_lineno=50, + end_col_offset=29)], + [], + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=11), + [ + Name( + 'sum_of_numbers', + Load(), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=26), + Constant( + 5, + lineno=51, + col_offset=28, + end_lineno=51, + end_col_offset=29)], + [], + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=11), + [ + Name( + 'sum_of_numbers', + Load(), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=26), + Constant( + 6, + lineno=52, + col_offset=28, + end_lineno=52, + end_col_offset=29)], + [], + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=30), + Name( + 'full_house', + Load(), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=14), + Name( + 'four_of_a_kind', + Load(), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=18), + Name( + 'little_straight', + Load(), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=19), + Name( + 'big_straight', + Load(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=16), + Name( + 'sum', + Load(), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=7)], + Load(), + lineno=45, + col_offset=12, + end_lineno=58, + end_col_offset=1), + lineno=45, + col_offset=0, + end_lineno=58, + end_col_offset=1), + FunctionDef( + 'score', + arguments( + [], + [ + arg( + 'dice', + lineno=61, + col_offset=10, + end_lineno=61, + end_col_offset=14), + arg( + 'category', + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Return( + Call( + Subscript( + Name( + 'functions', + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=24), + Name( + 'category', + Load(), + lineno=63, + col_offset=25, + end_lineno=63, + end_col_offset=33), + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=34), + [ + Name( + 'dice', + Load(), + lineno=63, + col_offset=35, + end_lineno=63, + end_col_offset=39)], + [], + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=40), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=40)], + [ + ExceptHandler( + Name( + 'IndexError', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=21), + 'error', + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=65, + col_offset=14, + end_lineno=65, + end_col_offset=24), + [ + Constant( + 'No such category.', + lineno=65, + col_offset=25, + end_lineno=65, + end_col_offset=44)], + [], + lineno=65, + col_offset=14, + end_lineno=65, + end_col_offset=45), + Name( + 'error', + Load(), + lineno=65, + col_offset=51, + end_lineno=65, + end_col_offset=56), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=56)], + lineno=64, + col_offset=4, + end_lineno=65, + end_col_offset=56)], + [], + [], + lineno=62, + col_offset=4, + end_lineno=65, + end_col_offset=56)], + [], + lineno=61, + col_offset=0, + end_lineno=65, + end_col_offset=56)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'collections', + [ + alias( + 'Counter', + lineno=1, + col_offset=24, + end_lineno=1, + end_col_offset=31)], + 0, + lineno=1, + col_offset=0, + end_lineno=1, + end_col_offset=31), + ImportFrom( + 'functools', + [ + alias( + 'partial', + lineno=2, + col_offset=22, + end_lineno=2, + end_col_offset=29)], + 0, + lineno=2, + col_offset=0, + end_lineno=2, + end_col_offset=29), + Assign( + [ + Name( + 'placeholder_0', + Store(), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=5)], + Constant( + 0, + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=9), + lineno=4, + col_offset=0, + end_lineno=4, + end_col_offset=9), + Assign( + [ + Name( + 'placeholder_1', + Store(), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=4)], + Constant( + 1, + lineno=5, + col_offset=7, + end_lineno=5, + end_col_offset=8), + lineno=5, + col_offset=0, + end_lineno=5, + end_col_offset=8), + Assign( + [ + Name( + 'placeholder_2', + Store(), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=4)], + Constant( + 2, + lineno=6, + col_offset=7, + end_lineno=6, + end_col_offset=8), + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=8), + Assign( + [ + Name( + 'placeholder_3', + Store(), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=6)], + Constant( + 3, + lineno=7, + col_offset=9, + end_lineno=7, + end_col_offset=10), + lineno=7, + col_offset=0, + end_lineno=7, + end_col_offset=10), + Assign( + [ + Name( + 'placeholder_4', + Store(), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=5)], + Constant( + 4, + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=9), + lineno=8, + col_offset=0, + end_lineno=8, + end_col_offset=9), + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=5)], + Constant( + 5, + lineno=9, + col_offset=8, + end_lineno=9, + end_col_offset=9), + lineno=9, + col_offset=0, + end_lineno=9, + end_col_offset=9), + Assign( + [ + Name( + 'placeholder_6', + Store(), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=5)], + Constant( + 6, + lineno=10, + col_offset=8, + end_lineno=10, + end_col_offset=9), + lineno=10, + col_offset=0, + end_lineno=10, + end_col_offset=9), + Assign( + [ + Name( + 'placeholder_7', + Store(), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=10)], + Constant( + 7, + lineno=11, + col_offset=13, + end_lineno=11, + end_col_offset=14), + lineno=11, + col_offset=0, + end_lineno=11, + end_col_offset=14), + Assign( + [ + Name( + 'placeholder_8', + Store(), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=14)], + Constant( + 8, + lineno=12, + col_offset=17, + end_lineno=12, + end_col_offset=18), + lineno=12, + col_offset=0, + end_lineno=12, + end_col_offset=18), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=15)], + Constant( + 9, + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=19), + lineno=13, + col_offset=0, + end_lineno=13, + end_col_offset=19), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=12)], + Constant( + 10, + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=17), + lineno=14, + col_offset=0, + end_lineno=14, + end_col_offset=17), + Assign( + [ + Name( + 'placeholder_11', + Store(), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=6)], + Constant( + 11, + lineno=15, + col_offset=9, + end_lineno=15, + end_col_offset=11), + lineno=15, + col_offset=0, + end_lineno=15, + end_col_offset=11), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'placeholder_13', + lineno=18, + col_offset=19, + end_lineno=18, + end_col_offset=25), + arg( + 'placeholder_14', + lineno=18, + col_offset=27, + end_lineno=18, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'sum', + Load(), + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=14), + [ + GeneratorExp( + Name( + 'placeholder_15', + Load(), + lineno=19, + col_offset=15, + end_lineno=19, + end_col_offset=18), + [ + comprehension( + Name( + 'placeholder_15', + Store(), + lineno=19, + col_offset=23, + end_lineno=19, + end_col_offset=26), + Name( + 'placeholder_14', + Load(), + lineno=19, + col_offset=30, + end_lineno=19, + end_col_offset=34), + [ + Compare( + Name( + 'placeholder_15', + Load(), + lineno=19, + col_offset=38, + end_lineno=19, + end_col_offset=41), + [ + Eq()], + [ + Name( + 'placeholder_13', + Load(), + lineno=19, + col_offset=45, + end_lineno=19, + end_col_offset=51)], + lineno=19, + col_offset=38, + end_lineno=19, + end_col_offset=51)], + 0)], + lineno=19, + col_offset=14, + end_lineno=19, + end_col_offset=52)], + [], + lineno=19, + col_offset=11, + end_lineno=19, + end_col_offset=52), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=52)], + [], + lineno=18, + col_offset=0, + end_lineno=19, + end_col_offset=52), + FunctionDef( + 'placeholder_16', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=22, + col_offset=15, + end_lineno=22, + end_col_offset=19)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=11)], + Call( + Name( + 'Counter', + Load(), + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=21), + [ + Name( + 'placeholder_14', + Load(), + lineno=23, + col_offset=22, + end_lineno=23, + end_col_offset=26)], + [], + lineno=23, + col_offset=14, + end_lineno=23, + end_col_offset=27), + lineno=23, + col_offset=4, + end_lineno=23, + end_col_offset=27), + Return( + IfExp( + Compare( + Call( + Name( + 'set', + Load(), + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=27), + [ + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=24, + col_offset=28, + end_lineno=24, + end_col_offset=35), + 'values', + Load(), + lineno=24, + col_offset=28, + end_lineno=24, + end_col_offset=42), + [], + [], + lineno=24, + col_offset=28, + end_lineno=24, + end_col_offset=44)], + [], + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=45), + [ + Eq()], + [ + Set( + [ + Constant( + 3, + lineno=24, + col_offset=50, + end_lineno=24, + end_col_offset=51), + Constant( + 2, + lineno=24, + col_offset=53, + end_lineno=24, + end_col_offset=54)], + lineno=24, + col_offset=49, + end_lineno=24, + end_col_offset=55)], + lineno=24, + col_offset=24, + end_lineno=24, + end_col_offset=55), + Call( + Name( + 'sum', + Load(), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=14), + [ + Name( + 'placeholder_14', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=19)], + [], + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=20), + Constant( + 0, + lineno=24, + col_offset=61, + end_lineno=24, + end_col_offset=62), + lineno=24, + col_offset=11, + end_lineno=24, + end_col_offset=62), + lineno=24, + col_offset=4, + end_lineno=24, + end_col_offset=62)], + [], + lineno=22, + col_offset=0, + end_lineno=24, + end_col_offset=62), + FunctionDef( + 'placeholder_18', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=27, + col_offset=19, + end_lineno=27, + end_col_offset=23)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_17', + Store(), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=11)], + Call( + Name( + 'Counter', + Load(), + lineno=28, + col_offset=14, + end_lineno=28, + end_col_offset=21), + [ + Name( + 'placeholder_14', + Load(), + lineno=28, + col_offset=22, + end_lineno=28, + end_col_offset=26)], + [], + lineno=28, + col_offset=14, + end_lineno=28, + end_col_offset=27), + lineno=28, + col_offset=4, + end_lineno=28, + end_col_offset=27), + Assign( + [ + Tuple( + [ + Name( + 'placeholder_13', + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=10), + Name( + 'placeholder_19', + Store(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=17)], + Store(), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=17)], + Subscript( + Call( + Attribute( + Name( + 'placeholder_17', + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=27), + 'most_common', + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=39), + [], + [], + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=41), + Constant( + 0, + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=43), + Load(), + lineno=29, + col_offset=20, + end_lineno=29, + end_col_offset=44), + lineno=29, + col_offset=4, + end_lineno=29, + end_col_offset=44), + Return( + IfExp( + Compare( + Name( + 'placeholder_19', + Load(), + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=30), + [ + GtE()], + [ + Constant( + 4, + lineno=30, + col_offset=34, + end_lineno=30, + end_col_offset=35)], + lineno=30, + col_offset=25, + end_lineno=30, + end_col_offset=35), + BinOp( + Constant( + 4, + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=12), + Mult(), + Name( + 'placeholder_13', + Load(), + lineno=30, + col_offset=15, + end_lineno=30, + end_col_offset=21), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=21), + Constant( + 0, + lineno=30, + col_offset=41, + end_lineno=30, + end_col_offset=42), + lineno=30, + col_offset=11, + end_lineno=30, + end_col_offset=42), + lineno=30, + col_offset=4, + end_lineno=30, + end_col_offset=42)], + [], + lineno=27, + col_offset=0, + end_lineno=30, + end_col_offset=42), + FunctionDef( + 'placeholder_20', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=33, + col_offset=20, + end_lineno=33, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Call( + Name( + 'set', + Load(), + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=20), + [ + Name( + 'placeholder_14', + Load(), + lineno=34, + col_offset=21, + end_lineno=34, + end_col_offset=25)], + [], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=26), + [ + Eq()], + [ + Set( + [ + Constant( + 1, + lineno=34, + col_offset=31, + end_lineno=34, + end_col_offset=32), + Constant( + 2, + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=35), + Constant( + 3, + lineno=34, + col_offset=37, + end_lineno=34, + end_col_offset=38), + Constant( + 4, + lineno=34, + col_offset=40, + end_lineno=34, + end_col_offset=41), + Constant( + 5, + lineno=34, + col_offset=43, + end_lineno=34, + end_col_offset=44)], + lineno=34, + col_offset=30, + end_lineno=34, + end_col_offset=45)], + lineno=34, + col_offset=17, + end_lineno=34, + end_col_offset=45), + Constant( + 30, + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=13), + Constant( + 0, + lineno=34, + col_offset=51, + end_lineno=34, + end_col_offset=52), + lineno=34, + col_offset=11, + end_lineno=34, + end_col_offset=52), + lineno=34, + col_offset=4, + end_lineno=34, + end_col_offset=52)], + [], + lineno=33, + col_offset=0, + end_lineno=34, + end_col_offset=52), + FunctionDef( + 'placeholder_21', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=37, + col_offset=17, + end_lineno=37, + end_col_offset=21)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Call( + Name( + 'set', + Load(), + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=20), + [ + Name( + 'placeholder_14', + Load(), + lineno=38, + col_offset=21, + end_lineno=38, + end_col_offset=25)], + [], + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=26), + [ + Eq()], + [ + Set( + [ + Constant( + 2, + lineno=38, + col_offset=31, + end_lineno=38, + end_col_offset=32), + Constant( + 3, + lineno=38, + col_offset=34, + end_lineno=38, + end_col_offset=35), + Constant( + 4, + lineno=38, + col_offset=37, + end_lineno=38, + end_col_offset=38), + Constant( + 5, + lineno=38, + col_offset=40, + end_lineno=38, + end_col_offset=41), + Constant( + 6, + lineno=38, + col_offset=43, + end_lineno=38, + end_col_offset=44)], + lineno=38, + col_offset=30, + end_lineno=38, + end_col_offset=45)], + lineno=38, + col_offset=17, + end_lineno=38, + end_col_offset=45), + Constant( + 30, + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=13), + Constant( + 0, + lineno=38, + col_offset=51, + end_lineno=38, + end_col_offset=52), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=52), + lineno=38, + col_offset=4, + end_lineno=38, + end_col_offset=52)], + [], + lineno=37, + col_offset=0, + end_lineno=38, + end_col_offset=52), + FunctionDef( + 'placeholder_22', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=41, + col_offset=10, + end_lineno=41, + end_col_offset=14)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + IfExp( + Compare( + Call( + Name( + 'len', + Load(), + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=20), + [ + Call( + Name( + 'set', + Load(), + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=24), + [ + Name( + 'placeholder_14', + Load(), + lineno=42, + col_offset=25, + end_lineno=42, + end_col_offset=29)], + [], + lineno=42, + col_offset=21, + end_lineno=42, + end_col_offset=30)], + [], + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=31), + [ + Eq()], + [ + Constant( + 1, + lineno=42, + col_offset=35, + end_lineno=42, + end_col_offset=36)], + lineno=42, + col_offset=17, + end_lineno=42, + end_col_offset=36), + Constant( + 50, + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=13), + Constant( + 0, + lineno=42, + col_offset=42, + end_lineno=42, + end_col_offset=43), + lineno=42, + col_offset=11, + end_lineno=42, + end_col_offset=43), + lineno=42, + col_offset=4, + end_lineno=42, + end_col_offset=43)], + [], + lineno=41, + col_offset=0, + end_lineno=42, + end_col_offset=43), + Assign( + [ + Name( + 'placeholder_23', + Store(), + lineno=45, + col_offset=0, + end_lineno=45, + end_col_offset=9)], + List( + [ + Name( + 'placeholder_22', + Load(), + lineno=46, + col_offset=4, + end_lineno=46, + end_col_offset=9), + Call( + Name( + 'partial', + Load(), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=11), + [ + Name( + 'placeholder_12', + Load(), + lineno=47, + col_offset=12, + end_lineno=47, + end_col_offset=26), + Constant( + 1, + lineno=47, + col_offset=28, + end_lineno=47, + end_col_offset=29)], + [], + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=11), + [ + Name( + 'placeholder_12', + Load(), + lineno=48, + col_offset=12, + end_lineno=48, + end_col_offset=26), + Constant( + 2, + lineno=48, + col_offset=28, + end_lineno=48, + end_col_offset=29)], + [], + lineno=48, + col_offset=4, + end_lineno=48, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=11), + [ + Name( + 'placeholder_12', + Load(), + lineno=49, + col_offset=12, + end_lineno=49, + end_col_offset=26), + Constant( + 3, + lineno=49, + col_offset=28, + end_lineno=49, + end_col_offset=29)], + [], + lineno=49, + col_offset=4, + end_lineno=49, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=11), + [ + Name( + 'placeholder_12', + Load(), + lineno=50, + col_offset=12, + end_lineno=50, + end_col_offset=26), + Constant( + 4, + lineno=50, + col_offset=28, + end_lineno=50, + end_col_offset=29)], + [], + lineno=50, + col_offset=4, + end_lineno=50, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=11), + [ + Name( + 'placeholder_12', + Load(), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=26), + Constant( + 5, + lineno=51, + col_offset=28, + end_lineno=51, + end_col_offset=29)], + [], + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=30), + Call( + Name( + 'partial', + Load(), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=11), + [ + Name( + 'placeholder_12', + Load(), + lineno=52, + col_offset=12, + end_lineno=52, + end_col_offset=26), + Constant( + 6, + lineno=52, + col_offset=28, + end_lineno=52, + end_col_offset=29)], + [], + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=30), + Name( + 'placeholder_16', + Load(), + lineno=53, + col_offset=4, + end_lineno=53, + end_col_offset=14), + Name( + 'placeholder_18', + Load(), + lineno=54, + col_offset=4, + end_lineno=54, + end_col_offset=18), + Name( + 'placeholder_20', + Load(), + lineno=55, + col_offset=4, + end_lineno=55, + end_col_offset=19), + Name( + 'placeholder_21', + Load(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=16), + Name( + 'sum', + Load(), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=7)], + Load(), + lineno=45, + col_offset=12, + end_lineno=58, + end_col_offset=1), + lineno=45, + col_offset=0, + end_lineno=58, + end_col_offset=1), + FunctionDef( + 'placeholder_24', + arguments( + [], + [ + arg( + 'placeholder_14', + lineno=61, + col_offset=10, + end_lineno=61, + end_col_offset=14), + arg( + 'placeholder_25', + lineno=61, + col_offset=16, + end_lineno=61, + end_col_offset=24)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Try( + [ + Return( + Call( + Subscript( + Name( + 'placeholder_23', + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=24), + Name( + 'placeholder_25', + Load(), + lineno=63, + col_offset=25, + end_lineno=63, + end_col_offset=33), + Load(), + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=34), + [ + Name( + 'placeholder_14', + Load(), + lineno=63, + col_offset=35, + end_lineno=63, + end_col_offset=39)], + [], + lineno=63, + col_offset=15, + end_lineno=63, + end_col_offset=40), + lineno=63, + col_offset=8, + end_lineno=63, + end_col_offset=40)], + [ + ExceptHandler( + Name( + 'IndexError', + Load(), + lineno=64, + col_offset=11, + end_lineno=64, + end_col_offset=21), + 'placeholder_26', + [ + Raise( + Call( + Name( + 'ValueError', + Load(), + lineno=65, + col_offset=14, + end_lineno=65, + end_col_offset=24), + [ + Constant( + 'No such category.', + lineno=65, + col_offset=25, + end_lineno=65, + end_col_offset=44)], + [], + lineno=65, + col_offset=14, + end_lineno=65, + end_col_offset=45), + Name( + 'placeholder_26', + Load(), + lineno=65, + col_offset=51, + end_lineno=65, + end_col_offset=56), + lineno=65, + col_offset=8, + end_lineno=65, + end_col_offset=56)], + lineno=64, + col_offset=4, + end_lineno=65, + end_col_offset=56)], + [], + [], + lineno=62, + col_offset=4, + end_lineno=65, + end_col_offset=56)], + [], + lineno=61, + col_offset=0, + end_lineno=65, + end_col_offset=56)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-yacht/representation.txt b/test/practice-yacht/representation.txt new file mode 100644 index 0000000..0da90af --- /dev/null +++ b/test/practice-yacht/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('collections', [alias('Counter', lineno=1, col_offset=24, end_lineno=1, end_col_offset=31)], 0, lineno=1, col_offset=0, end_lineno=1, end_col_offset=31), ImportFrom('functools', [alias('partial', lineno=2, col_offset=22, end_lineno=2, end_col_offset=29)], 0, lineno=2, col_offset=0, end_lineno=2, end_col_offset=29), Assign([Name('placeholder_0', Store(), lineno=4, col_offset=0, end_lineno=4, end_col_offset=5)], Constant(0, lineno=4, col_offset=8, end_lineno=4, end_col_offset=9), lineno=4, col_offset=0, end_lineno=4, end_col_offset=9), Assign([Name('placeholder_1', Store(), lineno=5, col_offset=0, end_lineno=5, end_col_offset=4)], Constant(1, lineno=5, col_offset=7, end_lineno=5, end_col_offset=8), lineno=5, col_offset=0, end_lineno=5, end_col_offset=8), Assign([Name('placeholder_2', Store(), lineno=6, col_offset=0, end_lineno=6, end_col_offset=4)], Constant(2, lineno=6, col_offset=7, end_lineno=6, end_col_offset=8), lineno=6, col_offset=0, end_lineno=6, end_col_offset=8), Assign([Name('placeholder_3', Store(), lineno=7, col_offset=0, end_lineno=7, end_col_offset=6)], Constant(3, lineno=7, col_offset=9, end_lineno=7, end_col_offset=10), lineno=7, col_offset=0, end_lineno=7, end_col_offset=10), Assign([Name('placeholder_4', Store(), lineno=8, col_offset=0, end_lineno=8, end_col_offset=5)], Constant(4, lineno=8, col_offset=8, end_lineno=8, end_col_offset=9), lineno=8, col_offset=0, end_lineno=8, end_col_offset=9), Assign([Name('placeholder_5', Store(), lineno=9, col_offset=0, end_lineno=9, end_col_offset=5)], Constant(5, lineno=9, col_offset=8, end_lineno=9, end_col_offset=9), lineno=9, col_offset=0, end_lineno=9, end_col_offset=9), Assign([Name('placeholder_6', Store(), lineno=10, col_offset=0, end_lineno=10, end_col_offset=5)], Constant(6, lineno=10, col_offset=8, end_lineno=10, end_col_offset=9), lineno=10, col_offset=0, end_lineno=10, end_col_offset=9), Assign([Name('placeholder_7', Store(), lineno=11, col_offset=0, end_lineno=11, end_col_offset=10)], Constant(7, lineno=11, col_offset=13, end_lineno=11, end_col_offset=14), lineno=11, col_offset=0, end_lineno=11, end_col_offset=14), Assign([Name('placeholder_8', Store(), lineno=12, col_offset=0, end_lineno=12, end_col_offset=14)], Constant(8, lineno=12, col_offset=17, end_lineno=12, end_col_offset=18), lineno=12, col_offset=0, end_lineno=12, end_col_offset=18), Assign([Name('placeholder_9', Store(), lineno=13, col_offset=0, end_lineno=13, end_col_offset=15)], Constant(9, lineno=13, col_offset=18, end_lineno=13, end_col_offset=19), lineno=13, col_offset=0, end_lineno=13, end_col_offset=19), Assign([Name('placeholder_10', Store(), lineno=14, col_offset=0, end_lineno=14, end_col_offset=12)], Constant(10, lineno=14, col_offset=15, end_lineno=14, end_col_offset=17), lineno=14, col_offset=0, end_lineno=14, end_col_offset=17), Assign([Name('placeholder_11', Store(), lineno=15, col_offset=0, end_lineno=15, end_col_offset=6)], Constant(11, lineno=15, col_offset=9, end_lineno=15, end_col_offset=11), lineno=15, col_offset=0, end_lineno=15, end_col_offset=11), FunctionDef('placeholder_12', arguments([], [arg('placeholder_13', lineno=18, col_offset=19, end_lineno=18, end_col_offset=25), arg('placeholder_14', lineno=18, col_offset=27, end_lineno=18, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('sum', Load(), lineno=19, col_offset=11, end_lineno=19, end_col_offset=14), [GeneratorExp(Name('placeholder_15', Load(), lineno=19, col_offset=15, end_lineno=19, end_col_offset=18), [comprehension(Name('placeholder_15', Store(), lineno=19, col_offset=23, end_lineno=19, end_col_offset=26), Name('placeholder_14', Load(), lineno=19, col_offset=30, end_lineno=19, end_col_offset=34), [Compare(Name('placeholder_15', Load(), lineno=19, col_offset=38, end_lineno=19, end_col_offset=41), [Eq()], [Name('placeholder_13', Load(), lineno=19, col_offset=45, end_lineno=19, end_col_offset=51)], lineno=19, col_offset=38, end_lineno=19, end_col_offset=51)], 0)], lineno=19, col_offset=14, end_lineno=19, end_col_offset=52)], [], lineno=19, col_offset=11, end_lineno=19, end_col_offset=52), lineno=19, col_offset=4, end_lineno=19, end_col_offset=52)], [], lineno=18, col_offset=0, end_lineno=19, end_col_offset=52), FunctionDef('placeholder_16', arguments([], [arg('placeholder_14', lineno=22, col_offset=15, end_lineno=22, end_col_offset=19)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_17', Store(), lineno=23, col_offset=4, end_lineno=23, end_col_offset=11)], Call(Name('Counter', Load(), lineno=23, col_offset=14, end_lineno=23, end_col_offset=21), [Name('placeholder_14', Load(), lineno=23, col_offset=22, end_lineno=23, end_col_offset=26)], [], lineno=23, col_offset=14, end_lineno=23, end_col_offset=27), lineno=23, col_offset=4, end_lineno=23, end_col_offset=27), Return(IfExp(Compare(Call(Name('set', Load(), lineno=24, col_offset=24, end_lineno=24, end_col_offset=27), [Call(Attribute(Name('placeholder_17', Load(), lineno=24, col_offset=28, end_lineno=24, end_col_offset=35), 'values', Load(), lineno=24, col_offset=28, end_lineno=24, end_col_offset=42), [], [], lineno=24, col_offset=28, end_lineno=24, end_col_offset=44)], [], lineno=24, col_offset=24, end_lineno=24, end_col_offset=45), [Eq()], [Set([Constant(3, lineno=24, col_offset=50, end_lineno=24, end_col_offset=51), Constant(2, lineno=24, col_offset=53, end_lineno=24, end_col_offset=54)], lineno=24, col_offset=49, end_lineno=24, end_col_offset=55)], lineno=24, col_offset=24, end_lineno=24, end_col_offset=55), Call(Name('sum', Load(), lineno=24, col_offset=11, end_lineno=24, end_col_offset=14), [Name('placeholder_14', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=19)], [], lineno=24, col_offset=11, end_lineno=24, end_col_offset=20), Constant(0, lineno=24, col_offset=61, end_lineno=24, end_col_offset=62), lineno=24, col_offset=11, end_lineno=24, end_col_offset=62), lineno=24, col_offset=4, end_lineno=24, end_col_offset=62)], [], lineno=22, col_offset=0, end_lineno=24, end_col_offset=62), FunctionDef('placeholder_18', arguments([], [arg('placeholder_14', lineno=27, col_offset=19, end_lineno=27, end_col_offset=23)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_17', Store(), lineno=28, col_offset=4, end_lineno=28, end_col_offset=11)], Call(Name('Counter', Load(), lineno=28, col_offset=14, end_lineno=28, end_col_offset=21), [Name('placeholder_14', Load(), lineno=28, col_offset=22, end_lineno=28, end_col_offset=26)], [], lineno=28, col_offset=14, end_lineno=28, end_col_offset=27), lineno=28, col_offset=4, end_lineno=28, end_col_offset=27), Assign([Tuple([Name('placeholder_13', Store(), lineno=29, col_offset=4, end_lineno=29, end_col_offset=10), Name('placeholder_19', Store(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=17)], Store(), lineno=29, col_offset=4, end_lineno=29, end_col_offset=17)], Subscript(Call(Attribute(Name('placeholder_17', Load(), lineno=29, col_offset=20, end_lineno=29, end_col_offset=27), 'most_common', Load(), lineno=29, col_offset=20, end_lineno=29, end_col_offset=39), [], [], lineno=29, col_offset=20, end_lineno=29, end_col_offset=41), Constant(0, lineno=29, col_offset=42, end_lineno=29, end_col_offset=43), Load(), lineno=29, col_offset=20, end_lineno=29, end_col_offset=44), lineno=29, col_offset=4, end_lineno=29, end_col_offset=44), Return(IfExp(Compare(Name('placeholder_19', Load(), lineno=30, col_offset=25, end_lineno=30, end_col_offset=30), [GtE()], [Constant(4, lineno=30, col_offset=34, end_lineno=30, end_col_offset=35)], lineno=30, col_offset=25, end_lineno=30, end_col_offset=35), BinOp(Constant(4, lineno=30, col_offset=11, end_lineno=30, end_col_offset=12), Mult(), Name('placeholder_13', Load(), lineno=30, col_offset=15, end_lineno=30, end_col_offset=21), lineno=30, col_offset=11, end_lineno=30, end_col_offset=21), Constant(0, lineno=30, col_offset=41, end_lineno=30, end_col_offset=42), lineno=30, col_offset=11, end_lineno=30, end_col_offset=42), lineno=30, col_offset=4, end_lineno=30, end_col_offset=42)], [], lineno=27, col_offset=0, end_lineno=30, end_col_offset=42), FunctionDef('placeholder_20', arguments([], [arg('placeholder_14', lineno=33, col_offset=20, end_lineno=33, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(IfExp(Compare(Call(Name('set', Load(), lineno=34, col_offset=17, end_lineno=34, end_col_offset=20), [Name('placeholder_14', Load(), lineno=34, col_offset=21, end_lineno=34, end_col_offset=25)], [], lineno=34, col_offset=17, end_lineno=34, end_col_offset=26), [Eq()], [Set([Constant(1, lineno=34, col_offset=31, end_lineno=34, end_col_offset=32), Constant(2, lineno=34, col_offset=34, end_lineno=34, end_col_offset=35), Constant(3, lineno=34, col_offset=37, end_lineno=34, end_col_offset=38), Constant(4, lineno=34, col_offset=40, end_lineno=34, end_col_offset=41), Constant(5, lineno=34, col_offset=43, end_lineno=34, end_col_offset=44)], lineno=34, col_offset=30, end_lineno=34, end_col_offset=45)], lineno=34, col_offset=17, end_lineno=34, end_col_offset=45), Constant(30, lineno=34, col_offset=11, end_lineno=34, end_col_offset=13), Constant(0, lineno=34, col_offset=51, end_lineno=34, end_col_offset=52), lineno=34, col_offset=11, end_lineno=34, end_col_offset=52), lineno=34, col_offset=4, end_lineno=34, end_col_offset=52)], [], lineno=33, col_offset=0, end_lineno=34, end_col_offset=52), FunctionDef('placeholder_21', arguments([], [arg('placeholder_14', lineno=37, col_offset=17, end_lineno=37, end_col_offset=21)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(IfExp(Compare(Call(Name('set', Load(), lineno=38, col_offset=17, end_lineno=38, end_col_offset=20), [Name('placeholder_14', Load(), lineno=38, col_offset=21, end_lineno=38, end_col_offset=25)], [], lineno=38, col_offset=17, end_lineno=38, end_col_offset=26), [Eq()], [Set([Constant(2, lineno=38, col_offset=31, end_lineno=38, end_col_offset=32), Constant(3, lineno=38, col_offset=34, end_lineno=38, end_col_offset=35), Constant(4, lineno=38, col_offset=37, end_lineno=38, end_col_offset=38), Constant(5, lineno=38, col_offset=40, end_lineno=38, end_col_offset=41), Constant(6, lineno=38, col_offset=43, end_lineno=38, end_col_offset=44)], lineno=38, col_offset=30, end_lineno=38, end_col_offset=45)], lineno=38, col_offset=17, end_lineno=38, end_col_offset=45), Constant(30, lineno=38, col_offset=11, end_lineno=38, end_col_offset=13), Constant(0, lineno=38, col_offset=51, end_lineno=38, end_col_offset=52), lineno=38, col_offset=11, end_lineno=38, end_col_offset=52), lineno=38, col_offset=4, end_lineno=38, end_col_offset=52)], [], lineno=37, col_offset=0, end_lineno=38, end_col_offset=52), FunctionDef('placeholder_22', arguments([], [arg('placeholder_14', lineno=41, col_offset=10, end_lineno=41, end_col_offset=14)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(IfExp(Compare(Call(Name('len', Load(), lineno=42, col_offset=17, end_lineno=42, end_col_offset=20), [Call(Name('set', Load(), lineno=42, col_offset=21, end_lineno=42, end_col_offset=24), [Name('placeholder_14', Load(), lineno=42, col_offset=25, end_lineno=42, end_col_offset=29)], [], lineno=42, col_offset=21, end_lineno=42, end_col_offset=30)], [], lineno=42, col_offset=17, end_lineno=42, end_col_offset=31), [Eq()], [Constant(1, lineno=42, col_offset=35, end_lineno=42, end_col_offset=36)], lineno=42, col_offset=17, end_lineno=42, end_col_offset=36), Constant(50, lineno=42, col_offset=11, end_lineno=42, end_col_offset=13), Constant(0, lineno=42, col_offset=42, end_lineno=42, end_col_offset=43), lineno=42, col_offset=11, end_lineno=42, end_col_offset=43), lineno=42, col_offset=4, end_lineno=42, end_col_offset=43)], [], lineno=41, col_offset=0, end_lineno=42, end_col_offset=43), Assign([Name('placeholder_23', Store(), lineno=45, col_offset=0, end_lineno=45, end_col_offset=9)], List([Name('placeholder_22', Load(), lineno=46, col_offset=4, end_lineno=46, end_col_offset=9), Call(Name('partial', Load(), lineno=47, col_offset=4, end_lineno=47, end_col_offset=11), [Name('placeholder_12', Load(), lineno=47, col_offset=12, end_lineno=47, end_col_offset=26), Constant(1, lineno=47, col_offset=28, end_lineno=47, end_col_offset=29)], [], lineno=47, col_offset=4, end_lineno=47, end_col_offset=30), Call(Name('partial', Load(), lineno=48, col_offset=4, end_lineno=48, end_col_offset=11), [Name('placeholder_12', Load(), lineno=48, col_offset=12, end_lineno=48, end_col_offset=26), Constant(2, lineno=48, col_offset=28, end_lineno=48, end_col_offset=29)], [], lineno=48, col_offset=4, end_lineno=48, end_col_offset=30), Call(Name('partial', Load(), lineno=49, col_offset=4, end_lineno=49, end_col_offset=11), [Name('placeholder_12', Load(), lineno=49, col_offset=12, end_lineno=49, end_col_offset=26), Constant(3, lineno=49, col_offset=28, end_lineno=49, end_col_offset=29)], [], lineno=49, col_offset=4, end_lineno=49, end_col_offset=30), Call(Name('partial', Load(), lineno=50, col_offset=4, end_lineno=50, end_col_offset=11), [Name('placeholder_12', Load(), lineno=50, col_offset=12, end_lineno=50, end_col_offset=26), Constant(4, lineno=50, col_offset=28, end_lineno=50, end_col_offset=29)], [], lineno=50, col_offset=4, end_lineno=50, end_col_offset=30), Call(Name('partial', Load(), lineno=51, col_offset=4, end_lineno=51, end_col_offset=11), [Name('placeholder_12', Load(), lineno=51, col_offset=12, end_lineno=51, end_col_offset=26), Constant(5, lineno=51, col_offset=28, end_lineno=51, end_col_offset=29)], [], lineno=51, col_offset=4, end_lineno=51, end_col_offset=30), Call(Name('partial', Load(), lineno=52, col_offset=4, end_lineno=52, end_col_offset=11), [Name('placeholder_12', Load(), lineno=52, col_offset=12, end_lineno=52, end_col_offset=26), Constant(6, lineno=52, col_offset=28, end_lineno=52, end_col_offset=29)], [], lineno=52, col_offset=4, end_lineno=52, end_col_offset=30), Name('placeholder_16', Load(), lineno=53, col_offset=4, end_lineno=53, end_col_offset=14), Name('placeholder_18', Load(), lineno=54, col_offset=4, end_lineno=54, end_col_offset=18), Name('placeholder_20', Load(), lineno=55, col_offset=4, end_lineno=55, end_col_offset=19), Name('placeholder_21', Load(), lineno=56, col_offset=4, end_lineno=56, end_col_offset=16), Name('sum', Load(), lineno=57, col_offset=4, end_lineno=57, end_col_offset=7)], Load(), lineno=45, col_offset=12, end_lineno=58, end_col_offset=1), lineno=45, col_offset=0, end_lineno=58, end_col_offset=1), FunctionDef('placeholder_24', arguments([], [arg('placeholder_14', lineno=61, col_offset=10, end_lineno=61, end_col_offset=14), arg('placeholder_25', lineno=61, col_offset=16, end_lineno=61, end_col_offset=24)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Try([Return(Call(Subscript(Name('placeholder_23', Load(), lineno=63, col_offset=15, end_lineno=63, end_col_offset=24), Name('placeholder_25', Load(), lineno=63, col_offset=25, end_lineno=63, end_col_offset=33), Load(), lineno=63, col_offset=15, end_lineno=63, end_col_offset=34), [Name('placeholder_14', Load(), lineno=63, col_offset=35, end_lineno=63, end_col_offset=39)], [], lineno=63, col_offset=15, end_lineno=63, end_col_offset=40), lineno=63, col_offset=8, end_lineno=63, end_col_offset=40)], [ExceptHandler(Name('IndexError', Load(), lineno=64, col_offset=11, end_lineno=64, end_col_offset=21), 'placeholder_26', [Raise(Call(Name('ValueError', Load(), lineno=65, col_offset=14, end_lineno=65, end_col_offset=24), [Constant('No such category.', lineno=65, col_offset=25, end_lineno=65, end_col_offset=44)], [], lineno=65, col_offset=14, end_lineno=65, end_col_offset=45), Name('placeholder_26', Load(), lineno=65, col_offset=51, end_lineno=65, end_col_offset=56), lineno=65, col_offset=8, end_lineno=65, end_col_offset=56)], lineno=64, col_offset=4, end_lineno=65, end_col_offset=56)], [], [], lineno=62, col_offset=4, end_lineno=65, end_col_offset=56)], [], lineno=61, col_offset=0, end_lineno=65, end_col_offset=56)], []) \ No newline at end of file diff --git a/test/practice-yacht/results.json b/test/practice-yacht/results.json new file mode 100644 index 0000000..b249305 --- /dev/null +++ b/test/practice-yacht/results.json @@ -0,0 +1,205 @@ +{ + "version": 3, + "status": "fail", + "tests": [ + { + "name": "Yacht > yacht", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([5, 5, 5, 5, 5], yacht.YACHT), 50)", + "task_id": 0 + }, + { + "name": "Yacht > not yacht", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([1, 3, 3, 2, 5], yacht.YACHT), 0)", + "task_id": 0 + }, + { + "name": "Yacht > ones", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([1, 1, 1, 3, 5], yacht.ONES), 3)", + "task_id": 0 + }, + { + "name": "Yacht > ones out of order", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([3, 1, 1, 5, 1], yacht.ONES), 3)", + "task_id": 0 + }, + { + "name": "Yacht > no ones", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([4, 3, 6, 5, 5], yacht.ONES), 0)", + "task_id": 0 + }, + { + "name": "Yacht > twos", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([2, 3, 4, 5, 6], yacht.TWOS), 2)", + "task_id": 0 + }, + { + "name": "Yacht > fours", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([1, 4, 1, 4, 1], yacht.FOURS), 8)", + "task_id": 0 + }, + { + "name": "Yacht > yacht counted as threes", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([3, 3, 3, 3, 3], yacht.THREES), 15)", + "task_id": 0 + }, + { + "name": "Yacht > yacht of 3s counted as fives", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([3, 3, 3, 3, 3], yacht.FIVES), 0)", + "task_id": 0 + }, + { + "name": "Yacht > fives", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([5, 1, 5, 2, 6], yacht.FIVES), 10)", + "task_id": 0 + }, + { + "name": "Yacht > sixes", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([2, 3, 4, 5, 6], yacht.SIXES), 6)", + "task_id": 0 + }, + { + "name": "Yacht > full house two small three big", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([2, 2, 4, 4, 4], yacht.FULL_HOUSE), 16)", + "task_id": 0 + }, + { + "name": "Yacht > full house three small two big", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([5, 3, 3, 5, 3], yacht.FULL_HOUSE), 19)", + "task_id": 0 + }, + { + "name": "Yacht > two pair is not a full house", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([2, 2, 4, 4, 5], yacht.FULL_HOUSE), 0)", + "task_id": 0 + }, + { + "name": "Yacht > four of a kind is not a full house", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([1, 4, 4, 4, 4], yacht.FULL_HOUSE), 0)", + "task_id": 0 + }, + { + "name": "Yacht > yacht is not a full house", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([2, 2, 2, 2, 2], yacht.FULL_HOUSE), 0)", + "task_id": 0 + }, + { + "name": "Yacht > four of a kind one", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([4, 6, 6, 6, 6], yacht.FOUR_OF_A_KIND), 24)", + "task_id": 0 + }, + { + "name": "Yacht > four of a kind two", + "status": "fail", + "message": "AssertionError: 16 != 24", + "test_code": "self.assertEqual(yacht.score([6, 4, 6, 6, 6], yacht.FOUR_OF_A_KIND), 24)", + "task_id": 0 + }, + { + "name": "Yacht > four of a kind three", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([6, 6, 4, 6, 6], yacht.FOUR_OF_A_KIND), 24)", + "task_id": 0 + }, + { + "name": "Yacht > four of a kind four", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([6, 6, 6, 4, 6], yacht.FOUR_OF_A_KIND), 24)", + "task_id": 0 + }, + { + "name": "Yacht > four of a kind five", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([6, 6, 6, 6, 4], yacht.FOUR_OF_A_KIND), 24)", + "task_id": 0 + }, + { + "name": "Yacht > yacht can be scored as four of a kind", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([3, 3, 3, 3, 3], yacht.FOUR_OF_A_KIND), 12)", + "task_id": 0 + }, + { + "name": "Yacht > full house is not four of a kind", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([3, 3, 3, 5, 5], yacht.FOUR_OF_A_KIND), 0)", + "task_id": 0 + }, + { + "name": "Yacht > little straight", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([3, 5, 4, 1, 2], yacht.LITTLE_STRAIGHT), 30)", + "task_id": 0 + }, + { + "name": "Yacht > little straight as big straight", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([1, 2, 3, 4, 5], yacht.BIG_STRAIGHT), 0)", + "task_id": 0 + }, + { + "name": "Yacht > four in order but not a little straight", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([1, 1, 2, 3, 4], yacht.LITTLE_STRAIGHT), 0)", + "task_id": 0 + }, + { + "name": "Yacht > no pairs but not a little straight", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([1, 2, 3, 4, 6], yacht.LITTLE_STRAIGHT), 0)", + "task_id": 0 + }, + { + "name": "Yacht > minimum is 1 maximum is 5 but not a little straight", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([1, 1, 3, 4, 5], yacht.LITTLE_STRAIGHT), 0)", + "task_id": 0 + }, + { + "name": "Yacht > big straight", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([4, 6, 2, 5, 3], yacht.BIG_STRAIGHT), 30)", + "task_id": 0 + }, + { + "name": "Yacht > big straight as little straight", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([6, 5, 4, 3, 2], yacht.LITTLE_STRAIGHT), 0)", + "task_id": 0 + }, + { + "name": "Yacht > no pairs but not a big straight", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([6, 5, 4, 3, 1], yacht.BIG_STRAIGHT), 0)", + "task_id": 0 + }, + { + "name": "Yacht > choice", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([3, 3, 5, 6, 6], yacht.CHOICE), 23)", + "task_id": 0 + }, + { + "name": "Yacht > yacht as choice", + "status": "pass", + "test_code": "self.assertEqual(yacht.score([2, 2, 2, 2, 2], yacht.CHOICE), 10)", + "task_id": 0 + } + ] +} \ No newline at end of file diff --git a/test/practice-yacht/yacht.py b/test/practice-yacht/yacht.py new file mode 100644 index 0000000..dedcb7a --- /dev/null +++ b/test/practice-yacht/yacht.py @@ -0,0 +1,65 @@ +from collections import Counter +from functools import partial + +YACHT = 0 +ONES = 1 +TWOS = 2 +THREES = 3 +FOURS = 4 +FIVES = 5 +SIXES = 6 +FULL_HOUSE = 7 +FOUR_OF_A_KIND = 8 +LITTLE_STRAIGHT = 9 +BIG_STRAIGHT = 10 +CHOICE = 11 + + +def sum_of_numbers(number, dice): + return sum(idx for idx in dice if idx == number) + + +def full_house(dice): + counter = Counter(dice) + return sum(dice) if set(counter.values()) == {3, 2} else 0 + + +def four_of_a_kind(dice): + counter = Counter(dice) + number, count = counter.most_common()[0] + return 4 * number if count >= 4 else 0 + + +def little_straight(dice): + return 30 if set(dice) == {1, 2, 3, 4, 5} else 0 + + +def big_straight(dice): + return 30 if set(dice) == {2, 3, 4, 5, 6} else 0 + + +def yacht(dice): + return 50 if len(set(dice)) == 1 else 0 + + +functions = [ + yacht, + partial(sum_of_numbers, 1), + partial(sum_of_numbers, 2), + partial(sum_of_numbers, 3), + partial(sum_of_numbers, 4), + partial(sum_of_numbers, 5), + partial(sum_of_numbers, 6), + full_house, + four_of_a_kind, + little_straight, + big_straight, + sum, +] + + +def score(dice, category): + try: + return functions[category](dice) + except IndexError as error: + raise ValueError('No such category.') from error diff --git a/test/practice-zebra-puzzle/.meta/config.json b/test/practice-zebra-puzzle/.meta/config.json new file mode 100644 index 0000000..b0b2da5 --- /dev/null +++ b/test/practice-zebra-puzzle/.meta/config.json @@ -0,0 +1,29 @@ +{ + "authors": [ + "sjakobi" + ], + "contributors": [ + "behrtam", + "cmccandless", + "crsmi", + "Dog", + "lemoncurry", + "N-Parsons", + "pheanex", + "tqa236" + ], + "files": { + "solution": [ + "zebra_puzzle.py" + ], + "test": [ + "zebra_puzzle_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Solve the zebra puzzle.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Zebra_Puzzle" +} diff --git a/test/practice-zebra-puzzle/mapping.json b/test/practice-zebra-puzzle/mapping.json new file mode 100644 index 0000000..2b855d7 --- /dev/null +++ b/test/practice-zebra-puzzle/mapping.json @@ -0,0 +1,43 @@ +{ + "placeholder_0": "just_right_of", + "placeholder_1": "width", + "placeholder_2": "height", + "placeholder_3": "next_to", + "placeholder_4": "solution", + "placeholder_5": "houses", + "placeholder_6": "first", + "placeholder_7": "_", + "placeholder_8": "middle", + "placeholder_9": "orderings", + "placeholder_10": "result", + "placeholder_11": "idx", + "placeholder_12": "red", + "placeholder_13": "green", + "placeholder_14": "ivory", + "placeholder_15": "yellow", + "placeholder_16": "blue", + "placeholder_17": "english_man", + "placeholder_18": "spaniard", + "placeholder_19": "ukrainian", + "placeholder_20": "japanese", + "placeholder_21": "norwegian", + "placeholder_22": "coffee", + "placeholder_23": "tea", + "placeholder_24": "milk", + "placeholder_25": "orange_juice", + "placeholder_26": "water", + "placeholder_27": "old_gold", + "placeholder_28": "kools", + "placeholder_29": "chesterfields", + "placeholder_30": "lucky_strike", + "placeholder_31": "parliaments", + "placeholder_32": "dog", + "placeholder_33": "snails", + "placeholder_34": "fox", + "placeholder_35": "horse", + "placeholder_36": "zebra", + "placeholder_37": "placeholder_11", + "placeholder_38": "drinks_water", + "placeholder_39": "answer", + "placeholder_40": "owns_zebra" +} \ No newline at end of file diff --git a/test/practice-zebra-puzzle/representation.json b/test/practice-zebra-puzzle/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-zebra-puzzle/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-zebra-puzzle/representation.out b/test/practice-zebra-puzzle/representation.out new file mode 100644 index 0000000..7f8c62d --- /dev/null +++ b/test/practice-zebra-puzzle/representation.out @@ -0,0 +1,2466 @@ +## BEGIN NORMALIZED CODE ## +from itertools import permutations + + +def placeholder_0(placeholder_1, placeholder_2): + return placeholder_1 - placeholder_2 == 1 + + +def placeholder_3(placeholder_1, placeholder_2): + return abs(placeholder_1 - placeholder_2) == 1 + + +def placeholder_4(): + placeholder_5 = ( + placeholder_6, + placeholder_7, + placeholder_8, + placeholder_7, + placeholder_7, + ) = range(5) + placeholder_9 = list(permutations(placeholder_5)) + placeholder_10 = next( + ( + [ + { + placeholder_17: "Englishman", + placeholder_18: "Spaniard", + placeholder_19: "Ukrainian", + placeholder_20: "Japanese", + placeholder_21: "Norwegian", + }[placeholder_37] + for placeholder_37 in (placeholder_26, placeholder_36) + ] + for placeholder_12, placeholder_13, placeholder_14, placeholder_15, placeholder_16 in placeholder_9 + if placeholder_0(placeholder_13, placeholder_14) + for placeholder_17, placeholder_18, placeholder_19, placeholder_20, placeholder_21 in placeholder_9 + if placeholder_17 is placeholder_12 + if placeholder_21 is placeholder_6 + if placeholder_3(placeholder_21, placeholder_16) + for placeholder_22, placeholder_23, placeholder_24, placeholder_25, placeholder_26 in placeholder_9 + if placeholder_22 is placeholder_13 + if placeholder_19 is placeholder_23 + if placeholder_24 is placeholder_8 + for placeholder_27, placeholder_28, placeholder_29, placeholder_30, placeholder_31 in placeholder_9 + if placeholder_28 is placeholder_15 + if placeholder_30 is placeholder_25 + if placeholder_20 is placeholder_31 + for placeholder_32, placeholder_33, placeholder_34, placeholder_35, placeholder_36 in placeholder_9 + if placeholder_18 is placeholder_32 + if placeholder_27 is placeholder_33 + if placeholder_3(placeholder_29, placeholder_34) + if placeholder_3(placeholder_28, placeholder_35) + ) + ) + return placeholder_10 + + +def placeholder_38(): + placeholder_39, placeholder_7 = placeholder_4() + return placeholder_39 + + +def placeholder_40(): + placeholder_7, placeholder_39 = placeholder_4() + return placeholder_39 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + Expr( + Constant( + 'This solution for the Zebra Puzzle is adapted from a solution\nby Peter Norvig for the course "Design of Computer Programs" on Udacity.\nhttps://www.udacity.com/course/cs212\n', + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + lineno=1, + col_offset=0, + end_lineno=4, + end_col_offset=3), + ImportFrom( + 'itertools', + [ + alias( + 'permutations', + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=34)], + 0, + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=34), + FunctionDef( + 'just_right_of', + arguments( + [], + [ + arg( + 'width', + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=23), + arg( + 'height', + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + BinOp( + Name( + 'width', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=16), + Sub(), + Name( + 'height', + Load(), + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=25), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=25), + [ + Eq()], + [ + Constant( + 1, + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=30)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=30), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=30)], + [], + lineno=9, + col_offset=0, + end_lineno=10, + end_col_offset=30), + FunctionDef( + 'next_to', + arguments( + [], + [ + arg( + 'width', + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=17), + arg( + 'height', + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'abs', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + [ + BinOp( + Name( + 'width', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=20), + Sub(), + Name( + 'height', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=29), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=29)], + [], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 1, + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=35)], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=35), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=35)], + [], + lineno=13, + col_offset=0, + end_lineno=14, + end_col_offset=35), + FunctionDef( + 'solution', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'houses', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=10), + Tuple( + [ + Name( + 'first', + Store(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=18), + Name( + '_', + Store(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=21), + Name( + 'middle', + Store(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=29), + Name( + '_', + Store(), + lineno=18, + col_offset=31, + end_lineno=18, + end_col_offset=32), + Name( + '_', + Store(), + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=35)], + Store(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=35)], + Call( + Name( + 'range', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=43), + [ + Constant( + 5, + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=45)], + [], + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=46), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=46), + Assign( + [ + Name( + 'orderings', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=13)], + Call( + Name( + 'list', + Load(), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=20), + [ + Call( + Name( + 'permutations', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=33), + [ + Name( + 'houses', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=40)], + [], + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=41)], + [], + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=42), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=42), + Assign( + [ + Name( + 'result', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=10)], + Call( + Name( + 'next', + Load(), + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=17), + [ + GeneratorExp( + ListComp( + Subscript( + Dict( + [ + Name( + 'english_man', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=23), + Name( + 'spaniard', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=20), + Name( + 'ukrainian', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=21), + Name( + 'japanese', + Load(), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=20), + Name( + 'norwegian', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=21)], + [ + Constant( + 'Englishman', + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=37), + Constant( + 'Spaniard', + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=32), + Constant( + 'Ukrainian', + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=34), + Constant( + 'Japanese', + lineno=32, + col_offset=22, + end_lineno=32, + end_col_offset=32), + Constant( + 'Norwegian', + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=34)], + lineno=28, + col_offset=9, + end_lineno=34, + end_col_offset=9), + Name( + 'idx', + Load(), + lineno=34, + col_offset=10, + end_lineno=34, + end_col_offset=13), + Load(), + lineno=28, + col_offset=9, + end_lineno=34, + end_col_offset=14), + [ + comprehension( + Name( + 'idx', + Store(), + lineno=34, + col_offset=19, + end_lineno=34, + end_col_offset=22), + Tuple( + [ + Name( + 'water', + Load(), + lineno=34, + col_offset=27, + end_lineno=34, + end_col_offset=32), + Name( + 'zebra', + Load(), + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=39)], + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=40), + [], + 0)], + lineno=28, + col_offset=8, + end_lineno=34, + end_col_offset=41), + [ + comprehension( + Tuple( + [ + Name( + 'red', + Store(), + lineno=35, + col_offset=13, + end_lineno=35, + end_col_offset=16), + Name( + 'green', + Store(), + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=23), + Name( + 'ivory', + Store(), + lineno=35, + col_offset=25, + end_lineno=35, + end_col_offset=30), + Name( + 'yellow', + Store(), + lineno=35, + col_offset=32, + end_lineno=35, + end_col_offset=38), + Name( + 'blue', + Store(), + lineno=35, + col_offset=40, + end_lineno=35, + end_col_offset=44)], + Store(), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=45), + Name( + 'orderings', + Load(), + lineno=35, + col_offset=49, + end_lineno=35, + end_col_offset=58), + [ + Call( + Name( + 'just_right_of', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=24), + [ + Name( + 'green', + Load(), + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=30), + Name( + 'ivory', + Load(), + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=37)], + [], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=38)], + 0), + comprehension( + Tuple( + [ + Name( + 'english_man', + Store(), + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=24), + Name( + 'spaniard', + Store(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=34), + Name( + 'ukrainian', + Store(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=45), + Name( + 'japanese', + Store(), + lineno=37, + col_offset=47, + end_lineno=37, + end_col_offset=55), + Name( + 'norwegian', + Store(), + lineno=37, + col_offset=57, + end_lineno=37, + end_col_offset=66)], + Store(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=67), + Name( + 'orderings', + Load(), + lineno=37, + col_offset=71, + end_lineno=37, + end_col_offset=80), + [ + Compare( + Name( + 'english_man', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=22), + [ + Is()], + [ + Name( + 'red', + Load(), + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=29)], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=29), + Compare( + Name( + 'norwegian', + Load(), + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=42), + [ + Is()], + [ + Name( + 'first', + Load(), + lineno=38, + col_offset=46, + end_lineno=38, + end_col_offset=51)], + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=51), + Call( + Name( + 'next_to', + Load(), + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=62), + [ + Name( + 'norwegian', + Load(), + lineno=38, + col_offset=63, + end_lineno=38, + end_col_offset=72), + Name( + 'blue', + Load(), + lineno=38, + col_offset=74, + end_lineno=38, + end_col_offset=78)], + [], + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=79)], + 0), + comprehension( + Tuple( + [ + Name( + 'coffee', + Store(), + lineno=39, + col_offset=13, + end_lineno=39, + end_col_offset=19), + Name( + 'tea', + Store(), + lineno=39, + col_offset=21, + end_lineno=39, + end_col_offset=24), + Name( + 'milk', + Store(), + lineno=39, + col_offset=26, + end_lineno=39, + end_col_offset=30), + Name( + 'orange_juice', + Store(), + lineno=39, + col_offset=32, + end_lineno=39, + end_col_offset=44), + Name( + 'water', + Store(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=51)], + Store(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=52), + Name( + 'orderings', + Load(), + lineno=39, + col_offset=56, + end_lineno=39, + end_col_offset=65), + [ + Compare( + Name( + 'coffee', + Load(), + lineno=39, + col_offset=69, + end_lineno=39, + end_col_offset=75), + [ + Is()], + [ + Name( + 'green', + Load(), + lineno=39, + col_offset=79, + end_lineno=39, + end_col_offset=84)], + lineno=39, + col_offset=69, + end_lineno=39, + end_col_offset=84), + Compare( + Name( + 'ukrainian', + Load(), + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=20), + [ + Is()], + [ + Name( + 'tea', + Load(), + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=27)], + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=27), + Compare( + Name( + 'milk', + Load(), + lineno=40, + col_offset=31, + end_lineno=40, + end_col_offset=35), + [ + Is()], + [ + Name( + 'middle', + Load(), + lineno=40, + col_offset=39, + end_lineno=40, + end_col_offset=45)], + lineno=40, + col_offset=31, + end_lineno=40, + end_col_offset=45)], + 0), + comprehension( + Tuple( + [ + Name( + 'old_gold', + Store(), + lineno=41, + col_offset=13, + end_lineno=41, + end_col_offset=21), + Name( + 'kools', + Store(), + lineno=41, + col_offset=23, + end_lineno=41, + end_col_offset=28), + Name( + 'chesterfields', + Store(), + lineno=41, + col_offset=30, + end_lineno=41, + end_col_offset=43), + Name( + 'lucky_strike', + Store(), + lineno=41, + col_offset=45, + end_lineno=41, + end_col_offset=57), + Name( + 'parliaments', + Store(), + lineno=41, + col_offset=59, + end_lineno=41, + end_col_offset=70)], + Store(), + lineno=41, + col_offset=12, + end_lineno=42, + end_col_offset=14), + Name( + 'orderings', + Load(), + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=27), + [ + Compare( + Name( + 'kools', + Load(), + lineno=42, + col_offset=31, + end_lineno=42, + end_col_offset=36), + [ + Is()], + [ + Name( + 'yellow', + Load(), + lineno=42, + col_offset=40, + end_lineno=42, + end_col_offset=46)], + lineno=42, + col_offset=31, + end_lineno=42, + end_col_offset=46), + Compare( + Name( + 'lucky_strike', + Load(), + lineno=42, + col_offset=50, + end_lineno=42, + end_col_offset=62), + [ + Is()], + [ + Name( + 'orange_juice', + Load(), + lineno=42, + col_offset=66, + end_lineno=42, + end_col_offset=78)], + lineno=42, + col_offset=50, + end_lineno=42, + end_col_offset=78), + Compare( + Name( + 'japanese', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=19), + [ + Is()], + [ + Name( + 'parliaments', + Load(), + lineno=43, + col_offset=23, + end_lineno=43, + end_col_offset=34)], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=34)], + 0), + comprehension( + Tuple( + [ + Name( + 'dog', + Store(), + lineno=44, + col_offset=13, + end_lineno=44, + end_col_offset=16), + Name( + 'snails', + Store(), + lineno=44, + col_offset=18, + end_lineno=44, + end_col_offset=24), + Name( + 'fox', + Store(), + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=29), + Name( + 'horse', + Store(), + lineno=44, + col_offset=31, + end_lineno=44, + end_col_offset=36), + Name( + 'zebra', + Store(), + lineno=44, + col_offset=38, + end_lineno=44, + end_col_offset=43)], + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=44), + Name( + 'orderings', + Load(), + lineno=44, + col_offset=48, + end_lineno=44, + end_col_offset=57), + [ + Compare( + Name( + 'spaniard', + Load(), + lineno=44, + col_offset=61, + end_lineno=44, + end_col_offset=69), + [ + Is()], + [ + Name( + 'dog', + Load(), + lineno=44, + col_offset=73, + end_lineno=44, + end_col_offset=76)], + lineno=44, + col_offset=61, + end_lineno=44, + end_col_offset=76), + Compare( + Name( + 'old_gold', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=19), + [ + Is()], + [ + Name( + 'snails', + Load(), + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=29)], + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=29), + Call( + Name( + 'next_to', + Load(), + lineno=45, + col_offset=33, + end_lineno=45, + end_col_offset=40), + [ + Name( + 'chesterfields', + Load(), + lineno=45, + col_offset=41, + end_lineno=45, + end_col_offset=54), + Name( + 'fox', + Load(), + lineno=45, + col_offset=56, + end_lineno=45, + end_col_offset=59)], + [], + lineno=45, + col_offset=33, + end_lineno=45, + end_col_offset=60), + Call( + Name( + 'next_to', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=18), + [ + Name( + 'kools', + Load(), + lineno=46, + col_offset=19, + end_lineno=46, + end_col_offset=24), + Name( + 'horse', + Load(), + lineno=46, + col_offset=26, + end_lineno=46, + end_col_offset=31)], + [], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=32)], + 0)], + lineno=27, + col_offset=17, + end_lineno=46, + end_col_offset=33)], + [], + lineno=27, + col_offset=13, + end_lineno=46, + end_col_offset=33), + lineno=27, + col_offset=4, + end_lineno=46, + end_col_offset=33), + Return( + Name( + 'result', + Load(), + lineno=47, + col_offset=11, + end_lineno=47, + end_col_offset=17), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=17)], + [], + lineno=17, + col_offset=0, + end_lineno=47, + end_col_offset=17), + FunctionDef( + 'drinks_water', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'answer', + Store(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=10), + Name( + '_', + Store(), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=13)], + Store(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=13)], + Call( + Name( + 'solution', + Load(), + lineno=51, + col_offset=16, + end_lineno=51, + end_col_offset=24), + [], + [], + lineno=51, + col_offset=16, + end_lineno=51, + end_col_offset=26), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=26), + Return( + Name( + 'answer', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=17), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=17)], + [], + lineno=50, + col_offset=0, + end_lineno=52, + end_col_offset=17), + FunctionDef( + 'owns_zebra', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + '_', + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=5), + Name( + 'answer', + Store(), + lineno=56, + col_offset=7, + end_lineno=56, + end_col_offset=13)], + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=13)], + Call( + Name( + 'solution', + Load(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=24), + [], + [], + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=26), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=26), + Return( + Name( + 'answer', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=17), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=17)], + [], + lineno=55, + col_offset=0, + end_lineno=57, + end_col_offset=17)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ImportFrom( + 'itertools', + [ + alias( + 'permutations', + lineno=6, + col_offset=22, + end_lineno=6, + end_col_offset=34)], + 0, + lineno=6, + col_offset=0, + end_lineno=6, + end_col_offset=34), + FunctionDef( + 'placeholder_0', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=9, + col_offset=18, + end_lineno=9, + end_col_offset=23), + arg( + 'placeholder_2', + lineno=9, + col_offset=25, + end_lineno=9, + end_col_offset=31)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=16), + Sub(), + Name( + 'placeholder_2', + Load(), + lineno=10, + col_offset=19, + end_lineno=10, + end_col_offset=25), + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=25), + [ + Eq()], + [ + Constant( + 1, + lineno=10, + col_offset=29, + end_lineno=10, + end_col_offset=30)], + lineno=10, + col_offset=11, + end_lineno=10, + end_col_offset=30), + lineno=10, + col_offset=4, + end_lineno=10, + end_col_offset=30)], + [], + lineno=9, + col_offset=0, + end_lineno=10, + end_col_offset=30), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'placeholder_1', + lineno=13, + col_offset=12, + end_lineno=13, + end_col_offset=17), + arg( + 'placeholder_2', + lineno=13, + col_offset=19, + end_lineno=13, + end_col_offset=25)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Compare( + Call( + Name( + 'abs', + Load(), + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=14), + [ + BinOp( + Name( + 'placeholder_1', + Load(), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=20), + Sub(), + Name( + 'placeholder_2', + Load(), + lineno=14, + col_offset=23, + end_lineno=14, + end_col_offset=29), + lineno=14, + col_offset=15, + end_lineno=14, + end_col_offset=29)], + [], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=30), + [ + Eq()], + [ + Constant( + 1, + lineno=14, + col_offset=34, + end_lineno=14, + end_col_offset=35)], + lineno=14, + col_offset=11, + end_lineno=14, + end_col_offset=35), + lineno=14, + col_offset=4, + end_lineno=14, + end_col_offset=35)], + [], + lineno=13, + col_offset=0, + end_lineno=14, + end_col_offset=35), + FunctionDef( + 'placeholder_4', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Name( + 'placeholder_5', + Store(), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=10), + Tuple( + [ + Name( + 'placeholder_6', + Store(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=18), + Name( + 'placeholder_7', + Store(), + lineno=18, + col_offset=20, + end_lineno=18, + end_col_offset=21), + Name( + 'placeholder_8', + Store(), + lineno=18, + col_offset=23, + end_lineno=18, + end_col_offset=29), + Name( + 'placeholder_7', + Store(), + lineno=18, + col_offset=31, + end_lineno=18, + end_col_offset=32), + Name( + 'placeholder_7', + Store(), + lineno=18, + col_offset=34, + end_lineno=18, + end_col_offset=35)], + Store(), + lineno=18, + col_offset=13, + end_lineno=18, + end_col_offset=35)], + Call( + Name( + 'range', + Load(), + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=43), + [ + Constant( + 5, + lineno=18, + col_offset=44, + end_lineno=18, + end_col_offset=45)], + [], + lineno=18, + col_offset=38, + end_lineno=18, + end_col_offset=46), + lineno=18, + col_offset=4, + end_lineno=18, + end_col_offset=46), + Assign( + [ + Name( + 'placeholder_9', + Store(), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=13)], + Call( + Name( + 'list', + Load(), + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=20), + [ + Call( + Name( + 'permutations', + Load(), + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=33), + [ + Name( + 'placeholder_5', + Load(), + lineno=19, + col_offset=34, + end_lineno=19, + end_col_offset=40)], + [], + lineno=19, + col_offset=21, + end_lineno=19, + end_col_offset=41)], + [], + lineno=19, + col_offset=16, + end_lineno=19, + end_col_offset=42), + lineno=19, + col_offset=4, + end_lineno=19, + end_col_offset=42), + Assign( + [ + Name( + 'placeholder_10', + Store(), + lineno=27, + col_offset=4, + end_lineno=27, + end_col_offset=10)], + Call( + Name( + 'next', + Load(), + lineno=27, + col_offset=13, + end_lineno=27, + end_col_offset=17), + [ + GeneratorExp( + ListComp( + Subscript( + Dict( + [ + Name( + 'placeholder_17', + Load(), + lineno=29, + col_offset=12, + end_lineno=29, + end_col_offset=23), + Name( + 'placeholder_18', + Load(), + lineno=30, + col_offset=12, + end_lineno=30, + end_col_offset=20), + Name( + 'placeholder_19', + Load(), + lineno=31, + col_offset=12, + end_lineno=31, + end_col_offset=21), + Name( + 'placeholder_20', + Load(), + lineno=32, + col_offset=12, + end_lineno=32, + end_col_offset=20), + Name( + 'placeholder_21', + Load(), + lineno=33, + col_offset=12, + end_lineno=33, + end_col_offset=21)], + [ + Constant( + 'Englishman', + lineno=29, + col_offset=25, + end_lineno=29, + end_col_offset=37), + Constant( + 'Spaniard', + lineno=30, + col_offset=22, + end_lineno=30, + end_col_offset=32), + Constant( + 'Ukrainian', + lineno=31, + col_offset=23, + end_lineno=31, + end_col_offset=34), + Constant( + 'Japanese', + lineno=32, + col_offset=22, + end_lineno=32, + end_col_offset=32), + Constant( + 'Norwegian', + lineno=33, + col_offset=23, + end_lineno=33, + end_col_offset=34)], + lineno=28, + col_offset=9, + end_lineno=34, + end_col_offset=9), + Name( + 'placeholder_37', + Load(), + lineno=34, + col_offset=10, + end_lineno=34, + end_col_offset=13), + Load(), + lineno=28, + col_offset=9, + end_lineno=34, + end_col_offset=14), + [ + comprehension( + Name( + 'placeholder_37', + Store(), + lineno=34, + col_offset=19, + end_lineno=34, + end_col_offset=22), + Tuple( + [ + Name( + 'placeholder_26', + Load(), + lineno=34, + col_offset=27, + end_lineno=34, + end_col_offset=32), + Name( + 'placeholder_36', + Load(), + lineno=34, + col_offset=34, + end_lineno=34, + end_col_offset=39)], + Load(), + lineno=34, + col_offset=26, + end_lineno=34, + end_col_offset=40), + [], + 0)], + lineno=28, + col_offset=8, + end_lineno=34, + end_col_offset=41), + [ + comprehension( + Tuple( + [ + Name( + 'placeholder_12', + Store(), + lineno=35, + col_offset=13, + end_lineno=35, + end_col_offset=16), + Name( + 'placeholder_13', + Store(), + lineno=35, + col_offset=18, + end_lineno=35, + end_col_offset=23), + Name( + 'placeholder_14', + Store(), + lineno=35, + col_offset=25, + end_lineno=35, + end_col_offset=30), + Name( + 'placeholder_15', + Store(), + lineno=35, + col_offset=32, + end_lineno=35, + end_col_offset=38), + Name( + 'placeholder_16', + Store(), + lineno=35, + col_offset=40, + end_lineno=35, + end_col_offset=44)], + Store(), + lineno=35, + col_offset=12, + end_lineno=35, + end_col_offset=45), + Name( + 'placeholder_9', + Load(), + lineno=35, + col_offset=49, + end_lineno=35, + end_col_offset=58), + [ + Call( + Name( + 'placeholder_0', + Load(), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=24), + [ + Name( + 'placeholder_13', + Load(), + lineno=36, + col_offset=25, + end_lineno=36, + end_col_offset=30), + Name( + 'placeholder_14', + Load(), + lineno=36, + col_offset=32, + end_lineno=36, + end_col_offset=37)], + [], + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=38)], + 0), + comprehension( + Tuple( + [ + Name( + 'placeholder_17', + Store(), + lineno=37, + col_offset=13, + end_lineno=37, + end_col_offset=24), + Name( + 'placeholder_18', + Store(), + lineno=37, + col_offset=26, + end_lineno=37, + end_col_offset=34), + Name( + 'placeholder_19', + Store(), + lineno=37, + col_offset=36, + end_lineno=37, + end_col_offset=45), + Name( + 'placeholder_20', + Store(), + lineno=37, + col_offset=47, + end_lineno=37, + end_col_offset=55), + Name( + 'placeholder_21', + Store(), + lineno=37, + col_offset=57, + end_lineno=37, + end_col_offset=66)], + Store(), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=67), + Name( + 'placeholder_9', + Load(), + lineno=37, + col_offset=71, + end_lineno=37, + end_col_offset=80), + [ + Compare( + Name( + 'placeholder_17', + Load(), + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=22), + [ + Is()], + [ + Name( + 'placeholder_12', + Load(), + lineno=38, + col_offset=26, + end_lineno=38, + end_col_offset=29)], + lineno=38, + col_offset=11, + end_lineno=38, + end_col_offset=29), + Compare( + Name( + 'placeholder_21', + Load(), + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=42), + [ + Is()], + [ + Name( + 'placeholder_6', + Load(), + lineno=38, + col_offset=46, + end_lineno=38, + end_col_offset=51)], + lineno=38, + col_offset=33, + end_lineno=38, + end_col_offset=51), + Call( + Name( + 'placeholder_3', + Load(), + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=62), + [ + Name( + 'placeholder_21', + Load(), + lineno=38, + col_offset=63, + end_lineno=38, + end_col_offset=72), + Name( + 'placeholder_16', + Load(), + lineno=38, + col_offset=74, + end_lineno=38, + end_col_offset=78)], + [], + lineno=38, + col_offset=55, + end_lineno=38, + end_col_offset=79)], + 0), + comprehension( + Tuple( + [ + Name( + 'placeholder_22', + Store(), + lineno=39, + col_offset=13, + end_lineno=39, + end_col_offset=19), + Name( + 'placeholder_23', + Store(), + lineno=39, + col_offset=21, + end_lineno=39, + end_col_offset=24), + Name( + 'placeholder_24', + Store(), + lineno=39, + col_offset=26, + end_lineno=39, + end_col_offset=30), + Name( + 'placeholder_25', + Store(), + lineno=39, + col_offset=32, + end_lineno=39, + end_col_offset=44), + Name( + 'placeholder_26', + Store(), + lineno=39, + col_offset=46, + end_lineno=39, + end_col_offset=51)], + Store(), + lineno=39, + col_offset=12, + end_lineno=39, + end_col_offset=52), + Name( + 'placeholder_9', + Load(), + lineno=39, + col_offset=56, + end_lineno=39, + end_col_offset=65), + [ + Compare( + Name( + 'placeholder_22', + Load(), + lineno=39, + col_offset=69, + end_lineno=39, + end_col_offset=75), + [ + Is()], + [ + Name( + 'placeholder_13', + Load(), + lineno=39, + col_offset=79, + end_lineno=39, + end_col_offset=84)], + lineno=39, + col_offset=69, + end_lineno=39, + end_col_offset=84), + Compare( + Name( + 'placeholder_19', + Load(), + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=20), + [ + Is()], + [ + Name( + 'placeholder_23', + Load(), + lineno=40, + col_offset=24, + end_lineno=40, + end_col_offset=27)], + lineno=40, + col_offset=11, + end_lineno=40, + end_col_offset=27), + Compare( + Name( + 'placeholder_24', + Load(), + lineno=40, + col_offset=31, + end_lineno=40, + end_col_offset=35), + [ + Is()], + [ + Name( + 'placeholder_8', + Load(), + lineno=40, + col_offset=39, + end_lineno=40, + end_col_offset=45)], + lineno=40, + col_offset=31, + end_lineno=40, + end_col_offset=45)], + 0), + comprehension( + Tuple( + [ + Name( + 'placeholder_27', + Store(), + lineno=41, + col_offset=13, + end_lineno=41, + end_col_offset=21), + Name( + 'placeholder_28', + Store(), + lineno=41, + col_offset=23, + end_lineno=41, + end_col_offset=28), + Name( + 'placeholder_29', + Store(), + lineno=41, + col_offset=30, + end_lineno=41, + end_col_offset=43), + Name( + 'placeholder_30', + Store(), + lineno=41, + col_offset=45, + end_lineno=41, + end_col_offset=57), + Name( + 'placeholder_31', + Store(), + lineno=41, + col_offset=59, + end_lineno=41, + end_col_offset=70)], + Store(), + lineno=41, + col_offset=12, + end_lineno=42, + end_col_offset=14), + Name( + 'placeholder_9', + Load(), + lineno=42, + col_offset=18, + end_lineno=42, + end_col_offset=27), + [ + Compare( + Name( + 'placeholder_28', + Load(), + lineno=42, + col_offset=31, + end_lineno=42, + end_col_offset=36), + [ + Is()], + [ + Name( + 'placeholder_15', + Load(), + lineno=42, + col_offset=40, + end_lineno=42, + end_col_offset=46)], + lineno=42, + col_offset=31, + end_lineno=42, + end_col_offset=46), + Compare( + Name( + 'placeholder_30', + Load(), + lineno=42, + col_offset=50, + end_lineno=42, + end_col_offset=62), + [ + Is()], + [ + Name( + 'placeholder_25', + Load(), + lineno=42, + col_offset=66, + end_lineno=42, + end_col_offset=78)], + lineno=42, + col_offset=50, + end_lineno=42, + end_col_offset=78), + Compare( + Name( + 'placeholder_20', + Load(), + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=19), + [ + Is()], + [ + Name( + 'placeholder_31', + Load(), + lineno=43, + col_offset=23, + end_lineno=43, + end_col_offset=34)], + lineno=43, + col_offset=11, + end_lineno=43, + end_col_offset=34)], + 0), + comprehension( + Tuple( + [ + Name( + 'placeholder_32', + Store(), + lineno=44, + col_offset=13, + end_lineno=44, + end_col_offset=16), + Name( + 'placeholder_33', + Store(), + lineno=44, + col_offset=18, + end_lineno=44, + end_col_offset=24), + Name( + 'placeholder_34', + Store(), + lineno=44, + col_offset=26, + end_lineno=44, + end_col_offset=29), + Name( + 'placeholder_35', + Store(), + lineno=44, + col_offset=31, + end_lineno=44, + end_col_offset=36), + Name( + 'placeholder_36', + Store(), + lineno=44, + col_offset=38, + end_lineno=44, + end_col_offset=43)], + Store(), + lineno=44, + col_offset=12, + end_lineno=44, + end_col_offset=44), + Name( + 'placeholder_9', + Load(), + lineno=44, + col_offset=48, + end_lineno=44, + end_col_offset=57), + [ + Compare( + Name( + 'placeholder_18', + Load(), + lineno=44, + col_offset=61, + end_lineno=44, + end_col_offset=69), + [ + Is()], + [ + Name( + 'placeholder_32', + Load(), + lineno=44, + col_offset=73, + end_lineno=44, + end_col_offset=76)], + lineno=44, + col_offset=61, + end_lineno=44, + end_col_offset=76), + Compare( + Name( + 'placeholder_27', + Load(), + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=19), + [ + Is()], + [ + Name( + 'placeholder_33', + Load(), + lineno=45, + col_offset=23, + end_lineno=45, + end_col_offset=29)], + lineno=45, + col_offset=11, + end_lineno=45, + end_col_offset=29), + Call( + Name( + 'placeholder_3', + Load(), + lineno=45, + col_offset=33, + end_lineno=45, + end_col_offset=40), + [ + Name( + 'placeholder_29', + Load(), + lineno=45, + col_offset=41, + end_lineno=45, + end_col_offset=54), + Name( + 'placeholder_34', + Load(), + lineno=45, + col_offset=56, + end_lineno=45, + end_col_offset=59)], + [], + lineno=45, + col_offset=33, + end_lineno=45, + end_col_offset=60), + Call( + Name( + 'placeholder_3', + Load(), + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=18), + [ + Name( + 'placeholder_28', + Load(), + lineno=46, + col_offset=19, + end_lineno=46, + end_col_offset=24), + Name( + 'placeholder_35', + Load(), + lineno=46, + col_offset=26, + end_lineno=46, + end_col_offset=31)], + [], + lineno=46, + col_offset=11, + end_lineno=46, + end_col_offset=32)], + 0)], + lineno=27, + col_offset=17, + end_lineno=46, + end_col_offset=33)], + [], + lineno=27, + col_offset=13, + end_lineno=46, + end_col_offset=33), + lineno=27, + col_offset=4, + end_lineno=46, + end_col_offset=33), + Return( + Name( + 'placeholder_10', + Load(), + lineno=47, + col_offset=11, + end_lineno=47, + end_col_offset=17), + lineno=47, + col_offset=4, + end_lineno=47, + end_col_offset=17)], + [], + lineno=17, + col_offset=0, + end_lineno=47, + end_col_offset=17), + FunctionDef( + 'placeholder_38', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_39', + Store(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=10), + Name( + 'placeholder_7', + Store(), + lineno=51, + col_offset=12, + end_lineno=51, + end_col_offset=13)], + Store(), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=13)], + Call( + Name( + 'placeholder_4', + Load(), + lineno=51, + col_offset=16, + end_lineno=51, + end_col_offset=24), + [], + [], + lineno=51, + col_offset=16, + end_lineno=51, + end_col_offset=26), + lineno=51, + col_offset=4, + end_lineno=51, + end_col_offset=26), + Return( + Name( + 'placeholder_39', + Load(), + lineno=52, + col_offset=11, + end_lineno=52, + end_col_offset=17), + lineno=52, + col_offset=4, + end_lineno=52, + end_col_offset=17)], + [], + lineno=50, + col_offset=0, + end_lineno=52, + end_col_offset=17), + FunctionDef( + 'placeholder_40', + arguments( + [], + [], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Tuple( + [ + Name( + 'placeholder_7', + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=5), + Name( + 'placeholder_39', + Store(), + lineno=56, + col_offset=7, + end_lineno=56, + end_col_offset=13)], + Store(), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=13)], + Call( + Name( + 'placeholder_4', + Load(), + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=24), + [], + [], + lineno=56, + col_offset=16, + end_lineno=56, + end_col_offset=26), + lineno=56, + col_offset=4, + end_lineno=56, + end_col_offset=26), + Return( + Name( + 'placeholder_39', + Load(), + lineno=57, + col_offset=11, + end_lineno=57, + end_col_offset=17), + lineno=57, + col_offset=4, + end_lineno=57, + end_col_offset=17)], + [], + lineno=55, + col_offset=0, + end_lineno=57, + end_col_offset=17)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-zebra-puzzle/representation.txt b/test/practice-zebra-puzzle/representation.txt new file mode 100644 index 0000000..1e3543d --- /dev/null +++ b/test/practice-zebra-puzzle/representation.txt @@ -0,0 +1 @@ +Module([ImportFrom('itertools', [alias('permutations', lineno=6, col_offset=22, end_lineno=6, end_col_offset=34)], 0, lineno=6, col_offset=0, end_lineno=6, end_col_offset=34), FunctionDef('placeholder_0', arguments([], [arg('placeholder_1', lineno=9, col_offset=18, end_lineno=9, end_col_offset=23), arg('placeholder_2', lineno=9, col_offset=25, end_lineno=9, end_col_offset=31)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(BinOp(Name('placeholder_1', Load(), lineno=10, col_offset=11, end_lineno=10, end_col_offset=16), Sub(), Name('placeholder_2', Load(), lineno=10, col_offset=19, end_lineno=10, end_col_offset=25), lineno=10, col_offset=11, end_lineno=10, end_col_offset=25), [Eq()], [Constant(1, lineno=10, col_offset=29, end_lineno=10, end_col_offset=30)], lineno=10, col_offset=11, end_lineno=10, end_col_offset=30), lineno=10, col_offset=4, end_lineno=10, end_col_offset=30)], [], lineno=9, col_offset=0, end_lineno=10, end_col_offset=30), FunctionDef('placeholder_3', arguments([], [arg('placeholder_1', lineno=13, col_offset=12, end_lineno=13, end_col_offset=17), arg('placeholder_2', lineno=13, col_offset=19, end_lineno=13, end_col_offset=25)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Compare(Call(Name('abs', Load(), lineno=14, col_offset=11, end_lineno=14, end_col_offset=14), [BinOp(Name('placeholder_1', Load(), lineno=14, col_offset=15, end_lineno=14, end_col_offset=20), Sub(), Name('placeholder_2', Load(), lineno=14, col_offset=23, end_lineno=14, end_col_offset=29), lineno=14, col_offset=15, end_lineno=14, end_col_offset=29)], [], lineno=14, col_offset=11, end_lineno=14, end_col_offset=30), [Eq()], [Constant(1, lineno=14, col_offset=34, end_lineno=14, end_col_offset=35)], lineno=14, col_offset=11, end_lineno=14, end_col_offset=35), lineno=14, col_offset=4, end_lineno=14, end_col_offset=35)], [], lineno=13, col_offset=0, end_lineno=14, end_col_offset=35), FunctionDef('placeholder_4', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Name('placeholder_5', Store(), lineno=18, col_offset=4, end_lineno=18, end_col_offset=10), Tuple([Name('placeholder_6', Store(), lineno=18, col_offset=13, end_lineno=18, end_col_offset=18), Name('placeholder_7', Store(), lineno=18, col_offset=20, end_lineno=18, end_col_offset=21), Name('placeholder_8', Store(), lineno=18, col_offset=23, end_lineno=18, end_col_offset=29), Name('placeholder_7', Store(), lineno=18, col_offset=31, end_lineno=18, end_col_offset=32), Name('placeholder_7', Store(), lineno=18, col_offset=34, end_lineno=18, end_col_offset=35)], Store(), lineno=18, col_offset=13, end_lineno=18, end_col_offset=35)], Call(Name('range', Load(), lineno=18, col_offset=38, end_lineno=18, end_col_offset=43), [Constant(5, lineno=18, col_offset=44, end_lineno=18, end_col_offset=45)], [], lineno=18, col_offset=38, end_lineno=18, end_col_offset=46), lineno=18, col_offset=4, end_lineno=18, end_col_offset=46), Assign([Name('placeholder_9', Store(), lineno=19, col_offset=4, end_lineno=19, end_col_offset=13)], Call(Name('list', Load(), lineno=19, col_offset=16, end_lineno=19, end_col_offset=20), [Call(Name('permutations', Load(), lineno=19, col_offset=21, end_lineno=19, end_col_offset=33), [Name('placeholder_5', Load(), lineno=19, col_offset=34, end_lineno=19, end_col_offset=40)], [], lineno=19, col_offset=21, end_lineno=19, end_col_offset=41)], [], lineno=19, col_offset=16, end_lineno=19, end_col_offset=42), lineno=19, col_offset=4, end_lineno=19, end_col_offset=42), Assign([Name('placeholder_10', Store(), lineno=27, col_offset=4, end_lineno=27, end_col_offset=10)], Call(Name('next', Load(), lineno=27, col_offset=13, end_lineno=27, end_col_offset=17), [GeneratorExp(ListComp(Subscript(Dict([Name('placeholder_17', Load(), lineno=29, col_offset=12, end_lineno=29, end_col_offset=23), Name('placeholder_18', Load(), lineno=30, col_offset=12, end_lineno=30, end_col_offset=20), Name('placeholder_19', Load(), lineno=31, col_offset=12, end_lineno=31, end_col_offset=21), Name('placeholder_20', Load(), lineno=32, col_offset=12, end_lineno=32, end_col_offset=20), Name('placeholder_21', Load(), lineno=33, col_offset=12, end_lineno=33, end_col_offset=21)], [Constant('Englishman', lineno=29, col_offset=25, end_lineno=29, end_col_offset=37), Constant('Spaniard', lineno=30, col_offset=22, end_lineno=30, end_col_offset=32), Constant('Ukrainian', lineno=31, col_offset=23, end_lineno=31, end_col_offset=34), Constant('Japanese', lineno=32, col_offset=22, end_lineno=32, end_col_offset=32), Constant('Norwegian', lineno=33, col_offset=23, end_lineno=33, end_col_offset=34)], lineno=28, col_offset=9, end_lineno=34, end_col_offset=9), Name('placeholder_37', Load(), lineno=34, col_offset=10, end_lineno=34, end_col_offset=13), Load(), lineno=28, col_offset=9, end_lineno=34, end_col_offset=14), [comprehension(Name('placeholder_37', Store(), lineno=34, col_offset=19, end_lineno=34, end_col_offset=22), Tuple([Name('placeholder_26', Load(), lineno=34, col_offset=27, end_lineno=34, end_col_offset=32), Name('placeholder_36', Load(), lineno=34, col_offset=34, end_lineno=34, end_col_offset=39)], Load(), lineno=34, col_offset=26, end_lineno=34, end_col_offset=40), [], 0)], lineno=28, col_offset=8, end_lineno=34, end_col_offset=41), [comprehension(Tuple([Name('placeholder_12', Store(), lineno=35, col_offset=13, end_lineno=35, end_col_offset=16), Name('placeholder_13', Store(), lineno=35, col_offset=18, end_lineno=35, end_col_offset=23), Name('placeholder_14', Store(), lineno=35, col_offset=25, end_lineno=35, end_col_offset=30), Name('placeholder_15', Store(), lineno=35, col_offset=32, end_lineno=35, end_col_offset=38), Name('placeholder_16', Store(), lineno=35, col_offset=40, end_lineno=35, end_col_offset=44)], Store(), lineno=35, col_offset=12, end_lineno=35, end_col_offset=45), Name('placeholder_9', Load(), lineno=35, col_offset=49, end_lineno=35, end_col_offset=58), [Call(Name('placeholder_0', Load(), lineno=36, col_offset=11, end_lineno=36, end_col_offset=24), [Name('placeholder_13', Load(), lineno=36, col_offset=25, end_lineno=36, end_col_offset=30), Name('placeholder_14', Load(), lineno=36, col_offset=32, end_lineno=36, end_col_offset=37)], [], lineno=36, col_offset=11, end_lineno=36, end_col_offset=38)], 0), comprehension(Tuple([Name('placeholder_17', Store(), lineno=37, col_offset=13, end_lineno=37, end_col_offset=24), Name('placeholder_18', Store(), lineno=37, col_offset=26, end_lineno=37, end_col_offset=34), Name('placeholder_19', Store(), lineno=37, col_offset=36, end_lineno=37, end_col_offset=45), Name('placeholder_20', Store(), lineno=37, col_offset=47, end_lineno=37, end_col_offset=55), Name('placeholder_21', Store(), lineno=37, col_offset=57, end_lineno=37, end_col_offset=66)], Store(), lineno=37, col_offset=12, end_lineno=37, end_col_offset=67), Name('placeholder_9', Load(), lineno=37, col_offset=71, end_lineno=37, end_col_offset=80), [Compare(Name('placeholder_17', Load(), lineno=38, col_offset=11, end_lineno=38, end_col_offset=22), [Is()], [Name('placeholder_12', Load(), lineno=38, col_offset=26, end_lineno=38, end_col_offset=29)], lineno=38, col_offset=11, end_lineno=38, end_col_offset=29), Compare(Name('placeholder_21', Load(), lineno=38, col_offset=33, end_lineno=38, end_col_offset=42), [Is()], [Name('placeholder_6', Load(), lineno=38, col_offset=46, end_lineno=38, end_col_offset=51)], lineno=38, col_offset=33, end_lineno=38, end_col_offset=51), Call(Name('placeholder_3', Load(), lineno=38, col_offset=55, end_lineno=38, end_col_offset=62), [Name('placeholder_21', Load(), lineno=38, col_offset=63, end_lineno=38, end_col_offset=72), Name('placeholder_16', Load(), lineno=38, col_offset=74, end_lineno=38, end_col_offset=78)], [], lineno=38, col_offset=55, end_lineno=38, end_col_offset=79)], 0), comprehension(Tuple([Name('placeholder_22', Store(), lineno=39, col_offset=13, end_lineno=39, end_col_offset=19), Name('placeholder_23', Store(), lineno=39, col_offset=21, end_lineno=39, end_col_offset=24), Name('placeholder_24', Store(), lineno=39, col_offset=26, end_lineno=39, end_col_offset=30), Name('placeholder_25', Store(), lineno=39, col_offset=32, end_lineno=39, end_col_offset=44), Name('placeholder_26', Store(), lineno=39, col_offset=46, end_lineno=39, end_col_offset=51)], Store(), lineno=39, col_offset=12, end_lineno=39, end_col_offset=52), Name('placeholder_9', Load(), lineno=39, col_offset=56, end_lineno=39, end_col_offset=65), [Compare(Name('placeholder_22', Load(), lineno=39, col_offset=69, end_lineno=39, end_col_offset=75), [Is()], [Name('placeholder_13', Load(), lineno=39, col_offset=79, end_lineno=39, end_col_offset=84)], lineno=39, col_offset=69, end_lineno=39, end_col_offset=84), Compare(Name('placeholder_19', Load(), lineno=40, col_offset=11, end_lineno=40, end_col_offset=20), [Is()], [Name('placeholder_23', Load(), lineno=40, col_offset=24, end_lineno=40, end_col_offset=27)], lineno=40, col_offset=11, end_lineno=40, end_col_offset=27), Compare(Name('placeholder_24', Load(), lineno=40, col_offset=31, end_lineno=40, end_col_offset=35), [Is()], [Name('placeholder_8', Load(), lineno=40, col_offset=39, end_lineno=40, end_col_offset=45)], lineno=40, col_offset=31, end_lineno=40, end_col_offset=45)], 0), comprehension(Tuple([Name('placeholder_27', Store(), lineno=41, col_offset=13, end_lineno=41, end_col_offset=21), Name('placeholder_28', Store(), lineno=41, col_offset=23, end_lineno=41, end_col_offset=28), Name('placeholder_29', Store(), lineno=41, col_offset=30, end_lineno=41, end_col_offset=43), Name('placeholder_30', Store(), lineno=41, col_offset=45, end_lineno=41, end_col_offset=57), Name('placeholder_31', Store(), lineno=41, col_offset=59, end_lineno=41, end_col_offset=70)], Store(), lineno=41, col_offset=12, end_lineno=42, end_col_offset=14), Name('placeholder_9', Load(), lineno=42, col_offset=18, end_lineno=42, end_col_offset=27), [Compare(Name('placeholder_28', Load(), lineno=42, col_offset=31, end_lineno=42, end_col_offset=36), [Is()], [Name('placeholder_15', Load(), lineno=42, col_offset=40, end_lineno=42, end_col_offset=46)], lineno=42, col_offset=31, end_lineno=42, end_col_offset=46), Compare(Name('placeholder_30', Load(), lineno=42, col_offset=50, end_lineno=42, end_col_offset=62), [Is()], [Name('placeholder_25', Load(), lineno=42, col_offset=66, end_lineno=42, end_col_offset=78)], lineno=42, col_offset=50, end_lineno=42, end_col_offset=78), Compare(Name('placeholder_20', Load(), lineno=43, col_offset=11, end_lineno=43, end_col_offset=19), [Is()], [Name('placeholder_31', Load(), lineno=43, col_offset=23, end_lineno=43, end_col_offset=34)], lineno=43, col_offset=11, end_lineno=43, end_col_offset=34)], 0), comprehension(Tuple([Name('placeholder_32', Store(), lineno=44, col_offset=13, end_lineno=44, end_col_offset=16), Name('placeholder_33', Store(), lineno=44, col_offset=18, end_lineno=44, end_col_offset=24), Name('placeholder_34', Store(), lineno=44, col_offset=26, end_lineno=44, end_col_offset=29), Name('placeholder_35', Store(), lineno=44, col_offset=31, end_lineno=44, end_col_offset=36), Name('placeholder_36', Store(), lineno=44, col_offset=38, end_lineno=44, end_col_offset=43)], Store(), lineno=44, col_offset=12, end_lineno=44, end_col_offset=44), Name('placeholder_9', Load(), lineno=44, col_offset=48, end_lineno=44, end_col_offset=57), [Compare(Name('placeholder_18', Load(), lineno=44, col_offset=61, end_lineno=44, end_col_offset=69), [Is()], [Name('placeholder_32', Load(), lineno=44, col_offset=73, end_lineno=44, end_col_offset=76)], lineno=44, col_offset=61, end_lineno=44, end_col_offset=76), Compare(Name('placeholder_27', Load(), lineno=45, col_offset=11, end_lineno=45, end_col_offset=19), [Is()], [Name('placeholder_33', Load(), lineno=45, col_offset=23, end_lineno=45, end_col_offset=29)], lineno=45, col_offset=11, end_lineno=45, end_col_offset=29), Call(Name('placeholder_3', Load(), lineno=45, col_offset=33, end_lineno=45, end_col_offset=40), [Name('placeholder_29', Load(), lineno=45, col_offset=41, end_lineno=45, end_col_offset=54), Name('placeholder_34', Load(), lineno=45, col_offset=56, end_lineno=45, end_col_offset=59)], [], lineno=45, col_offset=33, end_lineno=45, end_col_offset=60), Call(Name('placeholder_3', Load(), lineno=46, col_offset=11, end_lineno=46, end_col_offset=18), [Name('placeholder_28', Load(), lineno=46, col_offset=19, end_lineno=46, end_col_offset=24), Name('placeholder_35', Load(), lineno=46, col_offset=26, end_lineno=46, end_col_offset=31)], [], lineno=46, col_offset=11, end_lineno=46, end_col_offset=32)], 0)], lineno=27, col_offset=17, end_lineno=46, end_col_offset=33)], [], lineno=27, col_offset=13, end_lineno=46, end_col_offset=33), lineno=27, col_offset=4, end_lineno=46, end_col_offset=33), Return(Name('placeholder_10', Load(), lineno=47, col_offset=11, end_lineno=47, end_col_offset=17), lineno=47, col_offset=4, end_lineno=47, end_col_offset=17)], [], lineno=17, col_offset=0, end_lineno=47, end_col_offset=17), FunctionDef('placeholder_38', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Tuple([Name('placeholder_39', Store(), lineno=51, col_offset=4, end_lineno=51, end_col_offset=10), Name('placeholder_7', Store(), lineno=51, col_offset=12, end_lineno=51, end_col_offset=13)], Store(), lineno=51, col_offset=4, end_lineno=51, end_col_offset=13)], Call(Name('placeholder_4', Load(), lineno=51, col_offset=16, end_lineno=51, end_col_offset=24), [], [], lineno=51, col_offset=16, end_lineno=51, end_col_offset=26), lineno=51, col_offset=4, end_lineno=51, end_col_offset=26), Return(Name('placeholder_39', Load(), lineno=52, col_offset=11, end_lineno=52, end_col_offset=17), lineno=52, col_offset=4, end_lineno=52, end_col_offset=17)], [], lineno=50, col_offset=0, end_lineno=52, end_col_offset=17), FunctionDef('placeholder_40', arguments([], [], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Tuple([Name('placeholder_7', Store(), lineno=56, col_offset=4, end_lineno=56, end_col_offset=5), Name('placeholder_39', Store(), lineno=56, col_offset=7, end_lineno=56, end_col_offset=13)], Store(), lineno=56, col_offset=4, end_lineno=56, end_col_offset=13)], Call(Name('placeholder_4', Load(), lineno=56, col_offset=16, end_lineno=56, end_col_offset=24), [], [], lineno=56, col_offset=16, end_lineno=56, end_col_offset=26), lineno=56, col_offset=4, end_lineno=56, end_col_offset=26), Return(Name('placeholder_39', Load(), lineno=57, col_offset=11, end_lineno=57, end_col_offset=17), lineno=57, col_offset=4, end_lineno=57, end_col_offset=17)], [], lineno=55, col_offset=0, end_lineno=57, end_col_offset=17)], []) \ No newline at end of file diff --git a/test/practice-zebra-puzzle/zebra_puzzle.py b/test/practice-zebra-puzzle/zebra_puzzle.py new file mode 100644 index 0000000..a6ea8f9 --- /dev/null +++ b/test/practice-zebra-puzzle/zebra_puzzle.py @@ -0,0 +1,57 @@ +"""This solution for the Zebra Puzzle is adapted from a solution +by Peter Norvig for the course "Design of Computer Programs" on Udacity. +https://www.udacity.com/course/cs212 +""" + +from itertools import permutations + + +def just_right_of(width, height): + return width - height == 1 + + +def next_to(width, height): + return abs(width - height) == 1 + + +def solution(): + houses = first, _, middle, _, _ = range(5) + orderings = list(permutations(houses)) + + # The following you are about to witness is code from someone who loves 'comprehensions'. + # I just fixed the PEP-8 violations... + # Someone please write this in a way that it is actually read-able? + # Anyways, enjoy. + # - J08K <3 (1:05 AM, nov 29th, 2021) + + result = next( + [{ + english_man: 'Englishman', + spaniard: 'Spaniard', + ukrainian: 'Ukrainian', + japanese: 'Japanese', + norwegian: 'Norwegian' + }[idx] for idx in (water, zebra)] + for (red, green, ivory, yellow, blue) in orderings + if just_right_of(green, ivory) + for (english_man, spaniard, ukrainian, japanese, norwegian) in orderings + if english_man is red if norwegian is first if next_to(norwegian, blue) + for (coffee, tea, milk, orange_juice, water) in orderings if coffee is green + if ukrainian is tea if milk is middle + for (old_gold, kools, chesterfields, lucky_strike, parliaments + ) in orderings if kools is yellow if lucky_strike is orange_juice + if japanese is parliaments + for (dog, snails, fox, horse, zebra) in orderings if spaniard is dog + if old_gold is snails if next_to(chesterfields, fox) + if next_to(kools, horse)) + return result + + +def drinks_water(): + answer, _ = solution() + return answer + + +def owns_zebra(): + _, answer = solution() + return answer diff --git a/test/practice-zipper/.meta/config.json b/test/practice-zipper/.meta/config.json new file mode 100644 index 0000000..c26c555 --- /dev/null +++ b/test/practice-zipper/.meta/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "cmccandless" + ], + "contributors": [ + "Dog", + "N-Parsons", + "tqa236", + "yawpitch" + ], + "files": { + "solution": [ + "zipper.py" + ], + "test": [ + "zipper_test.py" + ], + "example": [ + ".meta/example.py" + ] + }, + "blurb": "Creating a zipper for a binary tree." +} diff --git a/test/practice-zipper/mapping.json b/test/practice-zipper/mapping.json new file mode 100644 index 0000000..fd7a94a --- /dev/null +++ b/test/practice-zipper/mapping.json @@ -0,0 +1,15 @@ +{ + "placeholder_0": "Zipper", + "placeholder_1": "from_tree", + "placeholder_2": "tree", + "placeholder_3": "__init__", + "placeholder_4": "ancestors", + "placeholder_5": "value", + "placeholder_6": "set_value", + "placeholder_7": "left", + "placeholder_8": "set_left", + "placeholder_9": "right", + "placeholder_10": "set_right", + "placeholder_11": "up", + "placeholder_12": "to_tree" +} \ No newline at end of file diff --git a/test/practice-zipper/representation.json b/test/practice-zipper/representation.json new file mode 100644 index 0000000..051b2b6 --- /dev/null +++ b/test/practice-zipper/representation.json @@ -0,0 +1,3 @@ +{ + "version": 2 +} \ No newline at end of file diff --git a/test/practice-zipper/representation.out b/test/practice-zipper/representation.out new file mode 100644 index 0000000..f8e8930 --- /dev/null +++ b/test/practice-zipper/representation.out @@ -0,0 +1,2124 @@ +## BEGIN NORMALIZED CODE ## +class placeholder_0: + @staticmethod + def placeholder_1(placeholder_2): + return placeholder_0(dict(placeholder_2), []) + + def placeholder_3(self, placeholder_2, placeholder_4): + self.placeholder_2 = placeholder_2 + self.placeholder_4 = placeholder_4 + + def placeholder_5(self): + return self.placeholder_2["value"] + + def placeholder_6(self, placeholder_5): + self.placeholder_2["value"] = placeholder_5 + return self + + def placeholder_7(self): + if self.placeholder_2["left"] is None: + return None + return placeholder_0( + self.placeholder_2["left"], self.placeholder_4 + [self.placeholder_2] + ) + + def placeholder_8(self, placeholder_2): + self.placeholder_2["left"] = placeholder_2 + return self + + def placeholder_9(self): + if self.placeholder_2["right"] is None: + return None + return placeholder_0( + self.placeholder_2["right"], self.placeholder_4 + [self.placeholder_2] + ) + + def placeholder_10(self, placeholder_2): + self.placeholder_2["right"] = placeholder_2 + return self + + def placeholder_11(self): + if not self.placeholder_4: + return None + return placeholder_0(self.placeholder_4[-1], self.placeholder_4[:-1]) + + def placeholder_12(self): + if any(self.placeholder_4): + return self.placeholder_4[0] + return self.placeholder_2 + +## END NORMALIZED CODE ## + +## BEGIN TREE BEFORE ## +Module( + [ + ClassDef( + 'Zipper', + [], + [], + [ + FunctionDef( + 'from_tree', + arguments( + [], + [ + arg( + 'tree', + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'Zipper', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=21), + [ + Call( + Name( + 'dict', + Load(), + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=26), + [ + Name( + 'tree', + Load(), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=31)], + [], + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=32), + List( + [], + Load(), + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=36)], + [], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=37), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=37)], + [ + Name( + 'staticmethod', + Load(), + lineno=2, + col_offset=5, + end_lineno=2, + end_col_offset=17)], + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=37), + FunctionDef( + '__init__', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=21), + arg( + 'tree', + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=27), + arg( + 'ancestors', + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'tree', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=17)], + Name( + 'tree', + Load(), + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=24), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'ancestors', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + Name( + 'ancestors', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=34), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=34)], + [], + lineno=6, + col_offset=4, + end_lineno=8, + end_col_offset=34), + FunctionDef( + 'value', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=19), + 'tree', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + Constant( + 'value', + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=32), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=33), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=33)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=33), + FunctionDef( + 'set_value', + arguments( + [], + [ + arg( + 'self', + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=22), + arg( + 'value', + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=12), + 'tree', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=17), + Constant( + 'value', + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=25), + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=26)], + Name( + 'value', + Load(), + lineno=14, + col_offset=29, + end_lineno=14, + end_col_offset=34), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=34), + Return( + Name( + 'self', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=19)], + [], + lineno=13, + col_offset=4, + end_lineno=15, + end_col_offset=19), + FunctionDef( + 'left', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=15), + 'tree', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=20), + Constant( + 'left', + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=27), + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=28), + [ + Is()], + [ + Constant( + None, + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=36)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=36), + [ + Return( + Constant( + None, + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=23), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=23)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=23), + Return( + Call( + Name( + 'Zipper', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=21), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=26), + 'tree', + Load(), + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=31), + Constant( + 'left', + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=38), + Load(), + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=39), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=45), + 'ancestors', + Load(), + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=55), + Add(), + List( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=59, + end_lineno=20, + end_col_offset=63), + 'tree', + Load(), + lineno=20, + col_offset=59, + end_lineno=20, + end_col_offset=68)], + Load(), + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=69), + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=69)], + [], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=70), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=70)], + [], + lineno=17, + col_offset=4, + end_lineno=20, + end_col_offset=70), + FunctionDef( + 'set_left', + arguments( + [], + [ + arg( + 'self', + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=21), + arg( + 'tree', + lineno=22, + col_offset=23, + end_lineno=22, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=12), + 'tree', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=17), + Constant( + 'left', + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=24), + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=25)], + Name( + 'tree', + Load(), + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=32), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=32), + Return( + Name( + 'self', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=19), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=19)], + [], + lineno=22, + col_offset=4, + end_lineno=24, + end_col_offset=19), + FunctionDef( + 'right', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=15), + 'tree', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=20), + Constant( + 'right', + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=28), + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=29), + [ + Is()], + [ + Constant( + None, + lineno=27, + col_offset=33, + end_lineno=27, + end_col_offset=37)], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=37), + [ + Return( + Constant( + None, + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=23), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=23)], + [], + lineno=27, + col_offset=8, + end_lineno=28, + end_col_offset=23), + Return( + Call( + Name( + 'Zipper', + Load(), + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=21), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=26), + 'tree', + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=31), + Constant( + 'right', + lineno=29, + col_offset=32, + end_lineno=29, + end_col_offset=39), + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=40), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=46), + 'ancestors', + Load(), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=56), + Add(), + List( + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=60, + end_lineno=29, + end_col_offset=64), + 'tree', + Load(), + lineno=29, + col_offset=60, + end_lineno=29, + end_col_offset=69)], + Load(), + lineno=29, + col_offset=59, + end_lineno=29, + end_col_offset=70), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=70)], + [], + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=71), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=71)], + [], + lineno=26, + col_offset=4, + end_lineno=29, + end_col_offset=71), + FunctionDef( + 'set_right', + arguments( + [], + [ + arg( + 'self', + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=22), + arg( + 'tree', + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'tree', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=17), + Constant( + 'right', + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=25), + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=26)], + Name( + 'tree', + Load(), + lineno=32, + col_offset=29, + end_lineno=32, + end_col_offset=33), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=33), + Return( + Name( + 'self', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=19), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=19)], + [], + lineno=31, + col_offset=4, + end_lineno=33, + end_col_offset=19), + FunctionDef( + 'up', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=19), + 'ancestors', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=29), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=29), + [ + Return( + Constant( + None, + lineno=37, + col_offset=19, + end_lineno=37, + end_col_offset=23), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=23)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=23), + Return( + Call( + Name( + 'Zipper', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=21), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=26), + 'ancestors', + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=36), + UnaryOp( + USub(), + Constant( + 1, + lineno=38, + col_offset=38, + end_lineno=38, + end_col_offset=39), + lineno=38, + col_offset=37, + end_lineno=38, + end_col_offset=39), + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=40), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=42, + end_lineno=38, + end_col_offset=46), + 'ancestors', + Load(), + lineno=38, + col_offset=42, + end_lineno=38, + end_col_offset=56), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=38, + col_offset=59, + end_lineno=38, + end_col_offset=60), + lineno=38, + col_offset=58, + end_lineno=38, + end_col_offset=60), + lineno=38, + col_offset=57, + end_lineno=38, + end_col_offset=60), + Load(), + lineno=38, + col_offset=42, + end_lineno=38, + end_col_offset=61)], + [], + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=62), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=62)], + [], + lineno=35, + col_offset=4, + end_lineno=38, + end_col_offset=62), + FunctionDef( + 'to_tree', + arguments( + [], + [ + arg( + 'self', + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Call( + Name( + 'any', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=14), + [ + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=19), + 'ancestors', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=29)], + [], + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=30), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=23), + 'ancestors', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=33), + Constant( + 0, + lineno=42, + col_offset=34, + end_lineno=42, + end_col_offset=35), + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=36), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=36)], + [], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=36), + Return( + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=19), + 'tree', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=24), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=24)], + [], + lineno=40, + col_offset=4, + end_lineno=43, + end_col_offset=24)], + [], + lineno=1, + col_offset=0, + end_lineno=43, + end_col_offset=24)], + []) +## END TREE BEFORE ## + +## BEGIN NORMALIZED TREE ## +Module( + [ + ClassDef( + 'placeholder_0', + [], + [], + [ + FunctionDef( + 'placeholder_1', + arguments( + [], + [ + arg( + 'placeholder_2', + lineno=3, + col_offset=18, + end_lineno=3, + end_col_offset=22)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=21), + [ + Call( + Name( + 'dict', + Load(), + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=26), + [ + Name( + 'placeholder_2', + Load(), + lineno=4, + col_offset=27, + end_lineno=4, + end_col_offset=31)], + [], + lineno=4, + col_offset=22, + end_lineno=4, + end_col_offset=32), + List( + [], + Load(), + lineno=4, + col_offset=34, + end_lineno=4, + end_col_offset=36)], + [], + lineno=4, + col_offset=15, + end_lineno=4, + end_col_offset=37), + lineno=4, + col_offset=8, + end_lineno=4, + end_col_offset=37)], + [ + Name( + 'staticmethod', + Load(), + lineno=2, + col_offset=5, + end_lineno=2, + end_col_offset=17)], + lineno=3, + col_offset=4, + end_lineno=4, + end_col_offset=37), + FunctionDef( + 'placeholder_3', + arguments( + [], + [ + arg( + 'self', + lineno=6, + col_offset=17, + end_lineno=6, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=6, + col_offset=23, + end_lineno=6, + end_col_offset=27), + arg( + 'placeholder_4', + lineno=6, + col_offset=29, + end_lineno=6, + end_col_offset=38)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=12), + 'placeholder_2', + Store(), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=17)], + Name( + 'placeholder_2', + Load(), + lineno=7, + col_offset=20, + end_lineno=7, + end_col_offset=24), + lineno=7, + col_offset=8, + end_lineno=7, + end_col_offset=24), + Assign( + [ + Attribute( + Name( + 'self', + Load(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=12), + 'placeholder_4', + Store(), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=22)], + Name( + 'placeholder_4', + Load(), + lineno=8, + col_offset=25, + end_lineno=8, + end_col_offset=34), + lineno=8, + col_offset=8, + end_lineno=8, + end_col_offset=34)], + [], + lineno=6, + col_offset=4, + end_lineno=8, + end_col_offset=34), + FunctionDef( + 'placeholder_5', + arguments( + [], + [ + arg( + 'self', + lineno=10, + col_offset=14, + end_lineno=10, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=24), + Constant( + 'value', + lineno=11, + col_offset=25, + end_lineno=11, + end_col_offset=32), + Load(), + lineno=11, + col_offset=15, + end_lineno=11, + end_col_offset=33), + lineno=11, + col_offset=8, + end_lineno=11, + end_col_offset=33)], + [], + lineno=10, + col_offset=4, + end_lineno=11, + end_col_offset=33), + FunctionDef( + 'placeholder_6', + arguments( + [], + [ + arg( + 'self', + lineno=13, + col_offset=18, + end_lineno=13, + end_col_offset=22), + arg( + 'placeholder_5', + lineno=13, + col_offset=24, + end_lineno=13, + end_col_offset=29)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=12), + 'placeholder_2', + Load(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=17), + Constant( + 'value', + lineno=14, + col_offset=18, + end_lineno=14, + end_col_offset=25), + Store(), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=26)], + Name( + 'placeholder_5', + Load(), + lineno=14, + col_offset=29, + end_lineno=14, + end_col_offset=34), + lineno=14, + col_offset=8, + end_lineno=14, + end_col_offset=34), + Return( + Name( + 'self', + Load(), + lineno=15, + col_offset=15, + end_lineno=15, + end_col_offset=19), + lineno=15, + col_offset=8, + end_lineno=15, + end_col_offset=19)], + [], + lineno=13, + col_offset=4, + end_lineno=15, + end_col_offset=19), + FunctionDef( + 'placeholder_7', + arguments( + [], + [ + arg( + 'self', + lineno=17, + col_offset=13, + end_lineno=17, + end_col_offset=17)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=15), + 'placeholder_2', + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=20), + Constant( + 'left', + lineno=18, + col_offset=21, + end_lineno=18, + end_col_offset=27), + Load(), + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=28), + [ + Is()], + [ + Constant( + None, + lineno=18, + col_offset=32, + end_lineno=18, + end_col_offset=36)], + lineno=18, + col_offset=11, + end_lineno=18, + end_col_offset=36), + [ + Return( + Constant( + None, + lineno=19, + col_offset=19, + end_lineno=19, + end_col_offset=23), + lineno=19, + col_offset=12, + end_lineno=19, + end_col_offset=23)], + [], + lineno=18, + col_offset=8, + end_lineno=19, + end_col_offset=23), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=21), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=26), + 'placeholder_2', + Load(), + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=31), + Constant( + 'left', + lineno=20, + col_offset=32, + end_lineno=20, + end_col_offset=38), + Load(), + lineno=20, + col_offset=22, + end_lineno=20, + end_col_offset=39), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=45), + 'placeholder_4', + Load(), + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=55), + Add(), + List( + [ + Attribute( + Name( + 'self', + Load(), + lineno=20, + col_offset=59, + end_lineno=20, + end_col_offset=63), + 'placeholder_2', + Load(), + lineno=20, + col_offset=59, + end_lineno=20, + end_col_offset=68)], + Load(), + lineno=20, + col_offset=58, + end_lineno=20, + end_col_offset=69), + lineno=20, + col_offset=41, + end_lineno=20, + end_col_offset=69)], + [], + lineno=20, + col_offset=15, + end_lineno=20, + end_col_offset=70), + lineno=20, + col_offset=8, + end_lineno=20, + end_col_offset=70)], + [], + lineno=17, + col_offset=4, + end_lineno=20, + end_col_offset=70), + FunctionDef( + 'placeholder_8', + arguments( + [], + [ + arg( + 'self', + lineno=22, + col_offset=17, + end_lineno=22, + end_col_offset=21), + arg( + 'placeholder_2', + lineno=22, + col_offset=23, + end_lineno=22, + end_col_offset=27)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=12), + 'placeholder_2', + Load(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=17), + Constant( + 'left', + lineno=23, + col_offset=18, + end_lineno=23, + end_col_offset=24), + Store(), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=25)], + Name( + 'placeholder_2', + Load(), + lineno=23, + col_offset=28, + end_lineno=23, + end_col_offset=32), + lineno=23, + col_offset=8, + end_lineno=23, + end_col_offset=32), + Return( + Name( + 'self', + Load(), + lineno=24, + col_offset=15, + end_lineno=24, + end_col_offset=19), + lineno=24, + col_offset=8, + end_lineno=24, + end_col_offset=19)], + [], + lineno=22, + col_offset=4, + end_lineno=24, + end_col_offset=19), + FunctionDef( + 'placeholder_9', + arguments( + [], + [ + arg( + 'self', + lineno=26, + col_offset=14, + end_lineno=26, + end_col_offset=18)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Compare( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=15), + 'placeholder_2', + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=20), + Constant( + 'right', + lineno=27, + col_offset=21, + end_lineno=27, + end_col_offset=28), + Load(), + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=29), + [ + Is()], + [ + Constant( + None, + lineno=27, + col_offset=33, + end_lineno=27, + end_col_offset=37)], + lineno=27, + col_offset=11, + end_lineno=27, + end_col_offset=37), + [ + Return( + Constant( + None, + lineno=28, + col_offset=19, + end_lineno=28, + end_col_offset=23), + lineno=28, + col_offset=12, + end_lineno=28, + end_col_offset=23)], + [], + lineno=27, + col_offset=8, + end_lineno=28, + end_col_offset=23), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=21), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=26), + 'placeholder_2', + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=31), + Constant( + 'right', + lineno=29, + col_offset=32, + end_lineno=29, + end_col_offset=39), + Load(), + lineno=29, + col_offset=22, + end_lineno=29, + end_col_offset=40), + BinOp( + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=46), + 'placeholder_4', + Load(), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=56), + Add(), + List( + [ + Attribute( + Name( + 'self', + Load(), + lineno=29, + col_offset=60, + end_lineno=29, + end_col_offset=64), + 'placeholder_2', + Load(), + lineno=29, + col_offset=60, + end_lineno=29, + end_col_offset=69)], + Load(), + lineno=29, + col_offset=59, + end_lineno=29, + end_col_offset=70), + lineno=29, + col_offset=42, + end_lineno=29, + end_col_offset=70)], + [], + lineno=29, + col_offset=15, + end_lineno=29, + end_col_offset=71), + lineno=29, + col_offset=8, + end_lineno=29, + end_col_offset=71)], + [], + lineno=26, + col_offset=4, + end_lineno=29, + end_col_offset=71), + FunctionDef( + 'placeholder_10', + arguments( + [], + [ + arg( + 'self', + lineno=31, + col_offset=18, + end_lineno=31, + end_col_offset=22), + arg( + 'placeholder_2', + lineno=31, + col_offset=24, + end_lineno=31, + end_col_offset=28)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + Assign( + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=12), + 'placeholder_2', + Load(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=17), + Constant( + 'right', + lineno=32, + col_offset=18, + end_lineno=32, + end_col_offset=25), + Store(), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=26)], + Name( + 'placeholder_2', + Load(), + lineno=32, + col_offset=29, + end_lineno=32, + end_col_offset=33), + lineno=32, + col_offset=8, + end_lineno=32, + end_col_offset=33), + Return( + Name( + 'self', + Load(), + lineno=33, + col_offset=15, + end_lineno=33, + end_col_offset=19), + lineno=33, + col_offset=8, + end_lineno=33, + end_col_offset=19)], + [], + lineno=31, + col_offset=4, + end_lineno=33, + end_col_offset=19), + FunctionDef( + 'placeholder_11', + arguments( + [], + [ + arg( + 'self', + lineno=35, + col_offset=11, + end_lineno=35, + end_col_offset=15)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + UnaryOp( + Not(), + Attribute( + Name( + 'self', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=19), + 'placeholder_4', + Load(), + lineno=36, + col_offset=15, + end_lineno=36, + end_col_offset=29), + lineno=36, + col_offset=11, + end_lineno=36, + end_col_offset=29), + [ + Return( + Constant( + None, + lineno=37, + col_offset=19, + end_lineno=37, + end_col_offset=23), + lineno=37, + col_offset=12, + end_lineno=37, + end_col_offset=23)], + [], + lineno=36, + col_offset=8, + end_lineno=37, + end_col_offset=23), + Return( + Call( + Name( + 'placeholder_0', + Load(), + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=21), + [ + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=26), + 'placeholder_4', + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=36), + UnaryOp( + USub(), + Constant( + 1, + lineno=38, + col_offset=38, + end_lineno=38, + end_col_offset=39), + lineno=38, + col_offset=37, + end_lineno=38, + end_col_offset=39), + Load(), + lineno=38, + col_offset=22, + end_lineno=38, + end_col_offset=40), + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=38, + col_offset=42, + end_lineno=38, + end_col_offset=46), + 'placeholder_4', + Load(), + lineno=38, + col_offset=42, + end_lineno=38, + end_col_offset=56), + Slice( + upper=UnaryOp( + USub(), + Constant( + 1, + lineno=38, + col_offset=59, + end_lineno=38, + end_col_offset=60), + lineno=38, + col_offset=58, + end_lineno=38, + end_col_offset=60), + lineno=38, + col_offset=57, + end_lineno=38, + end_col_offset=60), + Load(), + lineno=38, + col_offset=42, + end_lineno=38, + end_col_offset=61)], + [], + lineno=38, + col_offset=15, + end_lineno=38, + end_col_offset=62), + lineno=38, + col_offset=8, + end_lineno=38, + end_col_offset=62)], + [], + lineno=35, + col_offset=4, + end_lineno=38, + end_col_offset=62), + FunctionDef( + 'placeholder_12', + arguments( + [], + [ + arg( + 'self', + lineno=40, + col_offset=16, + end_lineno=40, + end_col_offset=20)], + kwonlyargs=[], + kw_defaults=[], + defaults=[]), + [ + If( + Call( + Name( + 'any', + Load(), + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=14), + [ + Attribute( + Name( + 'self', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=19), + 'placeholder_4', + Load(), + lineno=41, + col_offset=15, + end_lineno=41, + end_col_offset=29)], + [], + lineno=41, + col_offset=11, + end_lineno=41, + end_col_offset=30), + [ + Return( + Subscript( + Attribute( + Name( + 'self', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=23), + 'placeholder_4', + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=33), + Constant( + 0, + lineno=42, + col_offset=34, + end_lineno=42, + end_col_offset=35), + Load(), + lineno=42, + col_offset=19, + end_lineno=42, + end_col_offset=36), + lineno=42, + col_offset=12, + end_lineno=42, + end_col_offset=36)], + [], + lineno=41, + col_offset=8, + end_lineno=42, + end_col_offset=36), + Return( + Attribute( + Name( + 'self', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=19), + 'placeholder_2', + Load(), + lineno=43, + col_offset=15, + end_lineno=43, + end_col_offset=24), + lineno=43, + col_offset=8, + end_lineno=43, + end_col_offset=24)], + [], + lineno=40, + col_offset=4, + end_lineno=43, + end_col_offset=24)], + [], + lineno=1, + col_offset=0, + end_lineno=43, + end_col_offset=24)], + []) +## END NORMALIZED TREE ## \ No newline at end of file diff --git a/test/practice-zipper/representation.txt b/test/practice-zipper/representation.txt new file mode 100644 index 0000000..2a5eef1 --- /dev/null +++ b/test/practice-zipper/representation.txt @@ -0,0 +1 @@ +Module([ClassDef('placeholder_0', [], [], [FunctionDef('placeholder_1', arguments([], [arg('placeholder_2', lineno=3, col_offset=18, end_lineno=3, end_col_offset=22)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Call(Name('placeholder_0', Load(), lineno=4, col_offset=15, end_lineno=4, end_col_offset=21), [Call(Name('dict', Load(), lineno=4, col_offset=22, end_lineno=4, end_col_offset=26), [Name('placeholder_2', Load(), lineno=4, col_offset=27, end_lineno=4, end_col_offset=31)], [], lineno=4, col_offset=22, end_lineno=4, end_col_offset=32), List([], Load(), lineno=4, col_offset=34, end_lineno=4, end_col_offset=36)], [], lineno=4, col_offset=15, end_lineno=4, end_col_offset=37), lineno=4, col_offset=8, end_lineno=4, end_col_offset=37)], [Name('staticmethod', Load(), lineno=2, col_offset=5, end_lineno=2, end_col_offset=17)], lineno=3, col_offset=4, end_lineno=4, end_col_offset=37), FunctionDef('placeholder_3', arguments([], [arg('self', lineno=6, col_offset=17, end_lineno=6, end_col_offset=21), arg('placeholder_2', lineno=6, col_offset=23, end_lineno=6, end_col_offset=27), arg('placeholder_4', lineno=6, col_offset=29, end_lineno=6, end_col_offset=38)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Attribute(Name('self', Load(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=12), 'placeholder_2', Store(), lineno=7, col_offset=8, end_lineno=7, end_col_offset=17)], Name('placeholder_2', Load(), lineno=7, col_offset=20, end_lineno=7, end_col_offset=24), lineno=7, col_offset=8, end_lineno=7, end_col_offset=24), Assign([Attribute(Name('self', Load(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=12), 'placeholder_4', Store(), lineno=8, col_offset=8, end_lineno=8, end_col_offset=22)], Name('placeholder_4', Load(), lineno=8, col_offset=25, end_lineno=8, end_col_offset=34), lineno=8, col_offset=8, end_lineno=8, end_col_offset=34)], [], lineno=6, col_offset=4, end_lineno=8, end_col_offset=34), FunctionDef('placeholder_5', arguments([], [arg('self', lineno=10, col_offset=14, end_lineno=10, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Return(Subscript(Attribute(Name('self', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=19), 'placeholder_2', Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=24), Constant('value', lineno=11, col_offset=25, end_lineno=11, end_col_offset=32), Load(), lineno=11, col_offset=15, end_lineno=11, end_col_offset=33), lineno=11, col_offset=8, end_lineno=11, end_col_offset=33)], [], lineno=10, col_offset=4, end_lineno=11, end_col_offset=33), FunctionDef('placeholder_6', arguments([], [arg('self', lineno=13, col_offset=18, end_lineno=13, end_col_offset=22), arg('placeholder_5', lineno=13, col_offset=24, end_lineno=13, end_col_offset=29)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Subscript(Attribute(Name('self', Load(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=12), 'placeholder_2', Load(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=17), Constant('value', lineno=14, col_offset=18, end_lineno=14, end_col_offset=25), Store(), lineno=14, col_offset=8, end_lineno=14, end_col_offset=26)], Name('placeholder_5', Load(), lineno=14, col_offset=29, end_lineno=14, end_col_offset=34), lineno=14, col_offset=8, end_lineno=14, end_col_offset=34), Return(Name('self', Load(), lineno=15, col_offset=15, end_lineno=15, end_col_offset=19), lineno=15, col_offset=8, end_lineno=15, end_col_offset=19)], [], lineno=13, col_offset=4, end_lineno=15, end_col_offset=19), FunctionDef('placeholder_7', arguments([], [arg('self', lineno=17, col_offset=13, end_lineno=17, end_col_offset=17)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Subscript(Attribute(Name('self', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=15), 'placeholder_2', Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=20), Constant('left', lineno=18, col_offset=21, end_lineno=18, end_col_offset=27), Load(), lineno=18, col_offset=11, end_lineno=18, end_col_offset=28), [Is()], [Constant(None, lineno=18, col_offset=32, end_lineno=18, end_col_offset=36)], lineno=18, col_offset=11, end_lineno=18, end_col_offset=36), [Return(Constant(None, lineno=19, col_offset=19, end_lineno=19, end_col_offset=23), lineno=19, col_offset=12, end_lineno=19, end_col_offset=23)], [], lineno=18, col_offset=8, end_lineno=19, end_col_offset=23), Return(Call(Name('placeholder_0', Load(), lineno=20, col_offset=15, end_lineno=20, end_col_offset=21), [Subscript(Attribute(Name('self', Load(), lineno=20, col_offset=22, end_lineno=20, end_col_offset=26), 'placeholder_2', Load(), lineno=20, col_offset=22, end_lineno=20, end_col_offset=31), Constant('left', lineno=20, col_offset=32, end_lineno=20, end_col_offset=38), Load(), lineno=20, col_offset=22, end_lineno=20, end_col_offset=39), BinOp(Attribute(Name('self', Load(), lineno=20, col_offset=41, end_lineno=20, end_col_offset=45), 'placeholder_4', Load(), lineno=20, col_offset=41, end_lineno=20, end_col_offset=55), Add(), List([Attribute(Name('self', Load(), lineno=20, col_offset=59, end_lineno=20, end_col_offset=63), 'placeholder_2', Load(), lineno=20, col_offset=59, end_lineno=20, end_col_offset=68)], Load(), lineno=20, col_offset=58, end_lineno=20, end_col_offset=69), lineno=20, col_offset=41, end_lineno=20, end_col_offset=69)], [], lineno=20, col_offset=15, end_lineno=20, end_col_offset=70), lineno=20, col_offset=8, end_lineno=20, end_col_offset=70)], [], lineno=17, col_offset=4, end_lineno=20, end_col_offset=70), FunctionDef('placeholder_8', arguments([], [arg('self', lineno=22, col_offset=17, end_lineno=22, end_col_offset=21), arg('placeholder_2', lineno=22, col_offset=23, end_lineno=22, end_col_offset=27)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Subscript(Attribute(Name('self', Load(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=12), 'placeholder_2', Load(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=17), Constant('left', lineno=23, col_offset=18, end_lineno=23, end_col_offset=24), Store(), lineno=23, col_offset=8, end_lineno=23, end_col_offset=25)], Name('placeholder_2', Load(), lineno=23, col_offset=28, end_lineno=23, end_col_offset=32), lineno=23, col_offset=8, end_lineno=23, end_col_offset=32), Return(Name('self', Load(), lineno=24, col_offset=15, end_lineno=24, end_col_offset=19), lineno=24, col_offset=8, end_lineno=24, end_col_offset=19)], [], lineno=22, col_offset=4, end_lineno=24, end_col_offset=19), FunctionDef('placeholder_9', arguments([], [arg('self', lineno=26, col_offset=14, end_lineno=26, end_col_offset=18)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Compare(Subscript(Attribute(Name('self', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=15), 'placeholder_2', Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=20), Constant('right', lineno=27, col_offset=21, end_lineno=27, end_col_offset=28), Load(), lineno=27, col_offset=11, end_lineno=27, end_col_offset=29), [Is()], [Constant(None, lineno=27, col_offset=33, end_lineno=27, end_col_offset=37)], lineno=27, col_offset=11, end_lineno=27, end_col_offset=37), [Return(Constant(None, lineno=28, col_offset=19, end_lineno=28, end_col_offset=23), lineno=28, col_offset=12, end_lineno=28, end_col_offset=23)], [], lineno=27, col_offset=8, end_lineno=28, end_col_offset=23), Return(Call(Name('placeholder_0', Load(), lineno=29, col_offset=15, end_lineno=29, end_col_offset=21), [Subscript(Attribute(Name('self', Load(), lineno=29, col_offset=22, end_lineno=29, end_col_offset=26), 'placeholder_2', Load(), lineno=29, col_offset=22, end_lineno=29, end_col_offset=31), Constant('right', lineno=29, col_offset=32, end_lineno=29, end_col_offset=39), Load(), lineno=29, col_offset=22, end_lineno=29, end_col_offset=40), BinOp(Attribute(Name('self', Load(), lineno=29, col_offset=42, end_lineno=29, end_col_offset=46), 'placeholder_4', Load(), lineno=29, col_offset=42, end_lineno=29, end_col_offset=56), Add(), List([Attribute(Name('self', Load(), lineno=29, col_offset=60, end_lineno=29, end_col_offset=64), 'placeholder_2', Load(), lineno=29, col_offset=60, end_lineno=29, end_col_offset=69)], Load(), lineno=29, col_offset=59, end_lineno=29, end_col_offset=70), lineno=29, col_offset=42, end_lineno=29, end_col_offset=70)], [], lineno=29, col_offset=15, end_lineno=29, end_col_offset=71), lineno=29, col_offset=8, end_lineno=29, end_col_offset=71)], [], lineno=26, col_offset=4, end_lineno=29, end_col_offset=71), FunctionDef('placeholder_10', arguments([], [arg('self', lineno=31, col_offset=18, end_lineno=31, end_col_offset=22), arg('placeholder_2', lineno=31, col_offset=24, end_lineno=31, end_col_offset=28)], kwonlyargs=[], kw_defaults=[], defaults=[]), [Assign([Subscript(Attribute(Name('self', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=12), 'placeholder_2', Load(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=17), Constant('right', lineno=32, col_offset=18, end_lineno=32, end_col_offset=25), Store(), lineno=32, col_offset=8, end_lineno=32, end_col_offset=26)], Name('placeholder_2', Load(), lineno=32, col_offset=29, end_lineno=32, end_col_offset=33), lineno=32, col_offset=8, end_lineno=32, end_col_offset=33), Return(Name('self', Load(), lineno=33, col_offset=15, end_lineno=33, end_col_offset=19), lineno=33, col_offset=8, end_lineno=33, end_col_offset=19)], [], lineno=31, col_offset=4, end_lineno=33, end_col_offset=19), FunctionDef('placeholder_11', arguments([], [arg('self', lineno=35, col_offset=11, end_lineno=35, end_col_offset=15)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(UnaryOp(Not(), Attribute(Name('self', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=19), 'placeholder_4', Load(), lineno=36, col_offset=15, end_lineno=36, end_col_offset=29), lineno=36, col_offset=11, end_lineno=36, end_col_offset=29), [Return(Constant(None, lineno=37, col_offset=19, end_lineno=37, end_col_offset=23), lineno=37, col_offset=12, end_lineno=37, end_col_offset=23)], [], lineno=36, col_offset=8, end_lineno=37, end_col_offset=23), Return(Call(Name('placeholder_0', Load(), lineno=38, col_offset=15, end_lineno=38, end_col_offset=21), [Subscript(Attribute(Name('self', Load(), lineno=38, col_offset=22, end_lineno=38, end_col_offset=26), 'placeholder_4', Load(), lineno=38, col_offset=22, end_lineno=38, end_col_offset=36), UnaryOp(USub(), Constant(1, lineno=38, col_offset=38, end_lineno=38, end_col_offset=39), lineno=38, col_offset=37, end_lineno=38, end_col_offset=39), Load(), lineno=38, col_offset=22, end_lineno=38, end_col_offset=40), Subscript(Attribute(Name('self', Load(), lineno=38, col_offset=42, end_lineno=38, end_col_offset=46), 'placeholder_4', Load(), lineno=38, col_offset=42, end_lineno=38, end_col_offset=56), Slice(upper=UnaryOp(USub(), Constant(1, lineno=38, col_offset=59, end_lineno=38, end_col_offset=60), lineno=38, col_offset=58, end_lineno=38, end_col_offset=60), lineno=38, col_offset=57, end_lineno=38, end_col_offset=60), Load(), lineno=38, col_offset=42, end_lineno=38, end_col_offset=61)], [], lineno=38, col_offset=15, end_lineno=38, end_col_offset=62), lineno=38, col_offset=8, end_lineno=38, end_col_offset=62)], [], lineno=35, col_offset=4, end_lineno=38, end_col_offset=62), FunctionDef('placeholder_12', arguments([], [arg('self', lineno=40, col_offset=16, end_lineno=40, end_col_offset=20)], kwonlyargs=[], kw_defaults=[], defaults=[]), [If(Call(Name('any', Load(), lineno=41, col_offset=11, end_lineno=41, end_col_offset=14), [Attribute(Name('self', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=19), 'placeholder_4', Load(), lineno=41, col_offset=15, end_lineno=41, end_col_offset=29)], [], lineno=41, col_offset=11, end_lineno=41, end_col_offset=30), [Return(Subscript(Attribute(Name('self', Load(), lineno=42, col_offset=19, end_lineno=42, end_col_offset=23), 'placeholder_4', Load(), lineno=42, col_offset=19, end_lineno=42, end_col_offset=33), Constant(0, lineno=42, col_offset=34, end_lineno=42, end_col_offset=35), Load(), lineno=42, col_offset=19, end_lineno=42, end_col_offset=36), lineno=42, col_offset=12, end_lineno=42, end_col_offset=36)], [], lineno=41, col_offset=8, end_lineno=42, end_col_offset=36), Return(Attribute(Name('self', Load(), lineno=43, col_offset=15, end_lineno=43, end_col_offset=19), 'placeholder_2', Load(), lineno=43, col_offset=15, end_lineno=43, end_col_offset=24), lineno=43, col_offset=8, end_lineno=43, end_col_offset=24)], [], lineno=40, col_offset=4, end_lineno=43, end_col_offset=24)], [], lineno=1, col_offset=0, end_lineno=43, end_col_offset=24)], []) \ No newline at end of file diff --git a/test/practice-zipper/zipper.py b/test/practice-zipper/zipper.py new file mode 100644 index 0000000..570771d --- /dev/null +++ b/test/practice-zipper/zipper.py @@ -0,0 +1,43 @@ +class Zipper: + @staticmethod + def from_tree(tree): + return Zipper(dict(tree), []) + + def __init__(self, tree, ancestors): + self.tree = tree + self.ancestors = ancestors + + def value(self): + return self.tree['value'] + + def set_value(self, value): + self.tree['value'] = value + return self + + def left(self): + if self.tree['left'] is None: + return None + return Zipper(self.tree['left'], self.ancestors + [self.tree]) + + def set_left(self, tree): + self.tree['left'] = tree + return self + + def right(self): + if self.tree['right'] is None: + return None + return Zipper(self.tree['right'], self.ancestors + [self.tree]) + + def set_right(self, tree): + self.tree['right'] = tree + return self + + def up(self): + if not self.ancestors: + return None + return Zipper(self.ancestors[-1], self.ancestors[:-1]) + + def to_tree(self): + if any(self.ancestors): + return self.ancestors[0] + return self.tree diff --git a/test/test_representer.py b/test/test_representer.py index a105605..c7f2158 100644 --- a/test/test_representer.py +++ b/test/test_representer.py @@ -1,439 +1,129 @@ -import unittest -from textwrap import dedent -from representer import Representer -from representer.utils import reformat - - -class RepresenterNormalizationTest(unittest.TestCase): - def normalize_code(self, source: str) -> str: - """ - Normalize source to generated code. - """ - representer = Representer(source) - representer.normalize() - return representer.dump_code() - - def assertCodeEqual(self, first, second, msg=None): - """ - Assert that the pieces of code are equal, after formatting. - """ - received = self.normalize_code(dedent(first)) - expected = reformat(dedent(second)) - self.assertEqual(received, expected, msg) - - def test_module_empty(self): - before = "" - expect = before - self.assertCodeEqual(before, expect) - - def test_module_comments_ignored(self): - before = """\ - # comment - # comment - """ - expect = "" - self.assertCodeEqual(before, expect) - - def test_module_docstring_ignored(self): - before = '''\ - """ - Module level docstring - """ - ''' - expect = "" - self.assertCodeEqual(before, expect) - - def test_import(self): - before = """\ - import mod - import moda, modb - mod.name + modea.namea / modeb.nameb - """ - expect = before - self.assertCodeEqual(before, expect) - - def test_import_as(self): - before = """\ - import mod as name - import moda as namea, modb as nameb - name + namea / nameb - """ - expect = """\ - import mod as placeholder_0 - import moda as placeholder_1, modb as placeholder_2 - placeholder_0 + placeholder_1 / placeholder_2 - """ - self.assertCodeEqual(before, expect) - - def test_from_import(self): - before = """\ - from mod import name - from modb import namea, nameb - name + namea / nameb - """ - expect = before - self.assertCodeEqual(before, expect) - - def test_from_import_star(self): - before = """\ - from mod import * - print(star_name) - print(star_name.attribute) - """ - expect = before - self.assertCodeEqual(before, expect) - - def test_from_import_as(self): - before = """\ - from mod import name as aname - from modb import namea as anamea, nameb as anameb - aname + anamea / anameb - """ - expect = """\ - from mod import name as placeholder_0 - from modb import namea as placeholder_1, nameb as placeholder_2 - placeholder_0 + placeholder_1 / placeholder_2 - """ - self.assertCodeEqual(before, expect) - - def test_with(self): - before = """\ - with open("file.txt", "r"): - pass - """ - expect = before - self.assertCodeEqual(before, expect) - - def test_with_as(self): - before = """\ - with open("in", "r") as src, open("out", "w") as dst: - dst.write(src.read()) - """ - expect = """\ - with open("in", "r") as placeholder_0, open("out", "w") as placeholder_1: - placeholder_1.write(placeholder_0.read()) - """ - self.assertCodeEqual(before, expect) - - def test_try_except(self): - before = """\ - try: - raise TypeError from ValueError("foo") - except (TypeError, ValueError): - sys.exit(2) - else: - sys.exit(0) - finally: - sys.exit(1) - """ - expect = before - self.assertCodeEqual(before, expect) - - def test_try_except_as(self): - before = """\ - try: - raise TypeError from ValueError("foo") - except (TypeError, ValueError) as err: - print(err) - sys.exit(2) - else: - sys.exit(0) - finally: - sys.exit(1) - """ - expect = """\ - try: - raise TypeError from ValueError("foo") - except (TypeError, ValueError) as placeholder_0: - print(placeholder_0) - sys.exit(2) - else: - sys.exit(0) - finally: - sys.exit(1) - """ - self.assertCodeEqual(before, expect) - - def test_with_list_comprehension(self): - before = "[i + 1 for i in range(5) if not i % 2]" - expect = ( - "[(placeholder_0 + 1) for placeholder_0 in range(5)" - "if not placeholder_0 % 2]" - ) - self.assertCodeEqual(before, expect) - - def test_with_set_comprehension(self): - before = "{i + 1 for i in range(5) if not i % 2}" - expect = ( - "{(placeholder_0 + 1) for placeholder_0 in range(5)" - "if not placeholder_0 % 2}" - ) - self.assertCodeEqual(before, expect) - - def test_with_generator_comprehension(self): - before = "(i + 1 for i in range(5) if not i % 2)" - expect = ( - "(placeholder_0 + 1 for placeholder_0 in range(5)" - "if not placeholder_0 % 2)" - ) - self.assertCodeEqual(before, expect) - - def test_with_dict_comprehension(self): - before = "{k: None for k in range(5) if not k % 2}" - expect = ( - "{placeholder_0 : None for placeholder_0 in range(5)" - "if not placeholder_0 % 2}" - ) - self.assertCodeEqual(before, expect) - - def test_with_list_compound_comprehension(self): - before = "[i + n for i in range(5) for n in range(5) if not i % 2]" - expect = ( - "[(placeholder_0 + placeholder_1) for placeholder_0 in range(5)" - "for placeholder_1 in range(5) if not placeholder_0 % 2]" - ) - self.assertCodeEqual(before, expect) - - def test_with_set_compound_comprehension(self): - before = "{i + n for i in range(5) for n in range(5) if not i % 2}" - expect = ( - "{(placeholder_0 + placeholder_1) for placeholder_0 in range(5)" - "for placeholder_1 in range(5) if not placeholder_0 % 2}" - ) - self.assertCodeEqual(before, expect) - - def test_with_generator_compound_comprehension(self): - before = "(i + n for i in range(5) for n in range(5) if not i % 2)" - expect = ( - "(placeholder_0 + placeholder_1 for placeholder_0 in range(5)" - "for placeholder_1 in range(5) if not placeholder_0 % 2)" - ) - self.assertCodeEqual(before, expect) - - def test_with_dict_compound_comprehension(self): - before = "{k: v for k in range(5) for v in range(5) if not k % 2}" - expect = ( - "{placeholder_0 : placeholder_1 for placeholder_0 in range(5)" - "for placeholder_1 in range(5) if not placeholder_0 % 2}" - ) - self.assertCodeEqual(before, expect) - - def test_for_loop(self): - before = """\ - for name in range(21): - print(name + 1) - """ - expect = """\ - for placeholder_0 in range(21): - print(placeholder_0 + 1) - """ - self.assertCodeEqual(before, expect) - - def test_for_loop_with_expansion(self): - before = """\ - for idx, item in enumerate(range(21)): - print(idx, item) - """ - expect = """\ - for placeholder_0, placeholder_1 in enumerate(range(21)): - print(placeholder_0, placeholder_1) - """ - self.assertCodeEqual(before, expect) - - def test_i_am_the_walrus(self): - before = """\ - while name := True: - print(name) - """ - expect = """\ - while (placeholder_0 := True): - print(placeholder_0) - """ - self.assertCodeEqual(before, expect) - - def test_simple_assignment(self): - before = """\ - x = 10 - y = x + 10 - x = x + y - x, y = y, x - """ - expect = """\ - placeholder_0 = 10 - placeholder_1 = placeholder_0 + 10 - placeholder_0 = placeholder_0 + placeholder_1 - placeholder_0, placeholder_1 = placeholder_1, placeholder_0 - """ - self.assertCodeEqual(before, expect) - - def test_augmented_assignment(self): - before = """\ - x = 10 - y = x + 10 - x += y - y *= 0 - """ - expect = """\ - placeholder_0 = 10 - placeholder_1 = placeholder_0 + 10 - placeholder_0 += placeholder_1 - placeholder_1 *= 0 - """ - self.assertCodeEqual(before, expect) - - def test_def_functions(self): - before = """\ - def func(posarg, defarg=None, *varargs, **nameargs): - ''' - Docstrings are ignored. - ''' - # comments are ignored - with func() as name: - for item in name: - print(item) - return item - """ - expect = """\ - def placeholder_0(placeholder_1, placeholder_2=None, - *placeholder_3, **placeholder_4): - with placeholder_0() as placeholder_5: - for placeholder_6 in placeholder_5: - print(placeholder_6) - return placeholder_6 - """ - self.assertCodeEqual(before, expect) - - def test_def_functions_with_annotations_in_signature(self): - before = """\ - def func(a: int, b: int) -> int: - return a + b - """ - expect = """\ - def placeholder_0(placeholder_1, placeholder_2): - return placeholder_1 + placeholder_2 - """ - self.assertCodeEqual(before, expect) - - def test_def_functions_with_annotations_in_body(self): - before = """\ - def func(a: int, b: int) -> int: - c: int = 2 - return a + b + c - """ - expect = """\ - def placeholder_0(placeholder_1, placeholder_2): - placeholder_3 = 2 - return placeholder_1 + placeholder_2 + placeholder_3 - """ - self.assertCodeEqual(before, expect) - - def test_async_def_functions(self): - before = """\ - async def afunc(posarg, defarg=None, *varargs, **nameargs): - ''' - Docstrings are ignored - ''' - # comments are ignored - async with afunc() as aname: - async for item in aname: - print(item) - await afunc() - """ - expect = """\ - async def placeholder_0(placeholder_1, placeholder_2=None, - *placeholder_3, **placeholder_4): - async with placeholder_0() as placeholder_5: - async for placeholder_6 in placeholder_5: - print(placeholder_6) - await placeholder_0() - """ - self.assertCodeEqual(before, expect) - - def test_class_def_no_inheritance(self): - before = """\ - class Foo: - ''' - Docstrings are ignored. - ''' - class_attr = 2 - - def method(self, posarg, defarg=None, *varargs, **nameargs): - ''' - Docstrings are ignored. - ''' - # comments are ignored - self.instance_attr = self.class_attr + 2 # not self is preserved - """ - expect = """\ - class placeholder_0: - placeholder_1 = 2 - - def placeholder_2( - self, placeholder_3, placeholder_4=None, *placeholder_5, **placeholder_6 - ): - self.placeholder_7 = self.placeholder_1 + 2 - """ - self.assertCodeEqual(before, expect) - - def test_class_def_no_inheritance(self): - before = """\ - class Bar: pass - - class Foo(Bar): - ''' - Docstrings are ignored. - ''' - class_attr = 2 - - def method(self, posarg, defarg=None, *varargs, **nameargs): - ''' - Docstrings are ignored. - ''' - # comments are ignored - self.instance_attr = self.class_attr + 2 # not self is preserved - """ - expect = """\ - class placeholder_0: pass - - class placeholder_1(placeholder_0): - placeholder_2 = 2 - - def placeholder_3( - self, placeholder_4, placeholder_5=None, *placeholder_6, **placeholder_7 - ): - self.placeholder_8 = self.placeholder_2 + 2 - """ - self.assertCodeEqual(before, expect) - - @unittest.skip("TODO: HANDLE METACLASS ASSIGNMENT") - def test_class_with_metaclass(self): - before = """\ - from abc import ABCMeta - - class MyABC(metaclass=ABCMeta): - pass - """ - expect = """\ - from abc import ABCMeta - - class placeholder_0(metaclass=ABCMeta): - pass - """ - self.assertCodeEqual(before, expect) - - def test_lambda_def(self): - before = """\ - lambda : None - lambda a : a + 10 - lambda x,y : x + y - """ - expect = """\ - lambda : None - lambda placeholder_0 : placeholder_0 + 10 - lambda placeholder_1,placeholder_2 : placeholder_1 + placeholder_2 - """ - self.assertCodeEqual(before, expect) - - -if __name__ == "__main__": - unittest.main() +""" +Run tests on the test runner itself, using golden files. +""" + +import json +import subprocess +import os +import tempfile +from pathlib import Path + + +import pytest + +ROOT = Path(__file__).parent +REPRESENTER = ROOT.joinpath("..", "bin", "run.sh").resolve(strict=True) +TESTS = sorted(ROOT.glob("example*/example_*.py")) +CONCEPT_EXERCISES = sorted(ROOT.glob("concept*/*.py")) +PRACTICE_EXERCISES = sorted(ROOT.glob("practice*/*.py")) + +def run_in_subprocess(test_path, golden_path, args=None): + """ + Run given tests against the given golden file. + """ + exercise_dir = test_path.parent + exercise_name = exercise_dir.name + with tempfile.TemporaryDirectory(prefix="test-representer-tests", dir=ROOT) as tmp_dir: + rc = subprocess.run([REPRESENTER, exercise_name, exercise_dir, tmp_dir]).returncode + + mapping = Path(tmp_dir).joinpath("mapping.json").resolve(strict=True) + representation_json = Path(tmp_dir).joinpath("representation.json").resolve(strict=True) + representation_out = Path(tmp_dir).joinpath("representation.out").resolve(strict=True) + representation_txt = Path(tmp_dir).joinpath("representation.txt").resolve(strict=True) + + golden_mapping, golden_representation_json, golden_representation_out, golden_representation_txt = golden_path + + results = mapping, representation_json, representation_out, representation_txt + + return ((json.loads(mapping.read_text()), json.loads(golden_mapping.read_text())), + (json.loads(representation_json.read_text()), json.loads(golden_representation_json.read_text())), + (representation_out.read_text(), golden_representation_out.read_text()), + (representation_txt.read_text(), golden_representation_txt.read_text())), rc + + +@pytest.fixture(params=TESTS, ids=(os.path.split(path)[0].split("/")[-1] for path in TESTS)) +def test_with_golden(request): + """ + Path to a test and its golden files. + """ + path = request.param + + golden_mapping = path.parent.joinpath("mapping.json").resolve(strict=True) + golden_representation_json = path.parent.joinpath("representation.json").resolve(strict=True) + golden_representation_out = path.parent.joinpath("representation.out").resolve(strict=True) + golden_representation_txt = path.parent.joinpath("representation.txt").resolve(strict=True) + + golden = (golden_mapping, golden_representation_json, golden_representation_out, golden_representation_txt) + + + return path, golden + +@pytest.fixture(params=CONCEPT_EXERCISES, ids=(os.path.split(path)[0].split("/")[-1][8:] for path in CONCEPT_EXERCISES)) +def test_concept_exercises_with_golden(request): + """ + Path to a test and its golden files. + """ + path = request.param + + golden_mapping = path.parent.joinpath("mapping.json").resolve(strict=True) + golden_representation_json = path.parent.joinpath("representation.json").resolve(strict=True) + golden_representation_out = path.parent.joinpath("representation.out").resolve(strict=True) + golden_representation_txt = path.parent.joinpath("representation.txt").resolve(strict=True) + + golden = (golden_mapping, golden_representation_json, golden_representation_out, golden_representation_txt) + + + return path, golden + +@pytest.fixture(params=PRACTICE_EXERCISES, ids=(os.path.split(path)[0].split("/")[-1][9:] for path in PRACTICE_EXERCISES)) +def test_practice_exercises_with_golden(request): + """ + Path to a test and its golden files. + """ + path = request.param + + golden_mapping = path.parent.joinpath("mapping.json").resolve(strict=True) + golden_representation_json = path.parent.joinpath("representation.json").resolve(strict=True) + golden_representation_out = path.parent.joinpath("representation.out").resolve(strict=True) + golden_representation_txt = path.parent.joinpath("representation.txt").resolve(strict=True) + + golden = (golden_mapping, golden_representation_json, golden_representation_out, golden_representation_txt) + + + return path, golden + +def test_results_matches_golden_file(test_with_golden): + """ + Test that the results of a run matches the golden file. + """ + + results, rc = run_in_subprocess(*test_with_golden) + + for result, golden in results: + assert result == golden, "results must match the golden file" + + assert rc == 0, f"return code must be 0 even when errors occur: got {rc}" + +def test_concept_exercises_match_golden_file(test_concept_exercises_with_golden): + """ + Test that the results of a run matches the golden file. + """ + + results, rc = run_in_subprocess(*test_concept_exercises_with_golden) + + for result, golden in results: + assert result == golden, "results must match the golden file" + + assert rc == 0, f"return code must be 0 even when errors occur: got {rc}" + +def test_practice_exercises_match_golden_file(test_practice_exercises_with_golden): + """ + Test that the results of a run matches the golden file. + """ + + results, rc = run_in_subprocess(*test_practice_exercises_with_golden) + + for result, golden in results: + assert result == golden, "results must match the golden file" + + assert rc == 0, f"return code must be 0 even when errors occur: got {rc}" \ No newline at end of file