Some test cases violate a naive assumption: food should appear in screen

  • 0

    In real Snake Game, the food should always appear inside the boundary (or said shown in screen); unfortunately, some test cases violate this naive assumption.

    SnakeGame(int width, int height, vector<pair<int, int>> food) {
        // ...
        n = height;
        m = width;
        int rfood = food;
        int flag = 0;
        // ...
    int move(string direction) {
        // ...
        if (flag < rfood.size()) {
            int fr = rfood[flag].first;
            int fc = rfood[flag].second;
            assert(0 <= fr and fr < n and 0 <= fc and fc < m);
        // ...

    One of the test cases is in the shape of (width=100, height=30); however, one food appears at (58, 7).

    I would appreciate it if someone can kindly update the test cases.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.