Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Function Name: runBabyRun Inputs: (double) Target distance to run before half-ma

ID: 639798 • Letter: F

Question

Function Name: runBabyRun

Inputs:

(double) Target distance to run before half-marathon

(double) A 4x7 array of miles run each day in the month of February

Outputs:

(double) The most improvement made between consecutive days

(logical) Whether you met your target distance for a single run

(double) 1x4 vector of how many total miles you ran each week

Function Description:

With this New Year, you decide that you are actually going to run that half-marathon that has been on your calendar for three years now. You have a month to prepare for your race, so you decided to record how many miles you run each day and aim to run a target distance before the race; if you can run this many miles, then you will feel officially half-marathon ready!

The month is now over and your race is tomorrow, so you decided to look back and see the progress that you have made.

First, check the greatest mileage increase made between any two consecutive days. Next, check whether the number of miles run on any one day met the target distance you set before training (the number of miles will

Explanation / Answer

function [imp1 prep1 miles1] = runBabyRun(targetDistance, arr)


len = size(arr);
  
imp1=0;
prep1=false;
miles1 = zeros(1,len(1));
  
for i= 1:len(1)
for j=2:len(2)
diff= arr(i,j)-arr(i,j-1);
  
if imp1 < diff
imp1=diff;
end
end
  
for j=1:len(2)
if targetDistance <= arr(i,j)
prep1=true;
end
  
miles1(i) = miles1(i) + arr(i,j);
end
  
  
end

end


[imp1 prep1 miles1] = runBabyRun(
3.4,
[2.1 3.4 1.1 5.3 3.7 1.5 .5; 4.5 6.7 9.2 4.3 1.2 7.7 4.4; 6.7 13.6 8.7 3.5 6.5 8.3 5.4; 9 9.7 6.5 4.5 0 3.9 2.3]
)

---------------------------------------------------------------------------------------------------------------------------------------------------------

function TF = sudokuIsSolved(S)
TF = all(S(:));
end


input = sudokuIsSolved([ 8 2 4 9 5 3 6 7 1
6 3 5 8 1 7 9 2 4
7 1 9 6 2 4 8 5 3
5 8 7 2 9 1 3 4 6
1 4 2 7 3 6 5 8 9
3 9 6 4 8 5 2 1 7
2 6 1 5 4 9 7 3 8
4 7 8 3 6 2 1 9 5
9 5 3 1 7 8 4 6 2 ])

input = sudokuIsSolved([ 8 2 4 9 5 3 6 7 1
6 3 5 8 1 7 9 2 4
7 1 9 0 2 4 8 5 3
5 8 7 2 9 1 3 4 6
1 4 2 7 3 0 5 8 9
3 9 6 4 8 5 2 1 7
2 6 1 5 4 9 7 3 8
4 7 8 3 6 2 1 9 5
9 5 3 1 7 8 4 6 2 ])