{"id":18735868,"url":"https://github.com/tsimpdim/single-lane-bridge","last_synced_at":"2025-11-16T10:30:17.285Z","repository":{"id":90663542,"uuid":"172480237","full_name":"TsimpDim/Single-Lane-Bridge","owner":"TsimpDim","description":"Example solutions for the Single-Lane-Bridge problem","archived":false,"fork":false,"pushed_at":"2019-03-01T10:47:37.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T16:43:15.699Z","etag":null,"topics":["java","locks","multithreading","single-lane-bridge"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/TsimpDim.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":"2019-02-25T09:58:22.000Z","updated_at":"2019-09-05T16:47:30.000Z","dependencies_parsed_at":"2023-07-09T03:45:55.186Z","dependency_job_id":null,"html_url":"https://github.com/TsimpDim/Single-Lane-Bridge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsimpDim%2FSingle-Lane-Bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsimpDim%2FSingle-Lane-Bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsimpDim%2FSingle-Lane-Bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsimpDim%2FSingle-Lane-Bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TsimpDim","download_url":"https://codeload.github.com/TsimpDim/Single-Lane-Bridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239611992,"owners_count":19668274,"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":["java","locks","multithreading","single-lane-bridge"],"created_at":"2024-11-07T15:18:25.687Z","updated_at":"2025-11-16T10:30:16.130Z","avatar_url":"https://github.com/TsimpDim.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Single Lane Bridge Problem\n\nWhat we want to achieve is having a single lane bridge with cars passing from each direction without crashes. Below are shown the print outs of the different solutions/scenarios in the repo.\n\nArguments are given in order:\n1. Red car population\n2. Blue car population\n3. Frequency of arrival\n4. Car wait time at bridge\n\n## No Crash Scenario (master)\n5 Red[200ms], 2 Blue[200ms]\n```\nRedCar1 is crossing the bridge\n\t\t\t\t\t\t                        BlueCar1 is waiting to cross the bridge\nRedCar2 is waiting to cross the bridge\n\t\t\t\t\t\t                        BlueCar2 is waiting to cross the bridge\nRedCar3 is waiting to cross the bridge\nRedCar4 is waiting to cross the bridge\nRedCar5 is waiting to cross the bridge\nRedCar1 crossed the bridge\n\t\t\t\t\t                        \tBlueCar2 is crossing the bridge\n\t\t\t\t\t\t                        BlueCar2 crossed the bridge\nRedCar4 is crossing the bridge\nRedCar4 crossed the bridge\n\t\t\t\t\t\t                        BlueCar1 is crossing the bridge\n\t\t\t\t\t\t                        BlueCar1 crossed the bridge\nRedCar3 is crossing the bridge\nRedCar3 crossed the bridge\nRedCar2 is crossing the bridge\nRedCar2 crossed the bridge\nRedCar5 is crossing the bridge\nRedCar5 crossed the bridge\n```\n\n## Variable Wait Time Scenario (Random-Wait-Time)\n5 Red[Var], 2 Blue[Var]\n\n### Run 1\n```\n\t\t\t\t\t\t\t\t\t            BlueCar1 is crossing the bridge[10ms]\nRedCar2 is waiting to cross the bridge\nRedCar1 is crossing the bridge[8ms]\n\t\t\t\t\t\t\t\t\t            BlueCar2 is waiting to cross the bridge\nRedCar3 is waiting to cross the bridge\nRedCar4 is waiting to cross the bridge\nRedCar5 is waiting to cross the bridge\nRedCar1 crossed the bridge\n\t\t\t\t\t\t\t\t            \tBlueCar1 crossed the bridge\nRedCar2 is crossing the bridge[30ms]\nRedCar2 crossed the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 is crossing the bridge[22ms]\n\t\t\t\t\t\t\t\t\t            BlueCar2 crossed the bridge\nRedCar3 is crossing the bridge[11ms]\nRedCar3 crossed the bridge\nRedCar4 is crossing the bridge[4ms]\nRedCar4 crossed the bridge\nRedCar5 is crossing the bridge[29ms]\nRedCar5 crossed the bridge\n```\n\n### Run 2\n```\nRedCar1 is crossing the bridge[39ms]\n\t\t\t\t\t\t\t\t\t            BlueCar1 is waiting to cross the bridge\nRedCar2 is waiting to cross the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 is waiting to cross the bridge\nRedCar3 is waiting to cross the bridge\nRedCar4 is waiting to cross the bridge\nRedCar5 is waiting to cross the bridge\nRedCar1 crossed the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar1 is crossing the bridge[18ms]\n\t\t\t\t\t\t\t\t\t            BlueCar1 crossed the bridge\nRedCar2 is crossing the bridge[2ms]\nRedCar2 crossed the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 is crossing the bridge[45ms]\n\t\t\t\t\t\t\t\t\t            BlueCar2 crossed the bridge\nRedCar5 is crossing the bridge[25ms]\nRedCar5 crossed the bridge\nRedCar4 is crossing the bridge[14ms]\nRedCar4 crossed the bridge\nRedCar3 is crossing the bridge[18ms]\nRedCar3 crossed the bridge\n```\n\n## With Collisions (Main-Args-Collisions)\n```\nRedCar1 is crossing the bridge\nRedCar1 crossed the bridge\nRedCar2 is crossing the bridge\n\t\t\t\t  \u003c!\u003e Collision is about to happen\n\t\t\t\t\t\t\t\t\t            BlueCar1 is crossing the bridge\nRedCar2 crossed the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar1 crossed the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 crossed the bridge\n```\n\n## Without Collisions (Main-Args-No-Collision)\n```\nRedCar1 is crossing the bridge\nRedCar1 crossed the bridge\nRedCar2 is waiting to cross the bridge\nRedCar2 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar1 is waiting to cross the bridge\nRedCar2 crossed the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar1 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 is waiting to cross the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar1 crossed the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 crossed the bridge\n```\n\n## Alternating Cars (Main-Args-Alternating)\n```\nRedCar1 is crossing the bridge\nRedCar2 is waiting to cross the bridge\nRedCar1 crossed the bridge\n\t\t\t\t\t\t-BlueCar time-\n\t\t\t\t\t\t\t\t\t            BlueCar1 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar1 crossed the bridge\n\t\t\t\t\t\t-RedCar time-\nRedCar2 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar3 is waiting to cross the bridge\nRedCar2 crossed the bridge\n\t\t\t\t\t\t-BlueCar time-\n\t\t\t\t\t\t\t\t\t            BlueCar3 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar4 is waiting to cross the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar3 crossed the bridge\n\t\t\t\t\t\t-RedCar time-\nRedCar3 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar5 is waiting to cross the bridge\nRedCar3 crossed the bridge\n\t\t\t\t\t\t-BlueCar time-\n\t\t\t\t\t\t\t\t\t            BlueCar2 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar2 crossed the bridge\n\t\t\t\t\t-No more RedCars remaining -\u003e BlueCar time\n\t\t\t\t\t\t\t\t\t            BlueCar4 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar4 crossed the bridge\n\t\t\t\t\t-No more RedCars remaining -\u003e BlueCar time\n\t\t\t\t\t\t\t\t\t            BlueCar5 is crossing the bridge\n\t\t\t\t\t\t\t\t\t            BlueCar5 crossed the bridge\n\t\t\t\t\t\t\u003cEnd\u003e\n```\n## Alternating With Priorities (Main-Args-Alternating-Adjusted)\n```\nRedWeight -\u003e 4\nBlueWeight -\u003e 6\n[BlueCar5, BlueCar3, BlueCar4, RedCar4, RedCar3, RedCar2, BlueCar2, BlueCar6, BlueCar1, RedCar1, RedCar5]\n\n\n                                                BlueCar5 is crossing the bridge\n                                                BlueCar3 is waiting to cross the bridge\n                                                BlueCar5 crossed the bridge\nRedWeight -\u003e 5\nBlueWeight -\u003e 5\n                                                BlueCar4 is waiting to cross the bridge\n                                                BlueCar4 is crossing the bridge\nRedCar4 is waiting to cross the bridge\n                                                BlueCar4 crossed the bridge\nRedWeight -\u003e 5\nBlueWeight -\u003e 5\n                                                BlueCar3 is crossing the bridge\nRedCar3 is waiting to cross the bridge\nRedCar2 is waiting to cross the bridge\n                                                BlueCar3 crossed the bridge\nRedWeight -\u003e 6\nBlueWeight -\u003e 4\n\nRedCar4 is crossing the bridge\nRedCar4 crossed the bridge\n\nRedWeight -\u003e 5\nBlueWeight -\u003e 5\n\nRedCar3 is crossing the bridge\n                                                BlueCar2 is waiting to cross the bridge\n                                                BlueCar6 is waiting to cross the bridge\nRedCar3 crossed the bridge\n\nRedWeight -\u003e 5\nBlueWeight -\u003e 5\n\nRedCar2 is crossing the bridge\n                                                BlueCar1 is waiting to cross the bridge\nRedCar1 is waiting to cross the bridge\nRedCar2 crossed the bridge\n\nRedWeight -\u003e 4\nBlueWeight -\u003e 6\n\n                                                BlueCar2 is crossing the bridge\nRedCar5 is waiting to cross the bridge\n                                                BlueCar2 crossed the bridge\nRedWeight -\u003e 5\nBlueWeight -\u003e 5\n                                                BlueCar6 is crossing the bridge\n                                                BlueCar6 crossed the bridge\nRedWeight -\u003e 6\nBlueWeight -\u003e 4\n\n                                                BlueCar1 is crossing the bridge\n                                                BlueCar1 crossed the bridge\nRedWeight -\u003e 10\nBlueWeight -\u003e 1\n\nRedCar1 is crossing the bridge\nRedCar1 crossed the bridge\n\nRedWeight -\u003e 10\nBlueWeight -\u003e 1\n\nRedCar5 is crossing the bridge\nRedCar5 crossed the bridge\n\nRedWeight -\u003e 1\nBlueWeight -\u003e 10\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsimpdim%2Fsingle-lane-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsimpdim%2Fsingle-lane-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsimpdim%2Fsingle-lane-bridge/lists"}