李君 - MATLAB Cody - MATLAB Central

李君

1677
Rank
8
Badges
1545
Score
51 – 100 of 155

李君 submitted a Comment to Solution 859627

@David Verrelli Thanks! It works.

on 17 Mar 2021

李君 submitted a Comment to Solution 5087787

the 3rd, I get result is 3.0000 on my computer, but it failed, i am very confused now. prime = isprime(in); out = sum(in.*prime)/sum(prime);

on 17 Mar 2021

李君 submitted a Comment to Solution 5087507

easy. classical iteration problem. solving this problem is easy, but iteration is hard to master.

on 17 Mar 2021

李君 submitted a Comment to Solution 5087367

using martrix multiplitation make this problem easier.

on 17 Mar 2021

李君 submitted a Comment to Solution 5086957

I am used to program with C, could someone have a vectorization solution for this problem in MATLAB way? function y = KaprekarSteps(x) y = 0; while ~(x == 6174 || x == 0) x = step(x); y = y + 1; end if x == 0 y = inf; end end function x = step(x) digits = getDigits(x); gain = [1000 100 10 1]'; x_d = sort(digits,"descend")*gain; x_a = sort(digits,"ascend")*gain; x = x_d - x_a; end function digits = getDigits(x) digits = [0 0 0 0]; for i = 1:4 digits(i) = fix(x/(10^(4-i))); x = mod(x,10^(4-i)); end end

on 17 Mar 2021

李君 submitted Solution 5086957 to Problem 68. Kaprekar Steps

on 17 Mar 2021

李君 submitted Solution 5075737 to Problem 72. Interpolator

on 16 Mar 2021

李君 received Community Group Solver badge for Laws of motion

on 16 Mar 2021

李君 received Community Group Solver badge for Basics - Cell Arrays

on 16 Mar 2021

李君 submitted Solution 5066488 to Problem 41. Cell joiner

on 15 Mar 2021

李君 received Introduction to MATLAB Master badge

on 15 Mar 2021

51 – 100 of 155
Go to top of page