1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00

feat: rewrite programming-challenges CLI (#3)

This commit is contained in:
Divlo 2021-06-09 20:31:45 +02:00 committed by GitHub
parent 7aa12f313e
commit 677a55a9d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
256 changed files with 16829 additions and 1881 deletions

1
.commitlintrc.json Normal file
View File

@ -0,0 +1 @@
{ "extends": ["@commitlint/config-conventional"] }

View File

@ -12,3 +12,8 @@ insert_final_newline = true
[*.py] [*.py]
indent_size = 4 indent_size = 4
[*.txt]
indent_size = 1
trim_trailing_whitespace = false
insert_final_newline = false

View File

@ -1,112 +0,0 @@
# 💡 Contributing
## Types of contributions
- [Submit a challenge instructions](challenge-instructions)
- [Share a solution for an already existing challenge](solution-for-an-already-existing-challenge)
- [Add a language available for testing the code](language-available-for-testing-the-code)
- [Correct a spelling error](spelling-error)
## Challenge instructions
After running the command `npm run create-challenge` (see Installation & Usage part of [README.md](../README.md)).
You should have a new folder called the name of your challenge in [challenges](./challenges) folder.
### Structure and purpose of each files
- `README.md` : explain what the solution function should do (the instructions).
- `input-output.json` : An array of possible input/output. This file allows you to test solutions.
Example of file :
```json
[
{
"input": ["arg"],
"output": "Hello world arg!"
},
{
"input": ["Divlo"],
"output": "Hello world Divlo!"
}
]
```
Each object has a "input" key, an array where each item is an argument passed to the solution function when it's executed. The "output" key is the expected output with the given input.
- `solutions` folder where there are all solutions for this specific challenge.
## Solution for an already existing challenge
After running the command `npm run create-solution` (see Installation & Usage part of [README.md](../README.md)).
You should have a new folder called the name of your solution in the challenge folder then you can write your solution in the solution file.
You need to name your parameters of the function (see the instruction of the challenge).
When you feel it's right, you would need to test your code against `input-output.json` file to see if it's a valid solution..
Run this command `npm run test [challenge-name] [solution-name]`.
## Language available for testing the code
Before to add a new language, you should understand :
[/scripts/languages-wrapper](../scripts/languages-wrapper) folder contains all the files needed to execute solutions. Each programming challenge has a execute file, this execute file will be copied in the `temp` folder with the solution file.
Steps to add a new language :
1. Code the execute file in the appropriate language
Algorithm of the execute file :
- Import the solution function (same directory, ignore errors)
- Read the `./input.json` files and convert it as JSON (not plain text string)
- Execute the solution function imported with the inputs as arguments
- Create and write a new file called `./output.json`, with the output result of the solution function
Example in javascript with node.js ([execute.js](../scripts/languages-wrapper/execute.js)) :
```javascript
const path = require('path')
const fs = require('fs').promises
const solution = require('./solution')
const inputPath = path.join(__dirname, 'input.json')
const outputPath = path.join(__dirname, 'output.json')
const main = async () => {
const inputFile = await fs.readFile(inputPath)
const inputJSON = JSON.parse(inputFile)
const result = solution.apply(null, inputJSON)
await fs.writeFile(outputPath, JSON.stringify(result))
}
main()
```
1. Add the language in the `_languages.json` file as a new object of the array. Example for JavaScript :
```json
{
"name": "JavaScript",
"extension": ".js",
"launch": "node"
}
```
1. Create a new solution file with the default basic boilerplate code in `/scripts/languages-wrapper/templates`. Example : `solution.js`:
```js
function solution () {}
module.exports = solution
```
1. Add the language in the language available in [README.md](../README.md) file.
## Spelling error
Correct spelling errors, in the README or CONTRIBUTING files.
Thank you for your support!

20
.github/ISSUE_TEMPLATE/BUG.md vendored Normal file
View File

@ -0,0 +1,20 @@
---
name: '🐛 Bug Report'
about: 'Report an unexpected problem or unintended behavior.'
title: '[Bug]'
labels: 'bug'
---
<!--
Please provide a clear and concise description of what the bug is. Include
screenshots if needed. Please make sure your issue has not already been fixed.
-->
## Steps To Reproduce
1. Step 1
2. Step 2
## The current behavior
## The expected behavior

18
.github/ISSUE_TEMPLATE/DOCUMENTATION.md vendored Normal file
View File

@ -0,0 +1,18 @@
---
name: '📜 Documentation'
about: 'Correct spelling errors, improvements or additions to documentation files (README, CONTRIBUTING...).'
title: '[Documentation]'
labels: 'documentation'
---
<!-- Please make sure your issue has not already been fixed. -->
## Documentation
<!-- Please uncomment the type of documentation problem this issue address -->
<!-- Documentation is Missing -->
<!-- Documentation is Confusing -->
<!-- Documentation has Typo errors -->
## Proposal

View File

@ -0,0 +1,20 @@
---
name: '✨ Feature Request'
about: 'Suggest a new feature idea.'
title: '[Feature]'
labels: 'feature request'
---
<!-- Please make sure your issue has not already been fixed. -->
## Description
<!-- A clear and concise description of the problem or missing capability... -->
## Describe the solution you'd like
<!-- If you have a solution in mind, please describe it. -->
## Describe alternatives you've considered
<!-- Have you considered any alternative solutions or workarounds? -->

20
.github/ISSUE_TEMPLATE/IMPROVEMENT.md vendored Normal file
View File

@ -0,0 +1,20 @@
---
name: '🔧 Improvement'
about: 'Improve structure/format/performance/refactor/tests of the code.'
title: '[Improvement]'
labels: 'improvement'
---
<!-- Please make sure your issue has not already been fixed. -->
## Type of Improvement
<!-- Please uncomment the type of improvements this issue address -->
<!-- Files and Folders Structure -->
<!-- Performance -->
<!-- Refactoring code -->
<!-- Tests -->
<!-- Not Sure? -->
## Proposal

8
.github/ISSUE_TEMPLATE/QUESTION.md vendored Normal file
View File

@ -0,0 +1,8 @@
---
name: '🙋 Question'
about: 'Further information is requested.'
title: '[Question]'
labels: 'question'
---
### Question

7
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,7 @@
<!-- Please first discuss the change you wish to make via issue before making a change. It might avoid a waste of your time. -->
## What changes this PR introduce?
## List any relevant issue numbers
## Is there anything you'd like reviewers to focus on?

111
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,111 @@
name: 'ci'
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
lint:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v2'
- name: 'Use Node.js'
uses: 'actions/setup-node@v2.1.5'
with:
node-version: '16.x'
- name: 'Cache dependencies'
uses: 'actions/cache@v2.1.6'
with:
path: '.npm'
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Install'
run: 'npm ci --cache .npm --prefer-offline'
- run: 'npm run lint:commit -- --to "${{ github.sha }}"'
- run: 'npm run lint:editorconfig'
- run: 'npm run lint:markdown'
- run: 'npm run lint:typescript'
build:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v2'
- name: 'Use Node.js'
uses: 'actions/setup-node@v2.1.5'
with:
node-version: '16.x'
- name: 'Cache dependencies'
uses: 'actions/cache@v2.1.6'
with:
path: '.npm'
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Install'
run: 'npm ci --cache .npm --prefer-offline'
- name: 'Build'
run: 'npm run build'
test:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v2'
- name: 'Use Node.js'
uses: 'actions/setup-node@v2.1.5'
with:
node-version: '16.x'
- name: 'Cache dependencies'
uses: 'actions/cache@v2.1.6'
with:
path: '.npm'
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Install'
run: 'npm ci --cache .npm --prefer-offline'
- name: 'Test'
run: 'npm run test'
challenges:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v2'
- name: 'Use Docker'
uses: 'actions-hub/docker/cli@master'
env:
SKIP_LOGIN: true
- name: 'Use Node.js'
uses: 'actions/setup-node@v2.1.5'
with:
node-version: '16.x'
- name: 'Cache dependencies'
uses: 'actions/cache@v2.1.6'
with:
path: '.npm'
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Install'
run: 'npm ci --cache .npm --prefer-offline'
- name: 'Build'
run: 'npm run build'
- name: 'Install programming-challenges'
run: 'npm install --global'
- name: 'Test'
run: 'programming-challenges run test --affected'

27
.gitignore vendored
View File

@ -1,26 +1,16 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies # dependencies
node_modules node_modules
.pnp .npm
.pnp.js
# lockfiles
package-lock.json
yarn.lock
pnpm-lock.yaml
# production
build
# envs
.env
.env.production
# debug # debug
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log* # production
build
__pycache__
# testing
coverage
# editors # editors
.vscode .vscode
@ -29,3 +19,4 @@ yarn-error.log*
# misc # misc
.DS_Store .DS_Store
temp

View File

@ -1,4 +1,17 @@
image: 'gitpod/workspace-full' image: 'gitpod/workspace-full'
tasks: tasks:
- init: 'npm install' - name: 'programming-challenges'
before: 'npm install --global npm@7 && npm clean-install'
init: 'npm run build'
command: 'npm install --global && programming-challenges'
github:
prebuilds:
master: true
branches: true
pullRequests: true
pullRequestsFromForks: true
addComment: true
addBadge: true
addLabel: true

7
.markdownlint.json Normal file
View File

@ -0,0 +1,7 @@
{
"default": true,
"MD013": false,
"MD024": false,
"MD033": false,
"MD041": false
}

1
.npmrc
View File

@ -1,2 +1 @@
package-lock=false
save-exact=true save-exact=true

View File

@ -1,2 +0,0 @@
--install.no-lockfile true
save-exact true

132
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,132 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
contact@divlo.fr.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][mozilla coc].
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][faq]. Translations are available
at [https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
[mozilla coc]: https://github.com/mozilla/diversity
[faq]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

62
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,62 @@
# 💡 Contributing
Thanks a lot for your interest in contributing to **programming-challenges**! 🎉
## Types of contributions
- [Submit a challenge](#submit-a-challenge)
- [Submit a solution](#submit-a-solution)
- Add support for a new language
- Correct spelling errors, improvements or additions to documentation files (README, CONTRIBUTING...).
## Submit a challenge
You can submit a new challenge by running the command `programming-challenges generate challenge --challenge="<your-challenge-name>" --github-user="<your-github-user>"`
After running this command, a new folder will be created inside the [challenges](./challenges) folder.
You can start editing the `test` folder of the challenge with corresponding `input.txt` and `output.txt` also don't forget to update `README.md` with appropriate exercise statement, to explain what is intended for this challenge.
## Submit a solution
You can submit a new solution by running the command `programming-challenges generate challenge --challenge="<name>" --github-user="<your-github-user>" --language="<your-favorite-language>" --solution="<your-solution>"`.
After running this command, a new folder will be created inside the `solutions` folder of the challenge.
Start writing some code, inside the `solution` file with your favorite programming language, you will get the input thanks to STDIN, and you should output what is intended to STDOUT.
Before submitting the solution, make sure it passes all the tests by running `programming-challenges run test --affected`.
## Pull Requests
- **Please first discuss** the change you wish to make via [issue](https://github.com/Divlo/programming-challenges/issues) before making a change. It might avoid a waste of your time.
- Make sure your **code passes the tests**.
If you're adding new features to **programming-challenges**, please include tests.
## Commits
The commit message guidelines respect [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) and [Semantic Versioning](https://semver.org/) for releases.
### Types
Types define which kind of changes you made to the project.
| Types | Description |
| -------- | ------------------------------------------------------------------------------------------------------------ |
| feat | A new feature. |
| fix | A bug fix. |
| docs | Documentation only changes. |
| style | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc). |
| refactor | A code change that neither fixes a bug nor adds a feature. |
| perf | A code change that improves performance. |
| test | Adding missing tests or correcting existing tests. |
| build | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm). |
| ci | Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs). |
| chore | Other changes that don't modify src or test files. |
| revert | Reverts a previous commit. |
### Scopes
Scopes define what part of the code changed.

23
LICENSE
View File

@ -1,8 +1,21 @@
The MIT License (MIT) MIT License
Copyright (c)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Copyright (c) Divlo
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -9,7 +9,7 @@
<a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a> <a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a>
<a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome"/></a> <a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome"/></a>
<br/> <br/> <br/> <br/>
<img src="./.github/logo.png" width="120" alt="programming-challenges Logo" /> <img src="./logo.png" width="120" alt="programming-challenges Logo" />
</p> </p>
## 📜 About ## 📜 About
@ -18,42 +18,58 @@
Each challenge has its **solutions**, its **instructions** and **input/output examples** so you can try to solve them on your own. See [challenges](./challenges) folder. Each challenge has its **solutions**, its **instructions** and **input/output examples** so you can try to solve them on your own. See [challenges](./challenges) folder.
## ✅ Programming languages available ### ✅ Programming languages available
`npm run test` command will only work with these languages : - [C/C++ (gcc)](https://gcc.gnu.org/)
- [Dart](https://dart.dev/)
- [JavaScript/TypeScript (Node.js)](https://nodejs.org/)
- [Python](https://www.python.org/)
- [Rust](https://www.rust-lang.org/)
- JavaScript and TypeScript (Node.js >= 12) ## 🚀 Getting Started
- Python >= 3.8
## 🚀 Installation & Usage (CLI) ### ☁️ Try with a Single-Click
To easily create **new challenges instructions, solutions and test** your code, I made a **CLI tool** made with Node.js and TypeScript. Gitpod will automatically setup an environment for you.
### Requirements [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/Divlo/programming-challenges)
- Node.js >= 12 ### Locally
Then you need to run `npm install` in the root folder to install needed packages, you can now use one of these commands : #### Prerequisites
- ### `npm run create-challenge` - [Node.js](https://nodejs.org/) >= 16
- [npm](https://npmjs.com/) >= 7
- [Docker](https://www.docker.com/)
Create the basic files needed for a new challenge. It will ask you some questions and you will be ready to write the instructions and `input-output.json`. Please read [CONTRIBUTING.md](./.github/CONTRIBUTING.md). #### Installation
- ### `npm run create-solution` ```sh
# Clone the repository
git clone https://github.com/Divlo/programming-challenges.git
Create the basic files needed for a new solution for a challenge. It will ask you some questions and you will be ready to write your solution in the available programming languages (see above). If you wish to submit to everyone your solution. Please read [CONTRIBUTING.md](./.github/CONTRIBUTING.md). # Go to the project root
cd programming-challenges
- ### `npm run test [challenge-name] [solution-name]` # Install dependencies
npm install
Test if the solution is correct and display where it succeeds and fails with the inputs provided, the output of your function and the expected output. # Install the `programming-challenges` Command Line Interface (CLI)
npm install --global
```
Example : `npm run test hello-world python-hello` ### Usage
```sh
# Discover all the commands availables
programming-challenges --help
```
## 💡 Contributing ## 💡 Contributing
Feel free to submit your challenges, your solutions or even a simple spelling mistake. Anyone can help to improve the project, submit a challenge, a solution or even correct a simple spelling mistake.
Everyone can contribute to the improvement of the project! The steps to contribute can be found in the [CONTRIBUTING.md](./.github/CONTRIBUTING.md) file. The steps to contribute can be found in the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
## 📄 License ## 📄 License

View File

@ -1,29 +0,0 @@
# caesar-cipher
Created by [@Divlo](https://github.com/Divlo) on 21 October 2020.
## Instructions
In cryptography, a **Caesar cipher**, also known as **Caesar's cipher**, the **shift cipher**, **Caesar's code** or **Caesar shift**, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.
### Example of the alphabet with a rotation by 3
```txt
Original alphabet : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Alphabet rotated +3 : DEFGHIJKLMNOPQRSTUVWXYZABC
```
Complete the solution function. It should return the encrypted string.
The function has the following parameter(s):
- `string`: a string in cleartext (everything uppercase)
- `shift`: an integer, the alphabet rotation factor
## Source
- [Wikipedia - Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher)
## Examples
See the `input-output.json` file for examples of input/output.

View File

@ -1,18 +0,0 @@
[
{
"input": ["ANTHONY", 2],
"output": "YLRFMLW"
},
{
"input": ["THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG", 3],
"output": "QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD"
},
{
"input": ["PROGRAMMING CHALLENGES IS AWESOME", 14],
"output": "BDASDMYYUZS OTMXXQZSQE UE MIQEAYQ"
},
{
"input": ["JVUNYHABSHAPVUZ", 7],
"output": "CONGRATULATIONS"
}
]

View File

@ -1,5 +0,0 @@
# typescript-caesar-cipher - caesar-cipher
Programming language : TypeScript
Created by [@Divlo](https://github.com/Divlo) on 21 October 2020.

View File

@ -1,42 +0,0 @@
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
interface ShiftedLetter {
origin: string
shifted: string
}
function shiftAlphabet (shift: number): ShiftedLetter[] {
const result: ShiftedLetter[] = []
for (let index = 0; index < alphabet.length; index++) {
const letter = alphabet[index]
let shiftedIndex = index + shift
if (shiftedIndex > alphabet.length - 1) {
shiftedIndex = Math.abs(alphabet.length - shiftedIndex)
}
result.push({
origin: letter,
shifted: alphabet[shiftedIndex]
})
}
return result
}
function solution (str: string, shift: number): string {
const shiftedAlphabet = shiftAlphabet(shift)
let result = ''
for (const letter of str) {
if (letter === ' ') {
result += ' '
} else {
for (const { origin, shifted } of shiftedAlphabet) {
if (letter === shifted) {
result += origin
break
}
}
}
}
return result
}
export default solution

View File

@ -6,8 +6,8 @@ Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.
Write a simple camelCase function for strings. All words (except the first) must have their first letter capitalized without spaces. Write a simple camelCase function for strings. All words (except the first) must have their first letter capitalized without spaces.
**Note :** camelCase is the practice of writing phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. **Note :** camelCase is the practice of writing phrases such that each word in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation.
## Examples ## Examples
See the `input-output.json` file for examples of input/output. See the `test` folder for examples of input/output.

View File

@ -1,18 +0,0 @@
[
{
"input": ["camel case"],
"output": "camelCase"
},
{
"input": ["say hello "],
"output": "sayHello"
},
{
"input": [" camel case word "],
"output": "camelCaseWord"
},
{
"input": [""],
"output": ""
}
]

View File

@ -0,0 +1,3 @@
# camel-case/javascript/function
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.

View File

@ -0,0 +1,3 @@
{
"type": "module"
}

View File

@ -0,0 +1,27 @@
import readline from 'readline'
const input = []
const readlineInterface = readline.createInterface({
input: process.stdin,
output: process.stdout
})
readlineInterface.on('line', (value) => {
input.push(value)
})
readlineInterface.on('close', solution)
function solution() {
const string = input[0]
const output = string
.trim()
.split(' ')
.map((word, index) => {
const isFirstElement = index === 0
if (isFirstElement) {
return word
}
return word[0].toUpperCase() + word.slice(1)
})
.join('')
console.log(output)
}

View File

@ -1,5 +0,0 @@
# typescript-camelcase - camel-case
Programming language : TypeScript
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.

View File

@ -1,14 +0,0 @@
function solution (string: string) {
return string.length === 0
? ''
: string
.trim()
.split(' ')
.map((word, index) => {
if (index === 0) return word
return word[0].toUpperCase() + word.slice(1)
})
.join('')
}
export default solution

View File

@ -0,0 +1 @@
camel case

View File

@ -0,0 +1 @@
camelCase

View File

@ -0,0 +1 @@
camel case word

View File

@ -0,0 +1 @@
camelCaseWord

View File

@ -0,0 +1 @@
say hello

View File

@ -0,0 +1 @@
sayHello

View File

@ -1,17 +0,0 @@
# cats-childrens-of-childrens
Created by [@Divlo](https://github.com/Divlo) on 12 September 2020.
## Instructions
Write a function that allows you to get all the cat names in a single array.
The order, number and levels of subfolders are frequently changed, so we want a solution that adapts to these changes.
## Source
[jesuisundev.com/comprendre-la-recursivite-en-7-min](https://www.jesuisundev.com/comprendre-la-recursivite-en-7-min/)
## Examples
See the `input-output.json` file for examples of input/output.

View File

@ -1,79 +0,0 @@
[
{
"input": [
[
{
"type": "folder",
"name": "cats",
"children": [
{
"type": "image",
"name": "Buffy"
},
{
"type": "image",
"name": "Gizmo"
},
{
"type": "folder",
"name": "small-cat",
"children": [
{
"type": "image",
"name": "Fluffy"
},
{
"type": "image",
"name": "Harry"
},
{
"type": "folder",
"name": "black-cat",
"children": [
{
"type": "image",
"name": "Daisy"
},
{
"type": "image",
"name": "Toby"
}
]
},
{
"type": "folder",
"name": "white-cat",
"children": [
{
"type": "image",
"name": "Minnie"
},
{
"type": "image",
"name": "Lucy"
}
]
}
]
},
{
"type": "folder",
"name": "future-cat",
"children": []
}
]
}
]
],
"output": [
"Buffy",
"Gizmo",
"Fluffy",
"Harry",
"Daisy",
"Toby",
"Minnie",
"Lucy"
]
}
]

View File

@ -1,5 +0,0 @@
# javascript-recursive - cats-childrens-of-childrens
Programming language : JavaScript
Created by [@Divlo](https://github.com/Divlo) on 12 September 2020.

View File

@ -1,12 +0,0 @@
function solution (folders, result = []) {
for (const folder of folders) {
if (folder.type === 'image') {
result.push(folder.name)
} else if (folder.type === 'folder') {
solution(folder.children, result)
}
}
return result
}
module.exports = solution

View File

@ -1,66 +0,0 @@
# Defibrillators
Created by [@Divlo](https://github.com/Divlo) on 18 February 2021.
## Instructions
### Goals
The city of Montpellier has equipped its streets with defibrillators to help save victims of cardiac arrests. The data corresponding to the position of all defibrillators is available online.
Based on the data we provide in the tests, write a program that will allow users to find the defibrillator nearest to their location using their mobile phone.
### Rules
The input data you require for your program is provided in text format.
This data is comprised of lines, each of which represents a defibrillator. Each defibrillator is represented by the following fields:
- A number identifying the defibrillator
- Name
- Address
- Contact Phone number
- Longitude (degrees)
- Latitude (degrees)
**Note 1**: These fields are separated by a semicolon (;).
**Note 2**: Beware: the decimal numbers use the comma (,) as decimal separator. Remember to turn the comma (,) into dot (.) if necessary in order to use the data in your program.
### Distance
The distance `d` between two points `A` and `B` will be calculated using the following formula:
![Distance Formula](./distance-formula.png)
**Note**: Note: In this formula, the latitudes and longitudes are expressed in **radians**. 6371 corresponds to the radius of the earth in km.
**Note 2**: To convert radian to degrees : (π /180)
The program will display the name of the defibrillator located the closest to the users position. This position is given as input to the program.
The `solution` function takes 3 parameters :
- `userLongitude` (in degrees)
- `userLatitude` (in degrees)
- `defibrillators` array of strings with the following format : `1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;;3,87952263361082;43,6071285339217`
### Example
```js
solution('3,879483', '43,608177', [
'1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;;3,87952263361082;43,6071285339217',
'2;Hotel de Ville;1 place Georges Freche 34267 Montpellier;;3,89652239197876;43,5987299452849',
'3;Zoo de Lunaret;50 avenue Agropolis 34090 Mtp;;3,87388031141133;43,6395872778854'
])
```
It should returns `"Maison de la Prevention Sante"`.
## Source
[CodinGame - Defibrillators](https://www.codingame.com/training/easy/defibrillators)
## Examples
See the `input-output.json` file for examples of input/output.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,190 +0,0 @@
[
{
"input": [
"3,879483",
"43,608177",
[
"1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;;3,87952263361082;43,6071285339217",
"2;Hotel de Ville;1 place Georges Freche 34267 Montpellier;;3,89652239197876;43,5987299452849",
"3;Zoo de Lunaret;50 avenue Agropolis 34090 Mtp;;3,87388031141133;43,6395872778854"
]
],
"output": "Maison de la Prevention Sante"
},
{
"input": [
"3,88995587137398",
"43,6260090150577",
[
"1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;04 67 02 21 60;3,87952263361082;43,6071285339217",
"2;Hotel de Ville;1 place Georges Freche 34267 Montpellier;04 67 34 44 93;3,89652239197876;43,5987299452849",
"3;Zoo de Lunaret;50 avenue Agropolis 34090 Mtp;04 67 54 45 23;3,87388031141133;43,6395872778854",
"4;Centre municipal Garosud;34000 Montpellier;04 67 34 74 62;3,85859221929501;43,5725732056683",
"14;Service surveillance voie publique (ASVP); 8 Avenue Louis Blanc;04 99 58 80 31-32;3,87964814275905;43,6144971208687",
"16;Poste de police Ecusson Centre ville;19 bis Rue durand 34000 Montpellier;04 67 34 70 89;3,87860749270054;43,6050174770208",
"17;Unite Service Fourriere;1945 avenue de toulouse;04 67 06 10 51;3,85396082760103;43,5873825371736",
"18;Poste de police Hotel de ville;789 chemin de moulares;;3,89399056177745;43,5988579879724",
"20;Palais des sports Pierre-de-Coubertin;Avenue de Naples 34000 Montpellier;04 67 03 02 24;3,81388672389191;43,6382964524906",
"21;Gymnase Francois Spinosi;Rue de la Cavalade 34000 Montpellier;04 67 15 90 35;3,91771560379933;43,5989740159529",
"22;Plateau sportif de Grammont Terrain 9, 10, 11;Avenue Albert Einstein 34000 Montpellier;04 67 64 29 43;3,93528362675365;43,6141400501416",
"23;Maison de la Democratie;16, rue de la Republique 34 Mtp;04 67 34 88 00;3,87908231371128;43,605322134559",
"24;Gymnase Albert Batteux;150 rue Francois-Joseph-Gossec 34000 Montpellier;04 67 03 02 24;3,85685695958441;43,5740760521572",
"25;Gymnase Bernard-Jouanique;Rue Jaques-Dalcroze 34080 Montpellier;04 67 54 63 99;3,84713719383276;43,6209657932612",
"26;Stade Municipal Sabathe;Impasse Saint-Cleophas 34000 Montpellier;04 67 47 10 22;3,87069461025189;43,5979909515727",
"27;Salle de Sports Alain Achille;1 place Marcel-Godechot 34000 Montpellier;04 67 15 90 35;3,86929208332712;43,6186500172655",
"28;Gymnase Alain Le Hetet;237 route de Vauguieres 34 Montpellier;04 67 65 39 69;3,90623909083357;43,6056481110058",
"29;Maison pour tous Albert Dubout;1071 avenue de la Justice de Castelnau 34090 Montpellier;04 67 02 68 58;3,88249943562772;43,6264526269792",
"30;Maison pour tous Albert Camus;118 allee Maurice-Bonafos 34080 Montpellier;04 67 27 3341;3,86999152558735;43,5968636559527",
"31;Mairie annexe de proximite Mosson;111 place de Tipasa Mas de la Paillade 34080 Montpellier;04 67 75 19 10;3,81644667226683;43,6280352697417",
"32;Maison pour tous Francois Villon;Rue des Araucarias 34080 Montpellier;04 67 45 04 57;3,839535231275;43,6153516866351",
"33;Maison pour tous Melina Mercouri;842 rue de la Vieille Poste 34 Montpellier;04 99 92 23 80;3,90822213186834;43,6134538722091",
"35;Cimetiere Saint-lazare;2 rond-point du Souvenir Francais 34000 Montpellier;04 67 75 34 46;3,93613553570902;43,6154360341943",
"36;Cimetiere Saint-Etienne;Avenue Albert Einstein 34000 Montpellier;04 99 52 87 35;3,88995587137398;43,6260090150577",
"37;Piscine PITOT;40 Allee J.RAYMOND MONTPELLIER;04 67 52 58 89;3,870303933901;43,6123825678961",
"38;Piscine A. NAKACHE;237 route de Vauguieres MONTPELLIER;04 67 22 57 05;3,90629916344486;43,6064087905768",
"39;Piscine J. TARIS;67 rue L.Michel MONTPELLIER;04 67 79 03 11;3,90104518912559;43,6205269425253",
"41;Piscine J. VIVES;1933 AVENUE DE Maurin MONTPELLIER;04 67 27 74 79;3,87258256366286;43,5878357304832",
"40;Piscine M. SPILLIART;154 Rue C.DESMOULINS MONTPELLIER;04 67 42 00 92;3,8431426079266;43,5982457580602",
"42;Piscine S. BERLIOUX;551 rue Metairie de Saysset MONTPELLIER;04 67 65 38 71;3,89523245626307;43,5904333774241",
"43;Piscine NEPTUNE;Avenue de Heidelberg MONTPELLIER;04 67 75 34 93;3,89308118861399;43,6074454675728",
"44;Piscine OLYMPIQUE ANTIGONE;195 avenue J.CARTIER MONTPELLIER;04 67 15 63 04;3,81486874802702;43,6203748477124",
"45;STADE DE LA MOSSON;Avenue de Heidelberg MONTPELLIER; 04 67 75 74 16;3,81316555213326;43,6218734166524",
"46;STADE Y. DU MANOIR;Avenue de la Vanniere MONTPELLIER;04 67 13 60 00;3,85003952312189;43,5936065771106",
"47;PALAIS DES SPORTS R.BOUGNOL;1000, avenue du Val de Montferrand MONTPELLIER;04 67 52 76 14;3,87431554927809;43,6380433134334",
"48;PATINOIRE VEGAPOLIS;Place de France MONTPELLIER;04 99 522 600;3,91489059571308;43,6029210639592",
"49;CAP OMEGA;Rond point Benjamin Franklin MONTPELLIER;04 67 59 30 01;3,91427706121347;43,618609351242",
"50;S.F.M.A.;Avenue Albert EINSTEIN MONTPELLIER;04 67 22 83 78;3,93573870254207;43,6156043738023",
"51;MUSEE FABRE;13, rue Montpellieret 34000 Montpellier;04 67 14 83 00;3,88015202860524;43,6117202928099",
"52;MEDIATHEQUE E.ZOLA;218 Bd de l'Aeroport International 34000 Montpellier;04 67 34 87 00;3,89315695628937;43,6084838193755",
"53;DOMAINE DE LA PROVIDENCE;1784 Avenue de TOULOUSE MONTPELLIER;04 99 64 25 80;3,85389341433135;43,5886305406899",
"54;RDC PAVILLON JUNON;50 Place Zeus MONTPELLIER;04 67 13 69 27;3,89083244140238;43,6081660748674",
"55;RDC PAVILLON ZEUS;50 Place Zeus MONTPELLIER;04 67 13 69 27;3,89081696430097;43,6078670518814",
"58;PAVILLON ZEUS (Salle Marianne);50 Place Zeus MONTPELLIER;04 67 13 69 27;3,89066621413495;43,6077521695801",
"56;E.S.B.A.M.A.;130 , RUE YEHUDI MONTPELLIER;04 99 58 32 87;3,88438064294719;43,6169436571347",
"57;MONTPELLIER DANCE;18 Rue Sainte Ursule MONTPELLIER;04 67 60 83 60;3,87836849830977;43,6139908031415",
"59;CRR;14 Rue Eugene Lisbonne 34000 Montpellier;04 67 66 88 46;3,87409666178277;43,610433894746",
"60;TAM;Parking comedie centre ville;04 67 07 63 79;3,88022104344314;43,6089439889165",
"61;TAM;Parking Corum;04 67 07 63 79;3,88238703743398;43,6140271812289",
"62;CCAS (Banque d'Acceuil);125 place Thermidor 34000 MONTPELLIER;04 99 52 77 53 06 14 09 40 21;3,89927443503256;43,6020241114814",
"65;Universite Montpellier 1 UFR d'Economie (1er etage, a cote des bureaux de l'administration); Avenue Raymond Dugrand CS 79606 34960 MONTPELLIER Cedex 2;04 34 43 24 44;3,89956530126954;43,6037248716731",
"66;Universite Montpellier 1 UFR AES (1er etage, en face de la salle des professeurs);Espace Richter Avenue Raymond Dugrand CS 59640 34960 MONTPELLIER Cedex 2;04 34 43 23 33;3,89991643490189;43,6031038225234",
"64;Universite Montpellier 1 ISEM IPAG (Loge);Espace Richter Bat b Vendemiaire CS 19519 34960 MONTPELLIER Cedex 2;ISEM : 04 34 43 20 00 IPAG : 04 67 15 85 46;3,89904523736634;43,6042583430944",
"63;Universite Montpellier 1 Services Mutualises Richter PC Securite;Espace Richter Bat E, BIU, MdE, Rue Vendemiaire CS 19519 34960 MONTPELLIER Cedex 2;;3,89848334164309;43,6041786988646",
"67;Universite Montpellier 1 UFR Droit (accueil batiment1);39 rue de l'universite 34060 Montpellier Cedex 2;04 67 61 54 00;3,87717345678089;43,6140582253597",
"68;Universite Montpellier 1 UFR Droit (accueil batiment2);;;3,87633518840488;43,6138609333465",
"69;Universite Montpellier 1 UFR Medecine (Loge batiment Historique);2 rue Ecole de Medecine CS 59001 34060 MONTPELLIER Cedex 2;04 67 60 10 00;3,87354913287527;43,612951860071",
"70;Universite Montpellier 1 UFR Medecine (Loge Institut biologie);;;3,87409700190794;43,6150688127327",
"71;Universite Montpellier 1 UFR Odontologie (Hall Premier Etage Bat A);545, avenue du Professeur J.L Viala 34193 MONTPELLIER Cedex 5;04 67 10 44 70;3,82353507060243;43,6362497267334",
"72;Universite Montpellier 1 UFR Pharmacie (LogeBat A);15, avenue Charles Flahault BP 14491 34093 MONTPELLIER Cedex 5;04 67 54 80 00;3,86189868456889;43,6232360922128",
"73;Universite Montpellier 1 UFR Pharmacie (Galerie a cote de la pharmacie experimentale);;;3,86034021457447;43,6220496094564",
"74;Universite Montpellier 1 UFR Staps (Batiment A);700, avenue du Pic Saint-Loup 34090 MONTPELLIER;04 67 41 57 00;3,8538650451542;43,640831368515",
"75;Universite Montpellier 1 UFR Staps (P1);;;3,84875782514269;43,6393278958929",
"76;Universite Montpellier 1 UFR Staps (Palais des Sports);;;3,84872346174789;43,6401970759746",
"77;Universite Montpellier 2 PC Securite;;04 67 14 31 11;3,86080925535177;43,6320478884427",
"79;Universite Montpellier 2 Secretariat IAE;place Eugene Bataillon 34095 MONTPELLIER CEDEX 5;04 67 14 31 11;3,86173924182999;43,6324310982988",
"78;Universite Montpellier 2 Couloir de la presidence 1er etage;;04 67 14 31 11;3,86403637133178;43,6320955198071",
"80;Universite Montpellier 2 Laboratoire AREVA;;04 67 14 31 11;3,86719128258212;43,6340354958767",
"81;Universite Montpellier 2 SCOPPS;;04 67 14 31 11;3,86651938060978;43,6329423512668",
"82;Universite Montpellier 2 Laboratoire L2C;;04 67 14 31 11;3,86500072175922;43,6325272513173",
"86;Universite Montpellier 2 Centre Sportif Universitaire Piscine;;04 67 14 31 11;3,86372265447782;43,6347707699201",
"85;Universite Montpellier 2 Centre Sportif Universitaire Gymnase;Rue Emile Jeanbreau;04 67 14 31 11;3,86411975731741;43,634431102342",
"84;Universite Montpellier 2 HALL IEM;;04 67 14 31 11;3,86621601700653;43,6350134840932",
"88;Universite paul valery montpellier 3 Loge Entree;Av. Val de montferrand 34199 MONTPELLIER;04 67 14 55 23;3,86987294089832;43,6310996420996",
"89;Universite paul valery montpellier batiment Marc Bloch;Route de mende 34199 MONTPELLIER;04 67 14 55 23;3,86914576305111;43,6327403750896",
"90;Universite Paul Valery montpellier 3 Site Saint Charles Loge Entree;Rue du Professeur Henri Serre 34080 MONTPELLIER Arret tram \" albert 1er\";04 67 14 55 23;3,87378574801668;43,6165624740146",
"91;Montpellier Ecole National Superieure de Chimie;8, rue de l'ecole Normale 34000 MONTPELLIER;04 67 14 72 83;3,86759222312708;43,6208396831232",
"92;Montpellier Ecole National Superieure de Chimie (Laboratoire);104, rue de la galera 34090 MONTPELLIER;04 67 14 72 83;3,83738323298412;43,6371761537967",
"93;Montpellier Ecole National Superieure de Chimie;220 - 276 rue de la galera 34090 MONTPELLIER;04 67 14 72 83;3,83828534323613;43,6375710817093",
"94;CROUS de MONTPELLIER Restaurants Universitaires Boutonnet;2, Rue Emile Duploye 34090 MONTPELLIER Cedex 01;04 67 63 52 06;3,86940780515415;43,6234756772261",
"95;CROUS de MONTPELLIER Restaurants Universitaires Triolet;1061, av. Prof. Joseph Anglada 34090 MONTPELLIER;04 67 63 50 16;3,86018125270489;43,631191261367",
"96;CROUS de MONTPELLIER Restaurants Universitaires Vert-Bois;205, rue de la Chenaie 34090 MONTPELLIER;04 67 63 66 45;3,87086361964785;43,6348289810456",
"98;CROUS de MONTPELLIER Services Centraux;2, rue Monteil 34033 Montpellier; 04 67 41 50 08;3,87001135797271;43,6224491662391",
"97;CROUS de MONTPELLIER Restaurants Universitaires Richter;80, rue Brumaire- 34000 Montpellier;04 67 15 84 47;3,89922794228039;43,6028938663275",
"99;CREPS;2 Avenue Charles Flahault 34090 MONTPELLIER;;3,86618003917991;43,6191123089151",
"100;Maison des sports (Sport Et Psychologie) Herault Sport;200 avenue du Pere Soulas 34090 MONTPELLIER;04 67 54 82 29;3,86583323268375;43,6183423905225",
"101;Herault Sport;747 avenue des apothicaires Parc Euromedecine 34090 Montpellier;04 67 54 82 29;3,83559883662065;43,6416646402407",
"103;Lycee Frederic Bazille;3224 route de Mende 34093 MONTPELLIER;04 67 63 89 87;3,8639010584102;43,6460180385688",
"104;Lycee Jean Mermoz;717 avenue Jean Mermoz 34000 MONTPELLIER;04 67 20 60 00;3,89080547314588;43,610863473281",
"106;Lycee Leonard de Vinci;Rue du Professeur Blayac 34085 MONTPELLIER cedex 4;04 67 10 40 10;3,82313209556008;43,6271809795402",
"105;Lycee Jules Ferry;270 avenue de la colline 34070 MONTPELLIER;04 67 10 74 01;3,84226731025644;43,6052528635409",
"107;Caisse Primaire d'Assurance Maladie;29 cours Gambetta 34000 MONTPELLIER;04 99 52 54 49;3,87110915929521;43,6065196099402",
"108;Caisse Primaire d'Assurance Maladie;90 allee Almicare Calvetti 34000 Montpellier;04 99 52 54 49;3,82126953167633;43,6322018829039",
"109;Caisse d'assurance retraite et de la Sante au travail;29 cours Gambetta 34000 MONTPELLIER;04 67 12 94 72;3,87064343057042;43,6068847626242",
"110;Caisse d'assurance retraite et de la Sante au travail;Century 2 , 101 place pierre Duhem le millenaire 34000 MONTPELLIER;04 67 12 94 72;3,91465549573187;43,6068978500869",
"111;Prefecture de l'Herault;34 Place des Martyrs de la resistance 34000 MONTPELLIER;04 67 61 60 45;3,87675679668135;43,6114960399587",
"113;Cour d'appel;1 rue Foch 34000 MONTPELLIER;04 34 08 81 92;3,87282071734522;43,6112848970996",
"112;Tribunal de grande instance;Place Pierre Flotte 34000 MONTPELLIER;04 67 12 61 09;3,86914794017784;43,6102006063269",
"115;Gare Sncf de Montpellier St Roch;1, Place Auguste Gibert 34000 MONTPELLIER;06 25 91 00 28;3,88084502925211;43,6047523852628",
"114;Hotel de Police de Montpellier;206 avenue du Comte de Melgueil 34000 MONTPELLIER;04 99 13 50 00;3,89161633267666;43,603513899768",
"116;Pharmacie de L'Europe;2600 avenue de l'europe 34080 MONTPELLIER;04 67 75 16 37;3,82007583943153;43,6418758605771",
"117;Pharmacie de l'ovalie;2750 Boulevard Paul Valery 34070 MONTPELLIER;04 67 27 71 72;3,84964180769663;43,5950383978097",
"118;Pharmacie Ravoire;33, Rue du Faubourg Saint JAUMES 34000 MONTPELLIER;04 67 63 38 84;3,86983030264785;43,6147553510548",
"119;Citroen montpellier;730 Avenue des pres d'arenes 34000 MONTPELLIER;04 67 12 67 01;3,88299732333175;43,5906567856049",
"120;Grand Garage de l'Herault Peugeot Montpellier (commerce);905 rue de l'industrie 34007 MONTPELLIER;04 67 06 25 02 04 67 06 25 25;3,88118576492958;43,5829591529706",
"121;Grand Garage de l'Herault Peugeot Montpellier (atelier);905 rue de l'industrie 34007 MONTPELLIER;04 67 06 25 02 04 67 06 25 25;3,88146330454406;43,5835668089934",
"122;Centre commercial Polygone PC Securite (es1 montpellier);1 rue des Pertuisanes 34000 MONTPELLIER;04 67 99 41 60;3,88578382216927;43,6083221486189",
"123;Fnac Montpellier;Centre cial Le Polygone 1 rue des Pertuisanes 34000 MONTPELLIER;04 34 09 06 55;3,88567011518647;43,6085330470563",
"124;Galeries La Fayette;Centre cial Le Polygone 1 rue des Pertuisanes BP 3521 34000 MONTPELLIER;04 67 64 83 00;3,88553285006607;43,6081092231254",
"125;Geant casino Pres d'Arenes (Pc Securite); 504 Avenue du mas d'argelliers 34070 MONTPELLIER;04 67 86 43 69;3,88808523342942;43,586264441135",
"126;Geant casino Celleneuve (Pc Securite);129 bis avenue de Lodeve 34070 MONTPELLIER;04 67 86 43 69 04 99 77 34 00;3,83992052015185;43,6125224275035",
"127;Centre Commercial Odysseum;2 place de Lisbonne 34000 MONTPELLIER;04 67 13 50 55;3,92046106179072;43,6045260331335",
"128;Magasin IKEA;Odysseum 34000 MONTPELLIER;;3,92438329923687;43,6041477817148",
"129;Chronopost;1129 Rue de la castelle 34070 MONTPELLIER;04 67 99 11 03 06 69 58 35 62;3,86885461893472;43,5772303319782",
"130;DELL;1 rond-point Benjamin Franklin 34000 MONTPELLIER;06 58 57 85 24;3,91169360147975;43,6184228864032",
"131;France 3 Sud Montpellier;10 allee John Napier 34000 MONTPELLIER;04 67 20 30 40;3,90921459780798;43,6145658661223",
"132;France Telecom;245 rue de la Galera 34000 MONTPELLIER;04 67 14 66 66;3,83704301955449;43,6384175720502",
"133;Sanofi Aventis;371 rue professeur Blayac 34000 MONTPELLIER;04 99 77 78 79;3,82943569760855;43,6234283430937",
"134;Veolia Eau;765 rue Henri Becquerel BP41246 34965 MONTPELLIER CEDEX 2;04 67 20 73 73 06 20 69 33 70;3,91517278210411;43,612096722739",
"135;Banque de France;98 avenue de Lodeve 34061 MONTPELLIER;04 67 06 79 74;3,85350136943136;43,6102729619807",
"136;Mutuelle des motards;1056 rue de la croix verte 34294 MONTPELLIER;04 67 72 73 20;3,84315528199888;43,642457500046",
"137;Mutuelle des motards;1027 rue de la croix verte 34294 MONTPELLIER;04 67 72 73 20;3,84351021937092;43,6430362920199",
"138;Groupama Sud;Place Jean Antoine de Chaptal 34000 MONTPELLIER;04 67 34 78 86;3,86748181412747;43,6031265793569",
"139;Montpellier beton SERVANT Prestations;1, Rue de la Premiere Ecluse 34070 MONTPELLIER;04 67 92 15 10;3,89578183610751;43,5877632296267",
"140;Hotel IBIS Centre Comedie;Allee Jules Milhau Immeuble le Triangle 34000 MONTPELLIER;04 99 13 29 99;3,88315927070696;43,6089881225671",
"141;Hotel IBIS Montpellier Sud;164 avenue palavas 34070 MONTPELLIER;04 67 58 82 30;3,89172749729087;43,5892502551644",
"142;Hotel mercure;Carrefour de l'aeroport 34000 MONTPELLIER;04 67 20 63 63;3,8940718175978;43,6089445631649",
"143;Hotel mercure centre;Rue de la Spirale 34000 MONTPELLIER;04 67 99 89 89;3,88547541488289;43,6090902690373",
"144;Hotel NOVOTEL;125 avenue Palavas 34070 MONTPELLIER;04 99 52 34 34;3,89234991103325;43,5895487658564",
"145;CRS 56;1 Rue Louis Lepine 34000 MONTPELLIER;04 67 13 17 00;3,90653250762828;43,6122198808195",
"146;Accueil clinique du millenaire Accueil;220 bd penelope 34000 MONTPELLIER;04 99 53 61 03;3,91375491076165;43,6020754291092",
"147;Accueil clinique du millenaire Urgences;220 bd penelope 34000 MONTPELLIER;04 99 53 61 03;3,91353989374935;43,6014966033821",
"148;Ametra;201 place de Thessalie 34000 MONTPELLIER;04 67 84 76 40;3,89226740440157;43,6075603632208",
"149;apec;170 rue leon blum 34000 MONTPELLIER;;3,89052741878513;43,6087911504281",
"150;Arcade SFGE;1-55 Rue de la Constituante 34000 MONTPELLIER;;3,89422323604739;43,6019066687056",
"151;ASPM SECTION AFPS;1635 Avenue Albert Einstein 34000 MONTPELLIER;;3,9167804322775;43,6113532636814",
"152;Cafeteria UFR AES;257-269 Rue Vendemiaire 34000 MONTPELLIER;;3,89935218745248;43,603025020351",
"153;Caisse MSA Languedoc;4 place Jean Antoine de Chaptal 34000 MONTPELLIER;;3,86725032663434;43,6029957496972",
"154;Centre Mutualiste Neurologique PROPARA;263 Rue du Caducee 34000 MONTPELLIER;;3,83221040954412;43,6433843496942",
"155;Communaute d Agglomeration de Montpellier;50 place Zeus;;3,8906414844389;43,6076132052153",
"156;D.D.S.I.S. HERAULT;2 Rue Duval-Jouve 34000 MONTPELLIER;;3,86542459122745;43,610311327355",
"157;DDTM34 - site du Millenaire;233 rue Guglielmo Marconi 34000 MONTPELLIER;;3,91125189536332;43,6121330162831",
"158;Ecole Superieure Des Beaux Arts;130 Rue Yehudi Menuhin 34000 MONTPELLIER;;3,88398298908056;43,6171934153182",
"159;Faculte de Droit;Rue de l'Ecole Mage 34000 MONTPELLIER;;3,87687944359565;43,6137132951212",
"160;faculte de pharmacie;15 avenue charles flahault 34000 MONTPELLIER;;3,86185840432793;43,6239506766346",
"161;fafsea;2460 avenue albert einstein 34000 MONTPELLIER;;3,92771433730696;43,6106200898298",
"162;Hotel des impots;40 rue de louvois 34000 MONTPELLIER;;3,81969688714667;43,6323423132911",
"163;Inset de Montpellier;76 Place de la Revolution 34000 MONTPELLIER;;3,89825148899358;43,6039740268785",
"164;maison agriculture;place chaptal 34000 MONTPELLIER;;3,86633327325595;43,6038860913024",
"165;TALCO LR;40 rue de Pinville 34000 MONTPELLIER;;3,90506063238055;43,6138087474829",
"166;Zenith Sud;avenue Albert Einstein 34000 MONTPELLIER;;3,93074702939992;43,6128228432964",
"168;Action d'Urgence Internationale;1401 rue de fontcouverte 34070 MONTPELLIER;;3,85255897515535;43,5935288046927",
"169;Cfpmea;501 des metairies de saysset 34070 MONTPELLIER;;3,89423707713714;43,5906087749725",
"172;Amphitheatre d'O;121 Rue de la Carrierasse 34090 MONTPELLIER;;3,83507767297601;43,6351213340499",
"173;Batiment k Iut montpellier 2;139 Avenue d'Occitanie 34090 MONTPELLIER;;3,85149578101552;43,6350358178596",
"174;Bibliotheque st charles;Rue auguste broussonnet 34090 MONTPELLIER;;3,87258316660111;43,6155361363529",
"175;Centre de formation professionnel croix rouge;Rue de la valesiere 34090 MONTPELLIER;;3,83009545801086;43,6415334891597",
"176;Chru;Avenue Augustin Fliche 34090 MONTPELLIER;;3,86151292659671;43,6295976450315",
"177;Chru euromed;Rue du caduce 34090 MONTPELLIER;;3,8350137442276;43,6425510639908",
"179;CHU Lapeyronie hall d'accueil;Pont Lapeyronie 34090 MONTPELLIER;;3,85207580919409;43,6301375533552",
"178;Chru lapeyronie;Avenue du doyen gaston giraud 34090 MONTPELLIER;;3,85081289792181;43,6313023033573",
"181;Ipl sante envirronement durable Mediterrranee;778 rue de la croix verte 34090 MONTPELLIER;;3,84083465416705;43,6447155674701",
"182;Les Jardins de Grasse;1482 Rue de Saint-Priest 34090 MONTPELLIER;;3,83534242743301;43,6375404910418",
"183;Parcs Nationaux de France;1037 rue Jean Francois Breton 34090 MONTPELLIER;;3,87871736858804;43,6474178784164",
"187;Cirad;Avenue agropolis 34398 MONTPELLIER;;3,868430789818;43,6504884118088",
"188;Mornay;26 allee jules milhau 34965 MONTPELLIER;;3,88335468006384;43,6090204423773",
"189;Boulodrome Bernard Gasset;122 avenue Maurice Planes 34070 MONTPELLIER;;3,84329169898554;43,5967806501323"
]
],
"output": "Cimetiere Saint-Etienne"
}
]

View File

@ -1,5 +0,0 @@
# typescript-defibrilators - defibrillators
Programming language : TypeScript
Created by [@Divlo](https://github.com/Divlo) on 18 February 2021.

View File

@ -1,67 +0,0 @@
function convertStringToFloat(string: string): number {
return parseFloat(string.replace(',', '.'))
}
class Position {
public longitude: number
public latitude: number
constructor(longitude: number, latitude: number) {
this.longitude = this.convertDegreesToRadian(longitude)
this.latitude = this.convertDegreesToRadian(latitude)
}
static distance(pointA: Position, pointB: Position): number {
const x =
(pointB.longitude - pointA.longitude) *
Math.cos((pointA.latitude + pointB.latitude) / 2)
const y = pointB.latitude - pointA.latitude
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) * 6371
}
private convertDegreesToRadian(degrees: number): number {
return degrees * (Math.PI / 180)
}
}
class Defibrillator {
public id: string
public name: string
public address: string
public position: Position
public distance: number
constructor(array: string[], userPosition: Position) {
this.id = array[0]
this.name = array[1]
this.address = array[2]
this.position = new Position(
convertStringToFloat(array[array.length - 2]),
convertStringToFloat(array[array.length - 1])
)
this.distance = Position.distance(this.position, userPosition)
}
}
function solution(
longitudeInput: string,
latitudeInput: string,
defibrillatorsInput: string[]
): string {
const longitude = convertStringToFloat(longitudeInput)
const latitude = convertStringToFloat(latitudeInput)
const userPosition = new Position(longitude, latitude)
const defibrillators = defibrillatorsInput.map((currentLine) => {
const line = currentLine.split(';;').join(';')
return new Defibrillator(line.split(';'), userPosition)
})
let defibrillatorResult = defibrillators[0]
for (let index = 1; index < defibrillators.length; index++) {
if (defibrillatorResult.distance > defibrillators[index].distance) {
defibrillatorResult = defibrillators[index]
}
}
return defibrillatorResult.name
}
export default solution

View File

@ -1,6 +0,0 @@
[
{
"input": [14],
"output": [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]
}
]

View File

@ -1,5 +0,0 @@
# typescript-recursive - fibonacci-suite
Programming language : TypeScript
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.

View File

@ -1,8 +0,0 @@
function solution (counter: number, result: number[] = [], number1: number = 0, number2: number = 1): number[] {
if (counter === 0) return result
counter--
result.push(number1)
return solution(counter, result, number2, number1 + number2)
}
export default solution

View File

@ -1,4 +1,4 @@
# fibonacci-suite # fibonacci
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020. Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.
@ -10,4 +10,4 @@ The function should return an array of fibonacci numbers. The function takes a `
## Examples ## Examples
See the `input-output.json` file for examples of input/output. See the `test` folder for examples of input/output.

View File

@ -0,0 +1,3 @@
# fibonacci/python/function
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.

View File

@ -0,0 +1,13 @@
from typing import List
import sys
input_values: List[str] = []
for value in sys.stdin:
input_values.append(value.rstrip('\n'))
def fibonacci(number: int) -> int:
return number if number < 2 else fibonacci(number-1) + fibonacci(number-2)
print(fibonacci(int(input_values[0])))

View File

@ -0,0 +1 @@
14

View File

@ -0,0 +1 @@
377

View File

@ -8,4 +8,4 @@ You are given an array (which will have a length of at least 3, but could be ver
## Examples ## Examples
See the `input-output.json` file for examples of input/output. See the `test` folder for examples of input/output.

View File

@ -1,26 +0,0 @@
[
{
"input": [[2, 4, 0, 100, 4, 11, 2602, 36]],
"output": 11
},
{
"input": [[160, 3, 1719, 19, 11, 13, -21]],
"output": 160
},
{
"input": [[0, 1, 2]],
"output": 1
},
{
"input": [[1, 2, 3]],
"output": 2
},
{
"input": [[2, 6, 8, 10, 3]],
"output": 3
},
{
"input": [[1, 1, 0, 1, 1]],
"output": 0
}
]

View File

@ -1,5 +0,0 @@
# typescript-outlier - find-outlier-number
Programming language : TypeScript
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.

View File

@ -0,0 +1,3 @@
# find-outlier-number/typescript/function
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.

View File

@ -1,26 +1,35 @@
import readline from 'readline'
const input: string[] = []
const readlineInterface = readline.createInterface({
input: process.stdin,
output: process.stdout
})
readlineInterface.on('line', (value) => {
input.push(value)
})
readlineInterface.on('close', solution)
interface NumberObject { interface NumberObject {
value: number value: number
index: number index: number
} }
function isOdd (number: number): boolean { const isOdd = (number: number): boolean => {
return number % 2 !== 0 return number % 2 !== 0
} }
function solution (numbers: number[]): number { function solution() {
const numbers = input.map((value) => Number(value))
const oddNumbers: NumberObject[] = [] const oddNumbers: NumberObject[] = []
const evenNumbers: NumberObject[] = [] const evenNumbers: NumberObject[] = []
numbers.forEach((number, index) => { numbers.forEach((number, index) => {
const numberObject: NumberObject = { value: number, index } const numberObject: NumberObject = { value: number, index }
return isOdd(number) return isOdd(number)
? oddNumbers.push(numberObject) ? oddNumbers.push(numberObject)
: evenNumbers.push(numberObject) : evenNumbers.push(numberObject)
}) })
const isValueThatDiffersFromOthers = const isValueThatDiffersFromOthers =
oddNumbers.length === 1 ? oddNumbers[0] : evenNumbers[0] oddNumbers.length === 1 ? oddNumbers[0] : evenNumbers[0]
return isValueThatDiffersFromOthers.value console.log(isValueThatDiffersFromOthers.value)
} }
export default solution

View File

@ -0,0 +1,8 @@
2
4
0
100
4
11
2602
36

View File

@ -0,0 +1 @@
11

View File

@ -0,0 +1,7 @@
160
3
1719
19
11
13
-21

View File

@ -0,0 +1 @@
160

View File

@ -0,0 +1,3 @@
0
1
2

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,3 @@
1
2
3

View File

@ -0,0 +1 @@
2

View File

@ -0,0 +1,5 @@
2
6
8
10
3

View File

@ -0,0 +1 @@
3

View File

@ -0,0 +1,5 @@
1
1
0
1
1

View File

@ -0,0 +1 @@
0

View File

@ -16,4 +16,4 @@ If a string contains all repeating characters, it should return an empty string
## Examples ## Examples
See the `input-output.json` file for examples of input/output. See the `test` folder for examples of input/output.

View File

@ -1,34 +0,0 @@
[
{
"input": ["a"],
"output": "a"
},
{
"input": ["stress"],
"output": "t"
},
{
"input": ["moonmen"],
"output": "e"
},
{
"input": [""],
"output": ""
},
{
"input": ["abba"],
"output": ""
},
{
"input": ["aa"],
"output": ""
},
{
"input": ["~><#~><"],
"output": "#"
},
{
"input": ["hello world, eh?"],
"output": "w"
}
]

View File

@ -1,5 +0,0 @@
# javascript-non-repeating - first-non-repeating-character
Programming language : JavaScript
Created by [@Divlo](https://github.com/Divlo) on 15 November 2020.

View File

@ -0,0 +1,3 @@
# first-non-repeating-character/javascript/function
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.

View File

@ -0,0 +1,3 @@
{
"type": "module"
}

View File

@ -1,7 +1,16 @@
/** import readline from 'readline'
* @param {string} string
*/ const input = []
function solution (string) { const readlineInterface = readline.createInterface({
input: process.stdin,
output: process.stdout
})
readlineInterface.on('line', (value) => {
input.push(value)
})
readlineInterface.on('close', solution)
const firstNonRepeatingCharacter = (string) => {
const lettersCount = {} const lettersCount = {}
for (let index = 0; index < string.length; index++) { for (let index = 0; index < string.length; index++) {
const character = string[index] const character = string[index]
@ -15,7 +24,6 @@ function solution (string) {
lettersCount[character].total += 1 lettersCount[character].total += 1
} }
} }
let result = null let result = null
for (const character in lettersCount) { for (const character in lettersCount) {
const characterObject = lettersCount[character] const characterObject = lettersCount[character]
@ -27,11 +35,12 @@ function solution (string) {
} }
} }
} }
if (result == null) { if (result == null) {
return '' return ''
} }
return result.value return result.value
} }
module.exports = solution function solution() {
console.log(firstNonRepeatingCharacter(input[0]))
}

View File

@ -0,0 +1 @@
a

View File

@ -0,0 +1 @@
a

View File

@ -0,0 +1 @@
stress

View File

@ -0,0 +1 @@
t

View File

@ -0,0 +1 @@
moonmen

View File

@ -0,0 +1 @@
e

View File

@ -0,0 +1 @@
abba

View File

@ -0,0 +1 @@
~><#~><

View File

@ -0,0 +1 @@
#

View File

@ -0,0 +1 @@
hello world, eh?

View File

@ -0,0 +1 @@
w

View File

@ -1,11 +1,11 @@
# hello-world # hello-world
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020. Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.
## Instructions : ## Instructions
Your function should return Hello depending on the parameter. Your function should return Hello depending of the parameter.
## Examples : ## Examples
See the `input-output.json` file for examples of input/output. See the `test` folder for examples of input/output.

View File

@ -1,14 +0,0 @@
[
{
"input": ["world"],
"output": "Hello world!"
},
{
"input": ["everyone"],
"output": "Hello everyone!"
},
{
"input": ["Divlo"],
"output": "Hello Divlo!"
}
]

View File

@ -0,0 +1,3 @@
# hello-world/c/function
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.

View File

@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
char input[1024];
while (scanf("%s", &input) != EOF) {
printf("Hello, %s!", input);
}
return 0;
}

View File

@ -0,0 +1,3 @@
# hello-world/cpp/function
Created by [@Divlo](https://github.com/Divlo) on 7 June 2021.

View File

@ -0,0 +1,9 @@
#include <iostream>
#include <string>
int main() {
for (std::string line; std::getline(std::cin, line);) {
std::cout << "Hello, " + line + "!" << std::endl;
}
return 0;
}

View File

@ -0,0 +1,3 @@
# hello-world/dart/function
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.

View File

@ -0,0 +1,11 @@
import 'dart:io';
String readLineSync() {
String? string = stdin.readLineSync();
return string == null ? '' : string;
}
void main() {
String input = readLineSync();
print('Hello, $input!');
}

View File

@ -1,5 +0,0 @@
# javascript-hello - hello-world
Programming language : JavaScript
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.

View File

@ -1,5 +0,0 @@
function solution (arg) {
return 'Hello ' + arg + '!'
}
module.exports = solution

Some files were not shown because too many files have changed in this diff Show More