├── .gitignore ├── LICENSE ├── README.md ├── package-lock.json ├── package.json ├── postinstall.js ├── pull_request_template.md ├── src └── index.js └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Aliaksandr Yankouski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zeros 2 | 3 | ## Task 4 | 5 | Implement function `zeros(str)`, that for given expression will return the number of zeros in the end of number. 6 | Expression contains only factorials of numbers and multiplying signs, like: `zeros('5!*7!*6!!*7!!')` 7 | `5! === 1 * 2 * 3 * 4 * 5` 8 | `10!! === 2 * 4 * 6 * 8 * 10` 9 | `7!! === 1 * 3 * 5 * 7` 10 | 11 | ```js 12 | zeros('5!') // -> 1 because 5! === 120 13 | zeros('10!') // -> 2 because 10! === 3628800 14 | zeros('9!!*10!!') // 2 -> because 9!!*10!! === 3628800 15 | ``` 16 | 17 | Write your code in `src/index.js` 18 | 19 | ## Prepare and test 20 | 1. Install [Node.js](https://nodejs.org/en/download/) 21 | 2. Fork this repository: https://github.com/Shastel/zeros/ 22 | 3. Clone your newly created repo: https://github.com/<%your_github_username%>/zeros/ 23 | 4. Go to folder `zeros` 24 | 5. To install all dependencies use [`npm install`](https://docs.npmjs.com/cli/install) 25 | 6. Run npm test in command line 26 | 7. You will see the number of passing and failing tests you 100% of passing tests is equal to 100p in score 27 | 28 | ## Submit to [rs app](https://app.rs.school) 29 | 1. Open [rs app](https://app.rs.school) and login 30 | 2. Go to [submit task page](https://app.rs.school/course/submit-task?course=rs-2019-q3) 31 | 3. Select your task (zeros) 32 | 4. Press the submit button and enjoy 33 | 34 | ### Notes 35 | 1. We recommend you to use nodejs of version 10 or lower. If you using any of features that does not supported by node v10, score won't be submitted. 36 | 2. Please be sure that each of your test in limit of 30sec. 37 | 38 | credits [@yankouskia](https://github.com/yankouskia/) 39 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zeros", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "colors": { 8 | "version": "1.4.0", 9 | "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", 10 | "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" 11 | }, 12 | "semver": { 13 | "version": "6.3.0", 14 | "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", 15 | "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zeros", 3 | "version": "1.0.0", 4 | "description": "Zeros", 5 | "main": "test.js", 6 | "scripts": { 7 | "test": "mocha test.js", 8 | "postinstall": "node postinstall.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/yankouskia/additional_6.git" 13 | }, 14 | "author": "yankouskia", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/yankouskia/additional_6/issues" 18 | }, 19 | "engines": { 20 | "node": "<=10" 21 | }, 22 | "devDependencies": { 23 | "mocha": "^3.2.0" 24 | }, 25 | "homepage": "https://github.com/yankouskia/additional_6#readme", 26 | "dependencies": { 27 | "colors": "^1.4.0", 28 | "semver": "^6.3.0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /postinstall.js: -------------------------------------------------------------------------------- 1 | const semver = require('semver'); 2 | const colors = require('colors/safe'); 3 | 4 | const { engines: { node: nodeVersion }} = require('./package'); 5 | 6 | if (!semver.satisfies(process.version, nodeVersion)) { 7 | process.emitWarning( 8 | colors.red(` 9 | For this task we are strictly recomend you to use node ${nodeVersion}. 10 | Now you are using node ${process.version}, if you are using any of features that not supported by node ${nodeVersion}, score won't be submitted 11 | `) 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | # ⚠️ ALL CHECKOBOXES MUST BE CHECKED BEFORE SUBBMITING A PULL REQUEST ⚠️ 2 | 3 | - [ ] I confirm that everything below is true 4 | - [ ] I understand that I'm not supposed to put solution to this repository 5 | - [ ] I confirm that It is not a solution to the task, but fix in task itself 6 | - [ ] In case if it is a solution I agree to get **-100 points** for the task 7 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | module.exports = function zeros(expression) { 2 | // your solution 3 | } 4 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const zeros = require('./src/index.js'); 3 | 4 | it('should calculate the number of zeros 1', () => { 5 | assert.equal(zeros('5!'), 1); 6 | }); 7 | 8 | it('should calculate the number of zeros 3', () => { 9 | assert.equal(zeros('9!!*10!!*7!!'), 3); 10 | }); 11 | 12 | it('should calculate the number of zeros 11', () => { 13 | assert.equal(zeros('90!!*10!!'), 11); 14 | }); 15 | 16 | it('should calculate the number of zeros 7', () => { 17 | assert.equal(zeros('1!*2!*3!*4!*5!*6!*7!*8!*9!*10!'), 7); 18 | }); 19 | 20 | it('should calculate the number of zeros 4', () => { 21 | assert.equal(zeros('1!!*2!!*3!!*4!!*5!!*6!!*7!!*8!!*9!!*10!!'), 4); 22 | }); 23 | 24 | it('should calculate the number of zeros 1', () => { 25 | assert.equal(zeros('1!!*2!!*3!!*4!!*5!!*6!!*7!!*8!!*9!!*10!!*1!!*2!!*3!!*4!!*5!!*6!!*7!!*8!!*9!!*10!!'), 8); 26 | }); 27 | 28 | it('should calculate the number of zeros 6', () => { 29 | assert.equal(zeros('10!!*20!!*30!!'), 6); 30 | }); 31 | 32 | it('should calculate the number of zeros 7', () => { 33 | assert.equal(zeros('11!!*22!!*33!!'), 7); 34 | }); 35 | 36 | it('should calculate the number of zeros 0', () => { 37 | assert.equal(zeros('55!!*77!!*99!!'), 0); 38 | }); 39 | 40 | it('should calculate the number of zeros 0', () => { 41 | assert.equal(zeros('55!!*77!!*99!!*55!!*77!!*99!!*55!!*77!!*99!!*55!!*77!!*99!!'), 0); 42 | }); 43 | 44 | it('should calculate the number of zeros 36', () => { 45 | assert.equal(zeros('100!*100!!'), 36); 46 | }); 47 | 48 | it('should calculate the number of zeros 70', () => { 49 | assert.equal(zeros('99!*99!!*100!*100!!'), 70); 50 | }); 51 | 52 | it('should calculate the number of zeros 18', () => { 53 | assert.equal(zeros('23!*24!!*25!*26!!*27!!'), 18); 54 | }); 55 | 56 | it('should calculate the number of zeros 24', () => { 57 | assert.equal(zeros('45!*63!'), 24); 58 | }); 59 | 60 | it('should calculate the number of zeros 30', () => { 61 | assert.equal(zeros('45!*63!*28!'), 30); 62 | }); 63 | 64 | it('should calculate the number of zeros 1', () => { 65 | assert.equal(zeros('45!*63!*28!*55!!'), 37); 66 | }); 67 | 68 | it('should calculate the number of zeros 48', () => { 69 | assert.equal(zeros('45!*63!*28!*55!!*35!!*45!!'), 48); 70 | }); 71 | 72 | it('should calculate the number of zeros 66', () => { 73 | assert.equal(zeros('45!*63!*28!*55!!*35!!*45!!*25!!*65!!*50!!'), 66); 74 | }); 75 | 76 | it('should calculate the number of zeros 82', () => { 77 | assert.equal(zeros('45!*63!*28!*55!!*35!!*45!!*25!!*65!!*50!!*40!!*95!!'), 82); 78 | }); 79 | 80 | it('should calculate the number of zeros 88', () => { 81 | assert.equal(zeros('45!*63!*28!*55!!*35!!*45!!*25!!*65!!*50!!*40!!*95!!*25!'), 88); 82 | }); 83 | 84 | it('should calculate the number of zeros 125', () => { 85 | assert.equal(zeros('45!*63!*28!*55!!*35!!*45!!*25!!*65!!*50!!*40!!*95!!*25!*45!*63!*28!*55!!'), 125); 86 | }); 87 | 88 | it('should calculate the number of zeros 93', () => { 89 | assert.equal(zeros('45!*5!*63!*5!*28!*5!*55!!*5!*35!!*5!*45!!*5!*25!!*5!*65!!*5!*50!!*5!*40!!*5!*95!!*5!'), 93); 90 | }); 91 | --------------------------------------------------------------------------------