Monthly Archives: October 2017

Blackgate Penitentiary

Vangelis the Batbear trapped all the members of Joker’s Streetgang in a basement.
Your job as a police officer is to transport all gang members to Blackgate Penitentiary.

To facilitate the transport, you should form a row such that the heights of the gang members are in non-decreasing order. For each gang member you should find the min and the max position where they can be in a valid sorted row and produce a roster with this information.

Input data

Input will start with a line that contains only one integer M, the number of crew members that were arrested. On each of the following M lines there will be a single word N and an integer H separated by a space character, where N is the name and H is the height of the crew member.

Output data

On the output, there will be G lines. Each line will contain in alphabetical order and space separated the names of the crew members that have the same height, followed by the min and the max position where any member of the specific group can be placed.

Limitations and notes

1 ≤ M ≤ 1000
1 ≤ length(N) ≤ 10
120 ≤ H ≤ 250

Names are only composed of characters of the Latin alphabet.

Batman and the Bubbles challenge

Good evening master Wayne.

Joker and his gang attended Black Hat USA 2017 where they learned of a new way on how to damage our city!
Specifically, tomorrow night they will try to damage the water pumps of Gotham using bubbles!
The bubbles cause corrosion to the pumps and in a few hours they will damage them with catastrophic results!
To dash Joker’s plan, besides stopping him, you need to make sure that the city network does not contain loops.
If Joker manages to inject bubbles to the network and they enter a loop, they will still cause damage to that area even though you would have already arrested Joker and his gang.

Given the map of the water distribution system, you need to make sure that the map does not contain loops.

Input data

On the first line there will be an integer T, the number of test cases to follow.
For each test case, there will be 2 input lines:

  1. On the first line of the test case, there will be 2 integers V and E, where V is the number of vertices and E is the number of edges.
  2. On the second line, there will be E pairs of integers separated by a space character. Each pair shows a two way connection between vector A with vector B.

Output data

For each test case you will have to write one line that contains an integer, in the case where there is a loop you will write the number 1 or else you will write the number 0.

Limitations and notes

1 ≤ T ≤ 1000
1 ≤ V ≤ 1000
1 ≤ E ≤ 10000
0 ≤ A,B ≤ V-1

Vangelis the bear is Batman! (or Batbear to be more precise).

Vangelis the bear is Batman! (or Batbear to be more precise).

Reading material

Supplementary material

CentOS 6: install / start and stop / enable and disable ssh server


To install the openssh-server, you need to install the openssh-server package:

sudo yum install -y openssh-server;


To start the sshd daemon (openssh-server) in the current session:

sudo service sshd start;


To stop the active (if any) sshd daemon in the current session:

sudo service sshd stop;


To configure the sshd daemon to start automatically at boot time:

sudo chkconfig sshd --add;
sudo chkconfig sshd on --level 2,3,4,5;


To configure the sshd daemon to stop automatic initialization at boot time:

sudo chkconfig sshd off;
sudo chkconfig sshd --del;

Git: Perform a stash addition using a custom/meaningful message

Did you ever wonder “Is there more to git stash?”, we did!
We wanted to see if there is a way to manually set the stash message to something meaningful instead of the automated message that derives from the last commit.

Fortunately, there is the command git stash save "Meaningful message"; which allows you to add new changes in your stash and at the same time use a custom message.

By using the git stash save "custom message"; command you will be enhancing the results of the git stash list; command as it will contain more useful information for you.


$ git status;
On branch master
Changes not staged for commit:
 (use "git add <file>..." to update what will be committed)
 (use "git checkout -- <file>..." to discard changes in working directory)

modified: me

no changes added to commit (use "git add" and/or "git commit -a")
$ git stash save "custom message";
Saved working directory and index state On master: your message here
$ git stash list 
[email protected]{0}: On master: custom message
$ git stash show
 me | 1 +
 1 file changed, 1 insertion(+)