Two colors are considered complimentary (or opposite) if they produce a neutral color — black, white, or grey — when mixed evenly.
When placed next to each other, a colour and its complimentary colour create the strongest contrast that can be created with this initial colour.
RGB colours code consists of 3 values to identify a unique colour:
- Red Value: A number between 0 and 255
- Green Value: A number between 0 and 255
- Blue Value: A number between 0 and 255
For instance:
- (255,0,0) is the colour code for red,
- (255,0,255) is the colour code for magenta,
- (100,0,100) is the colour code for a dark purple colour,
- (255,255,255) is the colour code for white,
- (0,0,0) is the colour code for black,
Let’s consider a colour with a colour code of (Red, Green, Blue).
The colour code for its opposite colour will be (255 – Red, 255 – Green, 255 – Blue)
Opposite Colour (255 – Red, 255 – Green, 255 – Blue)
Your Challenge
Use the above formula to complete this codepen where the user can pick a colour (by inputting the RGB colour code) to preview this colour. The code should calculate the RGB code of the opposite colour and use it to preview this opposite colour code.
See the Pen Opposite Colours Tool by 101 Computing (@101Computing) on CodePen.
Extension Task
Complete this code to also calculate and display the colour codes of both colours using an hexadecimal colour code.


The purpose of this post is to demonstrate a basic example of how machine learning works.




Start by setting the starting node (A) as the current node.
Check all the nodes connected to A and update their “Shortest Distance from A” and set their “previous node” to “A”.
Set the current node (A) to “visited” and use the unvisited node with the smallest total distance as the current node (e.g. in this case: Node C).

Check all unvisited nodes connected to the current node (E) and add the distance from A to E to all distances from the connected nodes. Replace their values only if the new distance is lower than the previous one.
We found a path from A to Z, but is it the shortest one?

Start by setting the starting node (A) as the current node.
Check all the nodes connected to A and update their “Distance from A” and set their “previous node” to “A”.
Set the current node (A) to “visited” and use the closest unvisited node to A as the current node (e.g. in this case: Node C).
Check all unvisited nodes connected to the current node and add the distance from A to C to all distances from the connected nodes. Replace their values only if the new distance is lower than the previous one.
Set the current node C status to Visited.
B -> D 3+5 = 8 < 10 – Change Node D
D -> E 8+2 = 10 < 12 – Change Node E
E -> Z 10+5 = 15 > 14 – We do not change node Z.
We found the shortest path from A to Z.





















