Skip to content

Commit

Permalink
[REFACTOR]: markdownlint fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sir-gon committed Jul 30, 2023
1 parent 2f9d79d commit 400e57f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 44 deletions.
8 changes: 4 additions & 4 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
<[email protected]>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -116,13 +116,13 @@ the community.

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.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MIT License
# MIT License

Copyright (c) 2023 Gonzalo Diaz

Expand Down
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Algorithm Exercises

[![Node.js CI](https://github.com/sir-gon/algorithm-exercises-ts/actions/workflows/node.js.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-ts/actions/workflows/node.js.yml) [![codecov](https://codecov.io/gh/sir-gon/algorithm-exercises-ts/branch/main/graph/badge.svg?token=7NBP9SQAY0)](https://codecov.io/gh/sir-gon/algorithm-exercises-ts)
[![Node.js CI](https://github.com/sir-gon/algorithm-exercises-ts/actions/workflows/node.js.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-ts/actions/workflows/node.js.yml)
[![codecov](https://codecov.io/gh/sir-gon/algorithm-exercises-ts/branch/main/graph/badge.svg?token=7NBP9SQAY0)](https://codecov.io/gh/sir-gon/algorithm-exercises-ts)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsir-gon%2Fprojecteuler-ts.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsir-gon%2Fprojecteuler-ts?ref=badge_shield)

![GitHub](https://img.shields.io/github/license/sir-gon/algorithm-exercises-ts) ![GitHub language count](https://img.shields.io/github/languages/count/sir-gon/algorithm-exercises-ts) ![GitHub top language](https://img.shields.io/github/languages/top/sir-gon/algorithm-exercises-ts)
![GitHub](https://img.shields.io/github/license/sir-gon/algorithm-exercises-ts)
![GitHub language count](https://img.shields.io/github/languages/count/sir-gon/algorithm-exercises-ts)
![GitHub top language](https://img.shields.io/github/languages/top/sir-gon/algorithm-exercises-ts)

## What is this?

[Project Euler](https://projecteuler.net/) provide some algorithms and mathematical problems to solve to be used as experience tests.
[Project Euler](https://projecteuler.net/) provide some algorithms and
mathematical problems to solve to be used as experience tests.

Use this answers to learn some tip and tricks for algorithms tests.

Expand All @@ -18,10 +22,24 @@ As Project Euler says:
<https://projecteuler.net/about#publish>

```text
I learned so much solving problem XXX, so is it okay to publish my solution elsewhere?
It appears that you have answered your own question. There is nothing quite like that "Aha!" moment when you finally beat a problem which you have been working on for some time. It is often through the best of intentions in wishing to share our insights so that others can enjoy that moment too. Sadly, that will rarely be the case for your readers. Real learning is an active process and seeing how it is done is a long way from experiencing that epiphany of discovery. Please do not deny others what you have so richly valued yourself.
However, the rule about sharing solutions outside of Project Euler does not apply to the first one-hundred problems, as long as any discussion clearly aims to instruct methods, not just provide answers, and does not directly threaten to undermine the enjoyment of solving later problems. Problems 1 to 100 provide a wealth of helpful introductory teaching material and if you are able to respect our requirements, then we give permission for those problems and their solutions to be discussed elsewhere.
I learned so much solving problem XXX, so is it okay
to publish my solution elsewhere?
It appears that you have answered your own question. There is nothing quite
like that "Aha!" moment when you finally beat a problem which you have been
working on for some time. It is often through the best of intentions in wishing
to share our insights so that others can enjoy that moment too. Sadly, that
will rarely be the case for your readers. Real learning is an active process
and seeing how it is done is a long way from experiencing that epiphany of
discovery. Please do not deny others what you have so richly valued yourself.
However, the rule about sharing solutions outside of Project Euler does not
apply to the first one-hundred problems, as long as any discussion clearly aims
to instruct methods, not just provide answers, and does not directly threaten
to undermine the enjoyment of solving later problems. Problems 1 to 100 provide
a wealth of helpful introductory teaching material and if you are able to
respect our requirements, then we give permission for those problems and their
solutions to be discussed elsewhere.
```

If you have better answers or optimal solutions, fork and PR-me
Expand Down Expand Up @@ -123,8 +141,10 @@ make docker/compose-run -e LOG_LEVEL=DEBUG -e BRUTEFORCE=true
### Build and run a development image

Running container with development target.
Designed to develop on top of this image. All source application is mounted as a volume in **/app** directory.
Dependencies should be installed to run (not present in this target) so, you must install dependencies before run (or after a dependency add/change).
Designed to develop on top of this image. All source application is mounted as
a volume in **/app** directory.
Dependencies should be installed to run (not present in this target) so, you
must install dependencies before run (or after a dependency add/change).

```text
# install node_modules dependencies using docker runtime and store them in host directory
Expand Down
37 changes: 24 additions & 13 deletions src/hackerrank/implementation/betweenTwoSets.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ array
These numbers are referred to as being between the two arrays. Determine
how many such numbers exist.

# Example
## Example

$ a = [2, 6] $

$ b = [24, 36] $

There are two numbers between the arrays: $ 6 $ and $ 12 $.
$ 6 \bmod 2 = 0 $, $ 6 \bmod 6 = 0 $, $ 24 \bmod 6 = 0 $ and $ 36 \bmod 6 = 0 $ for the first value.
$ 12 \bmod 2 = 0 $, $ 12 \bmod 6 = 0 $, and $ 24 \bmod 12 = 0 $, $ 36 \bmod 12 = 0 $ for the second value. Return $ 2 $.
$ 6 \bmod 2 = 0 $, $ 6 \bmod 6 = 0 $, $ 24 \bmod 6 = 0 $ and $ 36 \bmod 6 = 0 $
for the first value.
$ 12 \bmod 2 = 0 $, $ 12 \bmod 6 = 0 $, and $ 24 \bmod 12 = 0 $,
$ 36 \bmod 12 = 0 $ for the second value. Return $ 2 $.

## Function Description

# Function Description
Complete the getTotalX function in the editor below. It should return the
number of integers that are betwen the sets.

Expand All @@ -32,37 +36,44 @@ getTotalX has the following parameter(s):
- int a[n]: an array of integers
- int b[m]: an array of integers

# Returns
## Returns

- int: the number of integers that are between the sets

# Input Format
## Input Format

The first line contains two space-separated integers, n and m, the number
of elements in arrays a and b.
The second line contains n distinct space-separated integers $ a[i] $ where
$ 0 \leq i < n $.
The third line contains m distinct space-separated integers $ b[j] $ where
$ 0 \leq j < m $.

# Constraints
## Constraints

- $ 1 \leq n, m < 10 $
- $ 1 \leq a[i] \leq 100 $
- $ 1 \leq b[j] \leq 100 $

# Sample Input
```
## Sample Input

```text
2 3
2 4
12 32 96
```

# Sample Output
```
## Sample Output

```text
3
```

# Explanation
## Explanation

2 and 4 divide evenly into 4, 8, 12 and 16.

4, 8 and 16 divide evenly into 16, 32, 96.

4, 8 and 16 are the only three numbers for which each element of a is a factor and each is a factor of all elements of b.
4, 8 and 16 are the only three numbers for which each element of a is a factor
and each is a factor of all elements of b.
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/birthday.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- Difficulty: #easy
- Category: #implementation

Two children, Lily and Ron, want to share a chocolate bar. Each of the squares has an integer on it.
Two children, Lily and Ron, want to share a chocolate bar. Each of the squares
has an integer on it.

Lily decides to share a contiguous segment of the bar selected such that:

Expand Down
41 changes: 25 additions & 16 deletions src/hackerrank/implementation/bonAppetit.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Bill Division
# [Bill Division](https://www.hackerrank.com/challenges/bon-appetit)

https://www.hackerrank.com/challenges/bon-appetit

- Difficulty: [#easy](#easy)
- Category: [#implementation](#implementation)
Difficulty: #easy
Category: #implementation

Two friends Anna and Brian, are deciding how to split the bill at a dinner.
Each will only pay for the items they consume. Brian gets the check and
Expand All @@ -15,66 +13,77 @@ the bill correctly, Anna will pay $ (2 / 4) / 2 = 3 $. If he includes the cost o
$ bill[2] $, he will calculate $ (2 + 4 + 6) / 2 = 6 $. In the second case, he
should refund $ 3 $ to Anna.


## Function Description

Complete the bonAppetit function in the editor below. It should print
**Bon Appetit** if the bill is fairly split. Otherwise, it should print
the integer amount of money that Brian owes Anna.
bonAppetit has the following parameter(s):

- bill: an array of integers representing the cost of each item ordered
- k: an integer representing the zero-based index of the item Anna doesn't
eat
- b: the amount of money that Anna contributed to the bill

## Input Format

The first line contains two space-separated integers $ n $ and $ k $, the number
of items ordered and the 0-based index of the item that Anna did not eat.
The second line contains $ n $ space-separated integers bill[i] where 0 <= i < n.
The third line contains an integer, b, the amount of money that Brian
charged Anna for her share of the bill.

## Constraints
* $ 2 \le n \le 10^5 $
* $ 0 \leq k < n $
* $ 0 \leq bill[i] < 10^4 $
* $ 0 \leq b \leq \sum_{i=0}^{n-1} bill[i] $
* The amount of money due Anna will always be an integer

- $ 2 \le n \le 10^5 $
- $ 0 \leq k < n $
- $ 0 \leq bill[i] < 10^4 $
- $ 0 \leq b \leq \sum_{i=0}^{n-1} bill[i] $
- The amount of money due Anna will always be an integer

## Output Format

If Brian did not overcharge Anna, print Bon Appetit on a new line;
otherwise, print the difference (i.e., b_charged - b_actual) that Brian must
refund to Anna. This will always be an integer.

## Sample Input 0
```

```text
4 1
3 10 2 9
12
```

## Sample Output 0
```

```text
5
```

## Explanation 0

Anna didn't eat item $ bill[i] = 10 $, but she shared the rest of the items with
Brian. The total cost of the shared items is $ 3 + 2 + 9 + 14 $ and, split in
half, the cost per person is $ b_{actual} = 7 $. Brian charged her $ b_{charged} = 12 $
half, the cost per person is $ b_{actual} = 7 $. Brian charged her
$ b_{charged} = 12 $
for her portion of the bill. We print the amount Anna was overcharged,
$ b_{charged} - b_{actual} = 12 - 7 = 5 $, on a new line.

## Sample Input 1
```

```text
4 1
3 10 2 9
7
```

## Sample Output 1
```

```text
Bon Appetit
```

Anna didn't eat item $ bill[1] = 10 $, but she shared the rest of the items with
Brian. The total cost of the shared items is $ 3 + 2 + 9 = 14 $ and, split in
half, the cost per person is b_actual = 7. Because b_actual = b_charged = 7,
Expand Down

0 comments on commit 400e57f

Please sign in to comment.