Improve your ability to solve algorithms with AtCoder

Hudai
4 min readFeb 24, 2020
Photo by Blake Connally on Unsplash

To get job of engineering, we may have to take code examinations. It is necessary not only to know algorithms but also to get used to apply them to real problems, and because of this fact they are sometimes largest wall for our goals.

Some of you may be using online services like LeetCode, CodeWars, Hacker Rank.

They all are very famous service and they have good problems to train for solving algorithms. But their problems are like the paper test in schools, they are sometimes boring, aren’t you?

I introduce you a another service in which you can improve your ability to solve algorithms like playing game. This is AtCoder!

What is AtCoder?

AtCoder is the Japanese startup company. Their home page supports Japanese and English. and they run programming contests almost every weekend (usually start 21:00 in Japan). You can take part in these contests but you can also practice the coding with past questions.

If you take part in the contests you can get “rate”, and get “color” corresponding to the rate range. If you know codeforces, you may be familiar with color system.

In AtCoder, you can use a lot of programming languages.

  • C
  • C++
  • Python2, Python3, PyPy2, PyPy3
  • Ruby
  • Julia
  • Java
  • JavaScript, TypeScript
  • Go
  • Rust
  • Fortran
  • Bash

…etc.

Color system on AtCoder

AtCoder classifies users with their ability. The beginners are“gray” and the professional-like coders are “red”. The concrete level of each color is explained in the blog of CEO (Japanese).

Summarizing it briefly,

  • grey: beginners
  • blown: keen on the algorithms if you are a student in CS degree
  • green: excellent if you are a student. feel secure to certain degree if you are an engineer.
  • light blue: excellent engineer in tech companies.
  • blue: excess of algorithm ability in some tech companies
  • yellow: excess of algorithm ability in almost all tech companies
  • orange: excellent scholar of algorithms
  • red: monsters

What do the problems on AtCoder like?

As I wrote above, you can enjoy solving coding problems with AtCoder. I introduce some problems questioned at a past contest.

AtCoder Beginners Contest 153

problem A

Serval is fighting with a monster.

The health of the monster is H.

In one attack, Serval can decrease the monster’s health by A. There is no other way to decrease the monster’s health.

Serval wins when the monster’s health becomes 0 or below.

Find the number of attacks Serval needs to make before winning.

problem B

Raccoon is fighting with a monster.

The health of the monster is H.

Raccoon can use N kinds of special moves. Using the i-th move decreases the monster’s health by Ai. There is no other way to decrease the monster’s health.

Raccoon wins when the monster’s health becomes 0 or below.

If Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.

problem C

Fennec is fighting with N monsters.

The health of the i-th monster is Hi.

Fennec can do the following two actions:

Attack: Fennec chooses one monster. That monster’s health will decrease by 1.

Special Move: Fennec chooses one monster. That monster’s health will become 0.

There is no way other than Attack and Special Move to decrease the monsters’ health.

Fennec wins when all the monsters’ healths become 0 or below.

Find the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.

Actually this contest has problems from A to F , but I only quote a part of A to C problems. (If you are interested in details please click the link above.) You may notice the setting is like fantasy or RPG, so you can feel as if you are making a part of a game.

Another important thing is the difficulty of these problems. The A problem are very easy if you can deal with standard I/O operations. If you use C++, an answer of this problem is like,

#include <bits/stdc++.h>
using namespace std;

int main() {
int H, A;
cin >> H >> A;

if (H % A == 0){
cout << H / A << endl;
} else {
cout << H / A + 1 << endl;
}
}

So, don’t worry if you have no confidence.

Conclusion

In this post, I introduced you the AtCoder, which is online programming contest service. In this site, you can enjoy coding and learn algorithms even if you are not competitive programmer.

--

--