## Problem Description and Formulation

The problem is a classic example of a linear programming problem. The factory produces two types of bags: laptop bags and briefcases. Each type of bag requires a certain amount of time for sewing and painting. The goal is to maximize the profit by determining the optimal number of laptop bags and briefcases to produce given the constraints on sewing and painting time.

Let's define the variables:
- \(L\): the number of laptop bags to produce
- \(B\): the number of briefcases to produce

The objective function to maximize profit (\(P\)) is:
\[ P = 80L + 50B \]

The constraints based on the given resources are:
1. Sewing time: \(12L + 10B \leq 300\)
2. Painting time: \(5L + 9B \leq 500\)
3. Non-negativity: \(L \geq 0, B \geq 0\)

## Gurobi Code

To solve this problem using Gurobi in Python, we will first install the Gurobi library if it's not already installed. You can install it via pip:

```bash
pip install gurobi
```

Now, let's formulate and solve the problem using Gurobi:

```python
import gurobi as gp

# Create a new model
model = gp.Model("Laptop_Bags_and_Briefcases")

# Define the variables
L = model.addVar(name="Laptop_Bags", lb=0, vtype=gp.GRB.CONTINUOUS)
B = model.addVar(name="Briefcases", lb=0, vtype=gp.GRB.CONTINUOUS)

# Define the objective function
model.setObjective(80*L + 50*B, gp.GRB.MAXIMIZE)

# Add constraints
model.addConstr(12*L + 10*B <= 300, name="Sewing_Time")
model.addConstr(5*L + 9*B <= 500, name="Painting_Time")

# Optimize the model
model.optimize()

# Print the results
if model.status == gp.GRB.OPTIMAL:
    print(f"Optimal solution found. Laptop Bags: {L.varValue}, Briefcases: {B.varValue}")
    print(f"Max Profit: ${model.objVal:.2f}")
else:
    print("No optimal solution found.")
```

This code sets up the optimization problem as described, solves it using Gurobi, and prints out the optimal number of laptop bags and briefcases to produce in order to maximize profit, along with the maximum achievable profit.