the world of big spenders and keyboards part 1

I’m sure everyone knows what a keyboard is.
Vanilla computer keyboards, POS keyboards, keyboard on phone (QWERTY ones), even virtual keyboards.
I’ve been lurking around a certain subreddit called r/mk.

R/MK?

MK is Mechanical Keyboard in short, not Mortal Kombat and surely not Mario Kart (both has its own subreddit though)
So. What’s hot about this… Mechanical Keyboards you ask ? Well, they use a special switch that is… Well, mechanical.
Most generic keyboards provided in offices (I’m talking about Logitech’s K120. It’s not bad.) uses rubber dome stuff, which produces somehow kicky feeling when you type.

T-primes

Problem Link : http://codeforces.com/problemset/problem/230/B

This problem asks you to find positive integers that can be divided by three different positive integers.
Ideal candidates for T-Prime numbers would be numbers that is formed by power of two of an integer. This means that the number supplied by the problem must have integer square root.
However, that is not enough to ensure that it would be a T-Prime number. If the roots are not prime, the number supplied can be divided by more than 3 positive integers.
Hence the root should be prime.

Holiday Of Equality

Problem Link : http://codeforces.com/problemset/problem/758/A

This problem asks you how many burles (currency in the story) would it take so that the citizens will have same amount of money.
It is stated in the problem we can’t take money from citizens, so the only way is to increment each citizen’s money until they have the same amount ( we are not supposed to increment a citizen’s money that has the highest value among all)

It’s possible to skip using arrays to store number of money each citizen has, by simply summing the number of money each citizen has and find out how much money the richest citizen has.
Doing so will allow us to count how much money would all citizen have in total, and then we simply substract it with amount of money all citizens have at first.

New Year and Hurry

Problem link : http://codeforces.com/problemset/problem/750/A

This problem requires you to count how many problems Limak can do in 240 – k minutes.

One way I can think of is to manually count how many minutes Limak need to do 1 problem – 10 problems (t1 – t10), and then based on the time left (240 -k), find how many problems he can solve. (Answer is i where ti < 240 -k < ti+1)

Or you can always simulate them. I did simulation and everything is smooth as silk.

Harnessing the magical power of Supervisord

Right, so I deployed a certain Python application on my EC2 instance.
I had a problem at that time : I’ll have to keep the pipe of the console which I am using to run the application alive, else the application would drop dead.
To solve this, I used supervisor. Supervisor is a program that allows you to monitor an app’s status.
In short, it allows me to keep the Python application alive, even if it killed itself at some point. It also mean that I don’t have to ssh to the instance and start the application manually ! Neat, no ?

Long story short, I jammed the command I used to start the app from Command Line, and added some extra modification to the application.
There was an issue with starting the application from Supervisor : it messed the relative directory locations. The app needs config which it imports using relative path. It seems that when supervisor starts the app, the directory supervisor is running the app from is not the directory of the script itself.

After tinkering abit with the app, it was good and still running until today !

Pashmak and Flowers

Problem Link: http://codeforces.com/problemset/problem/459/B

This problem asks you to find how many ways you can pick 2 flowers from the flower fields. My approach was : get numbers for most beautiful and least beautiful flower, then multiply those numbers. I used map to store the numbers due to the input.

However, there was a problem: it’s possible that the input has only one kind of flower. So you’ll have to count how many ways you can pick 2 flowers using combinations ( nC2 ).

In case if you don’t know how to code combinations, or if you are too lazy, you can see it here :

http://stackoverflow.com/questions/9330915/number-of-combinations-n-choose-r-in-c

Onto the unknown and beyond !

So I decided to try AWS. One year ec2 service for 1$ sounds pretty good.

Had some problems with phone verification, sent a ticket and everything got solved smoothly.

The only problem I have is that I can’t really experiment around with multi instance stuff since I’m using the ec2 instance for a certain project.

I guess I’ll have to revisit Lightsail / Vultr and see if the project can actually run there.

Given Length and Sum of Digits…

Problem link : http://codeforces.com/problemset/problem/489/C

I’m pretty sure this one can be categorized as implementation. I simply create the largest number first, by using all the 9s on the first digits, then reverse the number to get the smallest one after substracting one from the rightmost non zero number in the largest number, and add it to the rightmost number in case if the rightmost number is zero.

There’s also a trap which I didn’t check… even if m is equal to zero it doesn’t always mean that there’s no answer (-1 -1)