Cody

Problem 46838. The most decentralized RGB colors

Solution 3246628

Submitted on 17 Oct 2020 by 埃博拉酱
  • Size: 510
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
assert(MinDistance(ColorDistribute(1),1)>=500); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

2   Pass
assert(MinDistance(ColorDistribute(2),2)>441); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

3   Pass
assert(MinDistance(ColorDistribute(3),3)>360); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

4   Pass
assert(MinDistance(ColorDistribute(4),4)>360); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

5   Pass
assert(MinDistance(ColorDistribute(5),5)>284); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

6   Pass
assert(MinDistance(ColorDistribute(6),6)>266); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

7   Pass
assert(MinDistance(ColorDistribute(7),7)>255); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

8   Pass
assert(MinDistance(ColorDistribute(8),8)>=255); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

9   Pass
assert(MinDistance(ColorDistribute(9),9)>=219); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

10   Pass
assert(MinDistance(ColorDistribute(64),64)>=85); function Md=MinDistance(ColorMatrix,NumberOfColors) arguments ColorMatrix(:,3)uint8 NumberOfColors(1,1)uint8 end Md=500; ColorMatrix=double(ColorMatrix); for a=1:NumberOfColors-1 Color1=ColorMatrix(a,:); for b=a+1:NumberOfColors Md=min(Md,norm(Color1-ColorMatrix(b,:))); end end end

Suggested Problems

More from this Author4

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!