{"id":25791039,"url":"https://github.com/niki4/challenge_sumup_snake_api","last_synced_at":"2026-06-17T14:32:31.717Z","repository":{"id":133496215,"uuid":"347050159","full_name":"niki4/challenge_sumup_snake_api","owner":"niki4","description":"Snake game validator | Backend challenge of sumup.com","archived":false,"fork":false,"pushed_at":"2021-03-12T11:59:25.000Z","size":23143,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"submission","last_synced_at":"2025-02-27T15:47:08.431Z","etag":null,"topics":["challenge-project","sumup","take-home-assignment"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niki4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-03-12T11:57:02.000Z","updated_at":"2024-04-12T14:14:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"99cdc501-87c1-4161-a668-d20ab139f7a0","html_url":"https://github.com/niki4/challenge_sumup_snake_api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/niki4/challenge_sumup_snake_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niki4%2Fchallenge_sumup_snake_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niki4%2Fchallenge_sumup_snake_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niki4%2Fchallenge_sumup_snake_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niki4%2Fchallenge_sumup_snake_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niki4","download_url":"https://codeload.github.com/niki4/challenge_sumup_snake_api/tar.gz/refs/heads/submission","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niki4%2Fchallenge_sumup_snake_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34453431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["challenge-project","sumup","take-home-assignment"],"created_at":"2025-02-27T12:41:02.067Z","updated_at":"2026-06-17T14:32:31.712Z","avatar_url":"https://github.com/niki4.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SumUp Backend Challenge\n\nHello and welcome to the SumUp backend technical challenge. This document will\noutline the challenge and provide you with the information needed in order to\ncomplete your task.\n\nThis challenge can be performed in the language of your choice unless previously\nspecified during the interview process. \n\n## Overview\n\nThe concept of [Snake](https://en.wikipedia.org/wiki/Snake_(video_game_genre))\n(the video game) has been around since 1976–when the video game Blockade\ninvented the genre. However, it saw a new popularity and ultimately rose to\nprominence after the launch of Nokia's 6110 mobile phone in 1997. Its popularity\nexploded, leading to many spin-offs and coming preloaded on the majority of\nNokia's subsequent phones. This ultimately cemented Snake's place in the arcade\nhall-of-fame, where it resides to this day.\n\nIn order to continue the legacy of this arcade marvel, we would like to\nimplement the snake game with a global leaderboard on our SumUp Solo card\nreader.\n\nIn this challenge, we would like you to build a simple validator for the game.\nThis validator should have a simple HTTP API allowing clients to implement their\nown snake games, and allowing our hardware team to implement it on the Solo\nreader.\n\nYour API will be used to prevent cheating, and to make sure that a given set of\nmoves leads to a valid outcome; thus maintaining trust in our highly competitive\nglobal leaderboard.\n\nWe will intentionally be simplifying the game of snake in order to make it more\nachievable during this challenge. Here are some prior considerations.\n\n- Your snake will never be longer than length 1. It will *not* grow after eating\n    a fruit.\n- You will only have 1 single fruit at a time on the game board.\n- If the snake hits the edge of the game bounds, the game is over.\n- The snake will always start at position `(0, 0)`, with a velocity of `(1, 0)`.\n    - i.e. at `x=0`, `y=0` moving to the *right*.\n\nThe client will make an initial call to the validator to start a new game with\nthe provided parameters. It will then collect a series of \"ticks\", containing\nmoves that will lead the snake to the position of the fruit. A tick is a single\nmovement of the snake in a given (x, y) direction. Once the moves lead the snake\nto the fruit, the game state and ticks are sent back to your validator in order\nto confirm that the move-set is valid. If they are valid, the validator will\nincrement the game's score, generate a new position for the fruit and send back\nthe new game state, and so on and so forth.\n\n## Requirements\n\nThe validator should expose a web server with two routes. The server itself\nshould be stateless. We also appreciate thorough testing.\n\n- `GET /new?w=[width]\u0026h=[height]`:\n    - Query Params:\n        - `w: int`\n        - `h: int`\n    - Response:\n        - *200*: JSON marshalled `state`, with randomly generated fruit\n            position.\n        - *400*: Invalid request.\n        - *405*: Invalid method.\n        - *500*: Internal server error.\n\n\u003cbr /\u003e\n\n- `POST /validate`: \n    - JSON Body:\n    ```go\n    {\n        ...state // all fields in state type\n        ticks: [\n            { velX: int, velY: int }, // velocity at that tick\n            ...\n        ]\n    }\n    ```\n    - Response:\n        - *200*: Valid state \u0026 ticks. Returns JSON marshalled `state` with new\n            randomly generated fruit position and a score incremented by 1.\n        - *400*: Invalid request.\n        - *404*: Fruit not found, the ticks do not lead the snake to the fruit\n            position.\n        - *405*: Invalid method.\n        - *418*: Game is over, snake went out of bounds or made an invalid move. \n        - *500*: Internal server error.\n\n#### Types\n```go\ntype state struct {\n\tGameID string `json:\"gameId\"`\n\tWidth  int    `json:\"width\"`\n\tHeight int    `json:\"height\"`\n\tScore  int    `json:\"score\"`\n\tFruit  fruit  `json:\"fruit\"`\n\tSnake  snake  `json:\"snake\"`\n}\n\ntype fruit struct {\n\tX int `json:\"x\"`\n\tY int `json:\"y\"`\n}\n\ntype snake struct {\n\tX    int `json:\"x\"`\n\tY    int `json:\"y\"`\n\tVelX int `json:\"velX\"` // X velocity of the snake (-1, 0, 1)\n\tVelY int `json:\"velY\"` // Y velocity of the snake (-1, 0, 1)\n}\n```\n\n## Hints\n\n#### Velocity\n\nThe snake maintains its movement in a given direction until it is given an\ninstruction to change it. The format of this velocity is `(x, y)`, where `x` is\nthe velocity in the `x` direction and `y` is the velocity in the `y` direction.\nVelocity values can be one of `-1`, moving left/up, `0`, no movement for axis,\n`1`, down/right. \n\n#### Movement\n\nIn the rules of Snake, only certain movements are possible at each time. For\nexample, when the snake is moving to the right, velocity `(1, 0)`, it is\nimpossible for it to do an immediate 180-degree turn to velocity `(-1, 0)`.\nCalls to `/validate` with these sorts of invalid moves should return the invalid\nresponse. \n\n## Submission\n\nComplete the problem in this repository on a branch called `submission`. When\ncomplete, open a pull-request against the master branch in order to receive\nfeedback in the form of comments.\n\nWe have included a small acceptance testing binary at path `/run-test*` to help\nyou validate your solution. In order for us to be sure that your solution passes\nour acceptance tests, when run, the tests will output a code. The binary takes a\nflag `-port` for you to select which port your validation server is running on.\nThe default port is `8080`.\n\n**Note:** Make sure you run the binary that is applicable for your machine's OS\nand architecture.\n\ne.g. If you're using a Mac with an Intel CPU.\n```bash\n$ ./run-test_darwin_amd64 -port 8081\n```\n\nor Windows:\n```bash\n$ ./run-test_windows_amd64 -port 8081\n```\n\nIf the tests pass, you will see something similar to:\n\n```bash\n$ ./run-test_darwin_amd64\nPASS\n\n== PLEASE INCLUDE THIS WITH YOUR SUBMISSION. ==\nWell done! Your code is: [your_code_here] \n== PLEASE INCLUDE THIS WITH YOUR SUBMISSION. ==\n```\n\n**Please include the acceptance test verification code in your pull-request\ndescription**.\n\n## What we're looking for...\n\nWhen we assess your submission, we are looking at the following criteria.\n\n- **Simplicity**: Did you solve the problem in a convoluted manner, or did you\n    keep it simple? This is a big one for us. We *greatly* value simple\n    solutions over complex ones.\n\n- **Maintainability**: Is the code going to be easy to maintain in the future?\n    Will it act predictably to changes?\n\n- **Consistency**: Is the code consistent within itself?\n\n- **Testability**: How easy is your code to test? Does the structure lend itself\n    to being easily tested?\n\n## Extra for experts\n\n1. Consider that the state returned may be maliciously manipulated by the\n   client. How can we prevent this? Add this to your implementation.\n\n2. Highlight a deficiency with the solution. What would a solution be?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniki4%2Fchallenge_sumup_snake_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniki4%2Fchallenge_sumup_snake_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniki4%2Fchallenge_sumup_snake_api/lists"}