PIXELBANKv9.1.0
Menu

You are given a position in an overlap region and need to compute the blending weight for smooth image compositing.

Linear blending creates smooth transitions between overlapping images:

α=x−xstartxend−xstart\alpha = \frac{x - x_{start}}{x_{end} - x_{start}}

Where:

  • α\alpha is the weight for the second (right) image
  • 1−α1 - \alpha is the weight for the first (left) image
  • The final color is: C=(1−α)â‹…C1+α⋅C2C = (1-\alpha) \cdot C_1 + \alpha \cdot C_2

Outside the overlap:

  • x < x_start: α = 0 (use only first image)
  • x > x_end: α = 1 (use only second image)

Example:

Input:
x = 150
x_start = 100
x_end = 200
Output:
0.5
Reasoning:
  1. x = 150 is in the overlap region [100, 200]
  2. Apply linear interpolation: α = (x - x_start) / (x_end - x_start) α = (150 - 100) / (200 - 100) α = 50 / 100 α = 0.5

At x = 150 (middle of overlap), both images contribute equally.

  • First image weight: 1 - 0.5 = 0.5
  • Second image weight: 0.5

Constraints:

  • x is the current pixel position
  • x_start and x_end define the overlap region (x_start < x_end)
  • Return weight for second image (0 to 1)
  • Round to 4 decimal places
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.