-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: slowy07 <[email protected]>
- Loading branch information
Showing
8 changed files
with
342 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @slowy07 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Deskripsi (Description) | ||
<!-- Deskripsikan tentang perubahan yang kamu berikan. --> | ||
|
||
## Checklist: | ||
### Umum: | ||
<!-- Checklist semua perubahan yang sesuai. --> | ||
- [ ] Saya menambah algoritma terbaru. | ||
- [ ] Saya memperbaiki algoritma yang sudah ada. | ||
- [ ] Saya memperbaiki dokumentasi. | ||
- [ ] Saya menambah dokumentasi. | ||
|
||
### Contributor Requirements (Syarat Kontributor) dan Lain-Lain: | ||
<!-- Checklist semua perubahan yang sesuai. Wajib checklist opsi pertama. --> | ||
- [ ] Saya sudah membaca (I have read) [CONTRIBUTING](https://github.com/bellshade/Nim/blob/main/CONTRIBUTING.md) dan sudah menyetujui semua syarat. | ||
- [ ] Saya menggunakan bahasa Indonesia untuk memberikan penjelasan dari kode yang saya buat. | ||
|
||
## Environment | ||
|
||
Saya menggunakan (I'm using): | ||
<!-- Ganti sesuai yang digunakan. --> | ||
- ``os`` = ``linux / windows / macOS`` | ||
- ``Nim`` = ``nim --version (unix)`` | ||
|
||
<!-- Jika ada gagal pada salah satu test, kami akan mengeceknya kembali. --> | ||
<!-- If there is a failure in one of the tests, we will check it again. --> | ||
linked issue #NOMOR_ISSUE <!--contoh #1--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: nim testing | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
nim_testing: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
- windows-latest | ||
nim-version: | ||
- '2.0.8' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: jiro4989/setup-nim-action@v2 | ||
with: | ||
nim-version: ${{ matrix.nim-version }} | ||
|
||
- name: display version nim | ||
run: | | ||
nim --version | ||
- name: testing nim | ||
run: | | ||
nim test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# 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 | ||
[Discord Channel WPU](http://discord.gg/S4rrXQU). | ||
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. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# *Contributing* | ||
|
||
***Contributor*** | ||
|
||
Kami sangat senang anda telah ikut berkontribusi dalam implementasi algortima, struktur data, atau memperbaiki *error*. | ||
Semua boleh ikut berkontribusi sekecil apapun dengan pengecualian sebagai berikut: | ||
|
||
- Hasil pekerjaan kamu adalah buatan kamu sendiri dan tidak ada hak cipta dari orang lain. Jika kami menemukan kesamaan, maka tidak kami *merge*. | ||
- Hasil kerja kamu akan berlisensi [MIT](LICENSE) ketika *pull request* kamu sudah di-*merge*. | ||
- Hasil kerja kamu wajib mengikuti standar dan *style* koding dari kami. | ||
- Hanya menerima *file* dengan ekstensi ``*.nim``, selain itu dibuat pengecualian dengan menjelaskan secara detail. | ||
|
||
**Apa itu algoritma?** | ||
|
||
Algoritma adalah satu atau lebih fungsi dan/atau kelas yang: | ||
|
||
- memiliki satu atau lebih *input*; | ||
- melakukan beberapa internal kalkulasi atau manipulasi data; | ||
- mengembalikan satu atau lebih nilai hasil; | ||
|
||
## Tambahan Perubahan | ||
|
||
Jika ingin menambahkan algoritma atau *script* Nim yang sederhana atau menambahkan kode yang sederhana, kamu bisa menambahkan perubahan di folder `other`. Jika terdapat beberapa *file*, sebaiknya *file-file* tersebut ke dalam folder sesuai dengan nama *script* tersebut sebagai contoh: | ||
|
||
``` | ||
count_bullet_speed | ||
├── countBulletSpeed.nim | ||
└── fileTambahan.py | ||
``` | ||
|
||
# *Pull Request* | ||
|
||
***Pull request* yang baik** | ||
|
||
Informasi: gunakan [*issue*](https://github.com/bellshade/Nim/issues) apabila ingin menambahkan kode atau implementasi algoritma, dll (*basic*) agar tidak ada konflik dengan *pull request* lainnya. Kamu juga bisa menggunakan issue jika kamu ada | ||
kendala atau masalah ketika melakukan pull request. Kamu juga bisa bertanya pada forum discord **WPU** dan **Kelas Terbuka** perihal bellshade. | ||
|
||
- Lakukan penjelasan deskripsi perubahan yang anda lakukan pada repositori kami dengan membuat penjelasan di [*issue*](https://github.com/bellshade/Nim/issues). | ||
- Setelah menjelaskan perubahan anda di [*issue*](https://github.com/bellshade/Nim/issues) kemudian lakukan *fork* pada repositori kami. | ||
- Setelah melakukan *fork*, anda dibebaskan untuk mengubah atau menambah algoritma. | ||
- Untuk *pull request* merubah atau memperbaiki, diusahakan kamu menerapkan algoritma yang lebih baik dan lebih mudah serta memeberikan penjelasan lebih detail alasan dari perubahaan tersebut lebih baik dari sebelumnya. | ||
- Setelah merubah-rubah atau menambahkan algoritma serta melakukan tes lokal kode kamu, usahakan kamu membuat *local branch* baru: | ||
```bash | ||
git checkout -b <branch_name> | ||
git add . # atau git add nama_perubahan_kamu.py | ||
git commit -m "feat: menambahkan algoritma terbaru" | ||
``` | ||
- Lakukan *push* ke *branch* kamu dan kemudian *open pull request*. | ||
|
||
**Saran pesan commit** | ||
|
||
- `feat:` untuk menambah algoritma atau tambahan lainnya; | ||
- `fix:` untuk mengubah algoritma yang sudah ada atau memperbaiki; | ||
- `docs:` untuk mengubah atau membuat dokumentasi; | ||
- `add:` untuk menambah algoritma atau tambahan lainnya (opsional); | ||
|
||
Catatan: pesan commit harus menjelaskan perubahan secara singkat. | ||
|
||
Contoh yang benar: | ||
- ☒ feat: testX.nim | ||
- ☑ feat: tambah unittest untuk algoritma x | ||
|
||
Lebih lengkapnya bisa dilihat di: | ||
- [EN](https://www.conventionalcommits.org/en/v1.0.0/) | ||
- [ID](https://www.conventionalcommits.org/id/v1.0.0/) | ||
|
||
Pull request akan di-*merge* jika: | ||
|
||
- mengikuti standar dan arahan dari `CONTRIBUTING.md`; | ||
- lulus tes dan cek dari beberapa tes yang sudah kami siapkan. | ||
|
||
**Tambahan**: | ||
|
||
- Jika ada kendala atau masalah dalam *pull request*, kamu bisa laporkan masalahnya dalam [issue](https://github.com/bellshade/Nim/issues). | ||
- Jika ada tes yang tidak lewat atau gagal, kami akan cek kembali perubahan anda. | ||
|
||
Untuk *pull request*, disarankan untuk menjelaskan secara detail yang kamu ubah atau tambahkan, dan bersikap sopan serta selalu berterima kasih. Itu salah satu bentuk tata krama yang baik terhadap sesama *contributor* dan *programmer* lainnya. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
# Nim | ||
repository berisi tentang implementasi serta tutorial dengan bahasa pemograman nim | ||
Repositori ini berisi kumpulan berbagai macam _source code_ algoritma, struktur data, analisis matematika, dan sebagainya yang diimplementasikan dengan menggunakan bahasa pemograman Nim. | ||
|
||
## 🎉🎉 Selamat Datang di Nim 🎉🎉 | ||
|
||
Nim adalah bahasa pemograman yang dirancang untuk menjadi cepat, efisien, dan fleksibel. Nim pertama kali dikembangkan oleh Andreas Rumpf padah tahun 2008. Terinspirasi oleh bahasa pemograman seperti Python, Lisp, C, dan Modula-3. Nim awalnya dikenal dengan nama **Nimrod**, namun nama tersebut diubah menjadi Nim pada tahun 2014 untuk membuat namanya lebih sederhana dan lebih mudah dikenali. | ||
|
||
Nim memungkinan kompilasi langsung ke bahasa seperti `C`, `C++`, atau juga `Javascript`, sehingga sangat cocok untuk pengembangan aplikasi lintas platform. | ||
|
||
## 🤩 Ayo ikut kami dan berkontribusi! 🤩 | ||
|
||
Bantuan kalian diperlukan Agar Bellshade dapat lebih jauh lagi membantu anak-anak Indonesia belajar _programming_, kita butuh tenaga kalian! | ||
|
||
> "Dengan Bellshade, aku bisa jadi bisa _ngoding_! terima kasih Bellshade!" | ||
Kami sangat senang bila kalian ingin melakukan kontribusi pada repositori **Nim** ini. Tapi, sebelum itu, silahkan baca terlebih dahulu [peraturan dan pedomannya](CONTRIBUTING.md) yang telah kami siapkan. Terima kasih! | ||
|
||
Untuk informasi lebih lanjut, mari gabung dalam komunitas [Discord Channel WPU](http://discord.gg/S4rrXQU) dan [Discord Channel Kelas Terbuka](https://discord.gg/eavqxxTU) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{.push raises: [].} | ||
|
||
runnableExamples: | ||
assert absVal(-5.1) == 5.1 | ||
assert absMin(@[-1, 2, -3]) == 1 | ||
assert absMax(@[-1, 2, -3]) == 3 | ||
|
||
func absVal*[T: SomeFloat](angka: T): T = | ||
# mengembalikan nilai absolut dari angka | ||
return if angka < 0.0: -angka else: angka | ||
|
||
func absVal*[T: SomeInteger](angka: T): Natural = (if angka < | ||
0: -angka else: angka) | ||
|
||
func absMin*(x: openArray[int]): Natural {.raises: [ValueError].} = | ||
# mengembalikan nilai element terkecil dari nilai absolute dalam sebuah sekuens | ||
if x.len == 0: | ||
raise newException(ValueError, "Tidak bisa menemukan nilai absolut terkecil") | ||
result = absVal(x[0]) | ||
for i in 1 ..< x.len: | ||
if absVal(x[i]) < result: | ||
result = absVal(x[i]) | ||
|
||
func absMax*(x: openArray[int]): Natural {.raises: [ValueError].} = | ||
# mengembalikan nilai element terbesar dari nilai absolute dalam sebuah sekuens | ||
if x.len == 0: | ||
raise newException(ValueError, "Tidak bisa menemukan nilai absolut maksimum dari sekuens yang kosong") | ||
result = absVal(x[0]) | ||
for i in 1 ..< x.len: | ||
if absVal(x[i]) > result: | ||
result = absVal(x[i]) | ||
|
||
when isMainModule: | ||
import std/[unittest, random] | ||
randomize() | ||
|
||
suite "Test AbsVal": | ||
test "test fungsi absVal": | ||
check: | ||
absVal(11.2) == 11.2 | ||
absVal(5) == 5 | ||
absVal(-5.1) == 5.1 | ||
|
||
suite "Test absMin": | ||
test "test fungsi absMin": | ||
check: | ||
absMin(@[-1, 2, -3]) == 1 | ||
absMin(@[3, -10, -2]) == 2 | ||
absMin([3, -10, -2]) == 2 | ||
|
||
test "absMin jika sekuensnya kosong": | ||
doAssertRaises(ValueError): | ||
discard absMin(@[]) | ||
|
||
suite "Test absMax": | ||
test "test fungsi absMax": | ||
check: | ||
absMax(@[0, 5, 1, 11]) == 11 | ||
absMax(@[-1, 2, -3]) = 3 | ||
|
||
test "`absMax` jika sekuensnya kosong": | ||
doAssertRaises(ValueError): | ||
discard absMax(@[]) |