Enough Contrast?

Note: This problem needs knowledge of topics you haven't covered yet. Reading List

Problem Statement


For 2 Colors in RGB:
(R1, G1, B1) and (R2, G2, B2),

Brightness index is:
( 299*R1 + 587*G1 + 114*B1) / 1000

Brightness difference is:
Absolute difference in brighness indices

Hue difference is:
|R1 - R2| + |G1 - G2| + |B1 - B2|
where |x| is the absolute value of x

If Brightness difference is more than 125 and the Hue difference is more than 500 then the colors have sufficient contrast

Find out if the given color combos have sufficient contrast and get all the tests passing.

class Color
class Color
  attr_reader :r, :g, :b
  def initialize(r, g, b)
    @r = r
    @g = g
    @b = b
  end
 
  def brightness_index
    # your code here
  end
 
  def brightness_difference(another_color)
    #your code here
  end
 
  def hue_difference(another_color)
    #your code here
  end
 
  def enough_contrast?(another_color)
    # your code here
  end
end
 
 
 

Output Window


Reading list for this problem

You are yet to work on:

Congratulations, guest!


% of the book completed

or