{"id":15689236,"url":"https://github.com/christophevg/mastermind","last_synced_at":"2025-10-14T12:30:36.126Z","repository":{"id":137514691,"uuid":"77799464","full_name":"christophevg/mastermind","owner":"christophevg","description":"A small project to dive into the Swift programming language.","archived":true,"fork":false,"pushed_at":"2017-01-05T10:22:19.000Z","size":1099,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T06:31:44.168Z","etag":null,"topics":["mastermind","solver","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/christophevg.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-01-01T22:31:43.000Z","updated_at":"2023-10-28T09:51:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"75c9e4df-6d05-458f-af9c-4848cdf14145","html_url":"https://github.com/christophevg/mastermind","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/christophevg/mastermind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophevg%2Fmastermind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophevg%2Fmastermind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophevg%2Fmastermind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophevg%2Fmastermind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christophevg","download_url":"https://codeload.github.com/christophevg/mastermind/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophevg%2Fmastermind/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018662,"owners_count":26086576,"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-14T02:00:06.444Z","response_time":60,"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":["mastermind","solver","swift"],"created_at":"2024-10-03T18:01:26.199Z","updated_at":"2025-10-14T12:30:36.112Z","avatar_url":"https://github.com/christophevg.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MasterMind\n\nA small project to dive into the Swift programming language.    \nChristophe VG (\u003ccontact@christophe.vg\u003e)  \n[https://github.com/christophevg/mastermind](https://github.com/christophevg/mastermind)\n\n## Introduction\n\nAround Christmas 2016, our daughter got the new edition of [Mastermind](http://www.hasbro.com/nl-be/product/mastermind:93765D16-6D40-1014-8BF0-9EFBF894F9D4). Around that same time I was reading [iOS Programming Fundamentals with Swift](http://shop.oreilly.com/product/0636920055211.do). After finishing the first part on Swift, I needed a small project to get my hands dirty and try out some of that new programming language I'd been reading about.\n\nLooking across the table to the game we just gave, resulted in this repository ;-)\n\nThe algorithm implemented is a slightly adapted version of the one described by [Donald Knuth](https://en.wikipedia.org/wiki/Mastermind_(board_game)#Five-guess_algorithm). I havent' really focussed on performance, but rather on getting to know language features to implement the code representation and solver in a _clean_ way.\n\nEach code consists of 4 coloured balls, chosen out of 8 possible colours. Feedback on guesses is given in the form of red and white markers, with white indicating a correct colour, but in the wrong location, and red for a correct color in the correct location.\n\n## Running the solver...\n\nBelow is a screencast of a session, in which a code is randomly chosen and then solved...\n\n![Running the solver](assets/session.gif)\n\n## Running all unit tests\n\nTo become familiar with writing unit tests in Swift, I added a few, without being exhaustive, nor thorough. \n\n```bash\n$ make test\nCompile Swift Module 'MasterMindTests' (1 sources)\nLinking ./.build/debug/MasterMindPackageTests.xctest/Contents/MacOS/MasterMindPackageTests\nTest Suite 'All tests' started at 2017-01-03 22:07:13.385\nTest Suite 'MasterMindPackageTests.xctest' started at 2017-01-03 22:07:13.386\nTest Suite 'CodeTests' started at 2017-01-03 22:07:13.386\nTest Case '-[MasterMindTests.CodeTests testCodeByIndex]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeByIndex]' passed (0.008 seconds).\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonAllMisplaced]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonAllMisplaced]' passed (0.002 seconds).\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonEquality]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonEquality]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonEverythingOkay]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonEverythingOkay]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonHashValue]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonHashValue]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonMixedResults]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonMixedResults]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonNothingOkay]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeComparisonNothingOkay]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testCodeIndexBoundaries]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeIndexBoundaries]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testCodeSubscripting]' started.\nTest Case '-[MasterMindTests.CodeTests testCodeSubscripting]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testDescription]' started.\nTest Case '-[MasterMindTests.CodeTests testDescription]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testEqualCodes]' started.\nTest Case '-[MasterMindTests.CodeTests testEqualCodes]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testIndexBasedColorInit]' started.\nTest Case '-[MasterMindTests.CodeTests testIndexBasedColorInit]' passed (0.001 seconds).\nTest Case '-[MasterMindTests.CodeTests testInvalidComparisonBoundaries]' started.\nTest Case '-[MasterMindTests.CodeTests testInvalidComparisonBoundaries]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testNotEqualCodes]' started.\nTest Case '-[MasterMindTests.CodeTests testNotEqualCodes]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testStringBasedColorInit]' started.\nTest Case '-[MasterMindTests.CodeTests testStringBasedColorInit]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testTooFewParts]' started.\nTest Case '-[MasterMindTests.CodeTests testTooFewParts]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testTooManyParts]' started.\nTest Case '-[MasterMindTests.CodeTests testTooManyParts]' passed (0.000 seconds).\nTest Case '-[MasterMindTests.CodeTests testValidComparisonBoundaries]' started.\nTest Case '-[MasterMindTests.CodeTests testValidComparisonBoundaries]' passed (0.000 seconds).\nTest Suite 'CodeTests' passed at 2017-01-03 22:07:13.400.\n\t Executed 18 tests, with 0 failures (0 unexpected) in 0.013 (0.014) seconds\nTest Suite 'MasterMindPackageTests.xctest' passed at 2017-01-03 22:07:13.400.\n\t Executed 18 tests, with 0 failures (0 unexpected) in 0.013 (0.014) seconds\nTest Suite 'All tests' passed at 2017-01-03 22:07:13.400.\n\t Executed 18 tests, with 0 failures (0 unexpected) in 0.013 (0.016) seconds\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristophevg%2Fmastermind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristophevg%2Fmastermind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristophevg%2Fmastermind/lists"}