Cody

Recent Activity

1 – 50 of 11,482

Alex submitted a Comment to Problem 2635. Higher! Lower!

I used this idea to create a similar problem that requires solvers to apply the bisection method correctly (see previous comments). https://www.mathworks.com/matlabcentral/cody/problems/46603-higher-lower-correct

12 hours and 11 minutes ago

Rafael S.T. Vieira submitted a Comment to Problem 2982. Get a Fibonacci number's index.

I agree with Jan. http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibtable.html (this list begins at 0). The 100th fibonnaci number is 573147844013817084101 (5.731478440138171e+20), and not 5.731478440138172e+20.

20 hours and 29 minutes ago

Rafael S.T. Vieira submitted a Comment to Problem 43970. Calculate SNR in dB using original signal and quantized signal

It's a good problem, but it needs more test cases. For instance, you could create a random signal then apply floor to all values and request its SNR.

21 hours and 42 minutes ago

hu guang submitted a Comment to Solution 1730215

y=x(end:-1:1);

on 22 Sep 2020 at 13:28

ChrisR submitted a Comment to Problem 46571. Characterize the final state of the digit inventory sequence

William, I think I see the reason for the difference now. Let me know if you want a hint.

on 22 Sep 2020 at 12:34

yu wang submitted a Comment to Problem 23. Finding Perfect Squares

intersect的返回值为一个向量,即使a和b的交集为空集,返回值仍为向量 x=[20:30] 例如:intersect(x.^2,x) ans = 空的 1×0 double 行向量 所以isvector(intersect(x.^2,x))是错误的 而isempty是判断数组是不是空的,所以isempty可行

on 22 Sep 2020 at 8:03

ChrisR submitted a Comment to Problem 46571. Characterize the final state of the digit inventory sequence

William, our results differ for a starting value of 570. I'm not sure why yet.

on 22 Sep 2020 at 5:47

Rafael S.T. Vieira submitted a Comment to Problem 1883. GJam 2013 China Event: Happy Teams 100 Pairs

Good example from Alfonso. I had to fix my code. The problem is pretty much about trying to create a tree. Alfonso's example creates a small forest: a case that seems to be lacking from the test suite.

on 22 Sep 2020 at 3:03

Madeline Infante submitted a Comment to Solution 2876582

good job guys

on 22 Sep 2020 at 1:13

Rafael S.T. Vieira submitted a Comment to Solution 286810

That's Muller's method which is more computationally realiable than Bhaskaracharya's.

on 21 Sep 2020 at 16:19

Rafael S.T. Vieira submitted a Comment to Problem 1763. Primes for Large N: 2^30, System Memory Limit

Currently the MATLAB function primes is able to solve this problem. Since systems always evolve, the problem's author will probably have to be constantly updating it. Or at least, once a year.

on 21 Sep 2020 at 15:10

Rafael S.T. Vieira submitted a Comment to Solution 329484

It is not close to linear. Richard, since he is using the function max for every number. It is at least O(n^2), in which n is size, and maybe even a little bit more since he is using indexing, another comparison(besides max), creating new arrays and so on. His code is small and functional though: kudos.

on 21 Sep 2020 at 14:54

Rafael S.T. Vieira submitted a Comment to Problem 45349. Area-07

I recomend solving at first the previous problem, then this one becomes easy.

on 21 Sep 2020 at 6:51

Rafael S.T. Vieira submitted a Comment to Problem 45249. Frugal number

I recommend including the number 414720 to the test suite: 3^4*2^10*5.

on 21 Sep 2020 at 4:32

Rafael S.T. Vieira submitted a Comment to Problem 45249. Frugal number

It seems that the problem is not considering the exponent 1 as a valid digit, For instance, 115248 (6 digits) is called a frugal number in this problem since 115248 (6 digits) > 2^4*3*7^4 (5 digits). If we considered 3^1 as 2 digits instead of the 1-digit 3, 115248 should not be frugal. And the problem should have probably declared this restriction and that the considered base is 10. PS: The OEIS also imposes this same restriction https://oeis.org/A046759, since 3645 is considered frugal: 3^6*5 instead of 3^6*5^1.

on 21 Sep 2020 at 4:23

William submitted a Comment to Problem 46571. Characterize the final state of the digit inventory sequence

Rats. My solution got all the problems right except the last. How is that possible?

on 20 Sep 2020 at 21:53

Marlon Trujillo submitted a Comment to Problem 18. Bullseye Matrix

Nice one....

on 20 Sep 2020 at 17:19

ChrisR submitted a Comment to Problem 45398. Seconds

A nice problem that helped me to learn about the flexibility of MATLAB's built-in functions

on 20 Sep 2020 at 14:39

Rafael S.T. Vieira submitted a Comment to Problem 1339. Travelling Salesman Problem (TSP)

You need to specify the comparison method when sorting complex numbers. Any change done to the order of elements currently creates an invalid solution (even sorting elements), and I guess the one that you want is 'real'. Or don't use complex numbers and create pair of values [x,y]. I've commented my solution. Futhermore, the function calculateSize no longer exists.

on 20 Sep 2020 at 14:35

Weilai Li submitted a Comment to Solution 1640011

Ha! Small tricks.

on 20 Sep 2020 at 14:24

Rafael S.T. Vieira submitted a Comment to Problem 2262. GJam 2011 Africa Qualifier B: Optimum Profit

Again a better description for this problem is needed. Found it a at a blog. https://titanwolf.org/Network/Articles/Article?AID=47afa1e5-84c0-4745-b143-9cf7cb8c2030#gsc.tab=0 Basically, we have some money to buy stocks and a vector with the forecast of a stock price for the upcoming months. We must decide when to buy and later sell this stock to obtain the greatest profit (if possible), but this operation can only be done once. In this problem the author also wants the position for buying and selling (smallest buying price if more than one possibility exists).

on 20 Sep 2020 at 3:36

Rafael S.T. Vieira submitted a Comment to Problem 2260. GJam 2011 Africa Qual A: Maximum Loop Size

I guess that this is the official description https://open.kattis.com/problems/closingtheloop (found it at a blog.) Please copy from there if that's the case. Basically, Each number represents a length of rope that we are tying in a loop, and each knot consumes 1 unit (1/2 unit from each different type). We must answer what the maximum length of rope is possible for this loop. For instance, if we have 1 unit of red rope (type 0) and tie it with one piece of blue rope (type 1), we end up with a loop of zero units (due to the two knots that should not be taken into account for the length).

on 20 Sep 2020 at 3:14

Rafael S.T. Vieira submitted a Comment to Problem 2260. GJam 2011 Africa Qual A: Maximum Loop Size

You need to explain these problems better. It's not always clear what we are supposed to do. I guess that at Google Jam they've explained it better, but the link is currently broken. For instance if you give me two types and ask me to alternate between them I can create an infinite sequence...so why should we stop at some point?

on 20 Sep 2020 at 2:55

Rafael S.T. Vieira submitted a Comment to Solution 1732920

Add decimal and irrational numbers, but only check if the n-first digits are a permutation of each other.

on 19 Sep 2020 at 19:25

Alfonso Nieto-Castanon submitted a Comment to Problem 45279. Cryptography with A Square Matrix : Encoding

it's a bit unclear why padding is necessary in the first two test cases, where the number of characters (15) is already a multiple of the key size (3 or 5, respectively)

on 19 Sep 2020 at 18:06

Rafael S.T. Vieira submitted a Comment to Problem 42758. Convert float to base N

The problem actually considers 6 digits before and after the decimal point in the target base, which means 12 digits. Imho, when stating the number of digits after the decimal point, we must specify the base that we are referring to (since the digit 8 in base 10 is 4 digits in base 2, and the 2-digit number 15 in base 10 is only one digit F in base 16) .

on 19 Sep 2020 at 15:41

ChrisR submitted a Comment to Problem 46591. Ackerman Function

See also Cody Problem 734.

on 19 Sep 2020 at 13:07

Rafael S.T. Vieira submitted a Comment to Solution 906063

It someone doesn't believe 7e4 = (1+1)*(1+1)*(1+1)*(1+1)*(1+ (1+1)*(1+1+1)*(1+1+1)*(1+1+1)*(1+1+1)*(1+1+1)*(1+1+1)*(1+1+1)) (32 ones). Or 2^4*(1 + 2*3^7).

on 19 Sep 2020 at 6:55

Rafael S.T. Vieira submitted a Comment to Solution 906063

I was obtaining 34 for 7e4 too, but it's not a problem of the test suite. It just means that your code is not testing all possible combinations (and there are probably other numbers that will fail too). There is no known algorithm to generate the list of integer complexity (https://oeis.org/A005245), which means brute force is the only way to be sure. And brute force finds 32 for 7e4.

on 19 Sep 2020 at 6:22

Rafael S.T. Vieira submitted a Comment to Problem 45854. Least Absolute Deviations (L1-norm) line fit - degree n

The problem with L1-norm is that It may have more than one possible solution. And the test suite should probably take this into account. (And the test suite also needs some fixing.) PS: It's probably why people usually prefer the L2-norm instead of L1,L3 or LN-norm.

on 18 Sep 2020 at 19:57

Rafael S.T. Vieira submitted a Comment to Solution 1578291

Currently, my solutions and this one are the only that don't use brute force, but this one is the smallest. Congrats. :) (I was able to create a smaller solution after looking at your code.)

on 18 Sep 2020 at 19:23

Rafael S.T. Vieira submitted a Comment to Problem 42290. GJam 2015 Rd1B: Noisy Neighbors

There is no need to test all cases. The ideal case is a swiss cheese in which no guest share a wall. Just start filling rooms from there if needed (the only problems is that room filling must follow an order, which makes the code quite large (but repetitive and boring), and there are two base cases for the swiss cheese structure). Maybe it's possible to create a function and decrease code size, but unless you see it at the moment that you are coding it, it would mean loosing too much time during competition when a Ctrl+C, Ctrl+V would be faster (and better than testing all cases).

on 18 Sep 2020 at 18:52

Rafael S.T. Vieira submitted a Comment to Problem 43940. Hydrostatic Pressure

The employed gravity and density values should be part of the problem. Water density changes according to temperature. And according to the gravity's precision, results may vary. It seems that the values used were 9.81 m/s² for gravity and 1029 kg/m³ for water density, which is the maximum value for sea water.

on 17 Sep 2020 at 16:48

Rafael S.T. Vieira submitted a Comment to Problem 42692. Polynomial Evaluation

Maybe the author should prohibit the use of polyval, str2num and regexp for this problem.

on 17 Sep 2020 at 14:04

walid hamidi submitted a Comment to Problem 2120. Rounding off numbers to n decimals

easy y = round(x,n)

on 17 Sep 2020 at 13:16

元清 谭 submitted a Comment to Solution 2957872

test5 and 6 are false answer

on 17 Sep 2020 at 9:29

chenguang yan submitted a Comment to Solution 1733391

function ans = find_max_sigdec(x) a = @(x) length(num2str(x,15))-find(num2str(x,15)=='.'); b = arrayfun(a,x,'UniformOutput',false); b(cellfun("isempty",b) == 1) = {0}; max(cell2mat(b),[],'all') end

on 17 Sep 2020 at 7:21

Rafael S.T. Vieira submitted a Comment to Problem 1237. It's race time! Write a faster function than the test suite call of unique().

About your problem with arrays, try adding a comma between lists.

on 17 Sep 2020 at 3:21

Rafael S.T. Vieira submitted a Comment to Problem 1237. It's race time! Write a faster function than the test suite call of unique().

Jeremy, please increase the size of the third case. Performance tests are not made with small samples (unless they are run several times)...because many other factors may affect the time (alternating processes, server overload, memory usage, etc). A regular CPU is always multi-tasking.

on 17 Sep 2020 at 3:19

Rafael S.T. Vieira submitted a Comment to Solution 2956879

My code did well for large samples, but I am sorry for the last test case. The sample is too small for performance tests, and not even using a lookup table was as fast as unique.

on 17 Sep 2020 at 3:14

Jeremy Perez submitted a Comment to Problem 1794. 02 - Vector Variables 4

Isn't 10.^(0:0.01:1) more precise?

on 16 Sep 2020 at 17:52

chenguang yan submitted a Comment to Solution 1619892

function ans=longrun(a) d = find([true;diff(a(:))~=0;true]); f = [d(1:end-1) diff(d)]; a(f(f(:,2)==max(f(:,2)))) end

on 16 Sep 2020 at 17:25

Snigdha Mallapragada submitted a Comment to Solution 2955010

I couldn't identify what went wrong

on 16 Sep 2020 at 14:38

Jeremy Perez submitted a Comment to Problem 46028. Paint it black!

Really fun. Anti-cheat is brilliant.

on 16 Sep 2020 at 8:42

Rafael S.T. Vieira submitted a Comment to Solution 2953651

The value of pi is wrong, but so it is the test suite.

on 16 Sep 2020 at 7:22

Rafael S.T. Vieira submitted a Comment to Solution 2953603

At the end, apply sum_array(permute(n)). Or you could use actual random numbers using this same technique, but there maybe repeated values.

on 16 Sep 2020 at 6:47

Jeremy Perez submitted a Comment to Problem 554. Is the Point in a Circle?

Is the Point on a Disk? Is the Point inside a Circle?

on 16 Sep 2020 at 5:08

water shen submitted a Comment to Solution 2953219

m = [1:n]'*[1:n];

on 16 Sep 2020 at 3:50

1 – 50 of 11,482