
function w = reg_least_sq(X,y,lambda,w_0)

n = size(X,1); % number of (x,y) samples
M = size(X,2); % number of features

% precompute a_k's (doesn't vary w/ w)
a = sum(X.*X)'/n;

w = w_0;
niter = 0;
while (1)

  maxerr = 0.0;
  for k = 1:M

    % evaluate c_k based on w and X here
    % -- insert code here ---
    
    c_k = ...

    if (c_k < -lambda)
      w_hat_k = 
    elseif (c_k > lambda)
      w_hat_k = 
    else
      w_hat_k = 
    end
    maxerr = max(maxerr,abs(w(k) - w_hat_k));
    w(k) = w_hat_k;

  end

  niter = niter + 1;
  if (maxerr < 1e-8) return; end

end
