Python lists as local variables in recursion

Today I ran into a really interesting problem. Let's use Leetcode's Problem 77 combination as an example. I wanted write a function that prints all possible combinations (no order, unlike permutation).

So here is my function definition and call:
def helper(n, k, start, L):
    # L = list (L)  # make a copy 
    if len(L) == k:# all k elements have been drawn
        print L
        for i in range(start, n+1): 
            print "L before recursion", l
            helper(n,k,i+1, L) # down to next level
            print "L after recursion", l
            L = L[:-1] 

helper(3,2,1, []) # picking 2 from 3

But this was what I got:
L before recursion [1]
L before recursion [1, 2]
[1, 2]
L after recursion [1, 2]
L before recursion [1, 3]
[1, 3]
L after recursion [1, 3]   
L after recursion [1, 2]  --- l is supposed to be [1] here as quitting the inner recursion 
L before recursion [1, 2]
[1, 2]
L after recursion [1, 2]
L before recursion [1, 3]
[1, 3]
L after recursion [1, 3]

As you can see, L never came back to [1]. It became (at the 8th line of the print-out) [1,2] after executing helper(3,2,2, [1]). Further, there are unmatching numbers of "before" and "after" which made no sense to me.

It took me a couple of hours to think until I realized that maybe the reference of a list was the culprit. So I uncommented the "make a copy" line, and then things worked as expected:
L before recursion [1]
L before recursion [1, 2]
[1, 2]
L after recursion [1, 2]
L before recursion [1, 3]
[1, 3]
L after recursion [1, 3]
L after recursion [1]
L before recursion [2]
L before recursion [2, 3]
[2, 3]
L after recursion [2, 3]
L after recursion [2]
L before recursion [3]
L after recursion [3]

But I still had no clue why a copy fixed it, and even the in-and-out of recursions.
If you know why, let me know.

PS: An alternative fix is to let the function to return L[:-1]. In this way, the old l can be restored after a recursive call.

The evil and immoral cruise line business

I had my first cruise trip not long ago. It wasn't a pleasant experience. The food was good. The room was good. The view was good. So why wasn't it pleasant? The way that the service staff were treated by the company.

The food and stateroom service staff were talking to me as if I was the king and they were my peasants. I couldn't stand it. They acted like people who were not as equal as me, but inferior to me. I speculated that the company put lots of pressure on them to behave like that. I'd feel more comfortable should they interacted with me like how American hospitality works interact with me.

Now I feel morally wrong to take cruise trips. I wish the cruise companies could behave as hiring someone on American soil, e.g., a McDonald's garnisher. Technically, the cruise was on US water. So I don't know why they were treated so badly.

Crowdfunding first time: BreadShield for Arduino

Update 10/2/2019: BreadShield has hit the store of Mouser, and Tindie. Feel free to order from there. If you are outside of the US, I think our Tindie store offers the most inexpensive shipping methods, with tracking info.

tl;dr: Jump to here:

I prototype a lot in Arduino and breadboard. But quite often, I end up with a jumper wire mess or spaghetti, like the one below:

And more important, I cannot use any shield boards jointly with my circuit on the breadboard -- jumper wires take all the spots.

One day I thought, what if I could replace the mess with a shield board? So BreadShield was born.

Take a look:

And here is a comparison:

Once the campaign concludes, I will open up the Github repository with all KiCAD files. It is open hardware.

If you also think it can save you a lot of time, go grab one now It's just 7 dollars each (or 15 dollars for 3) and free US shipping is included. Thank you!

A filesystem being mounted as either ext4 and ext3?

I came across a very interesting problem on my computer today when moving my Dropbox folder as Dropbox is dropping support for non-ext4 filesystems on Linux now. I wasted a lot of time on this as I always believed that this partition was in ext4. So I couldn't figure out why I couldn't get expected by following instructions.

I could mount a partition on my hard drive as either ext4 or ext3 format. Dropbox's daemon is not stupid. If the partition is mounted as ext3, it will complain.

So here is the details. If I do not specify the format, it will be mounted as an ext3 partition.

forrest@test:~$ sudo mount  /dev/sdd1 /mnt/test/
forrest@test:~$ mount | grep sdd1
/dev/sdd1 on /mnt/test type ext3 (rw,relatime,data=ordered)

If I specify the ext4 format, it will be mounted as an ext4 partition.

forrest@test:~$ sudo umount /dev/sdc1
forrest@test:~$ sudo mount -t ext4 /dev/sdd1 /mnt/test/
forrest@test:~$ mount | grep sdc1
/dev/sdd1 on /mnt/test type ext4 (rw,relatime,data=ordered)

I don't know why. But it confused me quite a bit.

My template to reject fundamentally flawed papers

From time to time, I am invited to review papers that are fundamentally flawed. Those papers are written so poorly that I can decide their fates in 1 minute. To save myself from typing again, below is a template. I will just copy and paste.

This paper is very poorly written.
1. Lack of background from the biology problem to the computing counterpart to help broader audiences understand the problem.
2. Equations without explanation of the variables used.
3. No clear distinction between previous work and the authors' contribution(s).
4. Typesetting making reading extremely difficult, e.g., lengthy English phrases in math/italic fonts.
5. Too many English problems.