{"id":26059642,"url":"https://github.com/mnikander/landmasses","last_synced_at":"2025-07-31T02:36:21.963Z","repository":{"id":244531313,"uuid":"814707539","full_name":"mnikander/landmasses","owner":"mnikander","description":"coding exercise to count the number of islands on a map","archived":false,"fork":false,"pushed_at":"2024-06-15T11:22:50.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-10T15:41:43.960Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mnikander.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-06-13T14:37:21.000Z","updated_at":"2024-06-15T11:22:53.000Z","dependencies_parsed_at":"2024-06-15T12:51:30.236Z","dependency_job_id":null,"html_url":"https://github.com/mnikander/landmasses","commit_stats":null,"previous_names":["manik7/landmasses","mnikander/landmasses"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Flandmasses","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Flandmasses/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Flandmasses/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnikander%2Flandmasses/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnikander","download_url":"https://codeload.github.com/mnikander/landmasses/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242555314,"owners_count":20148675,"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":[],"created_at":"2025-03-08T13:26:53.146Z","updated_at":"2025-07-31T02:36:21.855Z","avatar_url":"https://github.com/mnikander.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Landmasses\n\nCount the number of islands in a map.\nEach map is encoded as a text file of ASCII characters.\nA `.` encodes water and other symbols encode forests, buildings, and other terrain types.\n\n## Getting started\n\n```bash\n# out-of-source build\ncd landmasses \u0026\u0026 mkdir out \u0026\u0026 cd out \u0026\u0026 cmake .. \u0026\u0026 cd ..\ncmake --build out/\n./out/landmasses resources/map1_6islands.txt\n```\n\n## Approach\n\nThis is a connected components problem.\nThe connected components are determined using depth-first search with a 3x3 image kernel.\nThe runtime and memory usage are both in O(n).\n\n## Program structure\n\n1. Input\n    - Parse and check command line argument\n    - Open the file (if possible)\n    - Read file and copy contents into a 2d nested array which distinguishes only between water and non-water pixels\n2. Connected components\n    - Iterate over all points and start a DFS, clustering any unassigned neighboring points\n    - Return the number of clusters found\n3. Output\n    - Print the author name and number of landmasses to the console\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnikander%2Flandmasses","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnikander%2Flandmasses","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnikander%2Flandmasses/lists"}