Solution for UVa 162 – Beggar My Neighbour

Solution for problem UVa 162 – Beggar My Neighbour from UVa Online Judge website.

Sometimes I stuck solving some problems from there (usually because my code either add unneeded new line or doesn’t add needed new line and I am finding what is wrong by trial and error), so here is working solution for UVa 162 – Beggar My Neighbour that can save you time if you encounter some strange Wrong Answer or NZEC errors. Continue reading

Solution for “Empty and Divide” problem

Problem statement:

There are two boxes. Initially, one box contains m chips and the other contains n chips. Such a position is denoted by (m,n), where m > 0 and n > 0. The two players alternate moving. A move consists of emptying one of the boxes, and dividing the contents of the other between the two boxes with at least one chip in each box. There is a unique terminal position, namely (1, 1). Last player to move wins. Find all P-positions.

Continue reading

C++ REST API frameworks benchmark

PHP, Python, C#, Java and Ruby are popular candidates to create REST API. But what about work horses like C and C++?

I decided to investigate most popular C++ frameworks for REST APIs creation and measure their performance relatively to PHP.

Source code of benchmark is freely available on https://github.com/metamaker/cpp-rest-frameworks-benchmark, as well as Vagrant virtual machine to easily reproduce my measurements.

Continue reading

Complete installation guide for LEMP stack with PHP 7 in Debian 8 “Jessie”

Binary Spaceship website

This guide will teach you how to install and configure LEMP stack with Nginx 1.10, MySQL 5.7, PHP 7.1 in Debian 8 “Jessie” on Digital Ocean droplet. All steps are covered, from creation of droplet to securing it with firewall and SSL encryption. You can use instructions from the guide not only for droplet on Digital Ocean, but for any VPS hosting with Debian 8 “Jessie” as well. Continue reading