{"id":21976845,"url":"https://github.com/stuartapp/ruby_challenge_july","last_synced_at":"2025-10-06T20:32:29.451Z","repository":{"id":86222289,"uuid":"95223400","full_name":"StuartApp/ruby_challenge_july","owner":"StuartApp","description":"Repository for the Stuart Ruby Coding Challenge of July","archived":false,"fork":false,"pushed_at":"2017-07-05T18:02:44.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":57,"default_branch":"master","last_synced_at":"2025-03-23T00:23:14.335Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/StuartApp.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":"2017-06-23T13:37:57.000Z","updated_at":"2018-03-07T05:33:28.000Z","dependencies_parsed_at":"2023-03-08T00:45:25.646Z","dependency_job_id":null,"html_url":"https://github.com/StuartApp/ruby_challenge_july","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/StuartApp/ruby_challenge_july","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StuartApp%2Fruby_challenge_july","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StuartApp%2Fruby_challenge_july/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StuartApp%2Fruby_challenge_july/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StuartApp%2Fruby_challenge_july/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StuartApp","download_url":"https://codeload.github.com/StuartApp/ruby_challenge_july/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StuartApp%2Fruby_challenge_july/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278673807,"owners_count":26026193,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-29T16:12:27.164Z","updated_at":"2025-10-06T20:32:29.418Z","avatar_url":"https://github.com/StuartApp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 1st Stuart Ruby Challenge\n\n## Environment setup\n\nTo participate in the challenge you only need to have Ruby installed in your machine (2.2.0+), with Tk enabled (most of the installations already have this).\n\n## 2d Roller Coaster\n\nIn this edition the challenge is to implement a simulator of a 2d roller coaster.\n\nA roller coaster track is given as a series of points, whose coordinates are passed through standard input to the program, one per line:\n\n```\n153.167706326906 170.818594853651\n152.705297542038 170.778692088403\n152.230255082701 170.621111633323\n```\n\nAll numbers are positive floats and represent coordinates in a 2d grid. The\nlimits of the coordinates in this system are (400, 600). You can find example\ntracks provided in the `lib/data` folder. Use them to ensure your simulation\nworks well.\n\n### Physics 😱\n\nTo help you with the Physics, which are not the focus of the problem, we're\ngoing to provide some formulas and explanations.\n\nIf the car is at point `p0`, with velocity `v0` and height `h0`, and the next point is `p1` at height `h1`, the car velocity at `p1` is going to be\n\n    v1 = sqrt(2*g*(h0 - h1) + v0**2)\n\nwhere `g` is the gravitational acceleration (9.8 m/s²). The problem assumes\nthere is no friction.\n\nThe average velocity when going from `p0` to `p1` is calculated as `v = (v0 +\nv1)/2`. Having that and computing the distance between the two points, you can\nknow the time it should take using the formula `time = space/velocity`.\n\nYou can assume that `2*g*(h0 - h1) + v0**2` is always positive, so the car always moves forward until the track ends, and the quotient above is always well-defined.\n\nAt the start of the track the car has some height, and has no initial velocity, it is left to the effect of gravity.\n\nWe are going to treat every 10 points as being equal to 1 meter. So remember\nthis when calculating distances.\n\n## Graphical visualization\n\nUsing Tk, a solution should draw the track in a canvas as a series of segments joining the given points, and the car as a little circle. Then make the car follow the track according to the computations above until the end of the track is found.\n\nMake the car jump from point to point with a `sleep` call for the computed\namount of time each segments take, no need to interpolate points or draw the actual continuous velocity variation.\n\nYou can use testing gems as you wish, but no other gems are allowed, only standard library.\n\n## Demo\n\nTo see a demo of the visualization working, please visit http://perl.plover.com/qotw/misc/e026/loops.mov.\n\n## Winning the challenge\n\nAfter the challenge is started, whenever someone thinks he has finished the\nproblem he raises his hand.\n\nCode quality is not evaluated, the only metric is getting the implementation right first.\n\nIf his code behaves correctly in the 3 tracks provided, he will be considered\nthe winner.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartapp%2Fruby_challenge_july","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuartapp%2Fruby_challenge_july","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartapp%2Fruby_challenge_july/lists"}