replace the solution of problem 66 and set the difficulty

This commit is contained in:
Fisher Wang committed 2021-03-11 17:10:53 +08:00
1 parent 0d8a4a025b
commit 8527c7c83c
6 files changed
+7 -37

No files matched your search

+1 -11
View File
@@ -855,22 +855,12 @@ F = np.bincount(I,X)
print(F)
< q66
Considering a (w,h,3) image of (dtype=ubyte), compute the number of unique colors (★★★)
Considering a (w,h,3) image of (dtype=ubyte), compute the number of unique colors (★★☆)
< h66
hint: np.unique
< a66
# Author: Nadav Horesh
w,h = 16,16
I = np.random.randint(0,2,(h,w,3)).astype(np.ubyte)
# The parenthesis around 256*256 ensure the dtpye promoted to uint32 properly.Otherwise the first term will overflow.
F = I[...,0]*(256*256) + I[...,1]*256 +I[...,2]
n = len(np.unique(F))
print(np.unique(I))
# Another solution
# Author: Fisher Wang
w, h = 16, 16