Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Expected Gain of Tossing a Dice

Suppose you toss a symmetric dice. You are allowed to quit the game and get money which equals the total points you get at any time if 6 has never showed up. Whenever 6 shows up, the game is over and you get nothing. For example, if the first three …

Randomly Select an Integer?!

I found this "probability" problem when I read a person's blog.

What's probability that two randomly chosen nature numbers are relatively prime?

It is claimed that there is a very elegant solution for this problem. This problem reminds me another one. Some people asked for an example of a 0-probability …

Fix Microphone Problem of Skype in Debian

Install Pulseaudio if you only have ALSA. ALSA alone does NOT work with skype whatever people on the #Debian channel might think and tell you.

sudo apt-get install pulseaudio

Install pulseaudio volume control

sudo apt-get install pavucontrol

Run Skype.

Go to the Sound devices sections. Click on the Open PulseAudio …

Culture of My Summer Intern Team

I work as a student intern in the Credit Portfolio Risk Analysis group in a bank this summer. One Friday afternoon, Jimmy, the manager of my manager, asked me to his office and talked about our team cultures.

  1. Ownership
    Whenever you have a project, you are the ownner. Be proud …

Java Programming Style

Good Writing Style

  1. It is recommend to always use {} if even there is only one statement inside it. The reason is that you never know whether you are going to add more statements into it or not. And it will make the code more readable.

  2. Feel free to declare the …

Pointers in C++

Pointers

  1. No pointer, no polymorphism.

  2. C/C++ is notorious for raw pointers. While pointers can boost up the speed of programs, it invites a trillion chances for making mistakes. You should avoid using raw pointers, instead, consider using unique_ptr, shared_ptr and weak_ptr. They are almost as efficient as raw pointers …