Python Implementation of Ubisoft's Clever-Initiative coding challenge#13
Open
andykdy wants to merge 11 commits intoMathieuNls:masterfrom
Open
Python Implementation of Ubisoft's Clever-Initiative coding challenge#13andykdy wants to merge 11 commits intoMathieuNls:masterfrom
andykdy wants to merge 11 commits intoMathieuNls:masterfrom
Conversation
lbajolet
reviewed
Mar 4, 2019
lbajolet
left a comment
There was a problem hiding this comment.
Overall it's concise, and the results are close to what is expected (the file list needs a rework)
The runtime looks ok to me, ~400ms for diff1; I guess a full run on all files takes ~450ms, a note on performance might have been nice though.
The commit's contents and messages look off in a few places (160e8e7 especially comes to mind).
Sorry for the delay for the review.
chadykamar
reviewed
Mar 4, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello, I have implemented a solution for your challenge using Python.
Part 1: Diff Logger
Instruction : python -p 1 -f <location of diff file>
There is a regex pattern for each stat being logged.
Each line of the diff file is checked using each pattern.
Depending on the stat, a counter is incremented, a value is appended to a list, or both in the case of function calls.
Known problems:
functionCalls will catch offsets from assembly code as a function call.
e.g. In the line
- "movl 8(%ebp),%eax \n\t"'8' will be noted as a function call which isn't correct.
Possible improvement:
I could see a modular approach to this question where each stat being recorded could be compartmentalized with its own regex pattern and method of storage.
For example,
Stat Name : Lineadded
Regex Pattern :
^(\+).*When Found: Increment
This way, the user could create new stats easily without having to change the code allowing extension but not modification.
Part 2: Variable declarations in Abstract Syntax Tree
Instruction : python -p 2 -f <astChallenge.json>
All variables are located within a 'VariableDeclaration' node, thus the code traverses through the AST recursively and stores all 'VariableDeclaration' nodes to a list.
Each 'VariableDeclaration' node in the list is then converted into a tuple.
The name of the variable is found under VariableDeclarator while the type of the variable is found under PredefinedType.