6 kyu

Gradient interpolation

Description:

You're involved in the creation of a game.

In the game, a certain color function is to be used, such that, say, different temperatures will have different colors. This color function can be changed during the game, and even be chosen by the player.

The exact choices aren't finalized, but you know that a simple linear gradient will be used. For this you will create a higher order function, i e, a function that returns another function. This is somewhat similar to dependency injection in OO systems.

The resulting function must take a single parameter x between 0 and 100 and return a color.

Create a function that, given two colors in a vector RGB format (such as [255 255 255] for white or [0 0 0] for black in Clojure) returns another function that interpolates between the two functions and returns a resulting color in the same format.

The resulting color should be rounded down to the closest lower or equal integer.

Fundamentals

Stats:

CreatedFeb 24, 2017
PublishedFeb 24, 2017
Warriors Trained152
Total Skips17
Total Code Submissions242
Total Times Completed63
Clojure Completions34
Haskell Completions31
Total Stars6
% of votes with a positive feedback rating94% of 18
Total "Very Satisfied" Votes16
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments3
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • niklasjansson Avatar
  • Torkel Avatar
  • flaco Avatar
Ad