Index Value Range

Each element at index must be within a specific range

Index-Value Range

Problem Statement

Write constraints to generate an array where each element at index i must be within a specific range dependent on its index. This tests understanding of index-dependent constraints and iterative constraint generation.

Your task is to write constraints where: 1. Array element at index i must be >= i 2. Array element at index i must be <= i+10 3. The constraint solver generates valid arrays satisfying this relationship

Constraints

  • Array size: 8 elements
  • Element at index i must be in range i, i+10
  • Example: arr0 ∈ 0,10, arr1 ∈ 1,11, ..., arr7 ∈ 7,17

Examples

Example 1:

Index : Value
  0   :  0
  1   :  1
  2   :  2
  3   :  3
  4   :  4
  5   :  5
  6   :  6
  7   :  7

Explanation: Each element equals its index (minimum value for that index).

Example 2:

Index : Value
  0   :  10
  1   :  11
  2   :  12
  3   :  13
  4   :  14
  5   :  15
  6   :  16
  7   :  17

Explanation: Each element at maximum value for its index.

Example 3:

Index : Value
  0   :  5
  1   :  7
  2   :  9
  3   :  6
  4   :  12
  5   :  10
  6   :  13
  7   :  15

Explanation: Mixed values within valid ranges for each index.

Example 4 (Invalid):

Index : Value
  0   :  2
  1   :  1
  2   : -1
  3   :  3
  4   :  4
  5   :  5
  6   :  6
  7   :  7

✗ INVALID: arr[2]=-1 not in range [2:12]

Explanation: Elements must satisfy their index-dependent range constraints.

Loading the interactive workspace...