James Baker
31818
31818
Rank3
3
Badges138
138
Score
James Baker submitted a Comment to Problem 1024. Doubling elements in a vector B = [ A A];
Is a valid answer! Your problem statement says nothing about the element in vector b being in order. Test 2 is correct for only one case.
on 8 Jan 2024 |
James Baker submitted Solution 13003846 to Problem 42651. Vector creation on 8 Jan 2024 |
James Baker submitted Solution 13003836 to Problem 2. Make the vector [1 2 3 4 5 6 7 8 9 10] on 8 Jan 2024 |
James Baker submitted Solution 13003816 to Problem 3076. Create a vector on 8 Jan 2024 |
James Baker submitted Solution 13003771 to Problem 2631. Flip the vector from right to left on 8 Jan 2024 |
James Baker submitted Solution 13003746 to Problem 605. Whether the input is vector? on 8 Jan 2024 |
James Baker submitted Solution 13003566 to Problem 1107. Find max on 8 Jan 2024 |
James Baker submitted Solution 13003551 to Problem 624. Get the length of a given vector on 8 Jan 2024 |
James Baker submitted Solution 13003436 to Problem 44944. Convert from Fahrenheit to Celsius on 8 Jan 2024 |
James Baker submitted Solution 13003401 to Problem 44943. Calculate Amount of Cake Frosting on 8 Jan 2024 |
James Baker submitted Solution 13003331 to Problem 1. Times 2 - START HERE on 8 Jan 2024 |
James Baker received Solver badge for Solution 13003321 on 8 Jan 2024 |
James Baker submitted Solution 13003321 to Problem 1. Times 2 - START HERE on 8 Jan 2024 |
James Baker liked Problem 3. Find the sum of all the numbers of the input vector on 8 Jan 2024 |
James Baker received Commenter badge for Problem 55. Counting Sequence on 7 Jan 2024 |
James Baker submitted a Comment to Problem 55. Counting Sequence
I’m pretty new to programming and took on the cody counting sequence problem. My sample code is below. I wasn’t going for the most compact code and wanted the code to be generic to solve any size input vector X. My code does work, but when I submit it in the problem section, I get an error running the test scripts? Not a wrong result, just errors. Comments - suggestions? Yes, I know the codes messy. lol.
x =[ 5, 5, 2, 1,1, 1,1,3];
n = numel(x);
seqy = zeros(2*n,1);
seqpos=1;
seqcount=1;
i=1;
while i < n ;
if x(i) == x( i+1);
seqcount = seqcount+1;
else
seqy(seqpos)=seqcount;
seqpos = seqpos+1 ;
seqy(seqpos) = x(i);
seqpos = seqpos+1;
seqcount =1;
end
i = i+1;
end
seqy(seqpos) = seqcount;
seqy(seqpos+1)=x(i);
seqy;
c =numel(seqy);
h = 1;
p =0;
while h < c ;
if seqy(h) ~= 0;
else
p=h;
b =trimdata(seqy,p-1);
break
end
h= h+1;
end
y = b;
y % final result
on 7 Jan 2024 |
James Baker received Promoter badge for Problem 55. Counting Sequence on 7 Jan 2024 |
James Baker liked Problem 55. Counting Sequence on 7 Jan 2024 |