Skip to main content

Python library for solving the McKinsey Solve Game

Project description

McKinsey Solve Game

This Python package helps solving the Ecosystem Building game from the McKinsey Solve Game. In this game, you need to find a sustainable chain of 8 species among many species (39 in total).

This package provides a function called find_sustainable_food_chain, which takes a list of species as input and returns a solution that optimizes the creation of sustainable food chains, maximizing the count of species involved.

Rules of the Game

A set of 39 species is given. From this set, you need to build a sustainable food chain. Species are divided into producers and animals. Producers do not need calories to survive and consume only natural resources. Animals consume other animals and producers and need calories to survive. Animals follow the following rules:

  • The species with the highest calories provided eats first.
  • It eats the species providing the highest calories provided as a food source. In case of a tie, it will eat half from each of the two species with the same calories.
  • Eating consumes calories from the food source by the amount needed by the predator. You need calories provided greater than zero for a species to survive and all calories needed equal to zero after they eat.

If a species does not get enough calories or reaches zero with its own calories provided, the food chain is not sustainable.

Installation

To install mckinseysolvegame, simply use pip:

pip install mckinseysolvegame

Usage

Define the input species

from mckinseysolvegame import Species

my_species = [
    Species(name="Producer1", calories_provided=4000, calories_needed=0, depth_range="0-30m", temperature_range="28.3-30", food_sources=[]),
    Species(name="Producer2", calories_provided=4050, calories_needed=0, depth_range="0-30m", temperature_range="28.3-30", food_sources=[]),
    Species(name="Producer3", calories_provided=5000, calories_needed=0, depth_range="0-30m", temperature_range="28.3-30", food_sources=[]),
    Species(name="Animal1", calories_provided=1000, calories_needed=1050, depth_range="0-30m", temperature_range="28.3-30", food_sources=["Producer1"]),
    Species(name="Animal2", calories_provided=800, calories_needed=900, depth_range="0-30m", temperature_range="28.3-30", food_sources=["Animal1", "Producer3"])
]

Find the species that form a sustainable food chain

from mckinseysolvegame import Solver

result = Solver.find_sustainable_food_chain(my_species)
result.to_json()

The API will return a JSON object with the following format:

{
    "number_of_species": 5,
    "species": ["Producer3", "Producer2", "Producer1", "Animal1", "Animal2"]
}

This object contains the maximum number of species that can sustain, as well as the list of species names.

Contributing

We welcome contributions to mckinseysolvegame! If you find a bug or would like to request a new feature, please open an issue on the Github repository. If you would like to contribute code, please submit a pull request.

License

mckinseysolvegame is released under the MIT License.

To Do List

Currently, we assume that the input is a subset of the 39 species. We assume that the input is made of only 3 producers (the ones for which the sum of calories provided is maximum).

  • Consider a list of 39 input species, not just 13 (3 producers + 10 animals)
  • Consider the case eating half of calories provided in case of a tie

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mckinseysolvegame-0.5.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

mckinseysolvegame-0.5.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file mckinseysolvegame-0.5.0.tar.gz.

File metadata

  • Download URL: mckinseysolvegame-0.5.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for mckinseysolvegame-0.5.0.tar.gz
Algorithm Hash digest
SHA256 556da6291990476bd2b32eb44bc1084405118a9337164130f4bd16fc294509ef
MD5 c621a44df9ce9929b5847b62c8aaaf35
BLAKE2b-256 4fb6c68a117d5dbd14d81b773df64140db17ac85354458877f891120103a742d

See more details on using hashes here.

File details

Details for the file mckinseysolvegame-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mckinseysolvegame-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7675d8a94f9a2c4035e1cb6b4c46c7c4ea9b77fcb11c95c6eb1a3dc2e477e6d
MD5 046d47a0fb41de00bc9aa477091b468a
BLAKE2b-256 5ee2190d63df1ec2e08b939b2037c1a9facbadc35cd360f63fafd98ac47f13bc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page