Skip to content

Commit 90d5ce3

Browse files
author
Gonzalo Diaz
committed
Update README.md
1 parent f60e80c commit 90d5ce3

File tree

1 file changed

+144
-78
lines changed

1 file changed

+144
-78
lines changed

README.md

Lines changed: 144 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,227 @@
11
# Algorithm Exercises (C# / .NET 8.0)
22

33
[![.NET](https://github.com/sir-gon/algorithm-exercises-csharp/actions/workflows/dotnet.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-csharp/actions/workflows/dotnet.yml)
4-
[![codecov](https://codecov.io/gh/sir-gon/algorithm-exercises-csharp/graph/badge.svg?token=C8JJA96CQR)](https://codecov.io/gh/sir-gon/algorithm-exercises-csharp)
54
[![Markdown Lint](https://github.com/sir-gon/algorithm-exercises-csharp/actions/workflows/markdown-lint.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-csharp/actions/workflows/markdown-lint.yml)
5+
[![YAML lint](https://github.com/sir-gon/algorithm-exercises-csharp/actions/workflows/yamllint.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-csharp/actions/workflows/yamllint.yml)
66

77
![GitHub](https://img.shields.io/github/license/sir-gon/algorithm-exercises-csharp)
88
![GitHub language count](https://img.shields.io/github/languages/count/sir-gon/algorithm-exercises-csharp)
99
![GitHub top language](https://img.shields.io/github/languages/top/sir-gon/algorithm-exercises-csharp)
10+
[![codecov](https://codecov.io/gh/sir-gon/algorithm-exercises-csharp/graph/badge.svg?token=C8JJA96CQR)](https://codecov.io/gh/sir-gon/algorithm-exercises-csharp)
1011

1112
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-csharp&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-csharp)
1213
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-csharp&metric=coverage)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-csharp)
1314
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-csharp&metric=bugs)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-csharp)
1415
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-csharp&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-csharp)
1516
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-csharp&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-csharp)
1617

18+
## TL;DR
19+
20+
[Install and run](#install-and-run)
21+
1722
## What is this?
1823

19-
[Project Euler](https://algorithm-exercises.net/) provide some algorithms and
20-
mathematical problems to solve to be used as experience tests.
24+
This repository is part of a series that share and solve the same [objectives](#objetives),
25+
with the difference that each one is based on a different software ecosystem,
26+
depending on the chosen programming language:
2127

22-
Use this answers to learn some tip and tricks for algorithms tests.
28+
- [Modern Javascript: algorithm-exercises-js](https://github.com/sir-gon/algorithm-exercises-js)
29+
- [Python 3.x: algorithm-exercises-py](https://github.com/sir-gon/algorithm-exercises-py)
30+
- [Typescript: algorithm-exercises-ts](https://github.com/sir-gon/algorithm-exercises-ts)
31+
- [Go / Golang: algorithm-exercises-csharp](https://github.com/sir-gon/algorithm-exercises-csharp)
32+
- [Java: algorithm-exercises-java](https://github.com/sir-gon/algorithm-exercises-java)
33+
- [.NET / C#: algorithm-exercises-csharp](https://github.com/sir-gon/algorithm-exercises-csharp)
2334

24-
## Why I publish solutions?
35+
## Objetives
2536

26-
As Project Euler says:
37+
### Functional
2738

28-
<https://algorithm-exercises.net/about#publish>
39+
- For academic purposes, it is an backup of some algorithm exercises
40+
(with their solutions), proposed by various sources:
41+
[leetcode, hackerrank, projecteuler](#algorithm-excersices-sources), ...
2942

30-
```text
31-
I learned so much solving problem XXX, so is it okay to publish my solution elsewhere?
32-
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.
43+
- The solutions must be written on "vanilla code", that is,
44+
avoiding as much as possible the use of external libraries (in runtime).
3345

34-
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.
35-
```
46+
- Adoption of methodology and good practices.
47+
Each exercise is implemented as a unit test set,
48+
using TDD (Test-driven Development) and Clean Code ideas.
3649

37-
If you have better answers or optimal solutions, fork and PR-me
50+
### Technical
3851

39-
Enjoy 😁 !
52+
Foundation of a project that supports:
4053

41-
## Using NET 8.0 runtime
54+
- Explicit **typing** when the language supports it, even when it is not mandatory.
55+
- Static Code Analysis (**Lint**) of code, scripts and documentation.
56+
- Uniform **Code Styling**.
57+
- **Unit Test** framework.
58+
- **Coverge** collection. High coverage percentage. Equal or close to 100%.
59+
- **Pipeline** (Github Actions). Each command must take care of its
60+
return status code.
61+
- **Docker**-based workflow to replicate behavior in any environment.
62+
- Other tools to support the reinforcement of software development **good practices**.
4263

43-
## Requirements
64+
## Install and Run
4465

45-
You must install dependencies:
66+
You can run tests in the following ways:
4667

47-
```text
48-
dotnet restore
49-
```
68+
- [Install and run directly](#install-and-run-directly) require runtime tools
69+
installed in your SO.
70+
- [Install and run with make](#install-and-run-using-make) require runtime tools
71+
and "make" installed in your SO.
72+
- [Install and run in Docker](#install-and-running-with-docker-) require Docker and
73+
docker-compose installed.
74+
- (⭐️)
75+
[Install and in Docker with make](#install-and-running-with-docker--using-make)
76+
require docker-compose and make installed.
5077

51-
Or using make
78+
⭐️: Prefered way.
5279

53-
```text
54-
make dependencies
55-
```
80+
### Install and Run directly
81+
82+
Using a dotnet 8.0 stack in your SO. You must install dependencies:
5683

57-
### Testing silently
84+
```bash
85+
dotnet restore --verbosity=normal
86+
```
5887

5988
Every problem is a function with unit test.
89+
6090
Unit test has test cases and input data to solve the problem.
6191

62-
Run all tests:
92+
Run all tests (skips static analysis, and "clean" test cache before running):
6393

64-
```text
94+
```bash
6595
dotnet test --verbosity normal
6696
```
6797

68-
### Testing with full logs
98+
#### Test run with alternative behaviors
6999

70-
Run all tests with debug outputs:
100+
> [!IMPORTANT]
101+
> BRUTEFORCE and LOG_LEVEL Not yet implemented
102+
> Currently, tests only have one behavior
71103
72-
```text
73-
dotnet test --verbosity detailed
74-
```
104+
~~You can change test running behaviour using some environment variables as follows:~~
75105

76-
### Testing using make
106+
| Variable | Values | Default |
107+
| ------ | ------ | ------ |
108+
| LOG_LEVEL | `debug`, `warning`, `error`, `info` | `info` |
109+
| BRUTEFORCE | `true`, `false`| `false` |
77110

78-
```text
111+
- ~~`LOG_LEVEL`: change verbosity level in outputs.~~
112+
- ~~`BRUTEFORCE`: enable or disable running large tests.
113+
(long time, large amount of data, high memory consumition).~~
114+
115+
#### Examples running tests with alternative behaviors
116+
117+
> [!IMPORTANT]
118+
> BRUTEFORCE and LOG_LEVEL Not yet implemented
119+
> Currently, tests only have one behavior
120+
121+
### Install and Run using make
122+
123+
`make` tool is used to standardizes the commands for the same tasks
124+
across each sibling repository.
125+
126+
Run tests (libraries are installed as dependency task in make):
127+
128+
```bash
79129
make test
80130
```
81131

82-
### Enable all large BRUTEFORCE tests
132+
### Install and Running with Docker 🐳
83133

84-
Direct in host using a make:
134+
Build an image of the test stage.
135+
Then creates and ephemeral container an run tests.
85136

86-
```text
87-
make test -e BRUTEFORCE=true
137+
BRUTEFORCE and LOG_LEVEL environment variables are passing from current
138+
environment using docker-compose.
139+
140+
```bash
141+
docker-compose --profile testing run --rm algorithm-exercises-csharp-test
88142
```
89143

90-
### Enable all DEBUG outputs
144+
### Install and Running with Docker 🐳 using make
91145

92-
```text
93-
make test -e LOG_LEVEL=debug
146+
```bash
147+
make compose/build
148+
make compose/test
94149
```
95150

96-
### Enable all large BRUTEFORCE tests and all DEBUG outputs
151+
## Development workflow using Docker / docker-compose
97152

98-
```text
99-
make test -e LOG_LEVEL=debug -e BRUTEFORCE=true
100-
```
153+
Running container with development target.
154+
Designed for development workflow on top of this image.
155+
All source application is mounted as a volume in **/app** directory.
156+
Dependencies should be installed to run so, you must
157+
install dependencies before run (or after a dependency add/change).
101158

102-
## Running with Docker 🐳
159+
```bash
160+
# Build development target image
161+
docker-compose build --compress algorithm-exercises-csharp-dev
103162

104-
### Build a complete image with and run all tests
163+
# Run ephemeral container and override command to run test
164+
docker-compose run --rm algorithm-exercises-csharp-dev dotnet test --verbosity normal
165+
```
105166

106-
Running container with testing (final) target.
167+
## Run complete workflow (Docker + make)
107168

108-
Designed to store all application files and dependencies as a complete runnable image.
109-
Coverage results will be stored in host **/coverage** directory (mounted as volume).
169+
Following command simulates a standarized pipeline across environments,
170+
using docker-compose and make.
110171

111-
```text
112-
# Build a complete image
113-
docker-compose build algorithm-exercises-csharp
114-
docker-compose run --rm algorithm-exercises-csharp make test coverage
172+
```bash
173+
make compose/build && make compose/lint && make compose/test && make compose/run
115174
```
116175

117-
### Enable BRUTEFORCE tests with full DEBUG output
176+
- Build all Docker stages and tag relevant images.
177+
- Run static analysis (lint) checks
178+
- Run unit tests
179+
- Run a "final" production ready image as a final container.
180+
Final "production" image just shows a minimal "production ready"
181+
build (with no tests).
118182

119-
With docker-compose:
183+
## About development
184+
185+
Developed with runtime:
120186

121187
```text
122-
docker-compose --profile testing run --rm algorithm-exercises-csharp make test -e LOG_LEVEL=debug -e BRUTEFORCE=true
188+
dotnet --version
189+
8.0.204
123190
```
124191

125-
Using make:
192+
## Algorithm excersices sources
126193

127-
```text
128-
make docker/compose-run -e LOG_LEVEL=DEBUG -e BRUTEFORCE=true
129-
```
194+
- [Leetcode](https://leetcode.com/) online platform for
195+
coding interview preparation.
196+
- [HackerRank](https://www.hackerrank.com/) competitive programming challenges
197+
for both consumers and businesses.
198+
- [Project Euler](https://projecteuler.net/) a series of computational problems
199+
intended to be solved with computer programs.
130200

131-
### Build and run a development image
201+
Use these answers to learn some tip and tricks for algorithms tests.
132202

133-
Running container with development target.
134-
Designed to develop on top of this image. All source application is mounted as
135-
a volume in **/app** directory.
136-
Dependencies should be installed to run (not present in this target) so, you
137-
must install dependencies before run (or after a dependency add/change).
203+
### Disclaimer. Why I publish solutions?
204+
205+
As Project Euler says:
206+
207+
<https://projecteuler.net/about#publish>
138208

139209
```text
140-
# install dependencies using docker runtime and store them in host directory
141-
docker-compose build algorithm-exercises-csharp-dev
142-
docker-compose run --rm algorithm-exercises-csharp-dev make dependencies
143-
docker-compose run --rm algorithm-exercises-csharp-dev make test
210+
I learned so much solving problem XXX, so is it okay to publish my solution elsewhere?
211+
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.
144212
213+
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.
145214
```
146215

147-
## About development
216+
If you have better answers or optimal solutions, fork and PR-me
148217

149-
Developed with runtime:
218+
Enjoy 😁 !
150219

151-
```text
152-
dotnet --version
153-
8.0.204
154-
```
220+
## Status
155221

156222
### License
157223

158-
See [LICENSE](LICENSE)
224+
See [LICENSE](LICENSE.md)
159225

160226
### Coverage
161227

0 commit comments

Comments
 (0)