Cody

Recent Activity

1 – 50 of 5,780

Shamma Sultan submitted a Comment to Problem 23. Finding Perfect Squares

The difference between test 4 and 5 which returns different answers is the number 36.. but 36 is not a square root of any number of the list in test 4!!

1 hour and 50 minutes ago

James submitted a Comment to Solution 945294

Having more than one sample question in your test suite would be helpful, Minhaj, if only to prevent "answers" like this one.

19 hours and 43 minutes ago

John D'Errico submitted a Comment to Problem 42935. Sums of cubes and squares of sums

I did not originally look to see exactly how far one could go. It looks like, IF one is careful in the important expression, you should be able to get to 3329020. I'd expect that the code I'd write that would solve this to go as far as 3329020 would employ an initial test to know if n is even or odd, changing the expression I'd write depending on the parity of n. Of course that branch would also increase the complexity, so raising the Cody score.

on 29 Aug 2016 at 8:54

Jan Orwat submitted a Comment to Solution 944708

works for n up to 2642245, so it doesn't use the full potential of the uint64

on 29 Aug 2016 at 7:09

Jan Orwat submitted a Comment to Solution 944984

works for n up to 3329020

on 29 Aug 2016 at 7:03

Peng Liu submitted a Comment to Solution 944705

isequal ignores the data type of the values in determining whether they are equal. isequal(uint64(15503197751395200),15503197751395199,15503197751395201,15503197751395200) flintmax('double') = 2^53 < 15503197751395200 eps(15503197751395200) = 2

on 28 Aug 2016 at 23:22

Jan Orwat submitted a Comment to Solution 944703

Big letters, small letters and a bit of luck.

on 28 Aug 2016 at 23:00

John D'Errico submitted a Comment to Problem 240. Project Euler: Problem 6, Natural numbers, squares and sums.

A problem where one must be at least a little careful about floating point arithmetic. It might have been interesting if one of the test cases were x=1e5 or larger. Even more interesting if the execution time were a factor in the "score". These factors might impact how the problem would be best solved.

on 28 Aug 2016 at 20:17

John D'Errico submitted a Comment to Problem 625. Determine Whether an array is empty

Terrible test set.

on 28 Aug 2016 at 15:39

Ben Petschel submitted a Comment to Problem 2465. Find the area of a rectangle if length of the diagonal is given.

The solution isn't unique - it could be anything between 0 and 12.5. Need to specify that only integer side lengths are allowed (even then there could be multiple solutions). Also more test cases are required.

on 28 Aug 2016 at 7:50

Raihan Ahmed submitted a Comment to Problem 42709. Find 1's Complement

I have updated the test case. Solvers should check if their solution sill works. Happy coding

on 28 Aug 2016 at 7:15

Mashharar Bhuiyan submitted a Comment to Problem 1. Times 2 - START HERE

very basic,very interesting indeed

on 28 Aug 2016 at 6:50

Rodrigo Erices submitted a Comment to Solution 6962

It works doesn't it? Haha.

on 27 Aug 2016 at 15:34

Ben Petschel submitted a Comment to Solution 612834

how does this work?

on 27 Aug 2016 at 8:28

Jan Orwat submitted a Comment to Problem 42922. Zero Cross

It would be beneficial for the problem if zeros were added to test cases, for example [...,1,2,0,-1,-2,...], [...,1,2,3,0,2,3,...], [...1,2,3,0,0,0,1,2,...], [...,1,2,0,0,-1,-2,...], etc.

on 27 Aug 2016 at 7:37

Jan Orwat submitted a Comment to Problem 42930. Unit conversion

Please use search before posting a problem. Similar or identical problems were posted many times before: https://www.mathworks.com/matlabcentral/cody?term=celsius&submitsearch=

on 27 Aug 2016 at 6:44

Jan Orwat submitted a Comment to Problem 42929. Annual Salary

please add more cases.

on 27 Aug 2016 at 6:41

Jan Orwat submitted a Comment to Problem 42933. Vector with a repeated entry

please fix the description

on 27 Aug 2016 at 6:33

goc3 submitted a Comment to Problem 42901. Free-time Equation

It seems to me that the fictitious person in the test suite sleeps way too much (half the day). Less sleeping would solve his free-time problem.

on 26 Aug 2016 at 3:05

Steven He submitted a Comment to Solution 942496

How can be a smaller size? tf = rem(n,2)

on 25 Aug 2016 at 11:40

Ben Petschel submitted a Comment to Problem 2145. Find the index of n in magic(n)

It's not clear how the output should be calculated

on 25 Aug 2016 at 10:54

Ben Petschel submitted a Comment to Problem 1207. Phonebook-like problem

wish we could downvote

on 25 Aug 2016 at 10:46

Vineet Kumar submitted a Comment to Problem 6. Select every other element of a vector

nice problem

on 25 Aug 2016 at 5:55

Hydrophilic Wonder submitted a Comment to Solution 941350

This problem, and more similar but difficult ones, are covered in depth in the CUP challenge

on 24 Aug 2016 at 9:41

John D'Errico submitted a Comment to Problem 174. Roll the Dice!

The first test case for this problem is flat out statistically terrible! In fact, it is quite easy for that assertion to fail on a well defined set of uniform dice! So if you submitted a "valid" solution to this trivial problem, and it failed, then re-submit it. It may well succeed the second time you try, with no change to your function at all.

on 23 Aug 2016 at 14:34

Ben Petschel submitted a Comment to Solution 417940

how does this work?

on 22 Aug 2016 at 14:12

John D'Errico submitted a Comment to Solution 940169

(lol) An expectedly poor score, but still fun to write it in recursive form. Accomplished by adding spare arguments both as input to and output from split_it, then calling split_it recursively as needed.

on 22 Aug 2016 at 12:08

Ben Petschel submitted a Comment to Problem 2056. Is this number Munchhausen Narcissistic?

Wikipedia link: https://en.wikipedia.org/wiki/Munchausen_number

on 22 Aug 2016 at 9:14

Ben Petschel submitted a Comment to Solution 940023

bad test suite

on 22 Aug 2016 at 8:45

John D'Errico submitted a Comment to Problem 660. Find a subset that divides the vector into equal halves

A basic one liner with intlinprog, but not an option in Cody. :)

on 22 Aug 2016 at 3:16

John D'Errico submitted a Comment to Problem 2595. Polite numbers. Politeness.

An interesting problem, enough so that I chose to solve it in three essentially different ways. As always, there are various ways to solve any problem. The first two ways were essentially constructive, so counting the set of solutions for any N. The last used a formulaic approach.

on 21 Aug 2016 at 15:15

John D'Errico submitted a Comment to Solution 939609

So, doing a little reading about polite numbers, one finds that the politeness divisors is related to the number of odd divisors.

on 21 Aug 2016 at 15:07

John D'Errico submitted a Comment to Solution 939594

vectorized & constructive, explicitly counting all solutions for even and odd k

on 21 Aug 2016 at 14:29

John D'Errico submitted a Comment to Solution 939566

Brute force, with a while loop. crude as hell, but it works for a first pass.

on 21 Aug 2016 at 13:41

Rong Zeng submitted a Comment to Solution 939409

y = x(mod(x,2)==1); why is it not working? it works in matlab

on 21 Aug 2016 at 7:41

Rong Zeng submitted a Comment to Problem 6. Select every other element of a vector

y = x(mod(x,2)==1); it's not working, and i cant see why

on 21 Aug 2016 at 7:37

John D'Errico submitted a Comment to Solution 939320

Note that the ratio of consecutive areas is asymptotically the golden ratio, i.e., phi=(1+sqrt(5))/2.

on 21 Aug 2016 at 2:57

Xiaoli Zhang submitted a Comment to Problem 18. Bullseye Matrix

never have the chance to see how people did it with less than 10 size

on 20 Aug 2016 at 20:30

John D'Errico submitted a Comment to Problem 42. Find the alphabetic word product

Well, if you happen to know someone named 'BettyJ', thus a first name of Betty, last initial J, this works: word_product('BettyJ').

on 20 Aug 2016 at 18:20

John D'Errico submitted a Comment to Problem 106. Weighted average

Yes. The description is completely wrong. To start with, a weighted average should have the property that weighted_average(x,w) == weighted_average(x,k*w) So a simple re-scaling of the weights should not impact the result.

on 20 Aug 2016 at 17:55

John D'Errico submitted a Comment to Solution 939161

This is a seriously flawed problem. I'm sorry, but it is. It uses an incorrect definition of a weighted average. As such, students might solve this problem, then try to use that same expression in code for some future job. A correct solution might better be: y = x*w'/sum(w);

on 20 Aug 2016 at 17:50

Peng Liu submitted a Comment to Solution 938316

@James oops! I was so careless that I didn't notice that single-line error checking (I thought your check was intended to forbid the usage of functions such as eval, str2num, etc, and thus I completely ignored that when I was solving the problem). Now I realized this is not a strange behavior or bug of Cody. Thanks for your clarification.

on 19 Aug 2016 at 18:39

James submitted a Comment to Solution 938316

The problem was with the following line in the error checking: st = sprintf('function y = partitions(x)\n%%%s', st); This automatically changed the first line of your script to use partitions(x) instead of partitions(n). That was done to prevent folks from using the "function ans=blahblahblah(x)" technique when that still worked, That was just a holdover that happened to trip you up. Now that that line (and the rest of the suite0 has been removed, partitions(n) should work just fine.

on 19 Aug 2016 at 11:41

James submitted a Comment to Solution 938316

Strange. The problem you were having had something to do with the error checking suite that was above the solutions. Your solution passed the error checks, but failed to actually work. Now that I have removed the error checks, your solution with partitions(n) passes. I may have to muck around with this a bit later on.

on 19 Aug 2016 at 11:38

Amninder Dhillon submitted a Comment to Problem 25. Remove any row in which a NaN appears

lol test case with transform was good one!

on 19 Aug 2016 at 1:00

Peng Liu submitted a Comment to Solution 938235

Thanks for the quick fix!

on 18 Aug 2016 at 21:00

Peng Liu submitted a Comment to Solution 938316

Either partitions(x) or partitions(n) should not matter in the function definition.

on 18 Aug 2016 at 20:59

Peng Liu submitted a Comment to Solution 938316

But this is just function definition.

on 18 Aug 2016 at 20:56

Aditya Jain submitted a Comment to Solution 938235

This is fixed now.

on 18 Aug 2016 at 19:18

Aditya Jain submitted a Comment to Solution 938316

isn't it suppose to be partitions(x)?

on 18 Aug 2016 at 19:18

1 – 50 of 5,780