To follow up: How could I tweak the solution to make it more permissive, to report values that are duplicates not in all columns, but in n-1, n-2 columns etc..
Like in the above matrix, have it report "4" if I input a minimum duplication of two columns?
Just a question of vocabulary: here you mean values that are present in all columns, right? As "duplicated" usually is used for "repeated within the same set".
In this case, we can start by finding the values in each column, removing duplicates:
So now if your goal is to find in how many columns a given value appears, the easiest is just to find how many times it appears in the list (since we used unique() to ensure a value appears only once per column):
So you directly see that 0 and 1 appear in all 5 columns, 4 appears in two, and the others appear only in a single column. This can then be automated with some filtering: