Week With Aniket Issue #2 - Dock Your Apps in Containers

Hi ,

What a busy week this has been. I hope you're doing well and taking care of yourself. I have been up to something really awesome which I want to tell you about.


Mentorship Opportunity

I started a mentorship program where I'll mentor a few interested people. I'm offering mentorship for Web Development (Node JS/Ruby on Rails/Vue JS), General programming (C, C++, Python), and Linux. Note that this is a mentorship and not a course, which means I'll not "teach" a full-fledged syllabus-based material. I will, however, guide you towards your goal, clear your doubts, prepare roadmaps for you, take weekly 1:1 sessions and give you projects and researches to do.

Currently, the seats are all booked. If you're interested, you can register here. Once more seats become available, I'll contact you.

Programming

Solution of previous week's challenge:

Write a C function void reverse_string(char *str) that takes a C-string and reverses it in place.

Answer: The algorithm is simple. We start with two pointers - one at the beginning and one at the end of the string. Then we swap the characters and move the pointers towards each other.

[caption align="alignnone" width="980"]

[/caption]

This Week's Topic

This week's topic in programming is Docker.

What exactly is Docker? When you're building new software, you need to set up a development environment. This includes installing dependencies and SDKs, as well as configuring them. When you're deploying the app to production, you need to do this step once again. Now you need to be careful since you need to replicate your development environment - including the exact version of the dependencies and SDKs, otherwise, your app might break. The process is tedious. An even bigger problem occurs when you have multiple apps requiring different versions of the same dependency running in the same machine.

Docker solves this problem by "containerizing" your apps. Effectively Docker puts the apps in small "containers" and separates them from each other as well as the host machine. This means each app is separate along with its dependencies. No more installing thousands of dependencies on the host machine, or fixing conflicts between two apps. Docker does that for you.

Docker is much more than just this. Here are some useful links about Docker -

  1. This video by freeCodeCamp.
  2. This interactive course by Katacoda.
  3. Docker official docs.

Weekly Challenge

Implement a function rotateArray(int[] arr, n) which rotates an array by n places.

Example: [1, 2, 3, 4, 5] rotated by 2 gives [4, 5, 1, 2, 3].

Reply to this email with your solution for a chance to get featured in the next issue.

Mathematics

Solution of previous week's challenge:

In a party of 6 people, every pair is either mutual friends or mutual enemies. (i. e. everyone knows everyone else and is either friend or enemy). Prove that there exist 3 people who are all friends or there exist 3 people who are all enemies. Also, prove that this is not true for 5 people.

Answer: Label the persons A, B, C, D, E, and F. Pick any one person, say A and look at their relationship with others. Draw a red line between them if they're enemies and draw a blue line if they're friends.


[caption align="alignnone" width="980"]

[/caption]

Now complete the triangles.

Now there are 5 lines, and 2 colors. A (modified) Pigeonhole principle tells us that one color must have at least 3 lines (why?). In our picture this is the color red (enemies!). Keep this color and throw out the other.


[caption align="alignnone" width="980"]

[/caption]

Now our claim is that if we see the remaining relations (BC, CE and BE) we will find at least one triangle of same color edges (which means we have found three people who are either all enemies or all friends).

Observe that if BC is red, we're done (ABC is a red triangle). So assume it is blue. If CE is red, we're done (ACE is a red triangle). So assume it is blue. If BE is red, we're done (ABE is a red triangle). So assume it is blue. But now BCE is a blue triangle and we're done. Basically if we try to avoid a red triangle, we end up with a blue one.


[caption align="alignnone" width="980"]

We got a blue triangle[/caption]

This theorem is not true for 5 people. Here's an example coloring where there is no triangle with only one color.

[caption align="alignnone" width="980"]

Pentagon without any monochromatic triangle[/caption]

This Week's Topic

This week's Maths topic is a continuation of the previous issue: The Ramsay Theorem. This theorem is a general version of the problem you just solved! I am deliberately avoiding talking in terms of Graph Theory (I don't want you to unsubscribe!) so I'll keep it simple with the example of a party.

The Ramsey number R(m,n) is the smallest party size that guarantees a group of m mutual friends or a group of n mutual enemies. (Observe that, in the previous problem, m = 3, n = 3). Ramsay's theorem says that for any m and n, such a number R(m,n) exists.

The computation of R(m,n) is however very difficult, and we only know a handful of values. You can check the known ones here: https://en.wikipedia.org/wiki/Ramsey%27s_theorem

There are other much more generalized versions of this theorem and it's one of the most famous and impactful theorems in Combinatorics.

Weekly Challenge

Every point in a plane is colored either red, green, or blue. Prove that there exists a rectangle in the plane such that all of its vertices are the same color.

Reply to this email with your solution, and you will be featured in the next week's issue!

That's all for this week. See you next week.

Questions or suggestions? Reply to this email.

You can submit a comment as answers to the challenges.

Aniket Bhattacharyea

Aniket Bhattacharyea