Generate WORKING Manim code for Scene 1.

IMPLEMENTATION: Certainly! Below is a detailed **plan implementation** for the described scene following your strict requirements and positioning rules.

---

## Layout Plan:

1. **Title**:  
   - Object type: `Text`  
   - Position method: `.to_edge(UP, buff=0.5)`  
   - Purpose: Display the scene title "Linear Search Algorithm"

2. **Main equation (array and target)**:  
   - Object type: `MathTex`  
   - Position method: `.shift(UP * 1.5)`  
   - Purpose: Show the example array `[3, 7, 1, 9, 5]` and highlight the target value `9`

3. **Secondary text (description)**:  
   - Object type: `Text`  
   - Position method: `.shift(DOWN * 1.5)`  
   - Purpose: Explain the problem statement and introduce linear search concept

4. **Array visualization (rectangles with numbers)**:  
   - Object type: `Rectangle` + `MathTex` inside each rectangle  
   - Position method: `.shift(LEFT * 2.5)`  
   - Purpose: Visual array elements displayed horizontally on left side

5. **Highlighted target value**:  
   - Object type: `SurroundingRectangle` around target element  
   - Position method: same as target element rectangle on left side  
   - Purpose: Highlight the target element in the array

---

## Animation Sequence:

### Step 1: Show title and problem introduction  
- Action: `Write`  
- Element: Title (`Text("Linear Search Algorithm")`) at top edge  
- Duration: 2 seconds  
- Cleanup: None (keep title visible)

- Action: `Write`  
- Element: Secondary text (problem intro) at lower center  
- Duration: 3 seconds  
- Cleanup: FadeOut secondary text only (title remains)

---

### Step 2: Show example array and target value (main equation)  
- Action: `Write`  
- Element: Main equation `MathTex("[3, 7, 1, 9, 5]")` with target `9` highlighted in RED, positioned upper center  
- Duration: 3 seconds  
- Cleanup: None (keep main equation visible)

---

### Step 3: Visualize the array on left side with rectangles and numbers  
- Action: `Create`  
- Element: Array of 5 rectangles horizontally aligned, each with number inside (MathTex), shifted LEFT * 2.5  
- Duration: 3 seconds  
- Cleanup: None (keep array visible)

- Action: `Create`  
- Element: `SurroundingRectangle` around the rectangle containing `9` (target), in RED  
- Duration: 2 seconds  
- Cleanup: FadeOut highlight (SurroundingRectangle) after showing

---

### Step 4: Show secondary text explaining the goal of linear search  
- Action: `Write`  
- Element: Secondary text at lower center explaining:  
  `"Goal: Find the index of target or determine it is not present by checking each element sequentially."`  
- Duration: 4 seconds  
- Cleanup: FadeOut secondary text

---

### Step 5: Transition text leading to step-by-step walkthrough  
- Action: `Write`  
- Element: Secondary text at lower center:  
  `"Next: We check each element step-by-step to find the target."`  
- Duration: 3 seconds  
- Cleanup: FadeOut secondary text, FadeOut array and main equation, keep title visible for next scene

---

## Summary of positioning:

| Element               | Object Type | Position                | Purpose                         |
|-----------------------|-------------|-------------------------|--------------------------------|
| Title                 | Text        | `.to_edge(UP, 0.5)`     | Scene title                    |
| Main equation         | MathTex     | `.shift(UP * 1.5)`      | Show example array + target    |
| Secondary text intro  | Text        | `.shift(DOWN * 1.5)`    | Problem statement intro        |
| Array visualization   | Rectangle + MathTex | `.shift(LEFT * 2.5)` | Visual array elements          |
| Highlight target      | SurroundingRectangle | same as target rect | Highlight target element       |
| Secondary text goal   | Text        | `.shift(DOWN * 1.5)`    | Explain goal of linear search  |
| Secondary text transition | Text    | `.shift(DOWN * 1.5)`    | Lead into step-by-step process |

---

If you want, I can also provide the exact Manim code snippet implementing this plan. Would you like that?
PATTERN: step_progression

CRITICAL CONSTRAINTS:
1. Use ONLY these objects: Text, MathTex, Axes, Circle, Rectangle, Line, Arrow, Dot, SurroundingRectangle, VGroup
2. Use ONLY these animations: Write, Create, FadeIn, FadeOut 
3. Use ONLY these colors (no quotes): BLUE, RED, GREEN, YELLOW, WHITE, ORANGE, PURPLE
4. NO undefined objects like VideoFile, Slider, ImageMobject
5. NO Unicode characters - use LaTeX: \sqrt{} not √, \pm not ±

POSITIONING REQUIREMENTS (CRITICAL):
- Each element MUST have unique position within screen bounds
- SAFE positions only: .to_edge(UP), .shift(UP*1.5), .shift(DOWN*1.5), .shift(LEFT*2.5), .shift(RIGHT*2.5)
- NO extreme shifts: avoid UP*3, DOWN*3, LEFT*4, RIGHT*4 (goes off-screen)
- NO overlapping: if one element uses .shift(UP*1.5), others must use different positions
- Test positions: Title=top, Main=upper center, Secondary=lower center, Sides=left/right

TEMPLATE TO ADAPT:

        # Title at top
        title = Text("{title}").scale(0.8).to_edge(UP, buff=0.5)
        
        # Step equations positioned vertically
        step1 = MathTex(r"{step1}").shift(UP * 2)
        step2 = MathTex(r"{step2}").shift(UP * 0.5)  
        step3 = MathTex(r"{step3}").shift(DOWN * 1)
        
        # Step labels on the right
        label1 = Text("{label1}").scale(0.5).shift(RIGHT * 4 + UP * 2)
        label2 = Text("{label2}").scale(0.5).shift(RIGHT * 4 + UP * 0.5)
        label3 = Text("{label3}").scale(0.5).shift(RIGHT * 4 + DOWN * 1)
        
        # Progressive revelation
        self.play(Write(title))
        self.wait(1)
        self.play(Write(step1))
        self.wait(1)
        self.play(Write(label1))
        self.wait(1)
        self.play(Write(step2))
        self.wait(1)
        self.play(Write(label2))
        self.wait(1)
        self.play(Write(step3))
        self.wait(1)
        self.play(Write(label3))
        self.wait(2)
                

Replace placeholders with scene-specific values and ensure working Manim code.

Generate complete Python code: