├── .gitignore ├── Contributing.md ├── README.md └── Solution.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Hi there! We're thrilled to have you contribute to our Symbl repository. 4 | 5 | 6 | ## Symbl.ai Github Externship Assignment 7 | 8 | For the recruitment process, please follow the below steps to solve the assignment. 9 | 10 | - Read the [problem statement](https://github.com/symblai/Github-Externship-Assignment/blob/main/README.md) carefully. 11 | - Follow the [developers guide](#developers-guide) to setup the repository on your machine. 12 | - Open [Solution.js](https://github.com/symblai/Github-Externship-Assignment/blob/main/Solution.js) file and implement and test your solution locally. 13 | - Once tested, commit the solution and raise a PR against `main` branch of [base](https://github.com/symblai/Github-Externship-Assignment) repository. 14 | 15 | > **Note:** _Your submissions will be checked for plagiarism._ 16 | ## Developers Guide 17 | This developer guide should be able to help you understand the steps on contributing effectively to this assignment. If you are new to the Git workflow process read the guide carefully. 18 | 19 | > Before you push your codes to the repository, please ensure you pull from the repository to avoid merge conflicts. 20 | 21 | git pull upstream main 22 | 23 | ### Main is the default branch. 24 | 25 | - Fork the repository to generate a copy of your own. 26 | 27 | - Clone the repository. 28 | 29 | ``` 30 | git clone 'your forked repo link' 31 | 32 | ``` 33 | 34 | - Checkout from main branch to a new branch 35 | ``` 36 | git checkout -b feat/chore/bugs/fix/docs(just choose one)/branch-name 37 | ``` 38 | - Make the original Github-Externship-Assignment repository the remote upstream (at upstream) 39 | ``` 40 | git remote add upstream https://github.com/symblai/Github-Externship-Assignment.git 41 | ``` 42 | - To confirm the remote upstream/origin 43 | 44 | ``` 45 | git remote -v 46 | ``` 47 | 48 | - Make your changes, add them 49 | 50 | ``` 51 | git add . 52 | ``` 53 | 54 | Make your commits 55 | 56 | ``` 57 | git commit -m "your message" 58 | ``` 59 | 60 | Write good commit messages, this is very important, so people reviewing can know what your fix, feature e.t.c. is doing 61 | 62 | - Push your codes to the branch on your forked remote upstream repository - 63 | "for-example: git push origin feat/landing-page" 64 | 65 | ``` 66 | git push origin your-branch-name 67 | ``` 68 | 69 | Make your Pull request from that branch of your repository to the main branch of this (Github-Externship-Assignment) repo and wait for it to be reviewed. 70 | 71 | Write good commit messages, this is very important, so people reviewing can know what your fix, feature e.t.c. is doing. 72 | Your PR should carry the story / task URL (instruction from above). 73 | if you are going to make changes to an existing code, state why you are doing so in the commit messages. 74 | 75 | It is not just about the code, user workflow matters too!! 76 | 77 | ## Commit Structure 78 | 79 | - type: subject e.g body, footer 80 | 81 | The title consists of the type of the message and subject. 82 | The type is contained within the title and can be one of these types: 83 | 84 | - feat: a new feature 85 | 86 | - fix: a bug fix 87 | 88 | - docs: changes to documentation 89 | 90 | - style: formatting, missing semi colons, etc; no code change 91 | 92 | - refactor: refactoring production code 93 | 94 | - test: adding tests, refactoring test; no production code change 95 | 96 | - chore: updating build tasks, package manager configs, etc; no production code change 97 | 98 | **An example of a good commit message** 99 | 100 | feat: Make login check for email and password 101 | 102 | More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the 103 | subject of the commit and the rest of the text as the body. The blank line separating the summary from the body is critical (unless 104 | you omit the body entirely); various tools like `log, shortlog and rebase` can get confused if you run the two together. 105 | Explain the problem that this commit is solving. Focus on why you are making this change as opposed to how (the code explains that). 106 | Are there side effects or other unintuitive consequenses of this change? Here's the place to explain them. 107 | 108 | - Further paragraphs come after blank lines. 109 | 110 | * Bullet points are okay, too 111 | * Typically a hyphen or asterisk is used for the bullet, preceded 112 | by a single space, with blank lines in between, but conventions 113 | vary here 114 | 115 | - If you use an issue tracker, put references to them at the bottom, 116 | like this: 117 | Resolves: #123 118 | See also: #456, #789 119 | And if your commit is just a simple thing, then make the message very short, but not just a title 120 | 121 | ### Have fun coding!! :) 122 | 123 | ## Resources 124 | 125 | - [How to contribute to open source on GitHub](https://guides.github.com/activities/contributing-to-open-source/) 126 | - [Using Pull Requests](https://help.github.com/articles/using-pull-requests/) 127 | - [GitHub Help](https://help.github.com) 128 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Github Externship Assignment 2 | 3 | ## Problem statement 4 | 5 | You are given a String equation containing an equation of the form `A * B + C = D`, where A, B, C and D are positive integers that don't have leading zeros. \ 6 | One digit in the equation is missing. \ 7 | Determine and return the correct digit. \ 8 | If the missing digit cannot be determined (i.e., there is no solution or there is more than one solution), return `-1` instead. 9 | 10 | ### Definition 11 | 12 | * **Class**: `FixEquation` 13 | * **Method** : `findMissingDigit` 14 | * **Parameters** : `String` 15 | * **Returns** : `Integer` 16 | * **Method signature** : `function findMissingDigit(equation)` 17 | 18 | 19 | > Note: A digit is correct if and only if it produces a valid equation in which A, B, C and D are positive integers with no leading zeros. 20 | 21 | ### Constraints 22 | - Equation will have the form `A * B + C = D`. 23 | - Each of A, B, C, D will be a nonempty string of 1 to 4 characters, i.e., `1 <= length of A, B, C, D <= 4`. 24 | - Each character in each of A, B, C, D will be either a digit ('0'-'9') or a question mark ('?'). 25 | - There will be exactly one question mark in equation. 26 | - The numbers represented by A, B, C, D will not have leading zeros. 27 | 28 | ### Test Cases 29 | :one: 30 | ``` 31 | Equation: 42 * 47 + 2 = 1?76 32 | 33 | Returns: 9 34 | 35 | We know that 42 * 47 + 2 = 1974, so the missing digit is 9. 36 | ``` 37 | 38 | :two: 39 | ``` 40 | Equation: 4? * 47 + 2 = 1976 41 | 42 | Returns: 2 43 | 44 | The same equation, another missing digit. 45 | ``` 46 | 47 | :three: 48 | ``` 49 | Equation: 42 * ?7 + 2 = 1976 50 | 51 | Returns: 4 52 | 53 | And again the same equation. 54 | ``` 55 | 56 | :four: 57 | ``` 58 | Equation: 42 * ?47 + 2 = 1976 59 | 60 | Returns: -1 61 | 62 | This test case has no valid solution. The numbers cannot have leading zeros, so we cannot fill in a zero in front of 47. 63 | ``` 64 | 65 | :five: 66 | ``` 67 | Equation: 2 * 12? + 2 = 247 68 | 69 | Returns: -1 70 | 71 | Two times something + 2 will never be 247, so this test case has no solution either. 72 | ``` 73 | -------------------------------------------------------------------------------- /Solution.js: -------------------------------------------------------------------------------- 1 | // Write your code here 2 | --------------------------------------------------------------------------------