{"id":15457145,"url":"https://github.com/raminmammadzada/fuel-calculation-with-ruby","last_synced_at":"2025-06-19T13:39:40.011Z","repository":{"id":73429416,"uuid":"473958504","full_name":"RaminMammadzada/fuel-calculation-with-ruby","owner":"RaminMammadzada","description":"The Ruby CLI app to calculate the fuel needed for the interplanetary flight journey.","archived":false,"fork":false,"pushed_at":"2022-03-25T19:08:03.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T10:21:17.560Z","etag":null,"topics":["cli-app","object-oriented-programming","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/RaminMammadzada.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":"2022-03-25T10:07:44.000Z","updated_at":"2022-03-25T10:09:29.000Z","dependencies_parsed_at":"2023-03-24T11:47:15.755Z","dependency_job_id":null,"html_url":"https://github.com/RaminMammadzada/fuel-calculation-with-ruby","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"3a95ad80577fea65112a14b6fc2341a27797096c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RaminMammadzada/fuel-calculation-with-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaminMammadzada%2Ffuel-calculation-with-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaminMammadzada%2Ffuel-calculation-with-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaminMammadzada%2Ffuel-calculation-with-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaminMammadzada%2Ffuel-calculation-with-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RaminMammadzada","download_url":"https://codeload.github.com/RaminMammadzada/fuel-calculation-with-ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaminMammadzada%2Ffuel-calculation-with-ruby/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260760373,"owners_count":23058587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cli-app","object-oriented-programming","ruby"],"created_at":"2024-10-01T22:42:14.077Z","updated_at":"2025-06-19T13:39:34.993Z","avatar_url":"https://github.com/RaminMammadzada.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Total Fuel Calculator with Ruby\n\n## Description\n\nThe fuel required for the whole interplanetary flight journey was needed to be calculated. It is needed to calculate the amount of fuel to launch from one planet of the Solar system, and to land on another planet of the Solar system, depending on the flight route.\n\n## Run app\n\nYou can run those functions in you own local environment. \n\n- Clone the repository by typing:\n\n    ```git clone https://github.com/RaminMammadzada/fuel-calculation-with-ruby```\n\n- Type ```./bin/main.rb``` in the root file of the project. ( You may need to update file permissions by typing ```chmod +x bin/main.rb ```)\n​\n\n- If you have an issuse related to file permissions, you can also easily type ```ruby bin/main.rb``` in the root file of the project.\n​\n## Details\n\nFormula to calculate fuel is quite simple, but it depends on the planet's gravity. Planets the organizator is interested in are:\n\n● Earth - 9.807 m/s\n\n● Moon - 1.62 m/s\n\n● Mars - 3.711 m/s\n\nThe formula for fuel calculations for the launch is the following:\nmass * gravity * 0.042 - 33 rounded down\nThe formula for fuel calculations for the landing is the following:\nmass * gravity * 0.033 - 42 rounded down\nFor example, for the Apollo 11 Command and Service Module, with a weight of 28801 kg, to land it\non the Earth, the required amount of fuel will be:\n28801 * 9.807 * 0.033 - 42 = 9278\n\nBut fuel adds weight to the ship, so it requires additional fuel, until additional fuel is 0 or negative.\n\nAdditional fuel is calculated using the same formula from above.\n9278 fuel requires 2960 more fuel\n2960 fuel requires 915 more fuel\n915 fuel requires 254 more fuel\n254 fuel requires 40 more fuel\n40 fuel requires no more fuel\n\nSo, to land Apollo 11 CSM on the Earth - 13447 fuel required (9278 + 2960 + 915 + 254 + 40).\nApplication should receive a flight route as 2 arguments. First one is the flight ship mass, and\nsecond is an array of 2 element tuples, with the first element being land or launch directive, and\nsecond element is the target planet gravity.\nBut take into account that to land a module on the Moon, you need additional fuel, which should\nbe launched from the Earth - we don’t have a refuel station in space - and we need to to carry\nfuel for all steps from the very beginning.\n\nFor example, for the program to launch the ship from the Earth, land it on the Moon, and return\nback to the Earth, input arguments will look like this:\n\nRuby - 28801, ```[[:launch, 9.807], [:land, 1.62], [:launch, 1.62], [:land, 9.807]]```\nElixir - 28801, ```[{:launch, 9.807}, {:land, 1.62}, {:launch, 1.62}, {:land, 9.807}]```\nPython - 28801, ```[(9.807, 1.62), (1.62, 9.807)]```\nAnd remember, you are hired by NASA, and reliability is crucial. We have no right for a mistake.\n\n\n## Example cases\n\nHere are examples of programs and required fuel for the whole mission:\n\n1. Apollo 11:\n\n● path: launch Earth, land Moon, launch Moon, land Earth\n\n● weight of equipment: 28801 kg\n\n● weight of fuel: 51898 kg\n\n● arguments: ```28801, [[:launch, 9.807], [:land, 1.62], [:launch, 1.62], [:land, 9.807]]```\n\n\n2. Mission on Mars:\n\n● path: launch Earth, land Mars, launch Mars, land Earth\n\n● weight of equipment: 14606 kg\n\n● weight of fuel: 33388 kg\n\n● arguments: ```14606, [[:launch, 9.807], [:land, 3.711], [:launch, 3.711], [:land, 9.807]]```\n\n\u003chr\u003e\n\n3. Passenger ship:\n\n● path: launch Earth, land Moon, launch Moon, land Mars, launch Mars, land Earth\n\n● weight of equipment: 75432 kg\n\n● weight of fuel: 212161 kg\n\n● arguments: ```75432, [[:launch, 9.807], [:land, 1.62], [:launch, 1.62], [:land, 3.711], [:launch, 3.711],[:land, 9.807]]```\n\n\n## Run the tests\n\nNone of the tests added yet. It will be added with Rspec.\n\n## Authors\n\n👤 **Ramin Mammadzada**\n\n- Github: [@RaminMammadzada](https://github.com/RaminMammadzada)\n- Twitter: [@RaminMammadzada](https://twitter.com/RaminMammadzada)\n- Linkedin: [@RaminMammadzada](https://www.linkedin.com/in/raminmammadzada) \n\n## 🤝 Contributing\n\nContributions, issues and feature requests are welcome!\n\nFeel free to check the [issues page](https://github.com/RaminMammadzada/fuel-calculation-with-ruby/issues).\n\n## Show your support\n\nGive a ⭐️ if you like this project!\n\n## 📝 License\n\nThis project is [MIT](lic.url) licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framinmammadzada%2Ffuel-calculation-with-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framinmammadzada%2Ffuel-calculation-with-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framinmammadzada%2Ffuel-calculation-with-ruby/lists"}