{"id":16359764,"url":"https://github.com/jmsv/crime-solver","last_synced_at":"2025-12-31T15:30:18.204Z","repository":{"id":95749605,"uuid":"72662796","full_name":"jmsv/crime-solver","owner":"jmsv","description":"C# program to solve a crime logic puzzle","archived":false,"fork":false,"pushed_at":"2017-04-04T00:37:30.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-29T17:34:22.562Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmsv.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":"2016-11-02T17:08:42.000Z","updated_at":"2021-12-03T17:27:43.000Z","dependencies_parsed_at":"2023-05-21T21:15:11.608Z","dependency_job_id":null,"html_url":"https://github.com/jmsv/crime-solver","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/jmsv%2Fcrime-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmsv%2Fcrime-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmsv%2Fcrime-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmsv%2Fcrime-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmsv","download_url":"https://codeload.github.com/jmsv/crime-solver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239727035,"owners_count":19687096,"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":"2024-10-11T02:09:36.149Z","updated_at":"2025-02-19T19:42:57.580Z","avatar_url":"https://github.com/jmsv.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crime-solver\nC# program to solve a crime logic puzzle\n\n---\n\n### PROBLEM:\n\n#### After a crime, four suspects were interviewed. Below are their statements. The detectives know that *each told one true statement* and *one false statement*. From the information below, can you tell who committed the crime?\n\nAlex said:\n\n- It wasn't David\n- It wasn't Brad\n\nBrad said:\n\n- It wasn't Charlie\n- It was David\n\nCharlie said:\n\n- It was Alex\n- It wasn't David\n\nDavid said:\n\n- It was Charlie\n- It wasn't Alex\n\n---\n\n### SOLUTION:\n\nUsing the program, every combination of true or false for four boolean variables is tested for validity with respect to the statements by the four suspects. If all four `Valid` suspect statments return `true`, the suspect name(s) are written to `Console`.\n\nView [`Program.cs`](https://github.com/jamesevickery/crime-solver/blob/master/CrimeSolver/Program.cs) to see the `C#` implementation.\n\n---\n\n#### Another way of solving the puzzle:\n\nLet '`A`' mean 'Alex commited the crime', '`B`' means that it was Brad, etc.\n\nFrom the four suspects' statements we can form a proposition:\n\n    ((¬D ∧ B) ∨ (D ∧ ¬B)) ∧\n    ((¬C ∧ ¬D) ∨ (C ∧ D)) ∧\n    ((A ∧ D) ∨ (¬A ∧ ¬D)) ∧\n    ((C ∧ D) ∨ (¬C ∧ ¬D))\n    \nIf we assume that only one suspect commited the crime:\n\n    ((¬D ∧ B) ∨ (D ∧ ¬B)) ∧\n    (¬C ∧ ¬D)\n    (¬A ∧ ¬D)\n    (¬C ∧ ¬D)\n\nSimplified to:\n\n    ¬C ∧ ¬D ∧ ¬A ∧ ((¬D ∧ B) ∨ (D ∧ ¬B))\n\nFinally, as we know `¬D` is true:\n\n    ¬C ∧ ¬D ∧ ¬A ∧ B\n\nIn English, this means: Charlie didn't commit the crime, David didn't commit the crime, Alex  didn't commit the crime, **Brad commited the crime**.\n\nThis result is (almost) the same as the program's result. Program output:\n\n    The crime was commited by: Alex, Charlie, David.\n    The crime was commited by: Brad.\n\nThe program's only answer assuming that only one person commited the crime is `The crime was commited by: Brad.`, although due to the original question's ambiguity (not specifying that only one person commited the crime) it is possible that all suspects *except* Brad commited the crime.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmsv%2Fcrime-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmsv%2Fcrime-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmsv%2Fcrime-solver/lists"}