-
Notifications
You must be signed in to change notification settings - Fork 21
Python Implementation of Ubisoft's Clever-Initiative coding challenge #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
lbajolet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.