Here are the problems we designed for the Shaker 2018 Coding Battle. These problems have been designed and written by INSAlgo.
-
Pre-contest (to try out the contest platform)
- A. 42: a simple input / output test with conditional statements.
- B. The Alchemist: find the number of ways to satisfy a mathematical formula.
- C. Riddle, find the n-th term of a special sequence.
-
Coding Battle (theme: pirates)
- A. Loot Sharing: calculate if the result of a simple formula is above or below a given target.
- B. The Parrots of Tortuga: find out which trainer can sell the biggest number of parrots for the amount of money you have.
- C. Sea Storm: decide if a line segment can be covered, given a list of line segments, and the possible locations of their center.
- D. The Pirate Alphabet: find the number of insertions needed to find the alphabet from a given string, with unlimited deletions.
- E. Treasure Map: find the maximum flow that you can get at the source of a tree, given the capacity of each edge and the amount emitted by each node.
- F. Two Ships: divide a crew in two such that no rivals are on the same boat, and the weights of the boats are as balanced as possible.
The solutions available are the ones we wrote and solutions from contributors that we approved. There are often many ways to solve a problem. Our solutions are not perfect but adapted to the skills we wanted to evaluate at each task. Please feel free to add the solutions in the missing languages, or better solutions than the ones we did.
If you translate an existing solution in a new language, please try to follow the structure, naming conventions and comments of the existing solution. Thanks for contributing :)
We won't reopen the platform, because it is costly to host and you can test your solutions locally or import the contest on your own platform.
To test your solutions, you can use piping in a terminal. For example, on Linux (if you don't use a Unix shell, you can find tutorials online):
# Python
python solution.py < ../input/input0.txt
# C++
./sol < ../input/input0.txt
# JavaScript
js sol.js < ../input/input0.txt
# etc
We read a lot of your submissions in the last few contests, and received many questions. Here is some advice if you want to avoid common mistakes:
- Learn to manage input / output. You can't afford to lose time on something like that when doing competitive programming. Most of the contests have the same format of input and output: reading space-separated lists of integers, strings, floats, or read multiple lines.
- Read carefully the format of input and output: a typo can ruin your solution.
- You don't have to check that the input is within the given bounds. The input is within the given bounds. Otherwise, why would we even provide the bounds?
This repo is under MIT license (see details below). However, some of the pictures used in the statements are not in the public domain or under a free license. We obtained the consent from their authors to use them, and you need to do the same.
MIT License
Copyright (c) 2018 INSAlgo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.```