Power Laws
Description:
A Power Law distribution occurs whenever "a relative change in one quantity results in a proportional relative change in the other quantity." For example, if y = 120 when x = 1 and y = 60 when x = 2 (i.e. y halves whenever x doubles) then when x = 4, y = 30 and when x = 8, y = 15.
Therefore, if I give you any pair of co-ordinates (x1,y1) and (x2,y2) in a power law distribution, you can plot the entire rest of the distribution and tell me the value of y for any other value of x.
Given a pair of co-ordinates (x1,y1) and (x2,y2) and another x co-ordinate x3, return the value of y3
powerLaw(x1y1, x2y2, x3)
e.g. powerLaw([1,120], [2,60], 4)
- when x = 1, y = 120
- when x = 2, y = 60
- therefore whenever x doubles, y halves
- therefore when x = 4, y = 60 * 0.5
- therfore solution = 30
(x1,y1) and (x2,y2) will be given as arrays. Answer should be to the nearest integer, but random tests will give you leeway of 1% of the reference solution to account for possible discrepancies from different methods.
Similar Kata:
Stats:
Created | Sep 11, 2017 |
Published | Sep 14, 2017 |
Warriors Trained | 280 |
Total Skips | 8 |
Total Code Submissions | 516 |
Total Times Completed | 77 |
JavaScript Completions | 27 |
Python Completions | 56 |
Total Stars | 6 |
% of votes with a positive feedback rating | 86% of 33 |
Total "Very Satisfied" Votes | 26 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |