Broken Image - Puzzles #1
Description:
Broken Image - Puzzles #1
The images have broken, a fault in the program has caused some colours to go off, your task is to filter them back, fortunatly the code returns a statement which can be interpreted to help fix the image and restore it.
Task
Your task is to decipher the given text to reveal the steps taken to restore the pixel colours. They will be specified if particular colours were modified or if none are specified they must all be changed.
Preload
You will have the pixel class preloaded in your solution. The class name is pixel
the properties are r g b
, the pixel class is there to help as when you receive the array it will be given as an array of pixel objects.
Input
An example of the input you might receive.. The statement or input string can be broken up into 3 main sections..
Section 1: Section 1 contains the image size it may look like this...
'Image has size of {Image_Size}'
, {Image_Size} is the size of the image itself and all images will be squares.Section 2: Section 2 can or cannot be present, it contains what pixel colours are being affected for example
'and each Green'
if this line is in the statement then the operations were applied to the g property in the pixel class, But if no coloures are specified then the operations will apply to all propertys in the pixel class e.g. r, g and b.Section 3: Section 3 is all about the operations applied to the pixels the four operations that can be applied are
plus
,minus
,divide
andmultiply
what will follow will be a number that has been used.
Example
You may receive a statement like this: Image has a size of 3 and each Green and multiply 78 and plus 4
. From this we can deduce the image has a size of 3, Each image is a square so you will receive a 2D array with 3 rows and 3 columns. and each Green
means that each Green colour in the pixel class must be filtered for. and multiply 78 and plus 4
means that the colour of each pixel has been multiplied by 78 and added 4, you need to undo that filter on it, so you must do it all in reverse e.g. minus 4 and divide by 78 to get the correct colour.
Quick tip : if you find any difficulty regarding floating point then use round function
UPDATE:
I have moved the pixel class to the preloaded section.
Similar Kata:
Stats:
Created | Jul 17, 2015 |
Published | Jul 17, 2015 |
Warriors Trained | 292 |
Total Skips | 5 |
Total Code Submissions | 1158 |
Total Times Completed | 73 |
JavaScript Completions | 73 |
Total Stars | 9 |
% of votes with a positive feedback rating | 88% of 32 |
Total "Very Satisfied" Votes | 26 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 10 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 5 kyu |