{"id":19806222,"url":"https://github.com/cubical22/group-divider","last_synced_at":"2026-04-08T16:02:06.473Z","repository":{"id":188884953,"uuid":"679615293","full_name":"Cubical22/Group-Divider","owner":"Cubical22","description":"a simple algorithm made  mainly to solve the lack of speed and dynamic-ness for group dividing","archived":false,"fork":false,"pushed_at":"2023-11-03T13:38:25.000Z","size":347,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-26T10:43:02.405Z","etag":null,"topics":["algorithm","algorithms","cpp","csharp","fine-tuning","flowchart","java","javascript","php","programming","python"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cubical22.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-17T08:30:17.000Z","updated_at":"2024-02-26T18:03:50.000Z","dependencies_parsed_at":"2023-08-17T10:25:01.008Z","dependency_job_id":"2ecc199e-e89f-4ebe-8c6f-b09270b9d289","html_url":"https://github.com/Cubical22/Group-Divider","commit_stats":null,"previous_names":["cubical22/group-divider"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Cubical22/Group-Divider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cubical22%2FGroup-Divider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cubical22%2FGroup-Divider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cubical22%2FGroup-Divider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cubical22%2FGroup-Divider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cubical22","download_url":"https://codeload.github.com/Cubical22/Group-Divider/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cubical22%2FGroup-Divider/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31562697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","algorithms","cpp","csharp","fine-tuning","flowchart","java","javascript","php","programming","python"],"created_at":"2024-11-12T09:06:43.787Z","updated_at":"2026-04-08T16:02:06.438Z","avatar_url":"https://github.com/Cubical22.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## The GroupDivider Algorithm\r\nThis is a simple algorithm I made in 6 different programming languages.\r\nI've looked up around the Internet and sadly have found no source code or anything\r\non this algorithm. so I decided to make it myself.\r\n## What's the purpose?\r\nwell, the entire purpose of this algorithm is to separate a number into different smaller fractions\r\nin a way that they all sum up to the `goal` value. for example:\r\n    \r\n    \u003e Imagine the `goal` value being 10 and the `dividers` being '2 and 5'\r\n    \r\n    \u003e The result is, two success points:\r\n        1. 2: 5 | 5: 0 (2 * 5 = 10)\r\n        2. 2: 0 | 5: 2 (5 * 2 = 10)\r\n\r\nnormally this would be an easy approach. Just make two nested for-loops to test every possibility.\r\nbut this approach raises three problems:\r\n    \r\n    1. finding out the limit of this loops.\r\n    \r\n    2. so many nested for loops at once. imagine making this for 10 dividers.\r\n    \r\n    3. It's S L O W.\r\n\r\nthis was my approach, solving all 3 problems at once:\r\n## The functionality\r\nit's rather simple and easy to understand since the code is pretty clear.\r\nthe most important point is the `failedStateCount` variable.\r\nthere are two (what I like to call them) 'states':\r\n    1. fail state 2. success state\r\n\u003e The fail state is used to keep track of how many times the sum of all values gets over the `goal` in a row.\r\nthis is pretty important, cause if it fails once and then on the next loop it doesn't, then the `failStateCount` resets \r\nback to 0.\r\nThis variable is used mainly to choose which multiplier we would like to increase by 1,\r\nand it is also used to stop the while loop after there are no more possibilities.\r\n\r\n\u003e The success state just does the counting of all possibilities and printing all of them to the screen.\r\n\r\non each loop, the first thing is checking if the `failedStateCount` is less than the length of our dividers. next up adding one to a multiplier value, based on the `failedStateCount` variable. Hopefully, you see what's going on under the hood. after that, we check ... if there is a success state or there is no state at all (meaning that the sum is less than our goal) we reset the `failedStateCount` back to 0.\r\none important thing to mention is that every time we add to the `failedStateCount` variable, meaning we move on to the next index, we also set all the values, including our currently working index (based on the `failedStateCount` variable) back into zero, and we do this before updating the `failedStateCount`. If we were to do it after, this would be excluding\r\n\r\nHave a look:\r\n\r\n![algo-image](https://github.com/Cubical22/Group-Divider/blob/main/Algorithm-Flowchart.png?raw=true)\r\n\r\n# Using this project\r\nthe algorithm is made in six different languages\r\n    python  java javascript C++ C# PHP\r\nto use each version, perform as mentioned:\r\n    \r\nPython:\r\n\u003e On the `main` directory, run `python index.py` on the terminal\r\n\r\nJavaScript:\r\n\u003e Using `NodeJS`, on the `main` directory, run `node index.js` on the terminal\r\n\r\nJava:\r\n\u003e On the `java` directory, you have two options:\r\n    1. run `javac Index.java` and then `java Index` or ...\r\n    2. use the cmd I have already set up for you. just run `run cmd` or `run.cmd`\r\n    no difference\r\n\r\nC++:\r\n\u003e On the `Cpp` directory, assuming you have gcc and/or g++ installed (check by running `gcc --version` or `g++ --version` in cmd), you just simply run `g++ index.cpp`\r\nto compile the code. There is also a pre-compiled version on the directory, called `index.exe`. To use, just run `index.exe` in your terminal/command line\r\n\r\nC#:\r\n\u003e On the `c#` directory, assuming you already have either a c# compiler or .Net installed on you local machine, run `dotnet run` to start the project, or use you prefered compiler as you wish\r\n\r\nPHP:\r\n\u003e On the `php` directory, assuming you have php installed on your local machine, run `php index.php` and, that's all\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcubical22%2Fgroup-divider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcubical22%2Fgroup-divider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcubical22%2Fgroup-divider/lists"}