{"id":19773205,"url":"https://github.com/mbarbin/catch-the-bunny","last_synced_at":"2025-07-03T09:05:46.846Z","repository":{"id":91167126,"uuid":"573730863","full_name":"mbarbin/catch-the-bunny","owner":"mbarbin","description":"Resolve a fun little logic puzzle","archived":false,"fork":false,"pushed_at":"2025-06-29T11:28:52.000Z","size":153,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T11:32:44.935Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://mbarbin.github.io/catch-the-bunny/","language":"OCaml","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/mbarbin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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,"zenodo":null}},"created_at":"2022-12-03T08:44:23.000Z","updated_at":"2025-06-06T07:49:37.000Z","dependencies_parsed_at":"2023-11-12T20:21:45.764Z","dependency_job_id":"f5271872-1290-4753-82f0-b040dfd22959","html_url":"https://github.com/mbarbin/catch-the-bunny","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mbarbin/catch-the-bunny","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarbin%2Fcatch-the-bunny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarbin%2Fcatch-the-bunny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarbin%2Fcatch-the-bunny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarbin%2Fcatch-the-bunny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbarbin","download_url":"https://codeload.github.com/mbarbin/catch-the-bunny/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarbin%2Fcatch-the-bunny/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263296418,"owners_count":23444489,"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-11-12T05:08:57.308Z","updated_at":"2025-07-03T09:05:46.823Z","avatar_url":"https://github.com/mbarbin.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# catch-the-bunny\n\n[![CI Status](https://github.com/mbarbin/catch-the-bunny/workflows/ci/badge.svg)](https://github.com/mbarbin/catch-the-bunny/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/mbarbin/catch-the-bunny/badge.svg?branch=main)](https://coveralls.io/github/mbarbin/catch-the-bunny?branch=main)\n\nThe is a toy project that implements a solver for a fun little logic puzzle.\n\n## What's the puzzle ?\n\nThe goal is to catch a bunny that hides in a box within a row of boxes.\n\nTo catch the bunny, you have to open the actual box where the bunny is hiding. When boxes are closed, you can't see what's in them.\n```\n+---+---+---+---+\n| 1 | 2 | 3 | 4 | Where is the bunny ?\n+---+---+---+---+\n```\nWhen the game starts, the bunny is located in one of the boxes, but you don't know which one. At each step, you choose a box and you open it. If the bunny is there, the game stops and you've won. If it isn't there, you close the box and then the bunny moves to a different box. Then the game repeats : you choose another box, if you haven't caught the bunny, it moves again and the game goes on.\n\n## How does the bunny move exactly ?\n\nThe bunny moves to the box that is either to the left or to the right of where it is currently.\n\nFor example, if the bunny starts in box number 2:\n```\n+---+---+---+---+\n|   | X |   |   | The 'X' is the bunny - it hides in box 2.\n+---+---+---+---+\n```\nafter it moves it will either be located in box number 1:\n```\n+---+---+---+---+\n| X |   |   |   | The bunny moved to the left.\n+---+---+---+---+\n```\nor in box number 3:\n```\n+---+---+---+---+\n|   |   | X |   | The bunny moved to the right.\n+---+---+---+---\n```\nIf the bunny is on the side, it may only move away from that side.\n\nFor example, if the bunny is in box number 1:\n```\n+---+---+---+---+\n| X |   |   |   | There's nowhere to go to the left !\n+---+---+---+---+\n```\nafter it moves it will necessarily be in box number 2:\n```\n+---+---+---+---+\n|   | X |   |   | The bunny had to move to the right.\n+---+---+---+---+\n```\nSymmetrically, if the bunny is in the last box, it has to move to the left.\n\n## What's an actual solution to the problem ?\n\nIt isn't sufficient to establish good odds of catching the bunny. You shall rather devise a strategy that will make sure that you catch the bunny in a maximum number of steps.\n\n### Examples : size 2\n\nIf the row is of size 2, then by opening the box 1 twice in a row, you'll make sure to catch the bunny in at most 2 steps.\n\nIf the bunny is initially in 1, you'll catch it at step 1:\n```\n+---+---+\n| X |   | You open box 1 and catch the bunny\n+---+---+\n```\nIf it is initially in 2, at first you won't see it in box 1:\n\nStep 1\n```\n+---+---+\n|   | X | You open box 1 - the bunny isn't there\n+---+---+\n```\nThe bunny moves. It is now necessarily in 1.\n\nStep 2:\n```\n+---+---+\n| X |   | You open box 1 and catch the bunny\n+---+---+\n```\n### Actual size\n\nCan you solve this puzzle for a row of 6 or 8 boxes ?\n\n# Where does the puzzle comes from ?\n\nIt comes from an online compute science challenge for kids that is hosted there:\n\nhttps://concours.castor-informatique.fr/\n\nThat specific puzzle was one of the training exercises of the year 2021.\n\n## Motivations\n\nWhile the puzzle isn't meant to be solved using a computer program, it's a fun little project to implement regardless.\n\n## Code Documentation\n\nThe code documentation of the latest release is built with `odoc` and published to `GitHub` pages [here](https://mbarbin.github.io/catch-the-bunny).\n\nThe code is executed through test files located in the [test/](test/) subdirectory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbarbin%2Fcatch-the-bunny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbarbin%2Fcatch-the-bunny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbarbin%2Fcatch-the-bunny/lists"}