C++ cond solution
class DiningPhilosophers {\n    \n    mutex m;\n    condition_variable c;\n    \n    array fStates;\n    \npublic:\n    DiningPhilosophers() {\n        fStates.
class DiningPhilosophers {\n    \n    mutex m;\n    condition_variable c;\n    \n    array<bool, 5> fStates;\n    \npublic:\n    DiningPhilosophers() {\n        fStates.fill(true);\n    }\n\n    void wantsToEat(int pId,\n                    function<void()> pickLeftFork,\n                    function<void()> pickRightFork,\n                    function<void()> eat,\n                    function<void()> putLeftFork,\n                    function<void()> putRightFork) {\n\t\t\n        if (pId > 4 || pId < 0) return;\n        \n        int rId = pId - 1;\n        if (rId == -1) rId = 4;\n\n        unique_lock<mutex> l(m);\n        \n        c.wait(l, [&]{return fStates[pId] && fStates[rId];});\n        \n        fStates[pId] = false;\n        fStates[rId] = false;\n        \n        l.unlock();\n        \n        pickLeftFork();\n        pickRightFork();\n        eat();\n        putRightFork();\n        putLeftFork();\n        \n        l.lock();\n        \n        fStates[pId] = true;\n        fStates[rId] = true;\n        \n        c.notify_all();\n    }\n};
[]